PAST PAGE SIX
Safe storage areas for machine language subroutines
The techniques and memory locations referred to in this article pertain only to Atari Dos 2.0S, which is by far the most widely used form of DOS for Atari computers. Do not use these techniques with any other type of DOS(e.g., OS/A+, DOS XL, DOS 3.0, etc.).
Page Six is an area of RAM (decimal 1536-1791) in all Atari computers that was set aside for use by the programmer. It's special because it's protected - under most circumstances, the computer's other operations won't affect what's there. Dozens of utilities and subroutines have been written for Page Six. Unfortunately, it only contains 256 bytes, so room is limited.
If you need more space, the standard procedure is to move MEMLO (the beginning of the memory that is available to you for BASIC programming) higher, and fit the additional program(s) below this BASIC user space. The disadvantage of this procedure is that it takes memory space away from your BASIC program. Also, initialization and RESET routines must be handled correctly or the added code will be lost.
My technique allows those of you with DOS 2.0S systems to add many extra programs and/or routines. These will be protected from the Operating System, and will be unaffected by RUN, NEW, and pressing [SYSTEM RESET].
STORING ROUTINE IN DOS RAM
The Disk Operating System (DOS) is nothing more than a collection of machine-language routines that perform functions such as reading the disk directory, coordinating disk input and output, and handling files. Some routines are used heavily, some hardly at all. Simply put, my technique locates routines in little-used areas of DOS RAM when you don't have enouugh room for them in Page Six. However, you must be very careful when you choose locations in DOS for your routines.
Locations 3033 to 3741 (decimal) contain the XIO routines that are used by BASIC to perform certain DOS functions. A total of 708 bytes are available here. However, if you use this space to store routines and then call DOS, you won't be able to use functions such as Rename, Lock, and Unlock, because the routines will have been overwritten. To avoid this problem, you can selectively overwrite the XIO routines you won't have any need for. You can find the source code for these routines in Inside Atari DOS by Bill Wilkinson.
Locations 5947 to 6043 contain the routine that creates MEM.SAV. There are 96 bytes here -- enough to store a lot of short routines. And you'll never miss MEM.SAV. Locations 6781 to 7419 contain the data and disk-drive buffers. Here you begin to tread on thin ice, because these buffers are used in various combinations, depending on which function of DOS is being used. Make sure that everything operates properly before committing your program to using this area. Otherwise, you may find that your "squatter" program has been evicted by the Operating System.
"Squatter" programs are usually unaffected by events within the Operating System. If you write DOS files to disk when a "squatter" is resident, the program is written right along with DOS. If you boot that disk, the "squatter" is loaded back into its proper place, and can be accessed as before.
If you wish to relocate routines from Page Six to DOS, you may need an assembler. Non-relocatable programs must be reassembled at their new location.
Vern Mastel is the manager of a Team Electronics store in Bismarck, North Dakota, where he sells computers an related equipment. His favorite pastime is writing programs for the Atari.