The following Z80 registers and register pairs apply:
Any of these preceeded by a “‘” refers to the alternate set.
- SA – Software accumulator
- SA1 – Alternate software accumulator
- RA – Register accumulator (E,D,C,B).
“In cassette systems, reset computer; in disk systems, cold boot of DOS. Could also be done via RST 00H.”
Checks for syntax. HL points to byte to be checked and proper byte follows RST 08H instruction.
“Vector used to resolve relocation address of calling routine. On exit, HL points to address following Call instruction.”
This routine gets a byte from a logical device or a file that is open. When calling, DE =starting address of DCB of device. On exit, A= byte received from device, z set if device ready. Uses AF.
Compare DE and HL as 16 bit unsigned intergers.
Outputs a byte to a logical device or FCB. Outputs a byte to a device. When calling, A = output byte, DE = starting address of DCB of device. On exit, z set if device ready. Uses AF. Don’t confuse with CTL at 0023.
Outputs a control byte to a logical device or FCB. DE = FCB and A = control byte.
Pressing Break key RST’s here and then jumps to location 400CH. Also normal DOS function vector.
Scan keyboard and return with accumulator containing result. DE is used.
Displays a character at current cursor location.
“Waits until printer is ready then prints charatcter. A = ASCII character. If BREAK is pressed, a return to caller is made.”
Call Input a line from the keyboard. B = max length of line. HL points at buffer. Buffer should be the length of B plus 1. To terminate, hit BREAK or ENTER. On exit, HL points at buffer and B = number of characters entered. Carry will be set if BREAK was pressed.
“Scans the keyboard until a key is pressed. If BREAK is pressed, it is returned like other keys.”
“Recieve a character from RS-232. No entry conditions. On exit, memory location 16872 contains character recieved. DE is altered. This routine honors wait status.”
“Transmit character to RS-232. On entry, Accumulator or memory location 16880 contains character. On exit, 16880 = 0 if no character sent. Wait status honored.”
Call Initialize RS-232 interface. On entry, memory location 16888 = send/recieve baud rate code, location 16890 = wait/don’t wait switch, location 16889 = RS-232 characteristics switch. On exit, DE is altered. For more detail, consult Model 3 reference manual.
“Load BC with how many times to loop, then call.”
“Initialize all I/O drivers to their ROM routines. No entry conditions. On exit, all registers changed.”
“On entry, location 4222H = two byte source device ASCII abbreviation and location 4220H = two byte destination ASCII abbreviation. On exit, DE is altered.”
An alternative for entering Basic. See also 1A19H.
Type in SYSTEM (even from DISK BASIC) and reply to the “*?” prompt with /177. The computer will then ask you for memory size. Upon return, you’ll still be in DISK BASIC, but your program will be gone. Also, it doesn’t get along with any high memory routines present.
Call this routine from BASIC and your computer will brag about it having Level II or Model III BASIC.
Basic’s POINT routine.
Basic’s SET routine.
Basic’s RESET routine.
This is the routine that is Basic’s SET, RESET, and POINT functions. Here’s how to use it. Load HL with return address and push. Load register A with one of the following: 00H = POINT, 01H = RESET, and 80H = SET. Push AF onto stack. Load A with X coordinate and push onto stack. Load A with Y coordianate and JP GRAPH.
“Checks for syntax of “”)”” via RST 08H.”
This routine turns off the cassette drive.
A register contains a 0 or 1 which is the cassette number. This routine defines cassette number and turns on cassette. Model I only.
Model I only (also may be used with Model III). Blinks right asterisk during tape load operations. NOTE: On Model III this location has jump to 0212H (zeroes A register and returns). Uses AF.
Inputs data one byte at a time from cassette after you use CSHIN. A = the data byte.
Outputs data one byte at a time to cassette after you use CSHWR. A = the output byte.
Turns on the cassette and writes the header.
Finds the cassette header info at the beggining of cassette file.
Basic’s SYSTEM routine.
Reads two bytes (LSB/MSB) and transfers to HL registers (used when reading SYSTEM format tapes). Uses AF,HL.
Output a byte to device determined by byte stored at (409CH) – FFH=Tape, 0=Video, l=Printer. When calling, A = output byte. Uses AF (may use other registers as well). Warning: This routine CALLS a Disk BASIC link at address 41ClH which may have to be “plugged” with a RETurn (C9H) instruction
Displays character in A on screen at next print position. Uses AF.
Calls keyboard scan routine.
Same as 002BH.
Reads keyboard into buffer until a carriage return is entered. 40A7H contains the address of the buffer.
Line printer driver for Model I.
Keyboard driver for Model I. Model III = 3024H.
Video driver for Model I.
Video driver for Model III.
“Start of cursor control table. Model I. 80 Microcomputing, Sept. 1980, p. 187.”
End of cursor control table.
Line printer driver for Model I.
Same as KBLINE. See 0040.
An alternative for entering Basic. See also 1A19H.
Start of Model 1 interrupts relocated to RAM on boot up.
End of Model 1 interrupts relocated to RAM on boot up.
Start of Model 1 keyboard DCB.
End of Model 1 keyboard DCB.
Start of Model 1 Video DCB.
End of Model 1 Video DCB.
Start of Model 1 Printer DCB.
End of Model 1 Printer DCB.
Subtract SA from RA; result in SA.
Add RA and SA; result in SA.
“If SA contains a 00H, RND generates a number between 0 and 1. Use this call to place a 00H in SA.”
Basic’s LOG function.
Multiply RA and SA; result in SA.
Divide RA by SA; result in SA.
Basic’s ABS function.
Move number of bytes shown by typeflag from area pointed to by DE to area pointed to by HL.
Basic’s SGN function.
Load SA into stack.
Load single precision number pointed to by HL into SA.
Load RA into SA.
Load SA into RA.
Load single precision number pointed to by HL into RA.
Load SA into area pointed to by HL.
Load single precision number pointed to by HL into area pointed to by DE; needs FLAGSP.
Load single precision number pointed to by DE into area pointed to by HL; needs FLAGSP.
“Move data; DE = source, HL = destination, A = how much to move.”
“Same as above, except B contains the count.”
Move number pointed to by HL into SA; needs FLAGDP.
Move SA into SA1.
Compare RA and SA1.
Compare DE and HL.
Compare SA and SA1.
Load parameter in USR(x) into HL; this must be first instruction of USR call. Also used for CINT function.
Return to Basic program with parameter.
Set typeflag of SA to interger.
Convert SA to single precision. Also Basic’s CSNG routine.
Value in workspace/accumulator is changed from integer to single precision.
Convert SA to double precision. Also Basic’s CDBL routine.
Set typeflag for SA to double precision.
Set typeflag for SA to single presision.
Basic’s FIX function.
Basic’s INT function.
Subtract HL from DE; result in HL and SA if no overflow (flag = 2); result in SA only if overflow (flag = 4).
Add DE and HL; result in HL and in SA if no overflow.
“Multiply DE and HL; result in HL and SA if no overflow (flag=2), result in SA only if overflow (flag=4)”
Subtract SA1 from SA; result in SA.
Add SA and SA1; result in SA.
Multiply SA and SA1; result in SA.
Divided SA by SA1; result in SA.
Display integer number in HL in ASCII decimal. The ASCII number will also be in memory at 4131H – 4135H.
Convert SA (set typeflag) to ASCII. Result (in dec) is placed in buffer starting at 4130H and terminated by a 00H byte and HL = 4130H.
Basic’s SQR function.
Raise RA to the power SA; result in SA.
Basic’s EXP function.
Basic’s RND function.
BASIC’s RND function if there is a number in the parenthetical
Basic’s COSine function.
Basic’s SIN function.
Basic’s TAN function.
Basic’s ATN function
“Beginning of jump table for Basic’s functions. For Basic’s jump statement table, see 1822H.”
End of jump table for Basic’s functions.
Beginning of table of names of Basic’s reserved words.
End of table of names of Basic’s reserved words.
“Beginning of jump table for Basic’s statements. For Basic’s jump funtion table, see 1608H.”
End of jump table for Basic’s statements.
“Start of BASIC error messages. Ie: NF, OM, etc.”
End of BASIC error messages.
Check for enough RAM for stack operation.
SN ERROR routine.
“Return to Basic and display Basic READY prompt (if you have difficulty with 1A19, try 06CCH or 0072H instead)”
Writes line pointers beginning from start of Basic program.
Writes line pointers beginning with line pointed to by DE.
“To use: Load DE with line number, call and this location. Upon exit, BC will contain location. 80 Micro, Feb. 1981, p. 148.”
Basic’s NEW routine.
“Reset Basic pointers? 80 Microcomputing, Nov 81, p. 386.”
Basic initialization routines (RUN).
Basic’s tokenizing routine. Point register pair HL to the start of the string to be tokenized terminated by a 0 byte and call 1BC0H. Upon exit, HL will point to one byte below the tokenized string which will be terminated by a 0 byte.
Basic’s FOR routine.
“HL points at “”:”” or 00H terminating a Basic statement or line; execution will proceed from next statement.”
Basic’s RESTORE routine.
Scan for shift @ and BREAK.
Basic’s STOP routine.
Basic’s END routine.
Basic’s CONT routine.
Basic’s TRON routine.
Basic’s TROFF routine.
Basic’s DEFSTR routine.
Basic’s DEFINT routine.
Basic’s DEFSNG routine.
Basic’s DEFDBL routine.
LOAD POSITIVE INTEGER EXPRESSION IN DE Same as following routine (at 1E5AH) except that HL may also point to any valid BASIC variable or expression, which must evaluate to a number in range 0 to 32767 decimal (used to get argument of BASIC CLEAR command). Note that this routine assumes that BASIC is operational. Results may be unpredictable if this is not the case, particularly if a BASIC variable name (or something that could be interpreted as such) is part of the string.
“Prints “”FC Error””.”
“Convert a string representing a decimal number and terminated by a 00H byte to a binary number. HL points at first character, DE contains result after call.”
LOAD POSITIVE INTEGER CONSTANT IN DE Evaluate the string at the address pointed to by the HL register pair for a positive integer value (such as a BASIC line number), stopping at the first non-numeric character. The result is returned in the DE register pair. A value of zero is returned if no numeric value is found. Maximum allowable number is 65529 decimal. NOTE: If this routine is being used to obtain a BASIC line number, it may be CALLed at 1E4FH. In this case, a period (2EH) character at (BL) will cause the routine to return with the “current” BASIC line number (as stored at 40ECH-40EDH).
Basic’s CLEAR routine.
Basic’s RUN routine.
Basic’s GOSUB routine.
Basic’s GOTO routine.
Basic’s RETURN routine.
Basic’s DATA routine.
Basic’s REM and/or ELSE routine.
Call Evaluate expression. Useful for doing complicated math functions in machine language. HL must point to a portion of memory that is in tokenized BASIC and terminated by a 00H byte or a “:” byte. Also known as Basic’s LET routine.
Basic’s ON routine.
Basic’s RESUME routine.
Basic’s ERROR routine.
Basic’s AUTO routine.
Basic’s IF routine.
Basic’s LPRINT routine.
Basic’s PRINT routine.
Basic’s INPUT routine.
Move string into space; HL points at first byte of buffer and BC points at variable name.
ASSIGN STRING(S) TO BASIC VARIABLE(S) This routine is part of the BASIC INPUT command routine, and can be used to process input obtained from CALLing one of the keyboard input routines at 1BB3B, 0361H, etc. On entry, BC must point to the first character of a string that contains the variable name(s) (if more than one variable name is used the names must be separated by commas, and a zero byte or colon must be placed after the last variable name). HL must point to the byte just prior to the beginning of the input string ( this is where it is placed by the above-mentioned input routines – note that this byte is altered by this routine), and the string may contain input for more than one variable (items must be separated by commas). String must be terminated with zero byte. On exit, the numbers or strings in the input will be assigned to the variables listed in the string containing the variable names. Numeric or string variables may be used, but only valid characters for numeric input may be used with numeric variables ( depending on how certain flags are set, a “?REDO” message or an error will occur if this rule is violated. To force the “?REDO” message, make sure that memory location 40DEH contains zero, and that location 40A9H contains a non-zero value. To determine if the “?REDO” message has occured, prior to calling the routine load memory locations 40E6H-40E7H with zero. If the HL register pair contains zero on exit, then an error has occured and the “?REDO” message has been printed). NOTE: For proper operation, the input string should be in the BASIC input buffer (as it will be if one of the input routines mentioned above is used) when this routine is CALLed. See chapter one of this book for information on the INPUT routine located at 21C9H.
Basic’s READ routine.
Basic’s NEXT routine.
“Gets a general (string, integer, single, or double precision) parameter in the accumulator and sets the type flag (40AFH) accordingly.”
EVALUATE EXPRESSION AT (HL) Evaluate BASIC string expression (may include constants, BASIC variables, BASIC functions, operators, etc.) and place result in ACCUM ( also set NTF). On entry, HL must point to first character of the string to be evaluated. On exit, HL will point to the string delimiter, which must be an acceptable BASIC expression terminator (such as a zero byte, a colon, a right parenthesis, etc.). NOTE: This routine may be entered at 2335H, in which case the HL register pair MUST point to a left parenthesis (which precedes the expression to be evaluated) or a BASIC syntax error will result. This routine assumes that BASIC is operational – result may be unpredictable if this is not the case.
Call Divide DE by HL; result in SA in single precision format. 2540 9536 LDVAWS Call Loads value of variable into workspace/ accumulator. On entry, HL points to first character of variable name. On exit, HL points to first character following variable name.
EVALUATE PARENTHESIZED EXPRESSION Evaluate any valid BASIC expression enclosed in parenthesis. Calls previous routine (at 2335H to check for right parenthesis). A BASIC syntax error will result if expression is not terminated with a right parenthesis.
LOAD ACCUM WITH VALUE OF BASIC VARIABLE Get value of BASIC variable and put in ACCUM ( also put precision of variable in NTF). On entry, HL must point to first character of variable name. On exit, HL will point to first character following variable name.
“Compare two strings. HL and BC point at strings, D and E contain lengths.”
Basic’s DIM statement.
“Get variable address in DE, HL points at variable name.”
LOCATE OR CREATE A BASIC VARIABLE This routine will locate the storage area in memory for an existing BASIC variable, or will assign a storage area for the specified variable if one does not presently exist. On entry, the HL register pair must point to the first character of the variable name. On exit, HL will point to the next character following the variable name, and DE will contain the address of the variable storage area ( same as would be returned in BASIC VARPTR function). NOTE: If the variable name does not contain a type declaration character ( !, %, #,or $ as the final character of the variable name), the variable will be set to the precision as defined by the variable type declaration table at 4101H through 411AH. This table is organized so that location 4101H contains a the variable type flag for variables that begin with the letter “A”, 4102H contains the flag for variables that start with “B”, 4103H contains the flag for variables starting with 91 C”, and so on. The flag digits are defined in the same manner as the NTF (integer= 2, string= 3, single= 4, double= 8). All table locations are set to 4 ( single precision) on power-up and when the BASIC RUN or CLEAR commands are executed. The table values are altered through use of the BASIC DEF commands (such as DEFINT, DEFSNG, DEFDBL, or DEFSTR).
Basic’s FRE routine.
Basic’s POS routine.
Basic’s STR$ routine.
“Output string terminated by a 00H byte or 22H (“”) byte.; HL points at first character, OUTSEL (409CH) selects device. See OUTSEL for device numbers.”
Basic’s LEN routine.
Basic’s ASC routine.
Basic’s CHR$ routine.
Basic’s STRING$ routine.
Basic’s LEFT$ routine.
Basic’s RIGHT$ routine.
Basic’s MID$ routine.
Basic’s VAL routine.
Basic’s INP routine.
Basic’s OUT routine.
Gets a two byte integer in DE.
LOAD INTEGER EXPRESSION IN DE Same as routine at 1E46H (described above) except allows negative argument. Number must evaluate within range -32768 to 32767.
“Evaluate expression? 80 Microcomputing, Nov 81, p. 386”
Gets a one byte integer in A.
Basic’s LLIST routine.
Basic’s LIST routine.
“Output string to current device. On entry, HL points to first character in string which ends in a 00 byte.”
“Write line of Basic in buffer, change tokens to words.”
Basic’s DELETE routine.
Basic’s CSAVE routine.
Basic’s CLOAD routine.
“Initialize for Basic. 80 Micro, Sep. 1980, p. 72.”
Basic’s PEEK routine.
Basic’s POKE routine.
Basic’s EDIT routine.
“Load HL with line number to edit and use this routine. 80 Micro, Feb. 1981, p. 148.”
Video driver for Model III.
“Get date in ASCII format. Mod III TRSDOS, LDOS, & MULTIDOS.”
“Get time in ASCII format. Mod III TRSDOS, LDOS, & MULTIDOS.”
Model III only. Prompts the user to set the cassette baud rate (displays “Cass?”). If user enters “L” the 500 baud rate is selected. If user enters “H” or “ENTER” the 1500 baud rate is selected. Cassette baud rate switch at 4211H is set to zero for 500 baud rate, 0DH or 48H (“ENTER” or “H”) if 1500 baud selected.
“Model I interrupt address port. Bit 7 set for clock, bit 6 set for disk.”
Model I disk drive select.
Model I cassette 1 or 2 select (0 or 1).
Lineprinter address port.
Model I disk command/status.
Model I disk track select.
Model I disk sector select.
Model I disk data.
Beginning of model I & III keyboard address ports.
End of model I & III keyboard address ports.