By Joe Kimbrough
PEEK and POKE power from DOS.
With this machine language Mini-Monitor you gain the very useful capability of being able to POKE and PEEK from DOS! This BASIC program works on any 8-bit Atari with disk drive.
Seasoned BASIC programmers know how useful the POKE and PEEK commands are. However, when you leave BASIC, your at the mercy of the DOS menu, restricted to the options it provides.
MiniMon is a machine language mini-monitor that gives you more control over your Atari when you're in DOS. MiniMon gives you emulated PEEK and POKE commands. Suppose you're tired of your Atari's bland blue and white default colors. In BASIC it's easy enough to POKE different values into the color registers, but in DOS you're stuck with the default colors. MiniMon lets you change these colors from DOS, just as you would in BASIC.
Many XL/XE owners sooner or later find themselves trapped in DOS when BASIC has been disabled by either the [OPTION] key or a machine-language program. MiniMon lets you enable or disable BASIC at will without rebooting.
GETTING STARTED Type in Listing 1, MINIMON.BAS, check it with TYPO II and SAVE a copy before you RUN it. When RUN, MINIMON.BAS creates a machine language file called MINIMON.EXE and writes it to your disk. This is the MiniMon program.
Listing 2, MINIMON.M65, Is MAC/65 assembly language source code for MiniMon. You do not need to type it in to use the program.
To start MiniMon, type DOS to get to a DOS 2.0 or 2.5 menu, then select menu choice L to load D:MINIMON.EXE. MiniMon will load and run automatically.
The menu offers three numbered choices--DOSPOKE, DOSPEEK and - EXIT TO DOS.
If you select DOSPOKE, type the value to be POKEd into an address, Press [RETURN] and then type the address and press [RETURN]. If you try to enter an illegal value (such as a negative number), MiniMon will ignore it and wait for a valid number. Press [ESC] to exit DOSPOKE and return to the MiniMon menu.
DOSPEEK works like DOSPOKE. Press [OPTION] to return to the MiniMon menu, press [START] to re-run DOSPEEK. The third menu choice simply returns you to DOS.
THINGS TO TRY
To change screen colors in DOS, run MiniMon and select DOSPOKE. Enter 200 at the first prompt and 710 at the second. Your screen will immediately turn green. This would be equivalent to typing SETCOLOR 2,12,8 in BASIC. IF you enter 0 and 709, you'll get black text. This would be equivalent to typing SETCOLOR 1,0,0.
To disable BASIC in XL/XE models, put 255 into 54017. Putting 253 into 54017 will enable BASIC. However, a word of caution is in order here.
If BASIC has been disabled by holding down the [OPTION] key, then screen memory has been moved up 32 pages. Some machine language programs also move screen memory. If you put a 253 into location 54017 under such circumstances, you'll get a screen full of garbage.
To handle this situation, you must reposition the display list by following this procedure:
1. Use DOSPOKE to put 160 into location 106. This location, called RAMTOP, gives the total number of available pages of memory.
2. Exit to DOS with MiniMon selection 3.
3. Choose DOS option M, type 2075 and press [RETURN]. This reprints the DOS menu, but it has the same effect as a BASIC GRAPHICS 0 command--it moves the display list and data below the new RAMTOP.
4. Re-run MINIMON.EXE and use DOSPOKE to put 253 into location 54017.
5. Exit to DOS with MiniMon option 3 and use DOS option B to go to BASIC.
HOW IT WORKS
MiniMon bypasses CIO and directly accesses the operating system's "put character" and "Keyboard GET-BYTE" routines for getting and printing characters.
Unfortunately the 800's OS and the XL or XE's OS place these routines in different locations. So MiniMon must begin by determining what type of computer it's running on and modify itself accordingly.
MiniMon determines what type of computer it's running on by inspecting memory location 64728 ($FCD8). If this location contains a 162, MiniMon is running on an 800 and must modify it self before continuing. A 76 here denotes an XL/XE, so MiniMon will not modify itself.
(Antic prefers to avoid such potentially dangerous programming practices whenever possible. We discourage readers from writing self-modifying programs or making illegal system calls to the OS, if it can possibly be avoided.--ANTIC ED)
All of the really hard work in MiniMon is done by the floating point routines in the operating system. When you type in a value, say 234, what actually goes into the computer is 50,51,52--the ASCII values for 2, 3 and 4. These three bytes must be converted into one byte containing the integer 234.
First, your Atari converts the ASCII values into floating point form, then converts the floating point number into an integer!
DOSPEEK works the opposite way. The value contained in an address is an integer which must be converted into ASCII for you to read it. Again, it's a two-step process--converting an integer to a floating point value, then changing the floating point value to ASCII.
MiniMon uses all four of these conversion routines--ASCII to Floating Point (beginning at address 55296, $D800), Floating Point to ASCII (55526, $D8E6), Integer to Floating point (55722, $D9AA), and Floating Point to Integer (55762, $D9D2).
MiniMon requires only 667 bytes and resides in memory at 13312 ($ 3400). It takes up only six disk sectors, and can give you much welcome additional flexibility when using DOS.
Joe Kimbrough is a professor of English from Houston, Texas. He uses his Atari for many tasks, but it does yeoman service as a wordprocessor. This is his first appearance in Antic.
Executable: MINIMON.EXE Download