Classic Computer Magazine Archive COMPUTE! ISSUE 25 / JUNE 1982 / PAGE 130

Supermonitor: Part III

Frank Cohen
Pacific Palisades, CA

Part I of this article appeared in the March, 1982, issue and Part II appeared last month. This completes the routines which comprise the Supermonitor for the Ohio Scientific Superboard Computer.

Here is the conclusion to a long and complex program which adds functions to a Superboard II which you would normally find only in an advanced operating system. These functions make it easy to display, move, and modify machine language programs and data.

The programs listed so far have made up the framework of the Supermonitor. The first program presented was called Hexdump and did nothing more than dump an address and eight bytes of data onto the screen. Hexdump was listed first because subsequent programs use some of its subroutines. The second article included two programs. Indata prints a line of eight bytes of data and allows you to modify the contents. After you have modified a byte, Indata allows you to move forward, backward, or skip over subsequent memory locations. Bmove is a simple block move program. Bmove moves a whole block of memory to another location in memory. With just these three programs, entering and editing maching language data is much more efficient and easy than using the ROM Monitor program OSI supplies.

Without a disk system, loading Supermonitor in its entirety takes about five minutes with the Superboard's 300 baud cassette interface. With the assembly listings of Supermonitor you can use only the programs you find interesting. By doing this, you can limit the size of Supermonitor. The listing of the main menu program shows all the equates for all the programs.

All of the programs of Supermonitor use a program called Supercursor V1.3 (COMPUTE!, December, 1981, #19, p. 124) to handle its video output. Supermonitor is installed directly below Supercursor at the top of an 8K byte Superboard II. If you don't want to use Supercursor, you can write your own video output routines. To use Supercursor V1.3 a program puts the ASCII character in the CPU's accumulator and executes a JSR to its start address, located at $1E80. Supercursor also has routines to "Home" the cursor and clear the screen. To use the Home functions, jump to the subroutine at $1E80 using a JSR. Use the same instruction to clear the screen at $1EC2.

A Brief Review

Let's go over some terms. An assembler is nothing more than a program which takes programs called source code and converts them into machine instructions (called object code) which can be directly executed by your computer. Assembly language is made up of three-letter codes which abbreviate what the CPU [Central Processing Unit] executes. For example, one commonly used instruction is the "load the accumulator" instruction. In machine language, the code is an A9 followed by the byte to be loaded into the accumulator. In assembly language, the instruction looks something like this: LDA. This stands for LoaD Accumulator. But load it with what?

The 6502 microprocessor has twelve different addressing modes. So, following the LDA instruction, the assembler looks for the type of addressing to use. One of the most common is the immediate mode. To load the accumulator with the value 00 (hex) the assembler instruction looks like this: LDA #$00. The pounds sign (#) stands for immediate addressing and the dollar sign ($) tells the assembler that this is a hexadecimal number. If you left out the pounds sign, the assembler would think that you want to load the accumulator with a byte residing at location $00 in the zero page of memory. Executing an instruction like LDA $1000 tells the assembler to load the accumulator with the byte at location $1000 in memory. Labels may be used instead of the actual numbers.

These labels are called equates. Before entering the program into the assembler labels can be defined. By defining the labels, specific numbers are assigned to alphanumeric names. In the listing of the main menu program, the major equates are shown. For example, the equate named cursor is assigned the value $1E40. So, when we tell the assembler to jump to a subroutine called cursor (JSR CURSOR) the assembler will execute the subroutine starting at $1E40. Using equates, assembly language becomes easier to read.

Main Menu

This is by far the simplest of the programs. By entering at $1A7B (called SPMON) the program first clears the screen, then homes the cursor and reads the keyboard. When a key is pressed, it checks to see if it is a valid character. If it is, we jump to the correct program. If not, the screen is cleared and we return to the beginning of the program. The valid characters are listed below:

G - EXECUT, transfers control to a machine language program

I - INDATA, displays and modifies memory

C - CLEAR, clears the screen

D - HXDMP, dumps memory to the screen

M - BMOVE, moves a block of data

S - TAPOUT, saves a block of data to cassette tape

F - FILL, fill a block of memory with a specified byte

As it is listed, SPMON fits directly under all the other programs. It uses the clear screen and home cursor functions of Supercursor and a subroutine in the ROM monitor (at $FFBA) to get a key from the keyboard.

Execut

If SPMON is the simplest of the programs, EXECUT is the smallest. Most of EXECUT is devoted to input the starting address of the machine language program. EXECUT prints "G = " on the screen and expects you to type in the four digit address. An infrequently used instruction is applied to jump to the address. This instruction is called the "jump indirect" instruction. EXECUT uses the INADR subroutine in HXDUMP to input the address to locations $00E7 and $00E8. We then use the jump indirect instruction to use these addresses.

Fill

This program is similar to BMOVE. FILL loads a block of memory with some value you input. It starts by asking the beginning address of memory by printing "S = " on the screen. Type in the four digit hexadecimal address. FILL then asks for the ending address by printing "E = ". Again, input the address. Then it asks what the block of memory is to be filled with. FILL is a very fast program and will fill all 64K in about two seconds. FILL is listed to fit after the main menu and before the cassette tape program.

Tapout

This is the most valuable program. There exist programs that save from machine language to tape, but the problem is that BASIC uses almost all of the zero page memory locations and some of the main memory making it difficult to work around. Since the Superboard's ROM monitor already has a tape input routine, this program only stores data onto cassette.

TAPOUT makes use of BASIC'S cassette output subroutine stored in ROM. By setting location $0205 to FF (hex) a jump to subroutine instruction outputs the contents of the accumulator to the cassette interface at 300 baud. After TAPOUT is finished, it resets location $0205 to 00. If you want to use TAPOUT from a machine language program, put the starting address at location $00E9 and $00EA and also the ending address at location $00E7 and $00E8. Then execute the program.

After you install the three programs in this issue, it is necessary to make some slight modifications so that all the programs will return control to the main menu program. To do this you will need to enter the following modifications:

1C36	  4C   7E   1A    ;ForBMOVE
1CB0	  4C   7E   1A    ;ForINDATA
1D1D	  4C   7E   1A    ;ForHEXDUMP
1D38	  F0   E3
;EQUATES
CURSOR      =$1E4O
CLS         =$1EC2
HOME        =$1E8O
INADR       =$1D93
CR          =$1E95
LF          =$1EAB
KEYIN       =$FFBA
EXECUT      =$1ABA
FILL        =$1ACA
TAPOUT      =$1B3F
BMOVE       =$1BC6
INDATA      =$1C56
HXDMP       =$1D2O
ADR         =$E7
EBAD        =$E9
SBAD        =$EB
TMP         =$ED
CVAHX       =$1DF3
CVHA        =$1D72
OFLAG       =$0205
AOUT        =$FFEE