Exit from: 1F05 TEST ROOM (3 times) 2AF4 GET HL*DE 2C2E D NO LOOP REPORT 5 OC86 "Out of screen" (13D2) This error message is printed if you try to print below the bottom of the available screen, eg with an AT command. Exit from: 0AAC PO AT ERR 0C55 PO SCR 0D02 PO SCR 4 REPORT 6 31AD, 3703 "Number too big" (13DF) This error message is printed if you specify a number too big to handle, eg BIN 10000000000000000, more than 65535d, or 2/0, or 10**40; the Spectrum can print 1e38 but not 1e39. Labelled "Arithmetic overflow" at 31AD; a misprint, but it comes to the same thing. Exit from: 2CA2 BIN DIGIT 2CFF ST E PART (twice) 309F ADD REP 6 313D DIVN EXPT 3146 OFLW1 CLR 3186 NORML NOW 31AF division 36C4 EXP (twice) REPORT 7 1F36 see also GO SUB stack "RETURN without GO SUB" (13ED) This error message is printed if a RETURN command produces the return address 3E00h/15872d; this is the end markerof the GO SUB stack, so it means there are no more return addresses available. Exit from: 1F23 RETURN REPORT 8 15E4 "End of file" (1401) This error message isn't used by the standard Spectrum, on which the only input subroutine is 10A8 KEY INPUT, the keyboard routine. But peripherals such as Interface 1 can open other channels including channels with other input commands, such as "PRINT INKEY$ (hatch)4;". These must be so arranged thatif the peripheral has no data available for input, the input routine returns with NC and NZ, which will produce the error message. Label not used in ROM. Exit from: 15DE WAIT KEY1 REPORT 9 1CEE "STOP statement" (140C) Called only from 1A8A P STOP in the syntax parameter table; in fact the executive routine of the STOP command. It operates just like any other report routine, so that if STOP is used in a BASIC line or command the effect is to print this "error message" and await a new input. See also Report H above, "STOP in INPUT". REPPER system variable 5C0A Bytes: 1. See also 5C09 REPDEL. The time in 50ths of a second before a pressed key will repeat_after the first time; 60ths of a second in the USA. It is set at 5 on start-up and not changed thereafter: if a different value is POKEd, it will be reset to 5by a NEW command. For the use of REPPER see NB 2 under KEYBOARD SCANNING. 5C09 REPDEL and REPPER are handled as a single 2-byte variable in 1219 RAM SET. Written by: 1219 RAM SET Read by: 0310 K REPEAT RESERVE 169E (0030 BC SPACES) Exit from: 0030 BC SPACES RESET subroutine 0066 What could have been an occasionally useful subroutine is vitiated by a mistake in the ROM: the sixth line reads JR NZ,NO RESET, but it was obviously intended to read JR Z,NO RESET. The result is that if 5CB0 NMIADD is given any other value than zero, the subroutine returns without action; if it is zero, the computer resets itself and blanks its memory completely! Fortunately there is no call from ROM. If the mistake were corrected, it would be possible to write m/c programs giving a subroutine address to 5CB0 NMIADD, which would then be called by some peripheral activating the non-maskable interrupt. re-stack subroutine 3297 Called from 0028 FP CALC with the literal 3D; also called direct in one case. See also 3293 RE ST TWO, which is a double call of re-stack. It converts a 5-byte FP number X to full 5-byte FP format; see CALCULATE. If X is already in full FP format, it is unchanged: the routine is only useful if X may be in small integer format, marked by the 1st of the 5 bytes being zero. In the ROM calls, X is nearly always the last value on the calculator stack, but this isn't essential for direct calls. In many cases it is used just before "end-calc"; the point is to be able to read the exponent of X directly from the calculator stack. In two cases, 36C4 EXP and 3783 get-argt, re- stack is followed by a multiplication, and seems pointless, as the 21DF multiply subroutine would restack X in any case. If the small integer is in the DE register, the requiredfull format version is XX DD EE 00 00, where - XX is the exponent, which must be determined - DD is the byte in D, with its hi bit marked for positive or negative - EE is the byte in E. The conversion is executed as follows: - put zeroes in the last two bytes - put 80+11h in the exponent byte for starters: this is the maximum possible for a small integer - test the hi byte DD for zero; if it isn't zero the exponent will be more than 80+9h - test the lo byte EE for zero; if both bytes are zero, all five bytes of the FP number are left at zero - if the hi byte is zero but the lo byte isn't, put 80+9hin the exponent, now the maximum possible, move the lo byte to the hi byte and zero the lo byte. The five bytes are now a correct true exponent and true mantissa for X, and only require to be normalized: - if the mantissa has any leading binary zeroes, they areleft-shifted out of it, with a decrement of the exponent for each shift - the hi bit of the mantissa is zeroed for positive X, set for negative. Input parameters: HL points to the first byte of X. Action: if the first byte isn't zero, return immediately;X is already in full format - save DE; usually a pointer to the calculator stack - call 2D7F INT FETCH to get ABS X and the sign flag into the registers; it leaves a pointer on the fourth byte - put zeroes in the last two bytes - make a provisional exponent 80+11h - if the hi byte of X isn't zero jump on to RS NRMLSE - (hi byte is zero) if the lo byte is zero jump on to RSSTORE; X is zero - (hi byte is zero but lo byte isn't) move the lo byte to the hi byte and zero the lo byte - put 80+9h in the exponent. _32B1_RS_NRMLSE: switch the pointers; X is now in HL, or maybe in H only. _32B2_RSTK_LOOP: decrement the exponent - double X; this shifts it one bit left (a misprint in the notes) - if there is no carry jump back to RSTK LOOP; the shiftgot rid of a leading zero - (there is carry) rotate the hi bit of the sign byte into the carry - rotate both bytes of X right, with the carry going into the hi bit; the hi bit will be zero if the flag was 00/ positive, one if it was FF/negative. _32BD_RS_STORE (the normalized FP format bytes for the exponent and the first two mantissa bytes of X are in B, D and Eregisters): put BDE in the first three bytes of the FP number; the last two are already zero - recover DE. Exit: RET - from RE STACK if X was already in full format - from RS STORE if X was zero or a small integer. Output parameters: HL and DE unchanged. Called with literal 3D from: 2320 CIRCLE 23A3 DR SIN NZ 36C4 EXP 3713 ln 3783 get-argt Called direct from: 37E2 atn Exit from: 3296 RESTK SUB (3293 RE ST TWO) RESTACK TWO SUBROUTINE see 3293 RE ST TWO restart routines RST 00H START resets the computer. RST 08H ERROR 1 notes the point reached in execution, reads the report value, clears the machine stack except for the error return address, clears the calculator stack, and returns to the preset error return address - usually 1303 MAIN 4, which prints an error report. RST 10H PRINT A 1 outputs a byte through the current channel. RST 18H GET CHAR makes HL a BASIC pointer to the addresscurrently in 5C5D CH ADD, or to the next printable character if the one at 5C5D CH ADD is unprintable, and loads the code. RST 20H NEXT CHAR same as GET CHAR, except that 5C5D CH ADD is first incremented. RST 28H FP CALC the floating point calculator. RST 30H BC SPACES makes extra room in the work space. RST 38H MASK INT works the clock and reads the keyboard. Introduction all possible restarts are used 0000 START heading RESTART ROUTINES RESTK SUB subroutine 3296 Not a real subroutine, just a dodge to be able to call 3297 re-stack twice in succession with a switch of pointers. See3293 RE ST TWO. RESTORE key (E5) see also commands, functions and operators,KEYBOARD SCANNING, 022C extended mode table (b) The S key in E mode without shift produces the command RESTORE. The command requires a line number, but zero is used ifnone is supplied by BASIC. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1ACF P RESTORE calls 1C0D CLASS 03 to fetch the line number before jumping via 1C16 JUMP C R to the executive routine 1E42 RESTORE. RESTORE subroutine 1E42 Called only from 1ACF P RESTORE in the syntax parameter table to execute the RESTORE X command. The entry point 1E45 REST RUN is called from the 1EA1 RUN command routine; in this case X is supplied in the BC register instead of on the calculator stack, which incidentally makes it much simpler to use from m/c. 5C57 DATADD marks the last address in the program from which DATA was READ. The subroutine resets 5C57 DATADD to mark the start of the line whose number is X from the RESTORE X command, or the first existing line after it. Input parameters: none - X is on the calculator stack. Action: call 1E99 FIND INT2 to get X off the stack. _1E45_REST_RUN (called by 1EA1 RUN with zero already in BC): call 196E LINE ADDR to find the start address of line X, orthe next after it if it doesn't exist - decrement the address; so it points to the end of the line before - put this address in 5C57 DATADD. Exit: RET, from 1E45 REST RUN. Output parameters: none - X is off the stack. Rems: 1EA1 RUN always does RESTORE 0 restoring division see 31AF division REST RUN subroutine 1E45 See 1E42 RESTORE. Called from: 1EA1 RUN Rems: 1E42 RESTORE used by RUN routine RE ST TWO subroutine 3293 See 3297 re-stack. This merely calls it twice so as to restack two numbers X and Y. In the ROM calls they are always the last two on the calculator stack, but this isn't essential. This is done for all four basic arithmetic operations unless both operands and the result come out as "small integers". Input parameters: HL and DE hold the start addresses of Xand Y respectively; Y would be last on the stack. Action: call RESTK SUB - immediately exit into it. _3296_RESTK_SUB: switch HL and DE. Exit: into 3297 RE STACK, which restacks the number addressed by HL and returns with HL and DE unchanged. Output parameters: the pointers have been restored to their starting values, after being exchanged twice. Called from: 303E FULL ADDN 30F0 MULT LONG 31AF division RESULT OK 370C (36C4 EXP) Exit from: 36C4 EXP (twice) RETURN key (FE) see also commands, functions and operators, KEYBOARD SCANNING The Y key in K mode produces the command RETURN, which accepts no operands. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A. 1A8D P RETURN causes a jump via 1C10 CLASS00 and 1C16 JUMP C R to the executive routine 1F23 RETURN. RETURN subroutine 1F23 see also GO SUB stack, 1B9E LINE NEW under 1BBA LINE RUN Called only from 1A8D P RETURN in the syntax parameter table; executes the RETURN command by taking a line number and statement number, three bytes or one-and-a-half POPs in all, from the GO SUB stack and transferring BASIC execution to them. Input parameters: none. Action: POP the return address of the statement loop, 1B76 STMT RET; this is held and put back on the stack later - POP the error address marked by the error stack pointer 5C3D ERR SP; also put back later - POP two bytes from the GO SUB stack; the RETURN line number of the last GO SUB command, or the end marker 3E00 of theGO SUB stack if there is none. - if the hi byte of the POP is 3E report "RETURN withoutGO SUB"; it can't be a line number, 3E00h would be line 15872. - move the stack pointer up one; DEC SP, this stack is upside down - exchange the top two bytes with the error address; thehi byte of the POP holds the statement number, the lo byte holdsthe hi byte of the line number again - move the statement number into the D register; for GO TO 2 - make the error stack pointer 5C3D ERR SP point to the new stack location of the error address - put the return address 1B76 STMT RET back on the stack.