- move on the BASIC pointer - jump on to IN NEXT 2. _20D8_IN_ITEM_2 (no bracketed expression): if the next code isn't CA LINE jump on to IN ITEM 3 - (INPUT ... LINE) move on the BASIC pointer - call 1C1F CLASS 01 to put an address in 5C4D DEST for the variable; it will report an error if a variable letter doesn't immediately follow LINE - flag "INPUT ... LINE" in FLAGX bit 7 - if FLAGS bit 6 shows "numeric input expected" report "Nonsense in BASIC"; INPUT ... LINE can only be used for string inputs - jump on to IN PROMPT. _20ED_IN_ITEM_3 (no LINE yet - it could still come later): call 2C8D ALPHA - if it returns with NC jump on to IN NEXT 1; the next character isn't a letter, ie not the beginning of a variable name - (variable letter found) call 1C1F CLASS 01 to get an address in 5C4D DEST for the variable - flag "not INPUT ... LINE" in FLAGX bit 7. _20FA_IN_PROMPT: in syntax checking jump on to IN NEXT 2 - clear the work space; where the prompt cursor will be formed - zero bit 6 of FLAGX "string result"; provisionally - set bit 5 of FLAGX "INPUT mode"; keyboard input will go to the work space - make a counter of one; one space for INPUT ... LINE ornumeric cursor - if bit 7 of FLAGX is set jump on to IN PR 2; INPUT ...LINE - if bit 6 of FLAGS is set jump on to IN PR 1; numeric entry - (cursor will be in quotes) make the counter three. _211A_IN_PR_1: copy bit 6 of FLAGS to bit 6 of FLAGX; correcting to "numeric result" if a numeric entry is expected. _211C_IN_PR_2: call 0030 BC SPACES with the counter to make space in the work space for the cursor - put a newline at the end of the space; the cursor itself will be inserted by 0E2C EDITOR called in IN VAR 2 or IN VAR 3 - if bit 1 of the counter is zero jump on to IN PR 3; itis either 00000011b or 00000001b, so jump if it is one. Bit 1 ismisprinted bit 6 in the notes - put 22h " in both the first two bytes of the space. _2129_IN_PR_3: point 5C5B K CUR at the start of the space - if the INPUT ... LINE flag is set jump on to IN VAR 3;no errors are reported in INPUT ... LINE, any code at all is accepted - (not INPUT ... LINE) park the BASIC pointer and the error stack pointer on the machine stack. _213A_IN_VAR_1 (no jumps to this label, it is solely usedas an error address): put IN VAR 1 on the stack as return address - if channel K isn't open jump on to IN VAR 2; this can only happen when peripherals are connected - point 5C3D ERR SP at this stack position; return will be to IN VAR 1 after an error in 24FB SCANNING called for syntaxchecking from 1C59 VAL FET in 21B9 IN ASSIGN. Errors detected bythe call to 0E2C EDITOR from IN VAR 2 won't return here, becauseEDITOR has its own error address 107F ED ERROR. _2148_IN_VAR_2: get a work space pointer from 5C61 WORKSP; on the start of the work space - call 11A7 REMOVE FP; if there has been an error, 268D S DECIMAL in SCANNING may have put number forms in the input line on syntax checking, and REMOVE FP will take them out again.They aren't wanted yet, error or no error, because 21B9 IN ASSIGN called below will put them in again - cancel any error number; if there has been an error, the error number will have been put in 5C3A ERR NR. Error reports aren't made, the input is merely copied to the lower screen with a flashing "?" and execution is returned to IN VAR 1 - call 0F2C EDITOR to make or correct the input - call 21B9 IN ASSIGN with the syntax checking flag; it checks that the input is a valid expression matching the variable in string/numeric status, and inserts any number forms required - jump on to IN VAR 4. _215E_IN_VAR_3 (INPUT ... LINE): call 0F2C EDITOR; there can be no errors in INPUT ... LINE, so no syntax checking is called for. _2161_IN_VAR_4: zero 5C5C K CUR hi; only the hi byte is zeroed, but this puts it well outside any possible address in the work space - call 21D6 IN CHAN K - if it returns with NZ jump on to IN VAR 5; channel K isn't open. It always will be open unless something like the network is in use [it is hard to see why this isn't checked by reference to FLAGS2 bit 4, as it was in IN VAR 1] - call 111D ED COPY to copy the input line again to the lower screen; in case there are multiple inputs on the same command, eg INPUT LINE s$ ' LINE t$ in which case the input for s$ is copied before the input for t$ is prompted. [If there is no second input, this display is cleared immediately; it can be seen well enough if a very long input, at least ten lines, is made and the cursor moved back near its beginning before pressing ENTER] - call 0DD9 CL SET with the value in 5C82 ECHO E, so that any further input prompts will follow those already on screen. _2174_IN_VAR_5 (input is finished, unless there are more items in the INPUT command): zero bit 5 of FLAGX; "edit mode" - zero bit 7 of FLAGX; not INPUT ... LINE - if it was set jump on to IN VAR 6 - (not INPUT ... LINE) drop the IN VAR 1 error address - put the old error address back in 5C3D ERR SP - recover the old BASIC pointer; stacked in IN PR 3 - park it temporarily in 5C5F X PTR - call IN ASSIGN with the run-time flag; this time it actually assigns the input to a variable in the variables area - recover the BASIC pointer, put it in 5C5D CH ADD and zero X PTR - jump on to IN NEXT 2; go round the outer loop again ifthere are more inputs in the INPUT command. _219B_IN_VAR_6 (INPUT ... LINE finished): subtract the value of 5C61 WORKSP from the value of 5C63 STKBOT to get the string length of the input - call 2AB2 STK STO $ to put the length and start address on the calculator stack as string parameters - call 2AFF LET which makes the assignment, ie copies the string to the variable in the variables area - jump on to IN NEXT 2; go round the outer loop again ifthere are more inputs in the INPUT command. _21AF_IN_NEXT_1 (jump to here from IN ITEM 3, after any position controller or bracketed expression): call 1FFC PR ITEM 1 to print out ATs, TABs, colours, or prompt strings in quotes before looping back. _21B2_IN_NEXT_2 (an input item has been completed): call PR POSN 1 again to see if there are any more position controllers - if the end of the statement hasn't been reached loop back to IN ITEM 1 - (it has) the IN ITEM 1 subroutine now returns into _INPUT_1 (continued): call 1BEE CHECK END, which in syntax checking prints an error report if the statement isn't complete or makes a double return to the statement loop if it is - (run time) get the current main screen print position from 5C88 S POSN - check its line number against the top line of the lower screen in 5C6B DF SZ - if the main screen print position is above the top line of the lower screen jump on to INPUT 2 - (the screen has been scrolled) make the upper screen line number equal to DF SZ and the column number 21h; the next output to the main screen will go to a new bottom line. _20AD_INPUT_2: put the new print position in 5C88 S POSN - correct the scroll counter in 5C8C SCR CT - zero TV FLAG bit zero; "print to main screen" - call 0DD9 CL SET to correct the system variables for the new print position. Exit: to 0D6E CLS LOWER, which clears the lower screen. Output parameters: none Rems: 0C55 PO SCR scroll may be needed 0E00 CL SCROLL [see note below]* 0F2C EDITOR called for INPUT 0F38 ED LOOP jump in INPUT ... LINE (ineffective) 1C1F CLASS 01 identifies variable for INPUT 1C56 VAL FET 1 used to evaluate variables 1FDF PRINT 2 called by INPUT routines 1FFC PR ITEM 1 called by INPUT routines 2AFF LET assignment routine for INPUT * [The header note on 0E00 CL SCROLL, "the entry point when scrolling for INPUT ... AT", is deeply inscrutable. In fact CL SCROLL may be called indirectly by several places in the INPUT routine, without AT necessarily being involved: calling 1FFC PR ITEM 1, which jumps on to 201E PR AT TAB, which calls 0010 PRINT A 1, which indirectly calls 09F4 PRINT OUT, which jumps on to 0A75 PO 2 OPER and thus on to 0A87 PO CONT and 0AAC PO AT ERR, which calls 0C55 PO SCR, which jumps to 0D02 PO SCR 4, and so through to 0D2D PO SCR 4B, which calls CL SCROLL. Not the most helpful note in the book.] INPUT AD subroutine 15E6 see also channels and streams Calls the input subroutine of the current channel. Input parameters: none. Action: switch to the alternate registers and save H'L' on the stack - read the address after the address in 5C51 CURCHL intoH'L'; the input routine of the current channel. Exit: into 15F7 CALL SUB, see under 0010 PRINT A 1, whichcalls the subroutine at the address found, still in the alternate registers, and on return restores H'L' from the stack and switches back to the main registers. Output parameters: all main registers unchanged after CALL SUB. Called from: 15DE WAIT KEY 3645 read-in input address of channel see channels and streams input area The first part of the work space when in input mode, up to the newline put there in 211C IN PR 2. The part after the newline is used by 24FB SCANNING for writing strings, etc. OFA9 ED EDIT cleared by EDIT key 111D ED COPY to be copied to lower screen INPUT line The line input to the work space and printed in the lower screen while in input mode. 0F81 ADD CHAR adds a character to 10A8 KEY INPUT copied to lower screen 117C ED C DONE exit after copying 2161 IN VAR 4 copied to display 21D0 IN STOP if INPUT line starts with STOP INPUT ... LINE see INPUT key, 2089 INPUT INPUT mode see FLAGX (bit 5) input/output routines A major section of ROM, see Introduction, from 028E KEY SCAN to 11A7 REMOVE FP: keyboard, speaker, cassettes, screen, printer handling. INPUT 1 2096 (2089 INPUT) Jumps from: 2089 INPUT INPUT 2 20AD (2089 INPUT) Jumps from: 2096 INPUT 1 IN STOP 21D0 (2089 INPUT) Exit from: 21B9 IN ASSIGN INT key (BA) see also commands, functions and operators, KEYBOARD SCANNING, 022C extended mode table (b) The R key in E mode without shift produces the function INT; it requires one numeric operand X, and the value of the function is X if X is an integer, or the largest integer smaller than X. If X is positive this is the integer part of X, but notif it is negative. On execution, 24FB SCANNING quickly leads to 26DF S NEGATE. This converts the key code BA first to 0B, then to E7, and adds the priority 10h/16d. Code and priority 10E7 are now pushed on to the machine stack (270D S PUSH PO) while the expression following INT is evaluated. When the code is taken off the stack (2734 S LOOP), it is converted (2773 S TIGHTER) from E7 to 27, the calculator offset for 36AF int. int subroutine 36AF see also integer part of number Called several times in ROM from 0028 FP CALC with literal 27; also executes the INT function in BASIC. Not called direct from ROM, but it could be called from m/c. INT X returns the next integer below X - for positive but not for negative X, this is the integer part of X. For example INT -2.5 is -3. Input parameters: none - X must be last value on the calculator stack, even fordirect calls. Action: use the calculator with literal 36 less-0 to check the sign of X - if it is negative jump on to X NEG - (X positive) truncate X and return. _36B7_X_NEG: truncate X - subtract the result from X, getting the fractional part of X - rearrange the stack with the fractional part of X on top and the integer part below - call 30 not, which replaces the fractional part with one if it is zero, with zero if it is non-zero - if the fractional part is zero jump on to EXIT, leaving only the integer part on the stack; X was a negative integer - (X negative, not an integer) subtract one from truncated X. _36C2_EXIT: close down the calculator. Exit: RET. Output parameters: none - INT X has replaced X as last value on the stack. Called from: 03F8 BEEP 2DA2 FP TO BC 2DC1 LOG(2**A) 2E01 PF LOOP 2E24 PF SMALL 36A0 n-mod-m 36C4 exp } The "1C46" printed after the label on 3783 get-argt } these two lines seems to be a misprint INT CASE 3483 (346E negate) Exit from: 3474 NEG TEST (346E negate) integer form of numbers see CALCULATE integer part of number Any number which isn't an integer has an integer part and a fractional part: eg pi, whose integer part is 3 and whose fractional part is 0.C90FDAA2h/0.1415927d. The fractional part isn't correctly called the "decimal part", eg in the note on 2F4A PF E SBRN: there is nothing decimal about it, it is still the same number whether expressed in binary, octal, decimal, hex, vulgar fractions, Chinese characters etc. The notes seem sometimes to use the term "modulus" to mean the integer part of a number: this is also incorrect, and confusing, because of expressions like "X modulo 16d" or "X mod 16d", which are short for "the remainder left when X is divided by 16d".