FP format Decimal 1. 64 E6 00 00 00 -0.000000003 2. 6C 1F 0B 00 00 0.000000592 3. 73 8F 38 EE 00 -0.000068294 4. 79 15 63 BB 23 0.004559008 5. 7E 92 0D CD ED -0.142630785 6. 81 23 5D 1B EA 1.276278962 See the BASIC demonstration program on page 223 of the notes; the result of the calculation is sin [W * (pi/2)] divided by W, ie (sin X)/W - multiply this by W for the result sin X. Exit: RET, from C ENT. Output parameters: none, but the last value on the stack is sin X. Called from: 238D DR 3 PRMS 23C1 DR PRMS 2497 DRAW SAVE (twice) 37DA tan Rems: Introduction uses Chebyshev polynomials 335B CALCULATE example of unary operation 3449 series-06 calculates approximation for 3783 get-argt transforms X to "reduced argument" for 37AA cos calculates complementary angle, then sin SINE FUNCTION see 37B5 sin above SINGLE CALCULATION SUBROUTINE, SINGLE OPERATION SUBROUTINE see 33A2 fp-calc-2 single strings see strings, 2AFF LET S INKEY$ subroutine 2634 Called only from 24FB SCANNING through the scanning function table at 2596. The executive routine of the INKEY$ function. The value of INKEY$ is a string from the keyboard, unless the INKEY$ token is followed by (hatch) and parameters for reading in from Microdrive etc, in which case other inputs may be used - of length zero, null string, if no key is now being pressed - or of length one, a single character. INKEY$ does not wait: it looks at the keyboard and accepts the character of any key which is pressed, but if there is none or no valid one, it takes a null value, ie a string of length zero. If you want it to wait you must write the classic BASIC line 1000 IF INKEY$="" THEN GO TO 1000 There would be little point in using 2634 S INKEY$ from m/c. To read the keyboard simply get a value from 5C08 LAST KEY at IY - 50; for the effect of the BASIC waiting line write something like LD (IY-50),0 LOOP LD A,(IY-50) AND A JR Z,LOOP This loop will repeat indefinitely till LAST KEY is given some non-zero value by the interrupt operating the keyboard scan. Input parameters: none. Action: make an op code 5A and priority 10h; see 24FB SCANNING. This will call 3645 read-in, which handles reading in from Microdrive etc - move on the BASIC pointer - if the code in BASIC is 23h (hatch) exit to 270D S PUSH PO to stack the op code and priority - (no hatch in BASIC, ie normal INKEY$) zero bit 6 of FLAGS for "string result" - if bit 7 of FLAGS shows syntax checking exit through SINK$ EN. - (run time; the keyboard is scanned, tested and decodedby direct calls to the appropriate subroutines, without waiting for the interrupt) call 028E KEY SCAN; it returns with NZ "no key" if two keys are being pressed or similar - make a zero length byte - if there is NZ jump on to S IK$ STK; no valid key - (key value received) call 031E K TEST; it returns withNC for no-key including "shift only" - if there is NC jump on to S IK$ STK; no-key - decrement D; which is returned zero by K TEST, so now FFh - call 0333 K DECODE; D is read as if it was 5C3B FLAGS,but the only relevant bit is 3 signalling "not K mode" - save the final code; it cannot be anything in K, E or G mode, but can be anything from L/C mode, including symbol shift tokens such as THEN, TO - call 0030 BC SPACES to make one space in the work space - load the code into it - make a length byte 01. _2660_S_IK$_STK: call 2AB2 STK STO $ to put the string parameters of the string on the calculator stack; its length is zero or one from the length byte, its start if any is the place in the work space. _2665_S_INK$_EN: exit. Exit: loops back into the scanning loop - through 270D S PUSH PO to 24FF S LOOP 1 for INKEY$ (hatch); the next code must be the stream number - to 2712 S CONT 2 when the keyboard input has been stacked; the next code might be a binary operator. Output parameters: none - for keyboard input the string parameters are now on the calculator stack. Rems: O28E KEY SCAN called by S INKEY$ 3645 read-in called by S INKEY$ S INK$ EN 2665 (2634 S INKEY$) Jumps from: 2634 S INKEY$ size of program/data block see program/data block SKIP CONS subroutine 33F7 Finds a particular constant in the calculator's constanttable at 32C5, which lists five constants, zero, one, half, pi/2and ten, in the compressed "stk-data" form. Could well be used in m/c programs of a mathematical type, to find constants in a list of up to 256d constants located anywhere in RAM. Input parameters: HL holds the address of the start of the table - A holds the serial number of the required constant starting at zero. Action: test the counter for zero. _33F8_SKIP_NEXT: if the counter is zero, return; the pointer is on the required constant - (non-zero counter) make a destination address 0000; asthis is in ROM, the output from STK CONST will not be accepted - call 33C8 STK CONST to expand the constant pointed to;the resulting 5-byte number just disappears, but it moves the pointer on through the table to the next entry - decrement the counter - loop back to SKIP NEXT. Exit: RET, from 33F8 SKIP NEXT. Output parameters: HL now holds the first address of the required constant - A is zero - DE is saved unchanged. Called from: 341B stk-zero Rems: 33C6 STK DATA called by to get constant literals SKIP NEXT 33F8 (33F7 SKIP CONS) Exit from: 33F7 SKIP CONS auto SKIP OVER subroutine 007D see also printable characters under character codes Checks the code at the BASIC pointer and sets flags to mark its syntax; if it is INK to OVER, moves the pointer on to skip the argument, if AT or TAB moves on twice to skip both arguments. If the pointer is moved, puts the new value into 5C5DCH ADD. Sets the carry unless the code is the newline or a code from 21h "!" upwards; the space also sets carry. Input parameters: A holds the code - HL holds the pointer. Action: if the code is more than 20h/32d return with no carry; alphanumerics, symbols, tokens - if it is a newline 0D return with no carry - if it is zero -> 0C, 0E or 0F, or 18h -> 20h, return with carry - (this leaves 10h -> 17h, INK to TAB) move the pointer on one - if the code was 16h AT or 17h TAB move it on again. _0090_SKIPS: set the carry and load the new pointer into 5C5D CH ADD. Exit: RETs, four from SKIP OVER and one from SKIPS. Output parameters: nothing changed except the flags and possibly HL - NC flag for newline 0D or anything above 20h - C flag for zero to 0C, 0E -> 20h inclusive. Called from: 001C TEST CHAR SKIPS 0090 (007D SKIP OVER) Exit from: 0070 SKIP OVER SKIP ZERO 315E (3155 TEST NORM) Jumps from: 3159 NEAR ZERO SL DEFINE 2A94 (2A52 SLICING) Jumps from: 2A7A SL RPT C 2A81 SL SECOND S LETTER 26C9 (24FB SCANNING) Jumps from: 2684 S ALPHANUM sliced strings see strings SLICING subroutine 2A52 Slicing is really a function: as SIN X finds the numerical value of a variable X and converts it into a new numerical value SIN X, so a$(3 TO 8) finds the string value of avariable a$ and converts it into a new string; new because it has a new start point and length. There is however no key token SLICE. The executive routine SLICING is called during 24FB SCANNING (a) at 2A45 SV SLICE, when the last subscript of a stringarray is reached and it is not replaced by a ")". (b) at 2713 S CONT 3, when a string expression has just been evaluated and the next character is a "(". Case (a) takes care of expressions such as a$(3,2) if a$only has two dimensions and a$(3,2 TO 7), case (b) of such as a$(2 TO 7), a$(3)(2 TO 7). In either case the string parameters of the string or string array element are already the last value on the calculator stack. The subroutine replaces them with the parameters of the slice. Input parameters: none - the BASIC pointer in 5C5D CH ADD is on either the comma before the slicing parameters or a "(" following a string expression. Action: call 2BF1 STK FETCH, which removes the string parameters of the whole string from the stack and puts them in A: the array flag, zero for a slice or array element, onefor a complete simple string BC: the length of the string DE: the start address of the string - move on the BASIC pointer - if the next code is 29h ), as in a$(), jump on to SL STORE; [a curiosity here: if the dimensions are a$(1,5), say, PRINT a$(1,) will pass syntax and print all five characters, just like PRINTa$(1)] - make an error register with a start value of zero; signalling "no errors yet" - make a slice start with a start value of one; signalling "slice starts at first character" - read the code again - get the length as a limit for the slice value - if it is CC TO jump on to SL SECOND with the slice start one - (slice start is given by BASIC) call 2ACD INT EXP2 to read the slice start from BASIC; if it is negative or more than 65535d then 1E99 FIND INT2 called from INT EXP2 will report "Integer out of range", but if it is over the limit value specified, the string length, it merely decrements the error register to a negative number - read the code after the slice start - if it is CC TO jump on to SL SECOND - check if it is 29h ). _2A7A_SL_RPT_C: if there is no match, report "Nonsense inBASIC" - (the code is ")") make a slice end byte equal to the slice start; this is a single character slice, eg a$(4) or a$(3,2) - jump on to SL DEFINE. _2A81_SL_SECOND: move the BASIC pointer on after "TO" - make a limit byte; again the length of the string - if the code found is 29h ) jump on to SL DEFINE; the slice end is equal to the length of the string - (slice end specified in BASIC) call 2ACD INT EXP2 to read the slice end from the BASIC; again it decrements the errorregister to a negative number if the BASIC value is over the limit value, the string length - if the code at the BASIC pointer is now not 29h ) jumpback to SL RPT C to report a "Nonsense". _2A94_SL_DEFINE: get back the string start pointer from the stack - add the string start byte - take away one; this is now the slice start address - take the slice start from the slice end - make a zero byte - if the subtraction made a carry jump on to SL OVER with zero as the length; slices of negative length are null strings, but are allowed as correct syntax - (zero or positive difference) increment the difference; this is the length of the slice, eg if start and endare equal the length should be one, not zero - check the error register - if it is negative report "Subscript wrong" - transfer the slice length to the length byte. _2AA8_SL_OVER: zero bit 6 of FLAGS; "string result". Exit: into 2AB1 STK ST 0, which puts the string parameters on the calculator stack, with the index zeroed to show "array/slice". Output parameters (into STK ST 0): the start and length of the slice are in DE and BC. Called from: 2713 S CONT 3 2A45 SV SLICE Rems: 2996 STK VAR check for slicing before stacking string parameters 2AB1 STK ST 0 array/slice flag is used in LET routines S LOOP 2734 (24FB SCANNING) Jumps from: 2713 S CONT 3 2723 S OPERTR 2770 S LOOPEND S LOOPEND 2770 (24FB SCANNING) Jumps from: 2764 S RUNTEST