ROM Entry Points to L2 Routines

Entry points to various Level II BASIC ROM routines which may be accessed by user programs.

Keyboard Routines:

LabelAddressRoutine Description
KBD1002BHINKEY$ call
$KBCHAR: Scan keyboard for a character
KBD20358HSave DE regs, then call 2B
$KBLINE0040HGet a line from the keyboard
KBWT10049HKBD input with wait
$KBWAIT: Wait for a keyboard character
KBWT20384HKBD input with wait, DE saved
LINP105D9HLine input routine
Enter with:
  • HL => Storage address
  • B => Max length to input
LINP20361HLine input routine 2
INPUT1BB3HSame as LINP2, but with "?"
LBUFF40A7HStorage buffer address for LINP2

Display Routines:

LabelAddressRoutine Description
DSP10033HDisplay byte at cursor pos
$VDCHAR: Display a character on the screen
CLS01C9HClear screen
BLINK022CHBlink "*" in right upper corner
DSP2033AHSaves DE and calls DSP1
DSTR28A7HDisplay string pointed to in HL
SETRES0150HEntry to SET/RESET routines
CURSOR4020HCursor position

Printer Routines:

LabelAddressRoutine Description
$PRCHAR003BHPrint a character on the printer

Miscellaneous routines & addresses

LabelAddressRoutine Description
BASIC1A19HReturn point for BASIC
DOS402DHReturn point for DOS
DOSERR4030HReturn to DOS with error
CHLDE1C90HCompare HL with DE
FETCH1D78HFetch next non-blank character following that in HL
DECBIN1E5AHDecimal # => Binary
WLDR0284HWrites leader on cassette tape
WBYTE0264HWrites one byte to tape
COFF01F8HTurns off cassette motor
RLDR0293HReads sync byte from cassette
RBYTE0235HReads one byte from tape

Floating-point arithmetic routines

TYPE FLAG IS 40AFH; VALUES AS FOLLOWS:

2 - INTEGER
3 - STRING
4 - SINGLE PRECISION FLOATING POINT
8 - DOUBLE PRECISION FLOATING POINT

Floating Point Accumulators (FPACC) as Follows:

TypeAddress Range
INTEGER4121H - 4122H
STRING4121H - 4122H (Holds descriptor address)
SINGLE PRECISION4121H - 4124H (4124H is exponent)
DOUBLE PRECISION411DH - 4124H (4124H is exponent)

Operand Locations as Follows:

Data TypeRegister / Address Location
IntegerRegister pairs DE & HL
Single PrecisionRegister pairs DE & HL
Double Precision4127H - 412EH
LabelAddressRoutine Description
TSTYP25D9HTest type flag at 40AFH
DSTOR09B4HStore single-precision value in DE:BC into FPACC
SLOAD09C2HLoad single-precision into DE:BC from address in HL
SCOPY09B1HCopy single-precision from HL address to FPACC
SGET09BFHLoad FPACC into DE:BC
SSTAK09A4HPush FPACC into stack (DE:BC)
ISTOR0A9AHStore integer in FPACC and set type
ASTOR0E6CHStore numeric string in FPACC
NEDIT0FBDHNon-formatted numeric edit
FEDIT0FBEHFormatted numeric edit
CSVEC2865HCreate string vector
FPACC4121HFloating point accumulator
DFPACC411DHDouble-precision FPACC
DOPER4127HDouble-precision operand registers

Arithmetic function routines

LabelAddressRoutine Description
IADD0BD2HInteger add: DE + HL => FPACC
ISUB0BC7HInteger subtract: DE - HL => FPACC
IMUL0BF2HInteger multiply: DE * HL => FPACC
IDIV2490HInteger divide: DE / HL => FPACC
SADD0716HSingle-precision add: OPER + FPACC => FPACC
SSUB0713HSingle-precision subtract: OPER - FPACC => FPACC
SMUL0847HSingle-precision multiply: OPER * FPACC
SDIV08A2HSingle-precision divide: OPER / FPACC
DADD0C77HDouble-precision add: OPER + FPACC
DSUB0C70HDouble-precision subtract: OPER - FPACC
DMUL0DA1HDouble-precision multiply: OPER * FPACC
DDIV0DE5HDouble-precision divide: OPER / FPACC
SGN098AHFPACC = SGN(FPACC)
INT0B37HFPACC = INT(FPACC)
ABS0977HFPACC = ABS(FPACC)
SQRT13E7HFPACC = SQRT(FPACC)
RNDM14C9HFPACC = RND(FPACC)
LOG0809HFPACC = LOG(FPACC)
EXP1439HFPACC = EXP(FPACC)
COSN1541HFPACC = COS(FPACC)
SINE1547HFPACC = SIN(FPACC)
TAN15A8HFPACC = TAN(FPACC)
ATAN15BDHFPACC = ATAN(FPACC)
CINT0A7FHFPACC = CINT(FPACC)
CSNG0AB1HFPACC = CSNG(FPACC)
CDBL0ADBHFPACC = CDBL(FPACC)
FIX0B26HFPACC = FIX(FPACC)

Other random locations

Memory AddressFunction / Description
14305 / 37E1H0, for better disk saves
16405 / 4015H1 = Keyboard on; 2 = Keyboard off
16413 / 401DH1 = Display off; 7 = Display on
16414 / 401EH141 = Display to printer; 88 = Restore display
16415 / 401FH5, 4 = ???
16449 / 4041HClock register: Seconds
16450 / 4042HClock register: Minutes
16451 / 4043HClock register: Hours
16452 / 4044HClock register: Year
16453 / 4045HClock register: Day
16454 / 4046HClock register: Month
16553 / 404FH255 = Data read after cassette input
14312 / 37E8H127 = Line printer not ready
15339 / 3BFFHCheck if key held down
16457 / 4049HTop-of-memory (DOS main system); Disk BASIC holds value-1 in 40B1H.
16544 / 40A0H-40A1HPointer to string storage area (e.g., CLEAR 50 sets this to 40B1H-40B2H minus 50). Always stored LSB/MSB.