48k Spectrum
Technical Information
Rom Routines
 

The Spectrum ROM is a 16K machine code program, which can be
broken down into 10 logical `blocks' as detailed below.

Address Routine

RESTART ROUTINES AND TABLES

0000 Start
0008 Error restart
0010 Print a character
0018 Collect a character
0020 Collect next character
0028 Calculator restart
0030 Create free locations in work space
0038 Maskable interrupt routine
0053 Error-2 routine
0066 Non-maskable interrupt routine
0074 CD_ADD + 1 subroutine
007D Skip over
0095 Token tables
0205 Key tables

KEYBOARD ROUTINES

028E Keyboard scanning
02BF Scan keyboard and decode value
0310 Repeat key routine
031E Test key value
0333 Keyboard decoding

LOUDSPEAKER ROUTINES

03B5 Routine to control loudspeaker
03F8 Handle BEEP command
046E Semi-tone table

CASSETTE HANDLING ROUTINES

04C2 Save header and program/data bytes
053F Reset border and check BREAK key for LOAD and SAVE
0556 Load header and block of information
05E3 Check signal being loaded
0605 Entry point for tape commands
07CB Handle VERIFY control
0802 Load a data block
0808 Handle LOAD control
08B6 Handle MERGE control
0970 Handle SAVE control
09A1 Canned cassette messages

SCREEN AND PRINTER HANDLING ROUTINES

09F4 General PRINT routine
0A11 Control character table
0A23 Cursor left routine
0A3D Cursor right routine
0A4F Perform carriage return
0A5F Print comma
0A69 Print question mark
0A6D Control characters with operands
0AD9 Print character(s)
0ADC Store line, column, and pixel address
0B03 Fetch position parameters
0B24 Print any character
0B7F Print all characters
0BDB Set attribute
0C0A Message printing
0C3B Handle recursive printing
0C41 Table search
0C55 Test for scroll
0CF8 `scroll?' message
0D4D Temporary colour items
0D6B Handle CLS command
0DAF Clearing whole display area
0DD9 Set line and column numbers
0DFE Handle scrolling
0E44 Clear bottom lines of display
0E88 Attribute handling
0E9B Handle display with line number
0EAC Handle COPY command
0ECD Pass printer buffer to printer
0EF4 Copy line routine
0F2C Editor routine for BASIC and INPUT
0F81 Add code to current line
0FA0 Editing keys table
0FA9 Handle EDIT key
0FF3 Cursor down editing
1007 Cursor left editing
100C Cursor right editing
1015 DELETE editing
101E Ignore next 2 codes from key-input routine
1024 Enter editing
1031 Move cursor when editing
1059 Cursor up editing
1076 Use of symbol and graphics codes
107F Editor error routine
1097 Clear work space
10A8 Handle keyboard input
111D Lower screen copying
1190 Point to first and last locations of work space
11A7 Remove floating point from line number

EXECUTIVE ROUTINES

11B7 Handle NEW command
11CB Main entry (initialization)
11DA Check RAMTOP
12A2 Main execution loop
1319 Canned report messages
155D Handle addition of BASIC line
15AF Initial channel information
15C6 Initial stream data
15D4 Control for input subroutine
15E6 Make HL point to input address
15EF Main printing
1601 Open channel
1615 Set channel flags
162D Channel code look-up table
1634 Channel K flag
1642 Channel S flag
164D Channel P flag
1652 Just one space required?
1655 Otherwise, make room
1664 Hold pointers for making room
168F Collect line number
169E Handle reserve room
16B0 Clear various editing areas
16D4 Reclaim edit-line
16DB Look through tables
16E5 Handle CLOSE# command
1716 CLOSE stream look-up table
171E Stream data
1736 Handle OPEN# command
177A OPEN stream look-up table
1793 Handle CAT, ERASE, FORMAT, MOVE commands
1795 Handle LIST, LLIST commands
1795 Perform AUTO-LIST
17F5 Handle LLIST
17F9 Handle LIST
1855 Print a whole BASIC line
18B6 Check for a number marker
18C1 Print a flashing character
18E1 Print the cursor
190F Get line number of next line
1925 Printing characters in a BASIC line
196E Get starting address of line, or line after
1980 Compare line numbers
1988 Find each statement
19B8 Get next one
19DD Difference routine
19E5 Handle reclaiming space
19FB Read line number of line in editing area
1A1B Report and line number printing

BASIC LINE AND COMMAND INTERPRETATION

1A48 Syntax tables
1B17 Main parser (BASIC interpreter)
1B28 Statement loop
1B52 Temporary pointer to entries in table
1B6F Check for syntactical spaces
1B76 Come here after interpretation
1B8A Run at a given line number
1B9E Find start address of new line
1BB2 Handle REM command
1BB3 End of line?
1BBF General line checking
1BD1 Go to next line
1BEE End of program?
1BF4 Go to next statement
1C01 Command class table
1C0D Command classes---00, 03, and 05
1C16 Jump to appropriate command
1C1F Command classes---01, 02, and 04
1C22 Variable in assignment
1C56 Fetch a value
1C79 Expect numeric/string expression
1C96 Set permanent colours (class 07)
1CBE Command class---09
1CDB Command class---0B
1CDE Fetch a number
1CEE Handle STOP command
1CF0 Handle IF command
1D03 Handle FOR command
1D86 Find DATA, DEF FN, or NEXT
1DAB Handle NEXT command
1DDA Perform NEXT loop
1DEC Handle READ command
1E27 Handle DATA command
1E39 Check statement for DATA or DEF FN
1E42 Handle RESTORE command
1E4F Handle RANDOMIZE command
1E5F Handle CONTINUE command
1E67 Handle GO TO command
1E7A Handle OUT command
1E80 Handle POKE command
1E85 Check parameters on calculator stack
1E94 Find integers
1EA1 Handle RUN command
1EAC Handle CLEAR command
1EED Handle GO SUB command
1F05 Check available memory
1F1A Free memory
1F23 Handle RETURN command
1F3A Handle PAUSE command
1F54 Check for BREAK key
1F60 Handle DEF FN command
1FC3 Returning early from subroutine
1FC9 Handle LPRINT command
1FCF Handle PRINT command
1FF5 Print carriage return
1FFC Print items
2045 End of printing
204E Print position
2070 Alter stream
2089 Handle INPUT command
21B9 Used during input
21D6 Only called for channel K
21E1 Colour item routines
226C Handle change of colour
2294 Handle BORDER command
22AA Get pixel address
22CB Get point
22DC Handle PLOT command
2307 Put two numbers in BC register
2314 Put stack in A register
2320 Handle CIRCLE command
2382 Handle DRAW command
247D Initial parameters
24B7 Line drawing

EXPRESSION EVALUATION

24FB Scan expression
2530 Check syntax
2535 Scanning SCREEN$
2580 Scanning ATTR
2596 Scanning function table
25AF Scanning function routines
26C9 Scanning variable routines
2734 Scanning main loop
2795 Table of operators
27B0 Table of priorities
27BD Scanning function (FN)
28AB Used with DEF FN
28B2 Used with variables and DEF FN
2951 Stack function argument
2996 Check variable table
2A52 Handle slicing of strings
2AB6 Pass five registers to calculator stack
2ACC Return result of evaluating next expression
2AEE Subroutine
2AF4 Subroutine
2AFF Handle LET command
2BF1 Get last value from calculator stack
2C02 Handle DIM command
2C88 Check whether digit or letter
2C9B Decimal floating point
2D1B Check for valid digit
2D22 and again
2D28 Convert binary to floating point for A register
2D2B Ditto for BC register
2D3B Integer to floating point

ARITHMETIC ROUTINES

2D4F E-format to floating point
2D7F Fetch integer
2D8E Store integer
2DA2 Floating point to BC register
2DC1 Handle LOG
2DD5 Floating point to A
2DE3 Print a floating point number
2F8B Handle printing floating point
2F9B Prepare to add
2FBA Fetch two numbers
2FDD Shift floating point number right
3004 Add back any carry
300F Handle subtraction (03)
3014 Handle addition (0F)
30A9 Used in 16 bit multiplication
30C0 Prepare to multiply or divide
30CA Handle multiplication (04)
31AF Handle division (05)
3124 Integer truncation towards zero (3A)
3293 Re-stack two `small' integers
3297 Re-stack one number in full form

FLOATING-POINT CALCULATOR

32C5 Table of constants
32D7 Table of addresses
335B Called in floating point
33A1 Handle delete (02)
33A2 Single operation (3B)
33A9 Test five-spaces
33B4 Stack number
33C0 Move a floating point number (31)
33C6 Stack literals (34)
33F7 Skip constants
3406 Memory location
340F Get from memory area (E0 etc.)
341B Stack a constant (A0 etc.)
342D Store in a memory area (C0 etc.)
343C Swap first number with second number
3449 Series generator (86 etc.)
346A Absolute magnitude (2A)
346E Handle unary minus (1B)
3492 Signum (29)
34A5 Handle IN command (2C)
34AC Handle PEEK command (2B)
34B3 USR number (2D)
34BC USR string (19)
34E9 Test for zero
34F9 Greater than zero (37)
3501 Handle NOT operator (30)
3506 Less than zero (36)
350B Zero or one
351B Handle OR operator (07)
3524 Handle number AND number (08)
352D Handle string ANF number (10)
353B Perform comparison (09--0E, 11--16)
359C String concatenation (17)
35BF Check stack pointers
35C9 Handle CHR$ (2F)
35DE Handle VAL and VAL$ (1D, 18)
361F Handle STR$ (2E)
3645 Read-in (1A)
3669 Handle CODE (1C)
3674 Handle LEN (1E)
367A Decrease the counter (35)
3686 Jump (33)
368F Jump on true (00)
369B End of calculation (38)
36A0 Modulus (32)
36AF Handle INT (27)
36C4 Exponential (26)
3713 Natural logarithm (25)
3783 Reduce argument (39)
37AA Handle cosine (20)
37B5 Handle sine (1F)
37DA Handle tangent (21)
37E2 Handle arctan (24)
3833 Handle arcsin (22)
3843 Handle arccos (23)
384A Handle square root (28)
3851 Handle exponential (06)

 

 

 
 
 
 
 
©2002 ZeDeX82