Called from: 12CF MAIN 3 1B17 LINE SCAN E LOOP 2D60 (2D4F E TO FP) Jumps from: 2D71 E TST END E L 1 1A15 (19FB E LINE NO; heading omitted by misprint: it should be on the line "JP C,1C8A,REPORT C") Jumps from: 19FB E LINE NO embedded colours, embedded control characters, embedded print items see colours, control characters E mode see 5C41 MODE enable interrupt see interrupts encoder (ZX printer) see ports end-calc subroutine 369B Must be called from 0028 FP CALC with literal 38 every time the calculator is used - it makes the exit from the literalstring. Not otherwise called from ROM. Could be called direct, for an indirect jump to HL', dropping the old return address. Input parameters: the return address 3365 RE ENTRY is on top of the machine stack, with the address of the last literal below it; put there by 335E GEN ENT 2 - H'L' holds the return address from the call to 0028 FPCALC; ie the address following the 38 end-calc literal. Action: drop the 3365 RE ENTRY return address - replace the last literal address on the stack with theH'L' return address. Exit: RET, to the address formerly in H'L'. Output parameters: HL and DE point to the last FP number on the stack and the stack end - H'L' holds a previous literal address. Calls: see under 0028 FP CALC; as it is always and only called to exit from FP CALC it is unnecessary to give the long list of occurrences. Rems: 335B CALCULATE last literal must be 38h END COMPL 30A3 (303E FULL ADDN) Jumps from: 307C TEST NEG end marker of GO SUB stack see GO SUB stack end marker of tables see 16DC INDEXER end-marker of variables area see 80-byte (after end of alphabet) end of BASIC line see ENTER key (0D) END TESTS 358C (353B no-l-eql) Exit from: 354E NU OR STR (353B no-l-eql etc) "E" notation of BASIC numbers see E-format numbers ENTER key (0D) This isn't a token, a character, a command or a function; it is handled in special ways wherever it is met with. 0D is returned as a "main code" by the keyboard scanningroutine, and isn't changed by 0333 K DECODE and 0367 K DIGIT regardless of the state of the various flags; ENTER is ENTER whatever shifts are pressed, even in E or G mode. A press of ENTER during editing makes an exit from the EDITOR loop; the 0D code isn't copied to the edit line. In the case of new BASIC in the editing area, there is already an 0D code at the end of the line - it is a fixture at the end of the editing area. In the case of an expression input against an INPUT command, it isn't required. Thus 0D will be found in the program area always and only at the end of BASIC lines. This use of ENTER is handled by a call from 0F92 ED KEYSthrough the editing keys table (0FA6) to 1024 ED ENTER. The methods of handling it when encountered in other uses are sufficiently indicated in the list of Rems below. 007D SKIP OVER return if encountered 07AD LD CH PR add carriage return to filename 0A4F PO ENTER empties print buffer during print 0C55 PO SCR called when handling 100C ED RIGHT returns if current character is ENTER 11A7 REMOVE FP returns if ENTER found 1219 RAM SET on start-up edit-line consists of single 0D 12CF MAIN 3 checks for null line 155D MAIN ADD line length calculated to carriage return 157D MAIN ADD1 checks for null line 16B0 SET MIN restores 0D at end of editing area 1835 LIST ALL printed 18A1 OUT LINE5 jump if ENTER found 19B1 EACH S 6 jumps back unless encountered 1B29 STMT L 1 treats as end of BASIC line 1BF4 STMT NEXT treats as end of BASIC line 1CDE FETCH NUM jumps forward on code 0D 1FF5 PRINT CR outputs carriage return 2048 PR ST END returns if ENTER found 2061 PR POSN 2 prints newline unless separator found 211C IN PR 2 automatically at end of INPUT prompt 21B9 IN ASSIGN signals return 250F S QUOTE S error if found after odd no of quotes 2712 S CONT 2 prints newline at end of expression 35DE val puts 0D at end of string in work space as end marker ENTER EDITING SUBROUTINE see 1024 ED ENTER entering BASIC characters see 0F2C EDITOR entries (INPUT) see 2089 INPUT entry in table, entry of array see tables, arrays ENT TABLE 338E (0028 FP CALC) Exit from: 336C SCAN ENT 338C DOUBLE A (335B CALCULATE, 0028 FP CALC) E PPC system variable 5C49 Bytes: 2 The number of the current line, ie - it is brought down for editing if EDIT is pressed - the ">" cursor must be printed against it in listings - an "automatic listing" scrolls till it appears on screen. The number is stored right way round in E PPC but in reverse in the BASIC program line; hence the reversed reading in1059 ED UP. Written by: 0FA9 ED EDIT (lo byte written twice) 155D MAIN ADD 1822 LIST 5 Read by: 0FA9 ED EDIT 0FF3 ED DOWN 1059 ED UP (read, then hi byte read to L) 157D MAIN ADD1 1795 AUTO LIST 1855 OUT LINE 190F LN FETCH Rems: 17E1 AUTO L 2 if < S TOP, put in S TOP ERASE key (D2) see also commands, functions and operators, KEYBOARD SCANNING, extended mode table 0284 The 7 key in E mode with symbol shift produces the command ERASE. The "ERASE statement" isn't accepted by the plainSpectrum, without attachments of some kind; with peripherals such as Interface 1 it requires to be followed by a channel letter, stream number and filename, or similar. The command is read by 1B29 STMT L 1 referring through the syntax offset table 1A48 to the syntax parameter table 1A7A.1B10 P ERASE causes a jump via 1C8C CLASS 0A, which collects thechannel letter, and 1C10 CLASS 00 to the executive routine 1793 CAT ETC - which however merely produces the error report "Invalid stream". ERR NR system variable 5C3A see also errors Bytes: 1 The_error_number, one less than the report code currently required; A is code 0A, other letters follow up to 1B for R. So the error number of R is 1Ah/26d. The report messages are stored in order of their report_codes at 1391 in the ROM. Initially set by 1219 RAM SET at FF to give report code zero "OK". This is the only possible value of ERR NR with bit 7 set; this fact is used eg at 1026 ED END. It is again set to FF each time a line is checked for syntax, by 1B17 LINE SCAN. All calls to RST 0008 ERROR 1 are followed by a byte from FF to 1A, which is loaded into ERR NR (0055 ERROR 3). This byte is read and incremented when it is time to print the error report, which is done at 1313 MAIN G and 133C MAIN 5. ERR NR is IY + 0; the IY index marker is set on it at 1219 RAM SET, and again in 2D2B STACK BC in case it has been changed by a USR routine. Written by: 0055 ERROR 3 1001 ED STOP 107F ED ERROR 1167 ED FULL 12AC MAIN 2 12CF MAIN 3 1B17 LINE SCAN 2148 IN VAR 2 Read by: 1026 ED END 12AC MAIN 2 1303 MAIN 4 133C MAIN 5 Rems: 1219 RAM SET loaded into IY; ERR NR is IY+0 2D2B STACK BC ditto; in case IY had been changed by a USR routine error address, error pointer see errors, 5C3D ERR SP, 5C5F XPTR (the terms are used ambiguously in the notes and may mean either of these) error cursor, error handling, error marker, error messages see errors error number see 5C3A ERR NR error register Used in 2ACC INT EXP1 and in 2A52 SLICING and following to mean the temporary "error flag" set up in the A register; if it is still zero, it signals "no errors yet". errors, see also 0008 ERROR 1, 2530 SYNTAX Z Errors in BASIC input are checked by_syntax_checking; this means making a "dry run" through the same routines as thoseused in execution, but with bit 7 of FLAGS cleared; constant reference to this flag, usually through the mini-subroutine 2530SYNTAX Z, enables parts of the execution to be skipped or replaced with specifically syntax-checking routines. Sometimes an error cannot be picked up till the program is actually running, eg a number calculated by the program which is out of its permitted range. Detection of any error produces a jump to one of the _report_routines; see the index entries for REPORT A etc. Nearlyall of these consist of a call to 0008 ERROR 1, which puts the _error_address in 5C5F X PTR; ERROR 2 reads the_error_number which must follow any call to ERROR 1; ERROR 3 puts the error number in 5C3B ERR NR and sets the stack pointer to the_error _return_address held in 5C3D ERR SP. Thus return is made not to the point from which ERROR 1 was called but to the error return address. [It is important to distinguish the error address and the error return address, though the notes don't always succeed in doing so; the error address is an address in the work space or editing area where a flashing error cursor will be inserted to signal the error, the error return address is the address to which execution must go to signal the error.] The error return address in run time is 1303 MAIN 4, because execution of BASIC commands, which includes RUN and therefore all program execution, is by the call to 1B8A LINE RUN(misprinted PROG RUN) just before MAIN 4. Whether the program isinterrupted by an error or goes to completion, the_error_report is now printed - but this may be "OK", which also counts as an error report. The error number is one less than the_report_code, ie the error number for REPORT 0 "OK" is FF, the number for REPORT 1 "NEXT without FOR" is zero, etc. This number is used to index into the list of_report_messages at 1391 by 133C MAIN 5. [Each of the report routines is only two bytes, and it is worth duplicating any of them if the duplicate is within JR range of only two exit jumps. Many such duplications actually occur, but they aren't carried to their logical extreme; eg there are seven JPs to 1C8A REPORT C within easy range of 06C3, where a duplicate could have been placed. One or two other inconsistencies in the labelling suggest a certain lack of coordination in the programming team.] Syntax checking takes place when ENTER is typed in to conclude input against the 0F2C EDITOR loop. While BASIC is actually being typed in to the editing area and copied to the lower screen, or an expression is being typed into the work space in response to an INPUT command, no check is made of the codes input and the only errors that are called are "Out of memory" if there is no room for the new inputs, or "Out of screen" if there is no room to print them on the screen. The error address now is 107F ED ERROR or 1167 ED FULL; either of these just makes a "rasp", without stopping the input or printing an error message. There is one exception to this: inputof a "down arrow" during an INPUT ... LINE input will break off the input with a "STOP in INPUT" message. This is implemented by0FF3 ED DOWN, 1001 ED STOP and 1026 ED END without any actual call to the ERROR routines. When 1024 ED ENTER makes the exit from the EDITOR loop, it restores the error stack pointer to the value it had on entryto the loop, but the EDITOR subroutine returns normally whether there is an error or not. On exit from the EDITOR loop after input of BASIC program lines or commands, a call to 1B17 LINE SCAN from 12AC MAIN 2 takes care of the syntax checking: it makes a dry run through the line with the syntax checking flag showing "check syntax". The machine stack is again empty, and the error addressis the same as the return address, so LINE SCAN will return intoMAIN 2 whether or not an error is found, with an error number in5C3B ERR NR; if there was an error, there will be an address in 5C5F X PTR showing the location of the error in the editing area. If the error number is anything but FF "OK", the EDITOR iscalled again from MAIN 2. This time, when the line is copied to the screen by 187D OUT LINE2 called from 111D ED COPY, it will have a flashing_error_cursor in it at the 5C5F X PTR address, printed by 1894 OUT LINE4. The returns from the EDITOR calls in the 2089 INPUT command routine are a little different, though the effect is similar. They are different again if input is being made otherwise than from the keyboard, but this complication will be ignored. For an ordinary INPUT, not ... LINE, the return address pointed to for error returns is set to 213A IN VAR 1; syntax is checked by the call to 21B9 IN ASSIGN from 2148 IN VAR 2, just after the call to EDITOR, so any errors will return to IN VAR 1,going back into EDITOR with an error address and producing a copy of the input with a flashing error cursor, just as for inputs of BASIC. The error stack pointer is replaced in 2174 IN VAR 5 before the second call to IN ASSIGN which actually makes the assignment. An INPUT ... LINE is the input of a string without its bounding quotes, and no errors need be looked for; any codes at all can be accepted between quotes. The error address hasn't been changed and it isn't changed back; IN VAR 1 was skipped, and the relevant part of IN VAR 5 is skipped as well. [Actually, K-mode tokens cannot be typed normally into an INPUT ... LINE, though symbol shift and E-mode tokens can. Even K-mode tokens can be typed in by preceding each one by THENand deleting THEN afterwards.]