Rems (to keep the following list to a reasonable length, references to the notes have been omitted if they merely commenton a call to 2530 SYNTAX Z or on jumps to the REPORT labels): Introduction syntax checking 0008 ERROR 1 address of error to X PTR 0053 ERROR 2 error number to ERR NR 0427 BE OCTAVE out-of-range pitch values excluded 053F SA/LD RET carry flag marks loading error 05E3 LD EDGE 2 carry flag signals tape error 0652 SA DATA can't save a new array 0672 SA V OLD mistake in error checking 0692 SA DATA 1 array must end with ')' 0802 LD BLOCK return if no error 0F30 ED AGAIN sets error address 107F ED ERROR 1026 ED END jump if any errors 107F ED ERROR special error address for editing 111D ED COPY sets error address 1167 ED FULL 1167 ED FULL deals with errors on copying edit line 117C ED C DONE drops temporary error return 117E ED C END restores ERR SP 1219 RAM SET sets ERR SP at bottom of machine stack 12A2 MAIN EXEC loop produces error reports 12AC MAIN 2 scan edit line for errors 12CF MAIN 3 edit line has passed syntax 1303 MAIN 4 error return address during execution 1313 MAIN G report code made letter or number 133C MAIN 5 print report code and message 155D MAIN ADD will print "No room for line" not "Out of memory" on memory overflow 15DE WAIT KEY1 error on input from peripherals 15F7 CALL SUB exit from printing routines if no error 1767 OPEN 3 continue if no error 1894 OUT LINE4 print error cursor 18C1 OUT FLASH prints error cursor 1B17 LINE SCAN entry to interpreter for syntax checking 1B6F SEPARATOR report routine only in run time 1BEE CHECK END error if not end of statement 1C59 VAL FET 2 syntax flag is in D register 1EDC CLEAR 2 save error return address in resetting stack pointer 1F23 RETURN juggle with error return address in getting GO SUB return address 1F36 REPORT 7 replace error return address before calling 0008 ERROR 1 1FC3 UNSTACK Z drops address when checking syntax 2129 IN PR 3 error address changed for BASIC input 213A IN VAR 1 sets error address for input 2148 IN VAR 2 removes FP forms in line after error 2522 S 2 COORD exits into SYNTAX Z 2530 SYNTAX Z checks flag for syntax checking 2634 S INKEY$ direct check of FLAGS bit 7 2668 S SCREEN$ errors checked by 2522 S 2 COORD 2672 S ATTR errors checked by 2522 S 2 COORD 267B S POINT errors checked by 2522 S 2 COORD 27BD S FN SBRN checks syntax of FN statement 27D9 SF ARGMTS call to 24FB SCANNING checks syntax of expressions 2831 SF VALUES spaces for FP numbers already made in DEF FN statement 2934 V SYNTAX deviation for syntax checking 2996 STK VAR when called from 2C02 DIM merely checks syntax 29EA SV LOOP deviation for syntax checking 2A81 SL SECOND set A register to FF if out of range 2A94 SL DEFINE checks A "error register" 2ACC INT EXP1 zeroes A for "error register" 2AE8 I CARRY move carry flag into error register 2C9B DEC TO FP syntax checking includes inserting FP number forms 2CA2 BIN DIGIT jump out with any character after BIN except 0 or 1 error stack pointer see 5C3D ERR SP ERROR 1 subroutine 0008 Deals with the printing of error reports. See errors above for a general discussion. Input parameters: the byte in the "return address" immediately following the call to ERROR 1 holds the error number. Action: copy the address in the editing area or workspacewhere the error was detected from 5C5D CH ADD into 5C5F X PTR. _0053_ERROR_2: POP the "return address" - read the error number. _0055_ERROR_3 (entry here from 1F15 REPORT 4 - "Out of memory". No address is required in 5C5F X PTR, because this error is only reported during execution; if it arises during input the signal is a "rasp"): copy the error number into 5C3B ERR NR - reset the machine stack pointer from 5C3D ERR SP; changing the return address. Exit: into 16C5 SET STK (from 0055 ERROR 3), which clearsthe calculator stack. Called by all the REPORT routines. ERR0R 2 0053 (0008 ERROR 1) Jumps from: 0008 ERROR 1 ERROR 3 0055 (0008 ERROR 1) Exit from: 0053 ERROR 2 (0008 ERROR 1) 1F15 REPORT 4 ERR SP system variable 5C3D see also errors, GO SUB stack Bytes: 2 The_error_stack_pointer: marks the address to which execution is to return from 0008 ERROR 1. This return address ison the machine stack, and the stack pointer setting to make it the immediate return address is kept in ERR SP. In run time and syntax checking by 1B17 LINE SCAN it is the last address on the machine stack above the GO SUB addresses, so 0008 ERROR 1 returns out of_all subroutines into the main execution loop. But it is temporarily changed while in editing mode to hold 107F ED ERROR or 1167 ED FULL - errors in this mode merely produce a rasp and return to the editing loop -and in input mode to hold 213A IN VAR 1 at IN VAR 1. Both ERR SP and 5C5F X PTR are called "error pointer" inthe notes, but they are quite different: 5C5F X PTR is an address in the editing area or work space where an error has been detected. Written by: 0F30 ED AGAIN 1026 ED END 111D ED COPY 117E ED C END 1219 RAM SET 1EDC CLEAR 2 1EED GOSUB 1F23 RETURN 213A IN VAR 1 2174 IN VAR 5 Read by: 0055 ERROR 3 0F2C EDITOR 111D ED COPY 2129 IN PR 3 E SAVE 2D55 (2D4F E TO FP) Jumps from: 2D4F E TO FP e-to-fp subroutine 2D4F In the ROM, always called direct as E TO FP. The option to call it from 0028 FP CALC with the literal 3C does however exist. Converts "xEy", ie x times 10 to the power y, to full FPformat. To put it like this is, however, illogical; for x must be in FP format already. It would be more logical to say: shiftsx by y_decimal places to the left, or shifts the decimal point of x by y decimal places to the right. Assuming y is positive, x must be multiplied by ten if bit zero of the binary number y is set; again by a hundred if its bit one is set; again by 10,000 = a hundred hundred if its bit two is set; again by 100,000,000 = 10,000 * 10,000 if its bit three is set; ... etc. If y is negative, the procedure is the same except that x is to be divided by ten etc, instead of multiplied. Input parameters: A holds y; always an integer, 00 -> 7F are read as positive, 80 -> FF as negative - x is last value on the calculator stack - HL and DE point to the last value on the stack and to the stack end. Action: get the sign of y in the carry flag; RLCA/RRCA has just the same effect as BIT 7,A except that it works the carry flag instead of the zero flag. The zero flag is needed later, in E TST END - if y is positive jump on to E SAVE - (y is negative) negate y to get its absolute value; the carry flag isn't changed _2D55_E_SAVE: save the flags and y - make a pointer on 5C92 MEMBOT; the address of mem-0 - call 350B FP 0/1; it reads the carry flag and puts a sign flag in mem-0, zero for positive or one for negative, as a small integer - use the calculator to put z = ten on the calculator stack; the stack holds, from the top, z, x - recover the flags and y. _2D60_E_LOOP: rotate the lo bit of y into the carry flag;zero goes into the hi bit, and the zero flag shows Z if y is nowzero - if the lo bit is zero jump on to E TST END - save the flags and the rotated y - use the calculator to put z in mem-1 and get the sign flag from mem-0 - if the sign flag is one jump on to E DIVSN; negative - multiply x by z; this effects the decimal shift left of x corresponding to the set bit of y - jump on to E FETCH. _2D6D_E_DIVSN (the sign is negative): divide x by z; thiseffects the decimal shift right of x corresponding to the set bit of y. _2D6E_E_FETCH: get z back from mem-1 - unstack the rotated y and the flags. _2D71_E_TST_END: if the flag shows zero jump on to E END;all the remaining bits of y are zero - (non-zero y) stack y and the flags - use the calculator to square z: replacing ten by a hundred, a hundred by 10,000, 10,000 by 100,000,000, and so on. This is done whether the last bit of y was set or not - unstack y and the flags - jump back to E LOOP. _2D7B_E_END (no more set bits in y): delete z from the calculator stack. Exit: RET, at 2D7B E END. Output parameters: the number xEy is last value on the calculator stack - mem-0 and mem-1 in the calculator memory corrupted. Called by: 2E24 PF SMALL 2E56 PF LARGE Exit from: 2D18 E FP JUMP Rems: 350B FP 0/1 called by; puts flag in mem-0 in this case E TST END 2D71 (2D4F E TO FP) Jumps from: 2D60 E LOOP exchange subroutine 343C Called frequently from 0028 FP CALC by the literal 01 totranspose the last two values on the calculator stack; also, once, called direct as EXCHANGE. A simple subroutine, which essentially only exchanges five bytes from the addresses starting at HL with the five starting at DE; it could be used from m/c for a much wider rangeof applications, especially if called at 342E SWAP BYTE with a counter already in B. If an even-numbered counter is used HL andDE will end up exchanged. Input parameters: DE and HL address the first bytes of the numbers to be exchanged; when the subroutine is called from the calculator they are the last and second last values on the calculator stack. Action: make a loop counter of five. _342E_SWAP_BYTE: put the byte from DE into C and the bytefrom HL into A - exchange DE and HL - replace the bytes the other way round - increment HL and DE - loop back to SWAP BYTE counting down to zero - exchange HL and DE back; assuming an odd number of exchanges. Exit: RET, from 343E SWAP BYTE. Output parameters: HL and DE have been moved on five bytes; if it was a calculator call DE is now on the stack end - the two numbers are exchanged - B zero, A and C corrupted. Called with literal 02 by: 0427 BE OCTAVE 1736 OPEN 1D16 F REORDER (twice) 1DDA NEXT LOOP 235A C ARC GE1 (4 times) 23A3 DR SIN NZ (twice) 23C1 DR PRMS (6 times) 2439 ARC START 245F ARC END (twice) 247D CD PRMS1 (twice) 2497 DRAW SAVE (twice) 2D40 NXT DGT 2 2E01 PF LOOP 3453 G LOOP 36A0 n-mod-m 36B7 X NEG 371C VALID (3 times) 373D GRE 8 (twice) 37A1 ZPLUS 37DA tan 37E2 atn (twice) 37FA CASES 3851 to-power 385D XISO (twice) Called as EXCHANGE by: 3543 EX OR NOT executing see BASIC INTERPRETER, FLAGS bit 7 EXECUTIVE ROUTINES A major section of ROM, see Introduction, from 11B7 NEW to 1A42 OUT NUM 4: initialization, main execution loop, channel and stream handling, reclaiming, listing BASIC, etc. existing variable see 2AFF LET, variables EXIT 36C2 (36AF int) Exit from: 36B7 X NEG (twice) (36AF int) EX OR NOT 3543 (353B no-l-eql etc) Jumps from: 353B no-l-eql EXP key (B9) see also commands, functions and operators, KEYBOARD SCANNING, 022C extended mode table (b) The X key in E mode without shift produces the function EXP; it requires one numeric operand X, and the value of the function is the constant e raised to the power X. For e see under the exp subroutine below. On execution, 24FB SCANNING quickly leads to 26DF S NEGATE. This converts the key code B9 first to 0A, then to E6, and adds the priority 10h/16d. Code and priority 10E6 are now pushed on to the machine stack (270D S PUSH PO) while the expression following EXP is evaluated. When the code is taken off the stack (2734 S LOOP), it is converted (2773 S TIGHTER) from E6 to 26, the calculator offset for 36C4 exp. exp subroutine 36C4 Called from 0028 FP CALC with literal 26 as the executive routine of the EXP function. Also used as exit from 3851 to-power, but not otherwise called from ROM. Could be called direct from m/c.