The Assembly Is Getting Out of Hand Call the Supervisor

Jean-Pierre Radley 320 Central Park West New York, NY 10025

"Si non e vero, e ben' trovato" . . . Italian proverb

My first computer was the Radio Shack hand-held PC-1. I learned BASIC on it by brute force. Three months later(!) I decided I was ready for the Model II. Opening its Manual was a bit short of devastating, but I forged ahead on my own in the wee hours. I was soon into Supervisor Calls and assembly language. I had two guides, Barden's TRS-80 Assembly Language Programming (RS #62-2006) and Rosenfelder's BASIC Faster and Better (RS #62-1002).

Think of an SVC as a subroutine which finds its marching orders in the low part of RAM where TRSDOS lives. Even the BASIC interpreter does not contain every last byte needed for one of its commands; a lot of its work is done by SVC's.

To start playing with SVC's, you need to read the DEBUG section of your Manual; you need an even dozen of Z-80 instructions; you need to be patient, careful, and accurate. Even without any Z-80 reference works, you could crib the necessary codes from the sample programs given in the Owner's Manual. The essential dozen is in Fig. 1.

MNEMONIC

CODE

RESULTS

LD A,n

3E

n

load register A with n

LD B,n

06

n

load register B with n

LD C,n

0E

n

load register C with n

LD D,n

16

n

load register D with n

LD E,n

1E

n

load register E with n

LD H,n

26

n

load register H with n

LD L,n

2E

n

load register L with n

RST 8

CF

jump to execute the SVC

RET

C9

return to where you came from

LD BC.ij

01

ji

load registers B & C with ij

LD DE.ij

11

ji

load registers D & E with ij

LD HL,ij

21

ji

load registers H & L with ij

Figure 1.

In the case of the last three, you must write code in the LSB/MSB format used by the Z-80, and you must always write values in hexadecimal (when hand-assembling code, that is; assembler programs accept values in any base, and addresses in "normal" MSB/LSB). If you need to load B with 66 and C with 60, first "hex" those values: 66D = 42H, 60D = 3CH. Then your four bytes of code are: 06 42 0E3C, using the second and third instructions in Fig. 1. You can do the same thing in three bytes with the antepenultimate instruction: 01 3C 42.

From TRSDOS READY, type CBCEPiBCuPCGDOCoPCNP [ent e fh. then CEDCIDCIDCLDGD (enter). Type CED, then some two-byte hex values, and use the up- and- down arrows. You can't get below 2800H, nor beyond F3FFH. The lower part is for TRSDOS itself, and the upper is for routines like DEBUG, DO, or SPOOL. The area between F000H and F3FFH is locked out to BASIC or VisiCalc or any other program. However, we can use it for short assembly language programs which will not be disturbed by loading other programs. If you wanted to put these exercises at E000H, and you were also using BASIC, then you would enter BASIC with -M:57344. To exit DEBUG, type (esc) and either GD or CQD. GD returns to TRSDOS with DEBUG still on while CQD turns DEBUG off before returning to TRSDOS.

(.Editor's note: the 4.x series of Model 11/12/16 TRSDOS operating systems reserve the right to use all memory above F000H. If user machine language routines are written so that no portion of them exceeds F000H, then there is no chance of them being overwritten by TRSDOS. Remember, however, to protect the routine from being overwritten by a BASIC or COBOL program.)

0 0

Post a comment

  • Receive news updates via email from this site