26C9 S LETTER parameters of entry put on stack 2713 S CONT 3 parenthesis may indicate element of array 28B2 LOOK VARS discriminate arrays from num variables 28DE V STR VAR set flag for strings and string arrays 2900 V EACH test for strings and string arrays 2934 V SYNTAX presence of "(" signals array 294B V END output parameters for arrays of LOOK VARS 2996 STK VAR finds address of individual element 29AE SV ARRAYS gets dimension no and checks subscript 29C0 SV PTR gets ready to evaluate subscript 29C3 SV COMMA loop to count elements 29D8 SV CLOSE checks string arrays for slicing 29EA SV LOOP ")" marks end of subscripts 29FB SV MULT compute each subscript in element count 2A12 SV RPT C distinguishes numeric from string array 2A22 SV NUMBER marks required element in number array 2A2C SV ELEM$ marks element in string array, and stacks its string parameters 2A49 SV SLICE? returns after last subscript 2AB1 STK STO 0 first byte of string parameters zero for elements of strings 2B66 L EXISTS splits numeric vbles from strings/arrays 2B72 L DELETE$ value written in work space and copied array strings see arrays, strings ASCII letter ASCII stands for American Standard Codes for InformationInterchange, and ASCII codes are the most widely-used set of one-byte codes for computer characters; used by the Spectrum except for the codes for 96d "`" and 127d "". However in the notes all it means really is "character codes", which see. ASN key (B5) see also commands, functions and operators, KEYBOARD SCANNING, 0246 extended mode table (c) The O key in E mode with either shift produces the function ASN; it requires one numeric operand X, and the value of the function is the number arc sin X whose SIN is X. X is in radians, see the index entry on 3783 get-argt. On execution, 24FB SCANNING quickly leads to 26DF S NEGATE. This converts the key code B5 first to 06, then to E2, and adds the priority 10h/16d. Code and priority 10E2 are now pushed on to the machine stack (270D S PUSH PO) while the expression following ASN is evaluated. When the code is taken off the stack (2734 S LOOP), it is converted (2773 S TIGHTER) from E2 to 22, the calculator offset for 3833 asn. asn subroutine 3833 Called from 0028 FP-CALC with offset 22; executes the ASN command, ie finds arc sin X, the number in radians whose SINis X. For radians, see the index entry on 3783 get-argt. Called once in ROM, through the calculator; can also be called from m/cdirect. Given X such that Y = arc sin X, then SIN Y = X, and COS Y = SQR(1 - X**2), a standard identity, which is easily worked out using the calculator's multiply and sqr routines. Given both SIN Y and COS Y, the calculator now finds TAN(Y/2) from another trigonometrical identity SIN Y TAN (Y/2) = ----------- (1 + COS Y) (misprinted in the note). Now the atn subroutine finds Y/2 by the use of Chebyshevpolynomials; doubling this gives the required result Y. Input parameters: the FP number X whose arc sin is to be found must be the last number on the calculator stack, even for direct calls. Action: use the calculator to find, as explained above: - COS Y from SQR(1 - X**2) - TAN (Y/2) from the formula shown - Y/2 by the atn function - finally Y. Exit: RET. Output parameters: the last number on the calculator stack is now the number whose SIN is X - mem-0 to mem-2 were corrupted in the sqr subroutine. Called from: 3843 acs assignment of variable value see 2AFF LET, variable AT key (AC) see also control codes, KEYBOARD SCANNING, 026A extended mode table (e) The I key with symbol shift produces the print control item code AT. AT can only be used within a PRINT etc statement, and must be followed by two parameters separated by a comma. Execution is from within the PRINT executive routine 1FCD PRINT;each new expression following the PRINT command is checked by a call to 1FFC PR ITEM 1 from 1FE5 PRINT 3. If it is an AT, the ATcontrol character 16h/22d and the two parameters are sent through the output routine. The way this works when printing on screen can be seen at 09F4 PRINT OUT; indexing with 16h for AT into the control character table at 0A11 produces an indirect jump to 0A75 (0A21 + 54) PO 2 OPER. See the index description of this subroutine under 09F4 PRINT OUT for the rather tricky way in which it collects the two parameters and sends execution to 0A87 PO CONT,which finally resets the print position to execute the AT command. The AT control character 22d can be used from BASIC: 10 LET a$=CHR$ 22 + CHR$ 7 + CHR$ 13 + "hello!" 20 PRINT a$ has just the same effect as 10 PRINT AT 7,13;"hello" This is much more useful when printing from m/c. 007D SKIP OVER skip twice, when setting CH ADD 0A6D PO TV 2 requires two operands 0A7D PO TV 1 control code saved in TVDATA 0A80 PO CHANGE next character is operand 0A87 PO CONT code and first operand now in TVDATA 0C55 PO SCR part skipped when handling INPUT ... AT 0E00 CL SCROLL entry point to scrolling subroutine when handling INPUT ... AT 0F38 ED LOOP handled here in EDITOR routine 103E ED EDGE 1 placing of cursor in EDITING 1FFC PR ITEM 1 code & 2 operands prepared for printing 201E PR AT TAB prints code and both operands 2089 INPUT statement can include ATs &c ATN key (B7) see also commands, functions and operators, KEYBOARD SCANNING, 0246 extended mode table (c) The E key in E mode with either shift produces the function ATN; it requires one numeric operand X, and the value of the function is arc tan X, the number whose TAN is X. X is inradians, see the index entry on 3783 get-argt. On execution, 24FB SCANNING quickly leads to 26DF S NEGATE. This converts the key code B7 first to 08, then to E4, and adds the priority 10h/16d. Code and priority 10E4 are now pushed on to the machine stack (270D S PUSH PO) while the expression following ATN is evaluated. When the code is taken off the stack (2734 S LOOP), it is converted (2773 S TIGHTER) from E4 to 24, the calculator offset for 37E2 atn. Introduction: calculation uses Chebyshev polynomials atn subroutine 37E2 Called from 0028 FP CALC with the offset 24; executes the ATN command, ie finds the number Y = arc tan X whose TAN is X. X is in radians, see the index entry on 3783 get-argt. Calledonce from ROM, through the calculator; can also be called directfrom m/c programs. This is the fundamental inverse trig function in the Spectrum system, used by both the ACS and ASN routines. The value of arc tan X ranges from -pi/2 for X = minus infinity through -pi/4 for X = -1, zero for X = zero, +pi/4 for X = 1, to +pi/2 for X = plus infinity. This range of X has to be reduced for the Chebyshev polynomials, and it is done by using the trigonometrical identity ATN X = pi/2 - ATN (1/X) derived from TAN Y = cot (pi/2 - Y). So if X is more than 1, the subroutine calculates -ATN (1/X) instead, which is the same as ATN (-1/X); 1/X of course isless than 1 in this case. Then it adds this to pi/2. And if X isnegative and less than one, it calculates -pi/2 - ATN (1/X). So the first step replaces ATN X with ATN Y', where Y' =either X or -1/X, and Y' now ranges only from -1 to +1. Y' is _not the result Y = arc tan X. A second step changes the argument of the function again, by using instead of Y' another value Z such that Z = 2Y'**2 - 1; the range of Z is still -1 to +1. The notes don't explain why this step is taken; possiblythe book of functions referred to at the bottom of page 226 (Abramowitz & Stegun,_Handbook_of_Mathematical_Functions, Dover 1965) explains it, but the reason is no doubt to make use of a set of already worked out, or just simpler, Chebyshev polynomials. The series-0C subroutine in any case works directly fromZ to (ATN Y')/Y', so all that remains to do is multiply by Y', and add pi/2 or -pi/2 if necessary. The twelve Chebyshev constants used are: FP form Decimal 1. 60 B2 -0.0000000002 2. 63 0E 0.0000000010 3. 65 E4 8D -0.0000000066 4. 68 39 BC 0.0000000432 5. 6B 98 FD -0.0000002850 6. 6E 00 36 75 0.0000019105 7. 70 DB E8 B4 -0.0000131076 8. 73 42 C4 0.0000928715 9. 76 B5 09 36 BE -0.0006905975 10. 79 36 73 18 5D 0.0055679210 11. 7C D8 DE 63 BE -0.0529464623 12. 80 61 A1 B3 0C 0.8813735870 Input parameters: the FP number X must be the last numberon the calculator stack, even for direct calls. Action: call 3297 RE STACK to put X in full FP format - check its exponent - if the exponent is less than 81 jump on to SMALL; X isless than 1 - (X > 1, so the arc tan of -1/X is found instead) use the calculator to get -1/X - get pi/2 - if -1/X is negative jump on to CASES; ie if X is positive. - (X is negative) change pi/2 to -pi/2 - jump on to CASES. _37F8_SMALL (X is less than 1, leave it alone: Y' = X): put zero on the calculator stack. _37FA_CASES (the top value on the stack is either zero orpi/2 or -pi/2, and the next one is Y' = -1/X or Y' = X): calculate Z = 2Y'**2 - 1; retaining the two values already on the stack - use the series generator to make (atn Y')/Y' - multiply this with the Y' on the stack - add the value below it; this gives the required result. Exit: RET (from 37FA CASES). Output parameters: the last number on the calculator stack is the number whose TAN is X - mem-0 to mem-2 corrupted, by the series subroutine. Called from: 3833 asn Rems: 3449 series-0C uses twelve Chebyshev polynomials page 226 BASIC demo of series generation ATTR key (AB) see also colours, commands, functions and operators, KEYBOARD SCANNING, 0246 extended mode table (c) The L key in E mode with either shift produces the function ATTR; it requires two numeric operands (X,Y), which must be in brackets, and the value of the function is the code number for the attributes of position (X,Y) on the screen. On execution, 24FB SCANNING indexes into the scanning function table at 2596 to find the executive routine 2672 S ATTR. 2580 S ATTR S finds value of ATTR (x,y) 26C3 S NUMERIC sets flag for numeric result attribute address, attribute area, attribute bytes, attribute value see colours ATTR P system variable 5C8D see also colours Bytes: 1 Holds the "permanent" attributes, ie those which are used to colour the screen as a whole, or print items in the absence of special instructions: 5C8F ATTR T, which is always used for actual printing, holds the colours specified by print instructions, or is copied from ATTR P in the absence of any. Sometimes handled as a 2-byte value with the next systemvariable 5C8E MASK P. The bits of ATTR P represent fbpapink. They are set to 00111000b/38h on start-up by 1219 RAM SET, black (7) INK on white (0) PAPER - the bits are copied from ATTR T, and MASK P is copied from MASK T, by 1296 PERMS whenever the INK to OVER codes are used as_autonomous BASIC commands, ie not merely as part of a PRINT or INPUT command - they are read and copied into ATTR T, and MASK T is copied from MASK P, by 0D4D TEMPS in executing a PRINT or INPUT command; individual bits in ATTR T may then be changed by subrodinated INK to OVER commands - they are read and poked into addresses in the attributes area by 0D6E CLS LOWER or 0E4D CL LINE 2 when executing CLS routines. Written by: 1219 RAM SET 1C96 PERMS (2 bytes) Read by: 0D4D TEMPS (2 bytes) 0D6E CLS LOWER 0E4D CL LINE 2 Rems: 0CD2 PO SCR 3 values in lower screen may be corrected on scrolling 0D6B CLS used to set attribute bytes 1646 CHAN S 1 set on exit through 0D4D TEMPS ATTR T system variable 5C8F see also colours Bytes: 1 Holds the "temporary" attributes, ie those which are used when characters are printed. These are copied from 5C8D ATTR P but may then be modified by INK to OVER commands in the PRINT or INPUT command. Sometimes handled as a 2-byte value withthe next system variable 5C90 MASK T. The bits of ATTR T represent fbpapink. They are set to 00111000b/38h on start-up by 1219 RAM SET - black (7) INK on white (0) PAPER - they are copied from ATTR P, and MASK T is copied from MASK P, by 0D5B TEMPS 1 whenever a PRINT or INPUT command is executed, and also whenever channel 2 "S" is opened to print on the main screen; so if printing is interrupted, eg to print the "scroll?" message or to scroll the screen , ATTR T and MASK T must be saved - they are adjusted to take account of local INK to OVER commands in 2246 CO TEMP 9 and following - they are poked to the attributes area by 0BDB PO ATTR and following. Written by: 0C88 PO SCR 2 (2 bytes) 0D2D PO SCR 4B (2 bytes) 0D5B TEMPS 1 (2 bytes) 1219 RAM SET 18C1 OUT FLASH (bit 7 set) 2287 CO TEMP E (using 226C CO CHANGE) Read by: OBDB PO ATTR (2 bytes; NB misprints) 0C88 PO SCR 2 (2 bytes) 0D02 PO SCR 4 (2 bytes) 18C1 OUT FLASH (2 bytes) 1C96 PERMS (2 bytes) 2246 CO TEMP 9