system pointers see 1664 POINTERS system reset see also 11B7 NEW The system is reset by a jump to 0000, equivalent to pressing the reset button on the later models, not fitted on theold Spectrum, or switching the computer off and on again. All memory of existing programs and sv settings is wiped out. The same effect can be achieved by PRINT [or RANDOMIZE] USR 0 from BASIC. The subroutine 0066 RESET achieves the same effect, due to an unfortunate mistake in ROM. See its index entry. system variables There are full lists of these in Chapter 25 of the original Handbook, Part 25 of the Plus 2 handbook; the addressesare only given in decimals but in this index they are all given in hex. Some notes: - CAPS LOCK is set by setting bit 3 of 5C6A FLAGS2: POKE 23658,8 will set it and POKE 23658,0 will clear it - scrolling can be inhibited by repeatedly POKing 5C8C SCR CT with any value greater than one - the normal value of 5C36 CHARS is 3C00h, zero in 23606dand 60d in 23607d - IY must be set at 5C3Ah/23610 ERR NR for all ROM operations except a few very simple ones, including of course calls to ROM subroutines from m/c; all the svs can be addressed by IY indexes - the fourteen system pointers, see 1664 POINTERS, are those from 5C4B VARS to 5C65 STKEND inclusive - safe locations for user flags and system variables, apart from the eleven "spare flags", see Introduction to this index, are as follows. Never disturbed (well, hardly ever): - 5CB0h/23728d/IY+118d NMIADD (two bytes) - 5C7Ah/23672d/IY+62d, the hi byte of FRAMES; if you zero all three bytes, the hi byte won't be disturbed for about 20 minutes! Never disturbed, and read only to print UDGs: - 537Bh/23675d/IY+65d UDG (two bytes) Disturbed only if channel 3 (ZX printer) is used: - 5C75h/23679d/IY+69d P POSN (two bytes) Disturbed only by the RANDOMIZE command and RND function: - 5C76h/23670d/IY+60d SEED (two bytes) Disturbed only by plotting or drawing on the screen: - 5C7Dh/23677d/IY+67d COORDS (two bytes) Disturbed only by automatic listings: - 5C3Fh/23615d/IY+5d LIST SP (two bytes) and - 5C6Ch/23660d/IY+50d S TOP (two bytes) Safe if the interrupt is disabled and the keyboard isn'tused, but FFh should be poked into 5C00h and 5C04h and suitable values should be poked back into REPDEL, REPPER, RASP/ PIP before reenabling it: - 5C00h/23552d/IY-58d KSTATE (8 bytes) - 5C08h/23560d/IY-50d LAST K (one byte) - 5C09h/23561d/IY-49d REPDEL (one byte) - 5C0Ah/23562d/IY-48d REPPER (one byte) - 5C0Dh/23565d/IY-45d K DATA (one byte) - 5C38h/23608d/IY- 2d RASP/PIP (two bytes) Safe so long as BASIC isn't used: - 5C0Bh/23563d/IY-47d DEFADD (two bytes) - 5C42h/23618d/IY+8d NEWPPC (two bytes) - 5C44h/23620d/IY+10d NSPPC (one byte) - 5C45h/23621d/IY+11d PPC (two bytes) - 5C47h/23623d/IY+13d SUBPPC (one byte) - 5C49h/23625d/IY+15d E PPC (two bytes) - 5C4Dh/23629d/IY+19d DEST (two bytes) - 5C5Fh/23647d/IY+37d X PTR (two bytes) - 5C6Eh/23662d/IY+52d OLDPPC (two bytes) - 5C70h/23664d/IY+54d OSPCC (one byte) - 5C72h/23666d/IY+56d STRLEN (two bytes) - 5C82h/23682d/IY+72d ECHO E (two bytes) Safe so long as neither BASIC nor certain ROM routines are used, see the index entry: - 5C92h/23698d/IY+88d MEMBOT (thirty bytes) Of course, anything above the address currently in 5CB2 RAMTOP is also safe. But be warned: the designers of peripherals sometimes use some of these. For example, the DISCiPLE interface uses NMIADD, and if you try to use it too you will crash the system. S 2 COORD subroutine 2522 Checks the BASIC to make sure that the expression currently pointed to by the pointer in 5C5D CH ADD takes the form required by ATTR, POINT and SCREEN$ "(X,Y)"; where X and Y may be expressions, but must be numeric. The values of X and Y are read on to the calculator stack. The coordinates for ATTR and SCREEN$ are character coordinates as in an AT command, but for POINT they are pixel coordinates as in a PLOT command. Input parameters: none. Action: if the next character isn't 28h ( jump on to S RPORT C to report "Nonsense in BASIC" - call 1C79 NEXT 2NUM to get the values on the stack; itreports "Nonsense" if either expression isn't numeric or if the comma isn't there, but it will accept any numeric expressions, even very large, negative or fractional ones; the function subroutines therefore have to check the numbers again - check that the next character is 29h ). _252D_S_RPORT_C: report "Nonsense in BASIC" if the character didn't match. Exit: into 2530 SYNTAX Z which sets the syntax/run flag. Output parameters: only the syntax/run flag and the two coordinate values on the calculator stack. Called from: 2668 S SCREEN$ 2672 S ATTR 267B S POINT TAB key (AD) see also control characters, KEYBOARD SCANNING,022C extended mode table (b) The P key in E mode without shift produces the print control item code TAB. TAB can only be used within a PRINT etc statement, and must be followed by one numeric parameter. It causes a jump forward to the specified print column reduced by any multiple of 32d, ie on the next line if necessary, but neverany further. Execution is from within the PRINT executive routine 1FCD PRINT; each new expression following the PRINT etc command is checked by a call to 1FFC PR ITEM 1 from 1FE5 PRINT 3. If it is a TAB, the TAB control character 17h/23d and_two parameters, the lo and hi bytes of the number supplied from BASIC, are sent through the output routine. The way this works when printing on screen can be seen at 09F4 PRINT OUT; indexing with 17h for TAB into the control character table at 0A11 produces an indirect jump to 0A75 (0A22 + 53) PO 2 OPER. See the index description of this subroutine for the rather tricky way in which it collects the two parameters and sends execution to 0A87 PO CONT, which finally resets the print position to comply with the TAB command. The TAB control character 23d can be used from BASIC, but it requires_two parameters, the second of which is really rather pointless: it is read as the hi byte of the tab value, but whatever value is specified it is invariably read as zero: 10 LET a$=CHR$ 23 + CHR$ 7 + CHR$ 97 + "hello!" 20 PRINT a$ has just the same effect as 10 PRINT TAB 7;"hello" This can also be done from m/c, but is much less useful than the AT code 22d. 0A5F PO COMMA tabs set by comma 0A75 PO 2 OPER different entry for AT/TAB 0A87 PO CONT partly skipped for TAB 0AC2 PO TAB executes TAB command 200E PR ITEM 2 outputs TAB and parameter tables There are several different kinds of table, and several different routines for reading them: - 0C41 PO SEARCH for lists of messages: this type of table is a continuous unindexed string of up to 256d messages preceded by an 80h, not separated from each other except that the last byte of each message has its bit 7 set. See 0C0A PO MSG - 16DC INDEXER for any table with a one-byte index followed by a single byte, with zero marking the end of the table; finds a one-byte "offset" in the 2nd, 4th, 6th ... place in the table by comparing its input index in the C register withthe 1st, 3rd, 5th ... place - 33BE ENT TABLE for the calculator "literals" - 3406 LOC MEM finds an FP format number in a list of such numbers - 22F7 SKIP CONS finds a "stk-data" format number in a list of constants. There are also "single-byte tables": each entry is a single byte, usually an "offset" which when added to the addresswhere it is found gives the address of a subroutine to be jumpedto. There is no general subroutine to read these tables, though it wouldn't have been difficult to write one; each is read by a different part of the ROM. [A convenient way of writing such tables in assembly language is as follows: TAB.ADD DEFB SR0 - TAB.ADD - 0 DEFB SR1 - TAB.ADD - 1 DEFB SR2 - TAB.ADD - 2 etc, followed by SR0 (first subroutine) SR1 etc. Of course there mustn't be more than 255d bytes between the end of the table and the start of the last of the subroutines.] Table of addresses (calculator functions) 32D7 The calculator literals, see CALCULATE, FP CALC. Each entry is a 2-byte subroutine address, unindexed. Read by 338E ENT TABLE 335B CALCULATOR "literal" used to find entry 338C DOUBLE A index double to find 2-byte entry Table of cassette messages see cassette messages Table of channel code look-ups 162D Leads to the subroutines setting the appropriate flags for channels K, S and P. See channels and streams. Read in 1615 CHAN FLAG by 16DC INDEXER. Table of close stream look-ups 1716 A dummy table - all three entries lead to the same address. Read in 1701 CLOSE 2 by 16DC INDEXER. Table of command classes 1C01 see also syntax offset table below A single-byte jump table: each entry forms the address of a "command class" routine to be jumped to. 1B55 GET PARAM computes its own return address. An indexderived from the "parameter table" at 1A7A and following fetchesan "offset" from the command class table and adds it to the table address; then this is stacked so that RET returns to it. Table of constants 32C5 The five calculator constants, zero, one, half, pi/2 andten; not indexed, and each a different number of bytes. The correct entry is found by 3357 SKIP CONS from the calculator literals A0 -> A4, after they has been converted to zero -> 04 by 336C SCAN ENT. 33C6 stk-data called by SKIP CONS 3418 stk-zero uses 33C8 STK CONST entry point Table of control characters 0A11 Another single-byte jump table. The table is indexed into in 09F4 PRINT OUT by a character code from 06, the PRINT comma, to 17h/23d, the TAB control. Its "base address" is therefore six bytes before the start of the table. The jump to the indexed subroutine isn't actually made till 0B03 PO FETCH. Table of control codes (d) 0260 see KEYBOARD SCANNING NB 3. Table of editing keys 0FA0 Very similar to the table of control characters at 0A11,but only handles character codes 07 EDIT to 0Fh GRAPHICS. The jump is computed and executed in 0F92 ED KEYS. Table of extended mode keys (b) 022C see KEYBOARD SCANNING NB 3. Table of extended mode keys (c) 0246 see KEYBOARD SCANNING NB 3. Table of extended mode keys (f) 0284 see KEYBOARD SCANNING NB 3. Table of initial channel information 15AF Not so much a table as a string of bytes ready to be copied by 1219 RAM SET from ROM into the channel information area in RAM on start-up. Table of initial stream data 15C6 Like the preceding, this isn't so much a table as a string of bytes ready to be copied by 1219 RAM SET from ROM intothe system variable 5C10 STRMS on start-up. But it is also indexed into from 16E5 CLOSE to reopen streams one -> 3 if an attempt is made to close them. Table of main keys 0205 see KEYBOARD SCANNING NB 3. Table of open stream look-ups 177A This is like the channel code look-up table at 162D, andis similarly looked up by the 16DC INDEXER subroutine from 1767 OPEN 3. Table of operators 2795 2723 S OPERTR uses 16DC INDEXER to convert a character code such as 2B "+" into an operator code - later in 274C S STK LIST to be transformed into a literal for the calculator. But its first use is to index into the priorities table at 27B0, getting the priority appropriate to that operation. Table of operator priorities 27B0 see table of operators above Table of report messages 1391 The error reports, read by 0C41 PO SEARCH in 0C0A PO MSGcall from 133C MAIN C. All the Spectrum messages are in this table except the cassette messages, the token extensions, the "scroll?", comma space and copyright messages; these are excluded to keep the table down to thirty-two entries, simplifying the control of leading spaces, see under PO MSG. Table of scanning functions 2596 see also BASIC INTERPRETER Read by 16DC INDEXER in 24FF S LOOP 1 to give a jump address for each of the functions taken over from the old ZX81 computer: the characters " ( . "unary plus", and the tokens FN, RND, PI, INKEY$, BIN, SCREEN$, ATTR and POINT. The other functions and operators are handled differently, see entry underthe individual token key. Table of semitones 046E A table, in five-byte FP format numbers, of the frequencies in hz of each semitone in the scale of middle C. 0427 BE OCTAVE uses 3406 LOC MEM, which just counts every fifth address in a table of FP format numbers, to find the required frequency from the table. Table of symbol keys (e) 026A see KEYBOARD SCANNING NB 3. Table of syntax offsets 1A48 A single-byte jump table of a slightly different form. 1B29 STMT L 1 computes the address of the right item in the table by adding an index derived from the token code, zero -> 31h for the fifty BASIC commands, to the base address. See undercommands, functions and operators. This address finds an offset,which however doesn't lead to a subroutine address but to an address in the syntax parameter table immediately following. This finds one or more new indexes which check that the command contains the appropriate separators, comma, TO, THEN etc, and finds subroutine addresses in yet another table, the command class table. A return address is preset before jumping to these subroutines, 1B52 SCAN LOOP, where the next index is read from the syntax parameter table and a jump made to the next subroutine. The loop is only broken when one of the CLASS subroutines is reached which drops the SCAN LOOP return address - eg 1C10 CLASS 00 which leads into 1C16 JUMP CR.