2825 SF NOT FD no match; prepare for more searching 2831 SF VALUES match; find value of FN 2852 SF ARG VL evaluates string/numeric argument in 2885 SF R BR 2 check for ")" 288D SF VALUE handles evaluation of function 28AB FN SKPOVR looks for end of DEF FN 28B2 LOOK VARS called to find arguments of DEF FN 28E3 V TEST FN searches for arguments of DEF FN 28EF V RUN/SYN find variable if not in DEF FN 2951 STK F ARG if in DEF FN, look there first for variable names DEF FN subroutine 1F60 Called by the statement loop from the syntax parameter table 1A7A. Executes the DEF FN command. Not otherwise called from ROM. In run time, the DEF FN statement is skipped. In syntax checking, apart from checking the various separators, the syntaxof the arguments and of the function expression, the subroutine puts a number marker and a 5-byte blank after each argument on the left side, before the comma or ")" and after the argument letter and "$" if any. This is put even after string arguments; such markers are never put after ordinary BASIC variables. When the FN command is executed in run-time, these spaces are filled with the current FP values of numeric arguments or pairs of string parameters for string arguments. Input parameters: the BASIC pointer in 5C5D CH ADD is on the first code after the DEF FN command - A holds the code at the pointer. Action: in syntax checking, jump on to DEF FN 1 - (run time) make a token byte CE DEF FN and exit to 1E39 PASS BY. _1F6A_DEF_FN_1: set bit 6 of FLAGS; "numeric status" - call 2CBD ALPHA; if the character isn't a letter, report "Nonsense in BASIC" - move on the pointer and read the character - if it isn't 24h $ jump on to DEF FN 2 - (string function) zero bit 6 of FLAGS; "string status" - move on the pointer and read the character. _1F7D_DEF_FN_2: if the character isn't 28h ( report "Nonsense in BASIC" - move on the pointer and read the character - if it is 29h ) jump on to DEF FN 6; the function has no arguments. _1F86_DEF_FN_3: call 2CBD ALPHA; it returns with carry for a letter. _1F89_DEF_FN_4: if there is no carry report "Nonsense in BASIC" - move on the pointer and read the character - if it isn't 24h $ jump on to DEF FN 5 - (it is "$") move on the pointer and read the character. _1F94_DEF_FN_5 (the manoeuvres with EX DE,HL in DEF FN 4 have left DE pointing to the first address after the argument letter, or after "$" if it is there): call 1655 MAKE ROOM to make six spaces after the argument - put a number marker 0E in the first space - if the next character isn't comma jump on to DEF FN 6 - (comma after argument signals more arguments) move on the pointer and read the character - jump back to DEF FN 3 for more arguments. _1FA6_DEF_FN_6 (no more arguments): if the character at the pointer isn't 29h ) report "Nonsense in BASIC" - if the next one isn't 3D = report "Nonsense in BASIC" - move on the pointer and read the character - stack the string/numeric status flag - call 24FB SCANNING; it will report any errors in the right side of the DEF FN statement, and return a status flag - XOR this flag with the one from the stack; the result will have bit 6 zero if they match - AND the result with 01000000b/40h; making zero if the flags match. _1FBD_DEF_FN_7: report "Nonsense in BASIC" if the flag shows NZ - call 1BEE CHECK END, which reports an error if this isn't the end of the statement and makes a double return to 1B76STMT RET if it is. Exit: in syntax checking, through 1BEE CHECK END to 1B76 STMT RET - in run time, into 1E39 PASS BY, which finds the next statement. Output parameters: A holds CE DEF FN on exit to PASS BY. DEF FN 1 1F6A (1F60 DEF FN) Jumps from: 1F60 DEF FN DEF FN 2 1F7D (1F60 DEF FN) Jumps from: 1F6A DEF FN 1 DEF FN 3 1F86 (1F60 DEF FN) Jumps from: 1F94 DEF FN 5 DEF FN 4 1F89 (1F60 DEF FN) Jumps from: 1F6A DEF FN 1 DEF FN 5 1F94 (1F60 DEF FN) Jumps from: 1F89 DEF FN 4 DEF FN 6 1FA6 (1F60 DEF FN) Jumps from: 1F7D DEF FN 2 1F94 DEF FN 5 DEF FN 7 1FBD (1F60 DEF FN) Jumps from: 1F7D DEF FN 2 1FA6 DEF FN 6 (twice) delay see KEYBOARD SCANNING, time period DELETE key (0C) see also control characters, KEYBOARD SCANNING, 0260 control code key table The zero key with caps shift in K, L or C mode effects the DELETE control in editing or INPUT mode. Later models of theSpectrum mostly have a special DELETE key, but caps shift zero still works. The character before the cursor is deleted. Nothingto do with the "delete" subroutine! If code 0C is encountered in output by 09F4 PRINT OUT, a"?" is output by 0A69 PO QUEST. 0260 control code table (d) 0A17 control character table 0F92 ED KEYS jumps to executive routine 0FA5 editing keys table 1015 ED DELETE executive routine Rems: 0389 K GRA DGT key zero read as 1051 ED EDGE 2 control character deleted by delete subroutine 33A1 Called frequently in the ROM from 0028 FP CALC with literal 02. Deletes the last value on the calculator stack. As it consists of a single RET at 33A1 there would be little point in calling it from elsewhere! The real action is in 335B CALCULATE: on entry or returnto CALCULATE, the end of the calculator stack 5C65 STKEND is given the value in DE at 3365 RE ENTRY. But CALCULATE treats anyoperation with a literal less than 18h as a binary operation (3380 FIRST 3D): for unary operations, it sets HL on the first byte of the last value and DE on the stack end, but for binary operations it sets DE on the start of the last value and HL on the second last. Thus merely by entering FIRST 3D with a literal less than 18h, the address to be put in 5C65 STKEND is moved back five bytes, and what was the last value will be ignored by subsequent calculator operations. No further action is required,so the "subroutine address" read from the table by 338E ENT TABLE need merely be a RET. The number isn't deleted in the sense of being reclaimed, and it can still be read from the DE pointer, or using 5C65 STKEND as a pointer, until it is really deleted by 16C5 SET STK. This is done several times in the ROM, see below. Called from: 0427 BE OCTAVE 1CF0 IF (34E9 TEST ZERO used on already deleted value) 1D16 F REORDER 1D34 F L&S (twice; two deleted numbers copied to looping variable) 1DAB NEXT 2320 CIRCLE 233B C R GRE 1 (3 times) 235A C ARC GE1 (twice) 238D DR 3 PRMS 23A3 DR SIN NZ (4 times) 23C1 DR PRMS (8 times; exponent of deleted value read) 2425 ARC LOOP (twice) 2439 ARC START 245F ARC END (twice) 2497 DRAW SAVE (3 times) 25F8 S RND 2B59 L NUMERIC (on exit, copies deleted number to vble) 2CD5 DEC STO 1 2D7B E END 2DAD FP DELETE (deleted small integer put in BC) 2DE3 PRINT FP 2DF8 PF POSTVE 2EO1 PF LOOP (deleted value checked for small integer) 2ECB PF MORE 2F2D PF COUNT 3449 series-06 3453 G LOOP 36A0 n-mod-m 370E RSLT ZERO 371C VALID 3783 get-argt 385D XISO 386A ONE Rems: 2E24 PF SMALL mistake: a delete literal omitted, with unfortunate results for the STR$ function 2E56 PF LARGE exponent of number deleted in 2E01 PF LOOP is tested 2E6F PF MEDIUM still using number deleted in 2E01 PF LOOP 342D stk-mem last value must be deleted if not required deleted string or variable see 19E5 RECLAIM 1 DELETE EDITING SUBROUTINE see 1015 ED DELETE DEST system variable 5C4D see also 28B2 LOOK VARS, 5C72 STRLEN, variables. Bytes: 2 The address of the "variable in assignment", eg the variable named on the left-hand side of a LET command. The actual address held depends on whether the variable has already been declared: - if the variable name hasn't been used before, DEST is the address of the first letter of the "variable in assignment" name in the BASIC program. - if it has been used before, DEST is the address in the variables area of the "destination variable" to which the new value will be copied; before the first byte of the old FP numbervalue, or on the first character of the old string value. One of the fourteen system pointer variables set by 1664POINTERS whenever space is made or reclaimed in RAM. Also used in 2BC6 L STRING as an ad hoc temporary store for HL. Written by: 166B PTR NEXT 1C46 VAR A 3 2BC6 L STRING Read by: 166B PTR NEXT 1DAB NEXT 2AFF LET 2B29 L SPACES 2B4F L SINGLE 2B72 L DELETE$ (unnecessary) 2BC0 L NEW$ 2BC6 L STRING Rems: 1C22 VAR A 1 finds value for 2BA3 L IN W/S used to copy new variable to variable area 2BAF L ADD$ shifted to point to variable name 2BEA L FIRST end of handling new variables destination address of variables see variables destination pointer (of save/load block) see program area destination variable see 28B2 LOOK VARS DF CC system variable 5C84 see DISPLAY AREA Bytes: 2 The first pixel address in the display area of the current print position in the upper part of the screen. Written by: 0ADC PO STORE Read by: 0B03 PO FETCH Rems: 0D2D PO SCR 4B value put in S POSN by 0DD9 CL SET DF CCL system variable 5C86 see DISPLAY AREA Bytes: 2 The first pixel address in the display area of the current print position in the lower part of the screen. Written by: 0AF0 PO ST E Read by: 0B03 PO FETCH DF SZ system variable 5C6B see also DISPLAY AREA Bytes: 1 The number of lines currently in the lower part of the screen, including one blank line. Always reset to two lines on start-up and whenever the screen is cleared: expanded as necessary by scrolling up when the bottom line has filled up by 0D1C PO SCR 4A. Because line numbers in the "print position" system are counted from the bottom of the screen, it is also the line number of the top line of the lower display. Written by: 0D1C PO SCR 4A 0D8E CLS 3 1219 RAM SET 12A2 MAIN EXEC 2096 INPUT 1 (ignore: a misprint for TV FLAG) Read by: 0AAC PO AT ERR 0C55 PO SCR 0CD2 PO SCR 3 0D02 PO SCR 4 0D1C PO SCR 4A 0D6E CLS LOWER 0DD9 CL SET 1795 AUTO LIST 1835 LIST ALL 2096 INPUT 1 diagonal move see 24B7 DRAW LINE DIFFER subroutine 19DD Calculates the length of a sector of memory for reclaiming purposes - the number of bytes from one "start" to another. Can be called from m/c to perform any subtraction BC = HL - DE, provided it is remembered that it returns with HL and DE exchanged. Input parameters: DE holds the first "start", HL the second. Action: subtract DE from HL and put the result in BC - add back DE to give the original value - exchange HL and DE. Exit: RET. Output parameters: BC holds the length required. The original values of HL and DE are returned reversed - the first "start" in HL.