![]() ![]() PRINT "RELOADING" : PRINT CHR$(4)"RUN THIS-PROGRAM" 10 REM If BASIC program load address is $0801,Ģ0 REM then change to $6001 and reload this program.ģ0 IF PEEK(104) = 8 THEN POKE 104,96 : POKE 24576,0 : The memory value directly before the start of a BASIC program must be zero, so $6000 is set to 0 before reloading. This location is configured when BASIC first loads and can be changed when running programs, and is stored at $67-$68 or 103,104 decimal.įor example if you have a very large BASIC program that overlaps hi-res page 1, but you want to use text page 2, hi-res page 1, and hi-res page 2, you can tell DOS and BASIC to load and run programs starting at $6001. To confine all variables to the graphics page 2 memory region, and protect $0800-$3FFF and $6000-$95FF, use LOMEM:16384 : HIMEM:24575Īn advanced memory management trick is to change where BASIC stores programs. ![]() To push all variables above $6000 so that the graphics pages are never overwritten accidentally, use LOMEM: 24576 To change where variables are stored, these two commands are used as soon as possible in a program before any variables are created. To obtain the current value, use: PRINT PEEK(76) + 256 * PEEK(77) HIMEM: is automatically adjusted by DOS to point to just before the beginning of DOS. To obtain the current value, use: PRINT PEEK(74) + 256 * PEEK(75) LOMEM: is automatically adjusted by BASIC to point to the memory just after the end of a BASIC program. these are odd commands in that the colon is part of the command name. It is possible to control where BASIC stores variables using the commands HIMEM: and LOMEM. ![]() ![]() This is used with the command PRINT CHR$(4)"FRE" In ProDOS, there is a DOS command FRE which is much faster than the FRE(0) built into Applesoft BASIC. Using this command frequently in large programs will keep variable usage from growing too large, as well as preventing garbage collection from becoming too slow when it does happen. You can force BASIC to do variable garbage collection immediately by using the command PRINT FRE(0), which both returns a value reporting free memory for variables, and also runs garbage collection. Garbage collection can be quite slow, if left to happen on its own in one huge process. Then BASIC will perform what is called garbage collection, scanning through variable memory and removing unused old values and recovering free space. Normally the variable and string use will grow indefinitely until the two come together. So, over time as a BASIC program runs, both graphics pages are at risk of being overwritten with variable data, from above and below.Īlso, if you were to write an assembly language program and store it at $6000, it is also at risk of eventually being overwritten by variables as a BASIC program continues to run. These are stored in two separate groups, with the number values being placed immediately after the end of the program and growing upward, and the strings placed high in memory below DOS and growing downward. When a BASIC program runs, it normally uses variables to store numbers and strings. If you do anything with hi-res page 1 in this situation, you will damage or delete the end of your program. BASIC programs load linearly into memory, and they cannot "jump over" memory regions.Īs a BASIC program grows past 6 kilobytes in length ($0800 to $1FFF), it starts to cross into hi-res graphics page 1 followed by hi-res page 2. If the number of buffers is reduced to 1, using the DOS command MAXFILES 1 then DOS occupies $9AA6 to $BFFF.Īpplesoft BASIC programs normally load starting at $801, overlapping text page 2. $9600-BFFF - DOS 3.3 and 3 file buffers 10.5 kB When DOS 3.3 boots, it loads itself as high as possible in memory, just below $C000, and normally occupies $9600 to $BFFF, with 3 file buffers each 595 bytes long. $0200-02FF - Input prompt character buffer 256 bytes $0800-0BFF - Free memory / Text page 2 1 kB $2000-3FFF - Free memory / Hi-Res page 1 8 kB $4000-5FFF - Free memory / Hi-Res page 2 8 kB $C100-C7FF - Permanent Slot ROM memory 256 per slot $D000-DFFF - BASIC ROM / RAM bank 1 & 2 4 / 4 / 4 kB Managing memory on an Apple II using Applesoft BASIC can be quite complicated, especially for large programs.Ī general map of Apple II memory at power-up looks like this: $E000-FFFF - Monitor ROM / Extended RAM 8 / 8 kB ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |