These 3 pages are a breakdown of the Model I ROM, with comments to help you understand what is going on. The two thing to keep in mind while reading this disassembly are:

- The ROM had to be one big long program starting from 0000H and ending at 2FFFH and everything it does had to be wedged into that single long block of code. This means that jumps to other locations are a necessity because once a particular portion of the ROM executes, if it was allowed to keep going, unintended portions would also execute. With this, there is a LOT of jumping away.
- There are only so many variables and only so many Z-80 instructions. There is no Z-80 instruction, for example, LD BC,SP. With this, there is a huge amount of variable swapping. I would dare say that whatever part of the ROM isn’t jumping, is just swapping variables around. The ROM would be a fraction of the size if there were more variables and more Z-80 instructions.

0000H-0004H – POWER UP ROUTINE – “DOSCLD” or “$RESET”

“SYNTAX”

(RST 008H)

This is the COMPARE SYMBOL routine which comparess the symbol in the input string pointed to by HL register to the value in the location following the RST 08 call. If there is a match, control is returned to address of the RST 08 instruction 2 with the next symbol in the Aregister and HL incremented by one. If the two characters do not match, a syntax error message is given and control returns to the Input Phase).

000BH-000FH – DISK ROUTINE – “WHERE”

This routine INCrements HL and tests the characters pointed to by the HL register pair. It will bypass any spaces and CHAR’S 9 and 10 (shifted left and down arrows respectively). Upon return from this routine HL will point to the next non-blank character; the carry flag will be SET if HL is pointing to a numeric ASCII character and the Z flag will be SET if the character pointed to happens to be zero (ASCII 30H) or 3AH (“:”). (BC and DE registers are unaffected) This routine can be used by CALLing 1D78H or RST l0H.

0013H-0017H – KEYBOARD ROUTINE

- This routine Inputs a byte from an input device. When calling, DE = starting address of DCB of device. On exit, A = byte received from device, Z set if device ready. Uses AF.

“INBYT”

“RST18”

(RST 018H)

This is the COMPARE DE:HL routine, which numerically compares DE and HL. Will not work for signed integers (except positive ones). Uses the A-register only. The result of the comparison is returned in the status register as: CARRY SET=HL<DE; NO CARRY=HL>DE; NZ=Unequal; Z=Equal).

001BH-001EH – DRIVER ENTRY ROUTINE – Part 1 – “PUT”

- This routine 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.

“OUTBYT”

Returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH). Integer = NZ/C/M/E and A is -1; String = Z/C/P/E and A is 0; Single Precision = NZ/C/P/O and A is 1; and Double Precision is NZ/NC/P/E and A is 5. This CALL is usually made to determine the type of the current value in REG 1. It should be used with caution, however since the mode flag and REG 1 can get out of phase particularly if some of the CALLS described here are used to load REG l.

“CTLBYT”

(RST 028H)

This is the DOS FUNCTION CALL routine at RST 28 (which passes request code in A-register to DOS for processing. Returns for non-disk system. For disk systems, the A register must contain a legitimate DOS function code. If the code is positive, the CALL is ignored and control returns to the caller. Note that the DOS routine discards the return address stored on the stack by the RST instruction. After processing control will be returned to the previous address on the stack).

002BH-002FH – KEYBOARD ROUTINE – “KBDSCN” or “$KBCHAR”

- Keyboard scanning routine. After CALLing 2BH, the A register will contain the ASCII value for the key that was pressed. The A register will contain 00H if no key was pressed at the time. Apart from the AF register pair the DE register pair is also used by the routine.

This Routine Performs an instantaneous scan of the keyboard. If no key is depressed control is returned to the caller with the Aregister and status register set to zero. If any key (except the BREAK key) is active the ASCII value for that character is returned in the A-register. If the BREAK key is active, a RST 28 with a system request code of 01 is executed. The RST instruction results in a JUMP to the DOS Exit 400C. On non-disk systems the Exit returns, on disk systems control is passed to SYSO where the request code will be inspected and ignored, because system request codes must have bit 8 on. After inspection of the code, control is returned to the caller of 002B. Characters detected at 002B are not displayed. Uses DE, status, and A register - This routine loads DE with address of keyboard DCB and scans keyboard. On exit, if no key pressed the A register will contain a zero byte, else the character input from the keyboard wi 11 be returned in A. Character is not echoed to video. Uses AF,DE (to save DE use routine at 03588).

“KBSCAN”

Note: 4015H holds Keyboard DCB – Device type.

This is the LOAD DEBUG routine, and loads the DEBUG program and transfers control to it. When DEBUG processing is complete, control is returned to the orginal caller. For non-disk systems control is returned immediately.

0033H-0037H – VIDEO ROUTINE – “$VDCHAR”

- Character print routine. A CALL 33H will print a character at the current cursor position. The A register must contain the ASCII code for the character or graphics figure that is to be printed before CALLing this routine. The DE register pair is used by the routine.

A call to 0033H displays the character in the A-register on the video. Control codes are permitted. All registers are used.

Note: 401DH holds Video DCB – Device type.

(RST 038H)

This is the INTERRUPT ENTRY POINT routine at RST 38H which is the system entry point for all interrupts. It contains a jump to a section of code in the Communications Region designed to field interrupts. That section of code consists of a DI (disables further interrupts) followed by a RET (returns to the point of interrupt) for non-disk systems, or a jump to an interrupt processor in SYSO if it is a DOS system. For DOS systems the interrupt handler consists of a task scheduler, where the exact cause of the interrupt is determined (usually a clock interrupt) and the next task from the task control block is executed. After task completion, control returns to the point of interrupt.

003BH-003FH – PRINTER ROUTINE – “PRCHAR” or “$PRCHAR”

- Character LPRINT routine. Same as 33H but outputs to line printer. (Contents of A register will be printed).
- A call to 003BH causes the character contained in the C-register to be sent to the printer. A line count is maintained by the driver in the DCB. When a full page has been printed (66 lines), the line count is reset and the status register returned to the caller is set to zero. Control codes recognized by the printer driver are:
- 00=Returns the printer status in the upper two bits of the A-register and sets the status as zero if not busy, and non-zero if busy.
- OB=Unconditionally skips to the top of the next page.
- OC=Resets the line count (DCB 4) and compares its previous value to the lines per page (DCB 3) value. If the line count was zero, no action is taken. If the line count was non-zero then a skip to the top form is performed.
- OD=Line terminator. Causes line count to be incremented and tested for full page. Usually causes the printer to begin printing.

“LPTBYT”

Note: 4025H holds Printer DCB – Device type.

0040H-0042H – INPUT ROUTINE – “KBLINE”

0046H-0048H – DRIVER ENTRY ROUTINE – Part 2

“GETCHR”

A CALL to this memory location returns as soon as any key on keyboard is pressed. ASCII value for character entered is returned in A register. Uses A, status, and DE registers.

0049H-004FH – KEYBOARD ROUTINE – “$KBWAIT”

- A call to 0049H returns as soon as any key on keyboard is pressed. ASCII value for character entered is returned in A register.

0050H-005FH – KEYBOARD LOOKUP TABLE

- This is a table of control characters used by BASIC.

“KBTBL”

0060H-0065H – DELAY ROUTINE – “$DELAY”

- This is a delay loop. The BC register pair is used as the loop counter. The duration of the delay, in microseconds, is the value of BC times 14.65. Register A is used.

“NMI”

This is the location to which program control jumps when the RESET button is pressed (Non Maskable Interrupt address).

0069H-0074H – NMI INTERRUPT ROUTINE (RESET) – “$INITIO”

- This part of the initialization routine checks to see if a disk drive is connected. If so, it will jump to 00H. (This is why the reset button will reinitialize DOS.)

0075H-0104H – INITIALIZATION ROUTINE

- This is part of the Level II initialization procedure. It moves a block of memory from 18F7H to l9lEH up to 4080H to 40A7H. (reserved RAM. area).

Note: 4080H-408DH is a division support routine.

“CSTLII”

Note: 4080H-408DH is a division support routine.

Note: 40A7H-40A8H holds the input Buffer pointer.

0091H-0104H – The rest of the initialization routine. Asks MEMORY SIZE ?, sets the memory pointers accordingly and prints RADIO SHACK LEVEL II BASIC , then it jumps to 1A19H which is the entry point for the BASIC command mode.

Note: 4152H-41A3H holds Disk Basic links.

001BH-001FH – VIDEO AND PRINTER ROUTINE

NOTE:

- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).

NOTE:

- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.

“MEMSIZ”

NOTE:

- The routine at 1E5A converts the ASCII string pointed to by HL to an integer deposited into DE. If the routine finds a non-numerica character, the conversion is stopped

Note: 40A0H-40A1H holds the start of string space pointer.

NOTE:

- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).

“DMEMSZ”

BASIC”

012DH-0131H – ?L3 ERROR ROUTINE

“L3ERR”

0132H-0134H – LEVEL II BASIC “POINT” COMMAND ENTRY POINT

“POINT“

“GRPHCS”

NOTE:

- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.

0135H-0137H – LEVEL II BASIC SET COMMAND ENTRY POINT

“SET“

“SET”

0138H-0139H – LEVEL II BASIC RESET COMMAND ENTRY POINT

“RESET”

“RESET”

013AH-019CH GRAPHICS ROUTINE

“GRAPH”

- Common code for SET/RESET/POINT – A will be 0 if POINT, 80H if SET and 1 for RESET.

28H

2CH

“SETRES”

Save the graphic character in register A in register B.

019DH-01C8H – LEVEL II BASIC INKEY$ ROUTINE

“INKEY”

NOTE:

- The RST 10H routine loads the next character from the string pointed to by the HL register into the A-register and clears the CARRY flag if it is alphabetic, or sets it if is alphanumeric.
- Blanks and control codes 09H and 0BH are ignored causing the following character to be loaded and tested.
- The HL register will be incremented before loading any character therfore on the first call the HL register should contain the string address minus one.
- The string must be terminated by a byte of zeros.

Note: 4099H holds the Last key pressed.

Note: 40AFH holds Current number type flag.

01C9H-01D2H – LEVEL II BASIC CLS ROUTINE – “$VDCLS”

- A CALL lC9H will clear the screen, select 64 characters and home the cursor. All registers are used.
- To use a ROM call to clear the screen, CALL 01C9H. The cursor is reset to the home position, which is 3C00H.

01D3H-01D8H – LEVEL II BASIC RANDOM ROUTINE

“RANDOM“

- This is part of the RANDOM routine which takes a value out of the REFRESH register, stores it in location 40ABH and then returns.

A call to 01D3H reseeds the random number seed (location 40AB) with the current contents of the refresh register. - NOTE: To run a RANDOM (seed the random number generator) via a ROM call just call CALL 01D3H. This causes the contents of R (memory refresh) to be stored in 40ABH. The entire 24 bit seed is stored in 40AAH-40ACH.

“RANDOM”

01D9H-01F7H – CASSETTE ROUTINE

“CWBIT”

01F8H-01FDH – CASSETTE ROUTINE (TURN OFF CASSETTE) – “$CSOFF”

- Turns cassette recorder off.
- To use a ROM call to turn the cassette off, CALL 01F8H

“CTON”

2CH

0212H-021DH – CASSETTE ROUTINE (TURN ON CASSETTE)

“DEFCAS”

- CALL 212H will select the cassette unit specified in A-register and starts motor. Units are numbered from one. All registers are used.
- To use a ROM call to turn on the cassette, execute the following instructions: LD A,0

CALL 0212H

“CLRCFF”

“STATFF”

Note: 403DH-4040H is used by DOS.

Note: 403DH-4040H is used by DOS.

022CH-0234H – CASSETTE ROUTINE (BLINK **)

- Alternately displays and clears an asterisk in the upper right hand comer. Uses all registers.

“CSTAR”

0235H-0240H – CASSETTE ROUTINE (READ A BYTE) – “$CSIN”

- This routine will read a byte from tape. A CALL 235H will return with the byte read from tape in the A register BC, DE and HL are unchanged.
- To use a ROM call to read a character from cassette (after the cassette has been turned on and leader and sync have been found), CALL 0235H. The input character will be in the A register. Again, the routine at 0235H must be called frequently enough to sustain the 500 baud rate if more than one character is to be read.

0241H-0260H – CASSETTE ROUTINE (READ A BIT)

- Routine waits for timing pulse, and then performs a timing loop. When the time is up it tests the tape for a bit, which will be “1” if present and “0” if not. A CALL 241H is used by 235H eight times to input one byte.

“CRBIT”

0261H-0263H – CASSETTE ROUTINE

“CW2BYT”

0264H-027DH – CASSETTE ROUTINE (WRITE A BYTE) – “$CSOUT”

- Writes the byte in the A register to tape. BC, DE and HL are unchanged by a CALL 264H.
- To use a ROM call to write a character onto cassette tape (after the cassette has been turned on and leader and sync have been recorded), load the character into the A register and CALL 0264H. If more than one character is to be written, the CALL 0264H must be executed with sufficient frequency to sustain the 500 baud recording rate. The routine provides automatic timing.

027EH-0283H – CASSETTE ROUTINE

0284H-0292H – CASSETTE ROUTINE (TURN ON CASSETTE AND WRITE LEADER)

- A call to 0284H writes a Level II leader on currently selected unit. The leader consists of 256 (decimal) binary zeros followed by a A5H. Uses the B and A registers.

“CWONWL”

“$CSHWR”

Load register B with the number of bytes to be written.

- To use a ROM call to write the cassette leader and sync byte, CALL 0287H

0293H-029EH – CASSETTE ROUTINE (TURN ON CASSETTE AND READ LEADER)

“$CSHIN”

Save the current BASIC program pointer in register pair HL on the stack.

- To use a ROM call to search for leader and sync byte, CALL 0296H

029FH-02A8H – CASSETTE ROUTINE (DISPLAY “**” ON VIDEO)

“CTSTARS”

Load register A with a * character. (“*” is 2AH).

02A9H-0329H – LEVEL II SYSTEM ROUTINE-ENTRY POINT-02B2H

“GSYSTR”

Note: 40DFH-40E0H holds Used by DOS.

“SYSTEM”

In NEWDOS 2.1, this is called during a SYSTEM operation.

NOTE:

- The string must be terminated by a byte of zeros.

0314H-0316H – This routine reads two bytes from tape (providing that the tape is already running) and puts them in the HL register pair. It is used by the SYSTEM routine to read the last two bytes on tape which give the entry point. A JP (HL) can then be executed to jump to the location specified, when used for this purpose. Only HL is used by this routine.

“GETADR”

“SYSGO”

Note: 40DFH-40E0H holds Used by DOS.

NOTE:

- The string must be terminated by a byte of zeros.

NOTE:

- The routine at 1E5A converts the ASCII string pointed to by HL to an integer deposited into DE. If the routine finds a non-numerica character, the conversion is stopped

032AH-0347H – OUTPUT ROUTINE

“OUTCHR”

- This is a general purpose output routine which outputs a byte from the A register to video, tape or printer. In order to use it, the location 409CH must be loaded with -1 for tape, 0 for video or 1 for the line printer.

Note: 409CH holds the current output device flag: -1=cassette, 0=video and 1=printer. - This routine outputs a byte to device determined by byte stored at (409CH) – FFH=Tape, 0=Video, l=Printer. When calling, A = output byte. Uses AF. Warning: This routine CALLs a Disk BASIC link at address 41ClH which may have to be “plugged” with a RETurn (C9H) instruction.

“DSPCHR”

In NEWDOS 2.1, this writes to the system output device.

Note: 409CH holds the current output device flag: -1=cassette, 0=video and 1=printer.

033AH-0347H – “CRTOUT” OUTPUT ROUTINE

- To use a ROM call to print a single character at the current cursor position, and to update the cursor position, load the ASCII value of the character into the A register and then CALL 033AH.
- To display special functions using a ROM call, load the A register with the value given below for the special function and then CALL 033AH.
- Backspace and erase previous character – 08H
- Carriage return and linefeed – 0DH
- Turn on cursor – 0EH
- Turn off cursor – 0FH
- Convert to 32 characters per line mode – 17H
- Backspace cursor – 18H
- Advance cursor one position – 19H
- Downward line feed – 1AH
- Upward line feed – 1BH
- Home (cursor to upper left corner) – 1CH
- Move cursor to beginning of current line – 1DH
- Erase from cursor position to end of line – 1EH
- Erase from cursor position to end of screen – 1FH

“CRTOUT”

Save the value in register pair DE on the stack.

Note: 40A6H holds the current cursor line position.

Note: 403DH-4040H is used by DOS.

Note: 4020H-4021H holds Video DCB – Cursor location.

0358H-0360H – KEYBOARD ROUTINE

Here is the routine to simulate the INKEY$ function. It performs exactly the same function as 2BH but it restores all registers, whereas 2BH destroys the contents of the DE register pair. This makes 35BH more useful than 2BH.

0361H-0383H – INPUT ROUTINE

“KIBUFF”

- This is one of the general purpose input routines (see 5D9 and 1BB3 also). This routine inputs a string from the keyboard, up to a maximum of 240 characters (F0H), and echoes them to the screen. It puts this data into a buffer located at the address pointed to by the buffer pointer at 40A7H. (e.g. If 40A7H contains 5000H the data will be stored from 5000H onwards). The string is terminated with a zero byte. The program returns from this routine as soon as the ENTER key has been pressed. When it does so, HL contains the start address of the input string and B contains the length of the string. (RST 10H can be used to make HL point to the first character of the string, if required.).

Note: 40A7H-40A8H holds the input Buffer pointer.

“LINP2”

Note: 4099H holds the Last key pressed.

Note: 40A6H holds the current cursor line position.

In NEWDOS 2.1, this is the satrt of keyboard input.

Note: 40A7H-40A8H holds the input Buffer pointer.

Note: 40A7H-40A8H holds the input Buffer pointer.

0384H-038AH – KEYBOARD ROUTINE

- Waits for keypress

- This routine resets device type flag at 409CH to zero (output to video display), also outputs a carriage return to the line printer if printer is not at beginning of line (determined by checking the contents of the printer line position flag at 409BH – if flag contains zero, printer is at start of line). Note that if printer line position flag does not contain zero and the printer is not on line, the computer will “hang up” waiting for a “printer ready” signal.

Note: 409CH holds the current output device flag: -1=cassette, 0=video and 1=printer.

Note: 409BH holds the printer carriage position.

- This is the LPRINT routine. All registers are saved. The byte to be printed should be in the A register.

Note: 409BH holds the printer carriage position.

Note: 409BH holds the printer carriage position.

03C2H-03E2H – DRIVER ENTRY ROUTINE

- This routine is called from a RST 14 (with a device code of 01H in Register B), RST 1C (with a device code of 02H in Register B), and RST 24 (with a device code of 04H in Register B).

- This is the keyboard driver. It scans the keyboard and converts the bit pattern obtained to ASCII and stores it in the A register.

Note: 4036H-403CH is the keyboard work area.

- This is the video driver. The character to be displayed should be in the C register. This routine handles scrolling etc.

This changes display to 64 character mode (A register is used).

Note: 403DH-4040H is used by DOS.

Note: 403DH-4040H is used by DOS.

Note: 403DH-4040H is used by DOS.

Note: 403DH-4040H is used by DOS.

Note: 403DH-4040H is used by DOS.

Note: 403DH-4040H is used by DOS.

“CURCON”

- 0541H – This subroutine displays the character in register A at the location HL and scrolls the screen if needed.

Note: 403DH-4040H is used by DOS.

- To use a ROM call to scroll (shift the entire display upward one line), CALL 0553H.

Clear to end of frame routine. To use this routine load the HL register pair with the screen address from which you want the erasing to start. The DE and A registers are used.

- To use a ROM call to clear the video screen from (including) position N – where N is an integer between 0 and 1023 (decimal), inclusive – to the end of the display, Load the HL register with the value 3C00H + N and then CALL 057CH.

- LPRINT driver routine, handling printer I/O etc. The character to be printed should be in register C.

05D1H – Get printer status routine.

- A call to 05D1 will return the status of the line printer in the status register as 0 if the printer is ready/selected, and non-zero if not ready, as follows:
- Bit 7 = Printer Busy. 1=Busy
- Bit 6 = Paper Status. 1= Out of paper.
- Bit 5 = Printer Ready. 1 = Ready.
- All other bits are not used.

05D9H-0673H – ACCEPT KEYBOARD INPUT ROUTINE

“KLINE”

- This is the most basic of the string input routines and is used by the two others (1BB3H and 0361H) as a subroutine. To use it, load HL with the required buffer address and the B register with the maximum buffer length required. Keyboard input over the specified maximum buffer length is ignored, and after pressing the (ENTER) key it will return with HL containing the original buffer address and B with the string length.

A call to this memory location Accepts keyboard input and stores each character in a buffer supplied by caller. Input continues until either a carriage return or a BREAK is typed, or until the buffer is full. All edit control codes are recognized, e.g. TAB, BACKSPACE, etc.

On exit the registers contain: HL=Buffer address, B=Number of characters transmitted excluding last, C=Orginal buffer size, A=Last character received if a carriage return or BREAK is typed. Carry Set if break key was terminator, reset otherwise. If the buffer is full, the A register will contain the buffer size. - To use a ROM call to accept a restricted number of keyboard characters for input (n), use:

LD HL,(40A7H)

LD B,n

CALL 05D9H

Up to n characters will be accepted, after which the keyboard will simply be ignored until the ENTER (or LEFT ARROW, or BREAK, or CLEAR) key is pressed. These characters will be stored in consecutive memory cells starting at the address contained in 40A7H-40A8H (the keyboard buffer area), with a 0DH (carriage return) byte at the end. Upon completion, the HL register pair will contain the address of the first character of the stored input, and the B register will contain the number of characters entered. NOTE: No “?” is displayed as a result of the execution of the above program. If the “?” display is desired to prompt the typing of the input, precede the above program segment with:

LD A,3FH

CALL 033AH

LD A,20H

CALL 033AH

“LINP1”

0630H – This subroutine assumes B is the number of characters received, and C is the size of the buffer.

0641H – This subroutine sends the position command.

0661H – This subroutine is called when a BREAK key is hit.

0674H-06D1H – INITIALIZATION ROUTINE

06CCH-06CEH – Alternative re-entry point into BASIC.

- A JP to here is often better than a jump to lA19H as the latter sometimes does strange things to any resident BASIC program.

06D2H-0707H – ROM STORAGE LOCATION FOR DATA TO BE MOVED TO RAM BY THE INITIALIZATION PROCESS.

070BH-070FH – SINGLE PRECISION ADDITION, REG 1 = (HL) + REG 1

- Single-precision addition (REG 1=(HL)+ACC) involving a buffer pointed to by the HL register pair and REG 1 (see arithmetic section in Part 2 of this manual for information on the ACC). This part of the program loads the BCDE registers with the value from the buffer, then passes control to 716H.

0710H-0712H – SINGLE PRECISION SUBTRACTION, REG 1 = (HL) – REG 1

- Single-precision subtraction (REG 1=(HL)-REG 1). This loads the BCDE registers with the value from (HL), then passes control to 0713H.

0713H-0715H – SINGLE PRECISION SUBTRACTION, REG 1 = BCDE – REG 1

“SUBSP”

- Single-precision subtraction (REG 1=BCDE-REG 1). The routine actually inverts REG 1 and adds it to the contents of the BCDE registers which, in effect, is a subtraction. The result will be stored in the arithmetic work area (REG 1).
- Note: If you wanted to subtract two single precision numbers, store the minuend in the BCDE registers and store the subtrahend in 4121H-4124H and then CALL 0713H. The result (in single precision format) is in 4121H-4124H in approximately 670 microseconds.

.

“SSUB”

0716H-0752H – SINGLE PRECISION ADDITION, REG 1 = BCDE + REG 1

“ADDSP”

- Single-precision addition (REG 1=BCDE+ACC). This routine adds two single-precision values and stores the result in REG 1 area.
- Note: If you wanted to add 2 single precision numbers via a ROM call, store one input into BCDE (with the exponent in B and the LSB in E) and the other into 4121H-4124H, and then call 0716H. The single precision result will be in 4121H-4124H approximately 1.3 milliseconds later.

“SADD”

0754H-077CH – SINGLE PRECISION MATH ROUTINE

“RSETSA”

077DH-07A7H – SINGLE PRECISION MATH ROUTINE

07A8H-07B6H – SINGLE PRECISION MATH ROUTINE

07B7H-07C2H SINGLE PRECISION MATH ROUTINE

07C3H-07D6H – SINGLE PRECISION MATH ROUTINE – Convert to a single precision number to positive.

Note: 4125H-4126H is used by floating point routines.

07D7H-07F7H – SINGLE PRECISION MATH ROUTINE

07F8H-07FBH – SINGLE PRECISION CONSTANT STORAGE LOCATION

07FCH-0808H – SINGLE PRECISION CONSTANTS STORAGE LOCATION2

0809H-0846H – LEVEL II BASIC LOG ROUTINE – LOG

- The LOG(n) routine, (REG 1=LOG (REG 1)). This routine finds the LOGarithm of the value in REG 1 area.

A call to 0809H computes the natural log (base E) of the single precision value in REG 1. The result is returned as a single precision value in REG 1. - NOTE: To use a ROM call to find LOG(X), where X is a positive single precision variable, store the value of X in 4121H-4124H and then CALL 0809H. The result (in single precision format) is in 4121H-4124Hin approximately 19 milliseconds. NOTE: A fatal error occurs if the value of the input variable is zero or negative.

0847H-0891H – SINGLE PRECISION MULTIPLICATION, REG 1 = BCDE * REG 1 – “MLTSP”

- Single-precision multiplication (REG 1=BCDE*ACC).

Multiplies the current value in WRAl by the value in (BC/DE). the product is left in WRAl. - Note: If you wanted to multiply two single precision numbers store one operand in the BCDE registers, the other in 4121H-4124H CALL 0847H. The result (in single precision format) is in 4121H-4124H in approximately 2.2 milliseconds.

0892H-0896H – SINGLE PRECISION MATH ROUTINE

This is accomplished by a circular shift of BC/DE one byte – B is lost, C is replaced by A.

0897H-08AlH – SINGLE PRECISION MATH ROUTINE

08A2H-0903H – SINGLE PRECISION DIVISION, REG 1 = BCDE / REG 1

- “DIVSP” – Single-precision division (REG 1=BCDE/REG 1). If REG 1=0 a ” /0 ERROR ” will result.

This routine will divide the SINGLE PRECISION value in register pairs BC and DE by the single precision value in REG 1. The result is returned in REG 1. - To use a ROM call to divide two single precision numbers, store the dividend in registers BCDE, and the divisor in 4121H-4124H and then CALL 08A2H. The result (in single precision format) is in 4121H-4124H and then pproximately 4.8 milliseconds. Overflow or /0 will error out and return to Level II.

Note: 4080H-408DH is a division support routine.

0904H-0906H – DISPLAY OV ERROR MESSAGE

0907H-0913H – DOUBLE PRECISION MATH ROUTINE

0914H-0930H – SINGLE PRECISION MATH ROUTINE

0931H-093DH – SINGLE PRECISION MATH ROUTINE

093EH-0954H – SINGLE PRECISION MATH ROUTINE

0955H-0963H – SINGLE PRECISION MATH ROUTINE

- Checks if REG 1=0. If so, the Z flag will be set.

0964H-0976H – SINGLE PRECISION MATH ROUTINE

0977H-0989H – LEVEL II BASIC MATH ROUTINE

“ABS“

- ABS routine (REG 1=ABS(REG 1)) input and output can be integer, single-precision or double-precision, depending on what is placed in the NTF (NTF=2, 4 or 8).

A call to 0977H converts the value in Working Register Area 1 (WRAl) to its positive equivalent. The result is left in REG 1. If a negative integer greater than 2** 15 is encountered, it is converted to a single precision value. The data type or mode flag (40AFH) will be updated to reflect any change in mode. - NOTE: To use a ROM call to find ABS(X),store the value of X in 4121H-4122H (integer), in 4121H-4124H (single precision), or in 411DH and then H (double precision), and store the variable type (2, 4, or 8, respectively) in 40AFH. Then CALL 0977H. The result (in the same format as the input variable) is in the same locations in which the input variable was stored. If the input was an integer, the result is also in the HL register pair.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

“MVVAR”

NEGATE function for single-precision values (REG 1=-REG 1). Only BC and DE are saved.

098AH-0993H – LEVEL II BASIC MATH ROUTINE

“SGN“

- SGN function (REG 1=SGN(REG 1)). After execution, NTF=2 and REG 1=-l, 0 or 1 depending on sign and value of ACC before execution.
- NOTE: To use a ROM call to find SGN(X), store the value of X in 4121H-4122H (integer), in 4121H-4124H (single precision), or in, s-4124H (double precision) and then store the variable type (2, 4, or 8, respectively) in 40AFH and then CALL 098AH. The result (in integer format) is in 4121H-4122H and in the HL register pair.

0994H-09A3H – LEVEL II BASIC MATH ROUTINE

- This routine checks the sign of the ACC. NTF must be set. After execution A register=00 if REG 1=0, A=01 if ACC > 0 or A=FFH if A < 1. The Flags are also valid.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

09A4H-09B0H – SINGLE PRECISION MATH ROUTINE

“LDSTSA”

- Loads Single-precision value from ACC to stack ((SP)=ACC). To retrieve this value, POP BC followed by POP DE. A, BC and HL are unchanged by this function.

“SSTAK”

09BlH-09BEH – SINGLE PRECISION MATH ROUTINE

“LDSAHL”

- This routine loads four bytes from the location pointed to by HL, into the ACC. (REG 1=(HL)).

“SCOPY”

“DSTOR”

This routine loads REG 1 with the contents of the BC and DE register pairs. (REG 1=BCDE). BC and HL remain unaltered.

09BFH-09CAH – SINGLE PRECISION MATH ROUTINE

“LDRASA”

- This routine is the opposite of the 09B4H routine. It loads four bytes from REG 1 (single-precision) into the BC and DE register pairs. (BCDE=ACC). A is unchanged.

“SGET”

This routine will load the BCDE register pairs with four bytes from the location pointed to by HL. (BCDE=(HL)),. With these types of data movements, the E register is loaded with the LSB and the B register. with the MSB.

09CBH-09DlH – SINGLE PRECISION MATH ROUTINE

“LDHLSA”

- This routine is the opposite of the 9B1H routine. It loads four bytes from REG 1 to the memory location pointed to by HL. ((HL)=ACC).

Data move routine. This moves four bytes from the location pointed to by DE into the location pointed to by HL. ((HL)=(DE)).

09D2H-09DEH – MOVE VALUE POINTED TO BY HL TO THE LOCATION POINTED TO BY DE

“LDDEHL”

- This is the VARIABLE MOVE Routine which moves the number of bytes specified in the type flag (40AFH) from the address in DE to the address in HL. Uses A, DE and HL.

Data move routine. The location pointed to by DE is loaded with bytes from the location pointed to by HL. The number of bytes moved is determined by the value in the NTF. ((DE)=(HL)).

“LDHLDE”

This routine is similar to 9D2H above. The only difference is that it moves data in the opposite direction. ((HL) = (DE)).

Note: 40AFH holds Current number type flag.

“MOVEA”

This routine is the same as 9D3H except that the number of bytes moved depends on the value in the A register ((HL) = (DE)).

“MOVEB”

This routine is the same as 9D6H except that the number of bytes shifted is determined by the value in the B register ((HL)=(DE)).

This is the GENERAL PURPOSE MOVE routine and moves the contents of the B Register bytes from the address in DE to the address in HL).

09DFH-09F3H – SINGLE PRECISION MATH ROUTINE

09F4H-09FBH – LEVEL II BASIC MATH ROUTINE

- This routine is used by the double-precision logic. It moves a number of bytes (the number depending on the value stored in the NTF) from the AACC into the ACC. ((REG 1)=(AACC)).

Note: 4127H-412EH holds REG 2.

“MVSAHL”

09FCH-0A0BH – LEVEL II BASIC MATH ROUTINE

- This is the opposite of 9F4H. ((AACC)=(REG 1)).

“MVALT”

Note: 4127H-412EH holds REG 2.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

Note: 411DH-4124H holds REG l.

0A0CH-0A25H – SINGLE PRECISION COMPARE

“CPSP”

- Single-precision compare. Compares REG 1 with the contents of BCDE registers. After execution of this routine, the A register will contain: A=0 if REG 1=BCDE, A=1 if ACC>BCDE or A=FFH if ACC<BCDE.
- NOTE: To use a ROM call to compare two single precision numbers, store the first input in registers BCDE, the second input in 4121H-4124H and then CALL 0A0CH. If the numbers are equal, the Z (zero) flag will be set. If they are not equal, the Z flag will be turned off. If the first input number is the smaller, the S (sign) and C (carry) flags will also be turned off. If the second input number is the smaller, the S and C flags will both be set.

0A26H-0A38H – SINGLE PRECISION COMPARISON ROUTINE

- Integer compare. Compares HL with DE. After execution, A=0 if HL=DE, A=1 if HL>DE or A=FFH if HL<DE. The S and Z flags are valid.
- NOTE: To use a ROM call to compare two integers, store the first input in DE, the second in HL and then CALL 0A39H. If the numbers are equal, the Z (zero) flag will be set. If they are not equal, the Z flag will be turned off. If the first input number is the smaller, the S (sign) and C (carry) flags will also be turned off. If the second input number is the smaller, the S and C flags will both be set.

0A49H-0A77H – DOUBLE PRECISION COMPARE

- Double-precision compare. Compares REG 1 with the AACC. After execution the A register will contain: A=0 if REG 1=AACC, A=1 if ACC > AACC or A=FFH if ACC < AACC. S and Z flags are valid.

Note: 4127H-412EH holds REG 2.

0A78H-0A7EH – DOUBLE PRECISION COMPARE

“CPDP”

- Double-precision compare. This compare is the opposite of the A4FH compare. It compares the AACC with the ACC. (Remember that a compare is actually a subtraction that is never executed therefore a compare can be done in two ways with the same values. (A-B and B-A)). The results are the same as the A4FH routine.
- NOTE: To use a ROM call to compare two double precision number, store the first input in 411DH-4124H, and store the second input in 4127H-412EH and then CALL 0A78H. If the numbers are equal, the Z (zero) flag will be set. If they are not equal, the Z flag will be turned off. If the first input number is the smaller, the S (sign) and C (carry) flags will also be turned off. If the second input number is the smaller, the S and C flags will both be set.

0A7FH-0AB0H – LEVEL II BASIC CINT ROUTINE

- CINT routine. Takes a value from ACC, converts it to an integer value and puts it back into the ACC. On completion, the HL register pair contains the LSB of the integer value, and the NTF contains 2 (Integer=2). If NTF=3 (string) a TM ERROR will be generated and control will be passed to BASIC.

“CINT”

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

- NOTE: To use a ROM call to call the CINT routine, store the single precision input variable in 4121H-4124H and then call to 0A8AH and bypass all the foregoing. After the call, the integer result would be in 4121H-4122H and in the HL register pair. Too big a number will generate a ?OV Error.

“ISTOR”

This is the routine that returns the value in the HL register pair to the BASIC program that called it. In effect it moves the content of HL into REG 1 (ACC = HL).

“FLAGIN”

Set NTF to Integer (2). (A=used).

Note: 40AFH holds Current number type flag.

NOTE: The routine at 0A0CH algebraically compares the single precision value in BC/DE to the single precision value REG 1.

The results are stored in A as follows:

- A=0 if REG 1 = BCDE
- A=1 if REG 1>BCDE; and
- A=FFH if REG 1<BCDE.

0AB1H-0ACBH – LEVEL II BASIC CSNG ROUTINE

“CSASP”

- CSNG routine. Takes value from ACC and converts it to single-precision. The result is put in ACC and NTF contains 4.

“CSNG”

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

0ACCH-0ADAH – LEVEL II BASIC MATH ROUTINE

“CHGIS”

- Convert Integer to Single Precision.
- Note: If you wanted to convert integer to single precision via a ROM call, you would store the integer input variable in 4121H-4122H and then call to 0ACCH. The result (as a single precision number) will be in 4121H-4124H.

0ADBH-0AEDH – LEVEL II BASIC CDBL ROUTINE

“CSADP”

- CDBL routine. Takes a value from ACC and converts it to double-precision. The result will be in ACC and NTF will be 8.

“CDBL”

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

Note: 411DH-4124H holds REG l.

“FLAGDP”

0AEEH-0AF3H – LEVEL II BASIC MATH ROUTINE

“FLAGSP”

0AF4H-0AFAH – LEVEL II BASIC MATH ROUTINE

- This routine calls 20H (RST 20H) and returns if NTF=3 (string) else if NTF is not 3 then it generates a TM ERROR. BC, DE, and HL are saved.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

This is the entry point for the TM ERROR.

0AFBH-0B1EH – LEVEL II BASIC MATH ROUTINE

- This routine will reset the BC and DE register pairs if the A register contains 0. (XOR A before calling this routine).

0BlFH-0B25H – LEVEL II BASIC MATH ROUTINE

0B26H-0B58H – LEVEL II BASIC FIX ROUTINE

“FIX”

- FIX routine. Takes a value from ACC and converts it to an integer value. The result will be in ACC. NTF will be 2 if value is smaller than 32767 else it will be 4. An error will be generated if NTF=3 (string).

A call to 0B26H unconditionally truncates the fractional part of a floating point number in REG 1. The result is stored in WRAl and the type flag is set to integer. - Note: If you wanted to call the FIX routine via a ROM call, you would store the single-precision input variable in 4121H-4124H, then put a 4 into 40AFH to flag as single precision, and then call to 0B26H. If the result can be an integer, it will be in 4121H-4122H and in the HL register pair. If single precision, the result will be in 4121H-4124H. If double precision, in 411DH-4124H. In all cases 40AFH will have the data mode flag as 2, 4, or 8, accordingly.

“FIX”

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

0B37H – LEVEL II BASIC INT( ROUTINE

A call to 0B37H returns the integer portion of a floating point number. If the value is positive, the integer portion is returned. If the value is negative with a fractional part, it is rounded up before truncation. The integer portion is left in REG 1. The mode flag is updated.

“INT”

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

Note: If you wanted to call the INT routine via a ROM call, you would store the single precision input variable in 4121H-4124H, put a 4 into 40AFH (to flag as single precision), and then call 0B3DH and bypass all the foregoing. After the call, the integer result would be in 4121H-4122H and in the HL register pair IF the absolute value of the input did not exceed 32767. Otherwise it will be in 4121H-4124H in single precision format, and 40AF will be a 2 for integer or 4 for single precision..

0B59H-0B9DH – LEVEL II BASIC MATH ROUTINE

Note: 411CH holds Used by floating point routines.

0BA0H-0BA9H – LEVEL II BASIC MATH ROUTINE

Note: 411DH-4124H holds REG l.

0BAAH-0BC6H – LEVEL II BASIC MATH ROUTINE

0BC7H-0BD1H – INTEGER SUBTRACTION

“SUBINT”

- Integer subtract. (REG 1=DE-HL) The result is returned in both REG 1 and the HL register pair.

Subtracts the value in DE from the value in HL. The difference is left in the HL register pair. DE is preserved. In the event of underflow, both values are converted to single precision and the subtraction is repeated. The result is left in REG 1 and the mode flag is updated accordingly. - Note: If you wanted to subtract 2 integers via a ROM call, store one into DE and the subtrahend in HL (i.e., to do 26-17, DE gets 26), and then call 0BC7H. The integer result will be stored in 4121H-4122H approximately 210 microseconds later, and 40AFH will be set to 2 (to flag it as an integer). If there is an overflow, it will be converted to single precision (with 40AFH being a 4 in that case) and will be stored in 4121H-4124H.

“ISUB”

0BD2H-0BF1H – INTEGER ADDITION

“ADDINT”

- Integer addition (REG 1=DE+HL). After execution NTF=2, or 4 if overflow has occurred, in which case the result in REG 1 will be single-precision. The result is returned in both REG 1 and the HL register pair.

Adds the integer value in DE to the integer in HL. The sum is left in HL and the orginal contents of DE are preserved. If overflow occurs (sum exceeds 2**15), both values are converted to single precision and then added. The result would be left in Reg 1 and the mode flag would be updated. - Note: If you wanted to add 2 integers via a ROM call, store one input into DE and the other into HL, and then call 0BD2H. The result will be in 4121H-4122H and in HL, with a 2 in 40AFH, and will take about 130 microseconds. If there is an overflow, the result will be converted to Single Precision and put into 4121H-4124H (with a 4 in 40AFH).

0BF2H-0ClEH – INTEGER MULTIPLICATION

“MLTINT”

- Integer multiply. (REG 1=DE*HL). Multiplies HL by DE. The product is left in HL and DE is preserved. If overflow occurs, both values are converted to single precision and the operation is restarted. The product would be left in REG 1.
- Note: If you wanted to multiply two integers, store one input in DE, the other in HL CALL 0BF2H. The result is in 4121H-4122H and in HL, with a 2 in 40AFH (but in an overflow the result is converted to single precision format and stored in 4121H-4124H, with a 4 in 40AFH. Process takes approximately 900 microseconds.

“IMUL”

0ClFH-0C34H – LEVEL II BASIC MATH ROUTINE

0C37H-0C44H – LEVEL II BASIC MATH ROUTINE

0C45H-0C5AH – LEVEL II BASIC MATH ROUTINE

Negate HL routine. This routine changes the sign of the HL register pair and stores it in the ACC. (HL=REG 1=-HL) The result is returned in both the HL register pair and the ACC.

0C5BH-0C6FH – LEVEL II BASIC MATH ROUTINE

0C70H-0C76H – DOUBLE PRECISION SUBTRACTION

“SUBDP”

- Double-precision subtraction (REG 1=ACC-AACC).

Subtracts the double precision value in REG 2 from the value in REG 1. The difference is left in REG 1. - Note: If you wanted to subtract two double precision numbers, store the minuend in 411DH-4124H and the subtrahend in 4127H-412EH, and CALL 0C70H. The result (in double precision format) is in 411DH-4124H in approximately 1.3 milliseconds.

“DSUB”

0C77H-0CCEH -DOUBLE PRECISION ADDITION

“ADDDP”

- Double-precision addition (REG 1=ACC+AACC).

Adds the double precision value in REG 2 to the value in REG 1. Sum is left in REG 1. - Note: If you wanted to add 2 double precision numbers via a ROM call, store one input into 411DH-4124H and the other in 4127H-412EH. Then call 0C77H. The double precision result will be stored in 411DH-4124H approximately 1.3 milliseconds later.

“DADD”

Note: 411CH holds Used by floating point routines.

0CCFH-0DlFH – DOUBLE PRECISION MATH ROUTINE

Note: 4125H-4126H is used by floating point routines.

Note: 411CH holds Used by floating point routines.

Note: 411CH holds Used by floating point routines.

Note: 411CH holds Used by floating point routines.

Note: 4125H-4126H is used by floating point routines.

0D20H-0D32H – DOUBLE PRECISION MATH ROUTINE

Note: 411DH-4124H holds REG l.

0D33H-0D44H – DOUBLE PRECISION MATH ROUTINE

Note: 4127H-412EH holds REG 2.

Note: 411DH-4124H holds REG l.

0D45H-0D56H – DOUBLE PRECISION MATH ROUTINE

Note: 4127H-412EH holds REG 2.

Note: 411DH-4124H holds REG l.

0D57H-0D68H – DOUBLE PRECISION MATH ROUTINE

Note: 411CH holds Used by floating point routines.

0D69H-0D8FH – DOUBLE PRECISION MATH ROUTINE

0D90H-0D96H – DOUBLE PRECISION MATH ROUTINE

0D97H-0DA0H – DOUBLE PRECISION MATH ROUTINE

0DAlH-0DD3H – DOUBLE PRECISION MULTIPLICATION

“MLTDP”

- Double-precision multiplication (REG 1=ACC*AACC).

Multiplies the double precision value in REG 1 by the value in REG 2. The product is left in REG 1. - Note: If you wanted to multiply two double precision numbers store one operand in 411DH-4124H, and store the other in 4127H-412EH and then CALL 0DA1H. The result (in double precision format) is in 411DH-4124H in approximately 22 milliseconds.

0DB2H – INTEGER ADD routine

Adds the integer value in DE to the integer in HL. The sum is left in HL and the orginal contents of DE are preserved. If overflow occurs (sum exceeds 2**15), both values are converted to single precision and then added. The result would be left in REG 1 and the mode flag would be updated.

“IADD”

0DD4H-0DDBH – DOUBLE PRECISION CONSTANT STORAGE AREA

0DDCH-0DE4H – DOUBLE PRECISION MATH ROUTINE

Note: 4127H-412EH holds REG 2.

0DE5H-0E38H – DOUBLE PRECISION DIVISION

“DIVDP”

- Double-precision division (REG 1=ACC / AACC).

Divides the double precision value in WRAl by the value in REG 2. The quotient is left in REG 1. - To use a ROM call to divide two double precision numbers, store the dividend in 411DH-4124H, and the divisor in 4127H-412EH and then CALL 0DE5H. The result (in double precision format) is in 411DH-4124H and then pproximately 42 milliseconds. Overflow or /0 will error out and return to Level II.

“DDIV”

Note: 414AH-4151H holds Used by floating pointer routines.

Note: 4127H-412EH holds REG 2.

Note: 414AH-4151H holds Used by floating pointer routines.

Note: 4127H-412EH holds REG 2.

Note: 411DH-4124H holds REG l.

Note: 414AH-4151H holds Used by floating pointer routines.

0E39H-0E4CH – DOUBLE PRECISION MATH ROUTINE

0E4DH-0E64H – LEVEL II BASIC MATH ROUTINE

- This routine multiplies the current DP value by 2 by adding it to itself. First the current value is moved to a saved location, and then DP add routine adds the current value to that saved value.

0E65H-0F88H – ASCII TO DOUBLE PRECISION

- This routine converts an ASCII string (pointed to by HL) to a double-precision value and stores it in the ACC. The NTF is fixed accordingly. The string must be terminated with a , or zero byte. Note that the AACC is destroyed in the process and that HL will point to the delimiter at the end of the string. The string formats must follow the same rules as in BASIC.

0E6CH – ASCII to Binary Converter

- A call to 0E6CH converts the ASCII string pointed to by HL to binary. If the value is less than 2** 16 and does not contain a decimal point or an E or D descriptor (exponent), the string will be converted to its integer equivalent. If the string contains a decimal point or an E, or D descriptor or if it exceeds 2** 16 it will be converted to single or double precision. The binary value will be left in REG 1 and the mode flag will be to the proper value.
- Note: If you wanted to do this conversion via a ROM call, first have the characters assembled in consecutive memory locations, with either a comma or a 00H at the end. Load HL with the address of the first character. Call 0E6CH. If the output can be an integer, it will be in 4121H-4122H (with 40AFH being a 2). If the output has to be single precision, it will be in 4121H-4124H (with 40AFH being a 4). If the output has to be double precision, it will be in 411DH-4124H (with 40AFH being an 8).

“ASTOR”

This routine is the same as E65H above, except that it fixes REG 1 and NTF to the smallest possible number type.

NOTE:

- The string must be terminated by a byte of zeros.

NOTE:

- The string must be terminated by a byte of zeros.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

NOTE: The RST 20H routine determines the type of the current value in REG 1 and returns a combination of STATUS flags and unique numeric values in the A Register according to the data mode flag (40AFH).

The results are returned as follows:

- Integer = NZ/C/M/E and A is -1
- String = Z/C/P/E and A is 0
- Single Precision = NZ/C/P/O and A is 1
- and Double Precision is NZ/NC/P/E and A is 5.

NOTE: The routine at 0A0CH algebraically compares the single precision value in BC/DE to the single precision value REG 1.

The results are stored in A as follows:

- A=0 if REG 1 = BCDE
- A=1 if REG 1>BCDE; and
- A=FFH if REG 1<BCDE.

0F89H-0F93H – SINGLE PRECISION MATH ROUTINE

0F94H-0FA6H – LEVEL II BASIC MATH ROUTINE

0FA7H-0FAEH – DISPLAY MESSAGE ROUTINE

NOTE:

- The routine at 28A7 displays the message pointed to by HL on current system output device (usually video).
- The string to be displayed must be terminated by a byte of machine zeros or a carriage return code 0D.
- If terminated with a carriage return, control is returned to the caller after taking the DOS exit at 41D0H (JP 5B99H).

0FAFH-0FBCH – CONVERT BINARY TO ASCII AND DISPLAY RESULT

This routine converts the value in the HL register pair (which is assumed to be an integer) to ASCII and display it at the current cursor position on the video screen.

0FBDH-1363H – BINARY TO ASCII CONVERSION ROUTINE

“CSAASC”

- Conversion routine. Converts the value from REG 1 to an ASCII string delimited with a zero byte. The number type can be any of Integer, single or double-precision. After execution HL will be pointing to the start of the string. REG 1 and AACC are destroyed by the process.
- To use a ROM call to convert a number to a string of digits, and to display the latter on the video screen starting at the current cursor position, store the number in 4121H-4122H (if it’s an integer), or in 4121H-4124H (if it’s single precision), or in 411DH-4124H (if it’s double precision). Then store the variable type (2, 4, or 8, respectively) in 40AFH. Call 0FBDH and then call the WRITE MESSAGE routine at 28A7H.
- NOTE 1: The routine at 0FBDH is the conversion routine described in Section 3.3 (a). The subroutine at 28A7H is a general program for displaying a string of characters and updating the cursor position. The string to be displayed must be terminated by a zero byte, and the HL register pair must contain the address of the first character of the string before 28A7H is called. (The routine at 0FBDH effects this setup automatically.)
- NOTE 2: Many of the ROM routines described in this book require a numeric input (or inputs). For most of these, the instructions given for calling them have not included the storage of the variable type flag in 40AFH. The reason is that, wherever possible, the variable type flag storage has been finessed by the choice of the subroutine entry point. In the routine of this section, that has not been possible, nor was it possible for the INT, the FIX, the Number to Numeric String, the SGN, or the ABS routines. Storing a 2, 4, or 8 in 40AFH takes only 5 bytes of machine code, but there are subroutines in the Level II ROM that can reduce the required code to 3 bytes. CALL 0A9DH will store a 2 in 40AFH. CALL 0AEFH will store a 4 in 40AFH. And, finally, CALL 0AECH will store an 8 in 40AFH; this last subroutine, however, destroys the contents of the BC register pair. DISK SYSTEM CAUTION: The subroutine at 28A7H has two exits to DISK BASIC, with RAM transfer points at 41C1H and 41D0H. To use this routine safely, either be certain that DISK BASIC is in place or have your assembly language program fill locations 41C1H and 41D0H with RET’s (C9H), before calling the routine.

“NEDIT”

0FBEH-0FC0H – FLOATING to ASCII Conversion Routine

- This routine converts a single or double precision number in REG 1 to its ASCII equivalent. The ASCII value is stored at the buffer pointed to by the HL register pair. As the value is converted from binary to ASCII, it is formatted as it would be if a PRINT USING statement had been invoked. The format modes that can be specified are selected by loading the following values into the A, B, and C registers as follows:
- A=0 means do not edit; this is a binary to ASCII conversion
- A=X means edit as follows: Bit 7=1 means edit the value, Bit 6=Print commas every third digit, Bit 5=Include leading asterisks, Bit 4=Print a leading $, Bit 3=Sign Follows Value, and Bit 1=Exponential Notation
- B = The number of digits to the left of the decimal point.
- C = The number of digits after the decimal point.

- Note: If you wanted to convert any integer/single/double into its character string, store the variable in 4121H-4122H for integer, 4121H-4124H for single, or in 411DH-4124H for double. Then load 40AFH with a 2, 4, or 8 depending on whether that variable was integer, single, or double. Then call 0FBDH. Upon return, the character string is stored in 4130H and on, ending with a 00H.

“FEDIT”

Note: 40D8H-40D9H holds the temporary storage location.

Note: 40AFH holds Current number type flag.

Note: 4130H-4149H holds Internal print buffer.

Note: 40D8H-40D9H holds the temporary storage location.