ONE SPACE subroutine 1652 Entry point into 1655 MAKE ROOM when only a single byte of space is required. Input parameters: HL is the address before which the space is required. Action: make a length byte one Exit: into 1655 MAKE ROOM, which makes one space at HL. Output parameters: see MAKE ROOM. Called from: 0F81 ADD CHAR OPEN subroutine 1736 Called only from the syntax parameter table 1A7A; executes the command OPEN (hatch) X,Y$. The command in the original Spectrum only allows streams 00 -> 0F to be opened to channels K, S or P; the routine seems incomplete and rather pointless. It is clearly designed for expansion by the addition of peripherals such as Interface 1. Input parameters: none - string parameters of a channel code Y$ are last value on the calculator stack - a stream number X is second last value. Action: call 0028 FP CALC to exchange Y$ and X on the stack; now X is last - call 171E STR DATA to get the stream data of stream X;it gets a pointer to the stream data from 5C10 STRMS and reports"Invalid stream" if X isn't 00 -> 0F, see channels and streams - if the stream data is zero jump on to OPEN 1; closed stream - (open stream) save the stream data pointer - add the stream data to the address in 5C4F CHANS and step on three times; now the pointer is on the channel code - if the code is 4Bh "K" or 53h "S" or 50h "P" jump on to OPEN 1 - (only K, S or P accepted) report "Invalid stream". _1756_OPEN_1: call 175D OPEN 2, which gets the string parameters of Y$ from the calculator stack and returns with the stream data for the corresponding channel - put these at the streams pointer. Exit: RET, in 1756 OPEN 1. Output parameters: none - the calculator stack has been cleared. OPEN END 178B (175D OPEN 2) Exit from: 175D OPEN 2 through one of 1781 OPEN K 1785 OPEN S 1789 OPEN P OPEN K 1781 OPEN P 1789 OPEN S 1785 Addresses jumped to from the open stream lookup table at177A by the JP (HL) command in 1767 OPEN 3; see 175D OPEN 2. OPEN STREAM LOOK-UP TABLE see tables OPEN 1 1756 (1736 OPEN) Exit from: 1736 OPEN (3 times) OPEN 2 subroutine 175D Given a channel letter, returns the stream data to find that channel; see channels and streams. In the standard Spectrumwithout peripherals, this routine achieves very little. However peripherals, by relocating the error stack pointer and thus introducing their own variations on the error routine for "Invalid file name", can allow new channels and other variationson the use of the OPEN command. Input parameters: none - the string parameters of the channel letter Y$ are on the calculator stack. Action: call 2BF1 STK FETCH, which reads the string parameters of Y$ into registers AEDBC; DE is the start address, BC the length of the string - if the length is zero report "Invalid file name". _1767_OPEN_3: read the channel letter - AND it with 11011111b/DFh; this makes it upper case - call 16DC INDEXER to index with it into the open stream look-up table at 177A; it has entries only for channels K, S and P - if the letter isn't K/S/P report "Invalid file name" - use the offset obtained to compute a jump to the next section; OPEN K, OPEN S or OPEN P. _1781_OPEN_K,_1785_OPEN_S,_1789_OPEN_P: each sets the lo byte of the stream data corresponding to the channel letter: 01 00 for channel K 06 00 for channel S 10 00 for channel P _178B_OPEN_END: decrement the length of Y$ - if the result isn't zero report "Invalid file name"; more than one letter - zero the hi byte of the stream data and return. Exit: RET, from OPEN END. Output parameters: DE holds the stream data - HL is unchanged. Called from: 1756 OPEN 1 OPEN 3 1767 (175D OPEN 2) Jumps from: 175D OPEN 2 OPEN (hatch) key (D3) see also commands, functions and operators, KEYBOARD SCANNING, 0284 extended mode key table (f) The 4 key in E mode with symbol shift produces the command OPEN (hatch). The "OPEN (hatch) statement" must also include a numeric expression for the stream and a single-letter string expression for the channel, separated by a comma. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1AFC P OPEN jumps in sequence to: 1C82 CLASS 06 to get an expression for the stream number back to 1AFD to check that there is a comma 1C8C CLASS 0A to get the expression for the channel 1C10 CLASS 00 to check the statement is ended and then via 1C16 JUMP C R to the executive routine 1736OPEN. OPEN (hatch) COMMAND ROUTINE see OPEN subroutine operands see arguments operands of BASIC commands see BASIC INTERPRETER operands of control characters see control characters operands of DEF FN statement/function see DEF FN key operands of INK to OVER see colours operation codes The token code for a single-valued function command is transformed twice to make it a calculator literal: once in 26DF S NEGATE before it is pushed on to the machine stack, and again in 2734 S LOOP when it is taken off. The version put on the stack, the_operation_code, has flags in bits 6 and 7: bit 6 is set for a numeric argument, zero for a string bit 7 is set for a numeric result, zero for a string Binary operators are all initially assumed to have numeric arguments and numeric result. The operators + = > < <= >= <> can also be used with two string arguments, and AND may have its first argument a string and its second a number. These are checked in 2773 S TIGHTER after the first argument has been read: if it was a string, not only are the argument and result flags changed, the op code itself is incremented by 8, which for example changes 0F addition for numeric arguments to 17 str-add$ for string arguments. 24FB SCANNING op code and priority stacked while arguments evaluated 26DF S NEGATE op codes and priorities allotted to all single-valued operations 2707 S NO TO $ clears bit 6 of CHR$ and STR$ 270D S PUSH PO stacks op code and priority 2723 S OPERTR binary operators all have both 6 & 7 set 2734 S LOOP priorities compared of "last" and "present" operation 274C S STK LST clear both flags, producing calc literal 275B S SYNTEST check result with FLAG 6 2764 S RUNTEST set FLAG 6 to match op code result flag 2773 S TIGHTER binary operator codes changed if 1st argument is string; all except AND now look for string as 2nd operand also 2788 S NOT AND some ops not possible between strings operation offset see CALCULATE operations/operators see commands, functions, and operators OR key (C5) see also commands, functions and operators, KEYBOARD SCANNING, 026A symbol code table The U key with symbol shift produces the operator OR; itmust be both preceded and followed by an expression with a logical value. The effect of the operator OR is to give a value to the expression "X OR Y": it is X if Y has logical value zero, otherwise it is one. This isn't the same as the Z80 assembly code OR, though it is analogous in the case where X and Y are both one or zero. OR cannot be used between strings. On execution, after the first expression has been evaluated in 268D S DECIMAL, 24FB SCANNING quickly leads to 2723S OPERTR. Here the token code C5 is looked up in the two tables 2795 table of operators and 27B0 table of priorities, giving a value 02C7 in BC and this is put on the machine stack in 2790 S NEXT: 02 is the priority and C7 the code of the OR operator. When the code comes off the calculator stack in 2734 S LOOP, C7 is converted to 07, the literal for 351B or. 2788 S NOT AND not accepted between strings or subroutine 351B Called from 0028 FP CALC by literal 07; executes the BASIC OR operator. The BASIC OR is analogous to the m/c OR; X ORY equals X if Y is zero, otherwise X OR Y = 1. If X and Y are each one/"true" or zero/"false", this works out the same as ORing m/c bits, rather than m/c bytes. Cf 3524 no-&-no. Not otherwise called from ROM; could be called either direct or through 0028 FP CALC from m/c programs. Input parameters: HL points to the first byte of X - DE to that of Y; for calls through the calculator Y must be the last value and X the second last value on the calculator stack, but for direct calls they may be located anywhere in RAM. Action: call 34E9 TEST ZERO for Y - if Y is zero, return; X becomes last value - (Y non-zero) set carry and exit into 350B FP 0/1; it changes the last value to one. Exit: RET or into 350B FP 0/1. Output parameters (from FP 0/1): HL and DE still point tothe same addresses, but on return to the calculator DE will be made the stack end so the result will become last value; the bytes of Y are still in place though they have been deleted fromthe stack - A is zero, other registers unchanged. ordinary listing see automatic listing OSPCC system variable 5C70 Bytes: 1 The statement number within the line to which execution jumps on CONTINUE. See 5C6E OLDPPC. [I don't know why OSPCC ends in PCC whereas all the other BASIC line and statement number svs end in PPC: PPC itself, E PPC, NEWPPC, NSPPC, OLDPPC, SUBPPC. But it is consistent throughout "ROM Disassembled" and all the Spectrum handbooks I have seen. I don't even know what PPC is supposed tostand for. There must be some arcane reason.] Written by: 1376 MAIN 7 Read by: 1E5F CONTINUE OTHER STR 35B7 (359C str-add$) Jumps from: 359C strs-add OUT key (DF) see also commands, functions and operators, KEYBOARD SCANNING, 0246 extended mode key table (c) The O key in E mode with either shift produces the command OUT. The "OUT statement" must also include two numeric expressions X,Y, separated by a comma; they needn't be integers but X must be positive and less than 10000h/65536d, Y may be negative but will be read in that case as 256d minus its absolute value, which must always be less than 256d. IN is a function, OUT a command; cf PEEK and POKE. The effect of the command is to send the byte Y to the port X. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1AF1 P OUT jumps in sequence to: 1C7A CLASS 08 to get the two parameters 1C10 CLASS 00 to check the statement is ended and then via 1C16 JUMP C R to the executive routine 1E7AOUT. OUT subroutine 1E7A Called only from the syntax parameter table 1A7A; executes the BASIC command OUT X,Y, when X is a port address, Y a one-byte value. Could be called from m/c, but it is simpler just to use OUT (C),A or similar. Input parameters: HL points to the first byte of X, second last value on the calculator stack - DE to that of Y, last value. Action: call 1E85 TWO PARAM to put Y in the A register and X in BC - now OUT (C),A has the desired effect. Exit: RET. Output parameters: A and BC as shown, X and Y have gone from the stack. OUT CHAR subroutine 1937 Prints any character code from the BASIC; ie outputs it to main screen, lower screen or ZX printer depending on the stream and channel in use. The subroutine is mainly concerned with deciding the mode, K or L/C, in which the next keystroke is to be interpretedor the cursor printed, by signalling with bit 2 of FLAGS; see the index entry. All codes signal L/C mode except THEN and usually the colon, because all K mode keystrokes occur at the start of a line or statement. [Error in REMs: if you try to write a REM such as: 5000 REM subroutine: display table the character after the ":" will print as a token: 5000 REM subroutine: DIM isplay table There are various ways of circumventing this, eg by putting quotes after the REM token - if you always do this, you needn't worry about the colon problem. Occasionally it can be made use of: REM : PRINT THEN RUN can be typed with only five keystrokes! This is the meaning of the cryptic note at the end of 196D OUT CH 3. It isn't easy to see how to correct the ROM, as there is no "REM" flag. Probably there should be one.] Input parameters: A holds a character code. Action: call 2D1B NUMERIC, and if the code is a digit jump on to OUT CH 3; there will be no mode change - if it is less than 21h jump on to OUT CH 3; PRINT comma, colour codes and space also make no change - zero bit 2 of FLAGS; K mode - if it is CB THEN jump on to OUT CH 3; THEN is always followed by a command, even in quotes or input mode - if it isn't 3A colon jump on to OUT CH 1; this will make L mode - (colon) if bit 5 of FLAGX is set jump on to OUT CH 2; L mode is used in input mode even after colon - (not in input mode) if bit 2 of FLAGS2 is zero jump onto OUT CH 3; K mode after colon not in quotes [even in REMS] - (in quotes) jump to OUT CH 2; L mode in quotes. _195A_OUT_CH_1 (all except digits, space, control codes, THEN and colon): - if it isn't code 22h " jump on to OUT CH 2 - (quotes) flop bit 2 of FLAGS2; the "quotes" flag. _1968_OUT_CH_2 (all but digits, space, control codes, THEN; colon in quotes or INPUT): set bit 2 of FLAGS; L mode.