{289B} in table of operators : [279B] 27BD S FN SBRN (ii in header) {compated} : [compared] 2951 STK F ARG {ip non-zero} : [is non-zero] 29A1 SV SIMPLE$ {STK STORE} : [STK STO $] 2A20 REPORT 3 {Subscript out of range} : [Subscript wrong] 2A2C SV ELEM$ {variable printer} : [variable pointer] 2AFF LET (last line of heading) {FLAGS} : [FLAGX] 2B3E L CHAR {Prepare the mark} : [Prepare to mark] 2B66 L EXISTS {lcoation} : [location] 2C2E D NO LOOP (11 lines from bottom of p.158) {overal length} : [overall length] 2CCB DECIMAL {decimal} : [decimal point] 2D6D E DIVSN {'+' ot '-'} : ['+' or '-'] 2DAD FP DELETE {points to iit} : [points to it] 2DF8 PF POSTVE {initalised} : [initialised] 2E7B PF BITS {where i us a small} : [where i is a small] 2EDF PF FRN LP {PR FR DGT} : [PF FR DGT] 2F2D PF COUNT {more than 9} : [more than 8] 2F46 PF NOT E label omitted: should be on AND A 2F6C PF E FRMT {jump nack} : [jump back] 2F85 PF E SIGN {OUT NUM} : [OUT NUM 1] 2FBA FETCH TWO (in heading note) {into the register} : [into the registers] 3004 subtract {and carried on} : [and carries on] 303E FULL ADDN (opposite PUSH HL) {Sace} : [Save] 30CA multiply (p.181 l.2) {that they} : [thus they] 3146 {OFLW 1 CLR} : [OFLW1 CLR] 31FA COUNT ONE (just above "Note:") {34the} : [34th] (top of page 186) {intp} : [into] 32B2 RSTK LOOP {right one position} : [left one position] 32D7 table of calculator addresses {21DF} : [31DF] 3362 GEN ENT 2 {is store} : [is stored] 33C8 STK CONST (4 from page bottom) {is fetch} : [is fetched] 3453 G LOOP first "38 end-calc" should be on new line, after "03 subtract" 34E4 USR STACK label omitted (just before 34E7 REPORT A) 35C9 {chrs} : [chr$] (twice) 35DC REPORT B {our of range} : [out of range] 3674 len {legnth} : [length] 367A dec-jr-nz {Decreae} : [Decrease] 36A0 n-mod-m {calculates M (mod M} : [calculates N (mod M)] 36AF INT (para 2 l.3 of header) {is gives} : [is given] 36C4 exp (p.212, in step ii) "1C46" is printed meaninglessly after "int" 3713 len (header) {a simply} : [a simple] 373D GRE.8 (p.214 8 from bottom) {constant} : [constants] (p.215 l.20,21) {LD} : [LN] (twice) 3783 get-argt (in header) {INT (X/2*PI) + 0.5)} : [INT (X/(2*PI) + 0.5)] (p.215, bottom) "1C46" and "174C" are printedmeaninglessly after "int" and "subtract" (near end) {enc-calc} : [end-calc] 37AA cos {SINE, subroutine} : [SINE subroutine] 3833 asn {return a real real number} : [returns a real number] {SIN Y/1(1 + COS Y)} : [SIN Y/(1 + COS Y)] Appx p.223 BASIC line {200!} : [200] Index p.235 {3124} Integer Truncation : [3214] mistakes in ROM "ROM Disassembled" notes these is a number of places, but the notes are often very cryptic and refer to subtle errors which aren't explained. It isn't even always clear whether an error is being identified. This index tries to give fuller explanations of some of them; see the entries marked with asterisks "*". Introduction problems with -65536d (*wrong number) *0066 RESET unusable; NZ shd be Z *04AA PROGRAM NAME subroutine wrongly included 0672 SA V OLD (*0605 SAVE ETC) saving simple strings 0685 SA V NEW (*0605 SAVE ETC) syntax checking error *0A23 PO BACK 1 character moved off screen *0A3D PO RIGHT position not stored; perhaps not a mistake *0A5F PO COMMA redundant subroutine call 0C88 PO SCR 2 (*0C55 PO SCR) no attempt to save DE 0F38 ED LOOP redundant routine (*control characters) *0FA9 ED EDIT line cursor may appear in edit line *103E ED EDGE 1 redundant routine 1076 ED SYMBOL redundant routine (*symbol code) *1313 MAIN G resets FLAGX twice (not spotted by notes) *1835 LIST ALL missing label (mistake of notes) 196D OUT CH 3 (*1937 OUT CHAR) ":" in REMs *1E67 GO TO wrong error report 257D S SCR STO (*2535 S SCRN$ S) stack loaded twice *28B2 LOOK VARS oddity or error in colour codes 293F V FOUND 2 redundant routine 2B72 L DELETE$ (*2AFF LET) redundant command 2CDA NXT DGT 1 (*2C9B DEC TO FP) badly placed label 2E24 PF SMALL (*361F str$) value left on calc stack 3014 addition sums to -65536d give *wrong number 30CA multiply unnecessary precautions against -65536d 31FA COUNT ONE (*31AF division) loop to wrong address 3221 T GR ZERO int -65536d = -1; see *wrong number 34B3 usr-no see *alternate registers *361F str$ value left on calculator stack MLT LOOP 3114 (30CA multiply) Jumps from: 3125 STRT MLT mod see also 36A0 n-mod-m A useful shorthand term from the Theory of Numbers, short for "modulo" which is Latin for "by the measure": X mod P or X (mod P) just means the remainder on dividing X by a positive whole number P. The BASIC equivalent of X mod P is X - P * INT (X/P). This isn't at all the same thing as the modulus of the number X, which in mathematics usually means its absolute value,at least for real numbers; in the notes it is sometimes wrongly used to mean its integer part. MODE system variable 5C41 Bytes: 1 Influences the type of cursor to be printed and the reading of a keystroke. The five key modes are - Keyword mode: MODE zero, FLAGS bits 2 and 3 off - Letter mode: MODE zero, FLAGS bit 2 on, FLAGS2 bit 3 off - Capitals mode: MODE zero, FLAGS bit 2 on, FLAGS2 bit 3 on - Extended mode: MODE 1 - Graphics mode: MODE 2 The final character code from an E mode keystroke, CAPS and SYMBOL SHIFT together on older Spectrums, is 0E for extendedmode on/off, and from GRAPHICS, CAPS SHIFT 9 on older Spectrums,it is 0F for graphics mode on/off. 10E6 KEY MODE converts these to 1 and 2 respectively, and writes them to MODE, but if the same value was there before, it rewrites MODE as zero. The value of MODE is passed in the C register to 0333 K DECODE from 02F1 K NEW when the main code of a key is to be converted to the final code. DEC C then gives an M flag for K/L/C modes or a Z flag for extended mode; the decoding proceeds accordingly. When the cursor is written by 18E1 OUT CURS etc, MODE is doubled; if the result is zero, a K, L, or C is printed depending on the flags, otherwise the character whose code is twice MOD E + 43h is printed, which gives E or G as required. Extended mode is cancelled in 0F81 ADD CHAR or 0F6C ED CONTR by zeroing bit zero of MODE each time a new byte is added to BASIC; but this doesn't cancel graphics mode. MODE is zeroed by 1097 CLEAR SP whenever the editing area or workspace is cleared. The notes explain the flag in TV FLAG bit 3 as signalling "the mode may have changed", but this is rather misleading, see under TV FLAG bit 3. Written by: 0F6C ED CONTR 0F81 ADD CHAR 1097 CLEAR SP 10E6 KEY MODE Read by: 02F1 K NEW 10E6 KEY MODE 18E1 OUT CURS Rems: 0205 key tables 0333 K DECODE key decoding depends on mode 0341 K E LET letter keys in E mode 034F K KLC LET letter keys KLC with/without S SHIFT 0367 K DIGIT digit key decoding depends on mode 0389 K GRA DGT digit keys in G mode 039D K KLC DGT digit keys KLC with/without shifts 0C88 PO SCR 2 letter mode signalled for "scroll?" 0F6C ED CONTR keyword mode for INK to TAB 0F81 ADD CHAR extended mode cancelled 1097 CLEAR SP extended and graphics modes cancelled 10A8 KEY INPUT jump forward for E MODE/GRAPHICS 10DB KEY M&CL jump forward for E MODE/GRAPHICS 10E6 KEY MODE adjust E MODE/GRAPHICS and write MODE 10F4 KEY FLAG signal mode change 111D ED COPY cancel mode change signal 1386 MAIN 9 cancel letter/capitals mode 15D4 WAIT KEY flag change if lower screen was cleared 1881 OUT LINE3 flags read for K or L mode 18E1 OUT CURS sv MODE signals E or G mode 18F3 OUT C 1 flags signal K L or C mode 1909 OUT C 2 choice of letter determines mode 1937 OUT CHAR flag set for K mode 1968 OUT CH 2 flag set for L mode 196D OUT CH 3 present character determines mode for next 2634 S INKEY$ always read INKEY$ in L mode mode cursor see 5C5B K CUR modes (key) see 5C41 MODE modulo see mod modulus of number see integer part, mod MODULUS SUBROUTINE see 36A0 n-mod-m motor (printer) see ports MOVE key (D1) see also commands, functions and operators, KEYBOARD SCANNING, 0284 extended mode key table (f) The 6 key in E mode with symbol shift produces the command MOVE; it requires to be followed by a string expression,comma, and string expression, but it is ineffective on the simple Spectrum, without peripherals such as Interface 1; and such peripherals often introduce other parameter options. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1B0A P MOVE causes a jump via - 1C86 CLASS 0A which collects the first string - back to 1B0B in the parameter table to check the comma - 1C86 CLASS 0A again for the second string - 1C10 CLASS 00 and 1C16 JUMP C R to the executive routine 1793 CAT ETC. MOVE A FLOATING POINT NUMBER SUBROUTINE, MOVE FP see 33C0 duplicate multiplicand see addend multiplication see 30CA multiply, 2AF4 GET HL*DE, 30A9 HL=HL*DE MULTIPLICATION OPERATION, multiplier, multiplier bit, multiplier loop see multiply multiply subroutine 30CA Called frequently from 0028 FP CALC with literal 04; executes the BASIC "*" operator to multiply one number by another. Not otherwise called from ROM, but could be called direct from m/c. Overflow, ie a result outside the FP format range of the Speectrum, will crash any m/c program and produce an error report. If both numbers are in small integer format the routine performs a_short_multiplication, using 30A9 HL=HL*DE. A problem here is that if one was negative and the other zero, the answer could be minus zero, 00 FF 00 00 00; see wrong number. Otherwise it must perform a_long or_full_multiplication.In principle, multiplication of FP numbers is simpler than addition or subtraction: add the exponents and multiply the mantissas together by the binary equivalent of long multiplication. But both mantissas and exponents have to be handled in "true" form, see 335B CALCULATE, and after the multiplication the result has to be "normalized" to standard FP format; and the signs of the numbers and of the result also haveto be taken into account. The binary long multiplication of the two mantissas is handled by the_multiplier_loop, MLT LOOP to STRT MLT, which usesno less than thirteen registers: AC'CB and D'E'DE for the mantissas to be multiplied, H'L'HL for the result, and B' for a loop counter. The loop turns 21h/33d times, producing a series of rotations, the effect of which is to add the DEs into the correct position of the HLs whenever there is a set bit, the _multiplier_bit, in AC'CB. The loop can be illustrated by an example in which the mantissas are only four bits each and there are only five turns of the loop: X = 1101 Y = 1011 Z (result) set to zero. Written out normally, the binary long multiplication is as follows: 0.1101 0.1011 ------ 1101 0000 1101 1101 ---------- 0.10001111 First turn of the loop: Shift Y right to 0101 and carry; Z = 0000 + X = 0000 + 1101 = 1101 with no carry; shift Z right to 0110 and carry Second turn: Shift Y right with the carry to 1010 and carry; Z = 0110+ X = 0110 + 1101 = 0011 with carry; shift Z right with the carry to 1001 and carry Third turn: Shift Y right with the carry to 1101 and no carry; skip the addition, Z = 1001 with no carry; shift Z right with no carry to 0100 and carry Fourth turn: Shift Y right with the carry to 1110 and carry; Z = 0100+ X = 0100 + 1101 = 0001 with carry; shift Z right with carry to1000 and carry Fifth turn: Shift Y right with the carry to 1111 and no carry; and exit from the loop. The four most significant bits of the result are in Z, the rest are in Y. The hi byte of Y is used to round the last binary digit. The notes are more difficult to follow than they need bebecause of their constant reference to "multiplicands", "multipliers", "first numbers", "second numbers", etc; see the index entry on addend. It may help to summarize the terms used. Suppose a multiplication Z = X * Y; on entry to the subroutine, the first byte of X is in HL and of Y in DE. Then the terms usedare: First byte in HL DE X Y first number second number _multiplicand _multiplier second value last value In the notes on 2FBA FETCH TWO names are given to the individual bytes of the numbers: exponent byte M1 goes into H' N1 goes into L' sign byte M2 goes into B' N2 goes into D' M3 goes into C' N3 goes into E' M4 goes into C N4 goes into D M5 goes into B N5 goes into E Note the reversal in BC of M4 and M5. Input parameters: HL and DE point to the first byte of X and Y respectively; in calls from FP CALC, X and Y are the last two values on the calculator stack, Y last, but if the routine is called directly they could be any RAM addresses; they don't even need to be consecutive.