Routines |
Prev: 13248 | Up: Map | Next: 13303 |
Used by the routine at series.
The address of this routine is found in the table of addresses. It is called via the calculator literal 52 by the routines at BEEP, CD_PRMS1, S_RND, LOG_2_A, exp, ln and get_argt.
This subroutine places on the calculator stack, as a 'last value', the floating-point number supplied to it as 2, 3, 4 or 5 literals.
When called by using offset '52' the literals follow the '52' in the list of literals; when called by the series generator, the literals are supplied by the subroutine that called for a series to be generated; and when called by SKIP_CONS and stk_con the literals are obtained from the calculator's table of constants.
In each case, the first literal supplied is divided by 64, and the integer quotient plus 1 determines whether 1, 2, 3 or 4 further literals will be taken from the source to form the mantissa of the number. Any unfilled bytes of the five bytes that go to form a 5-byte floating-point number are set to zero. The first literal is also used to determine the exponent, after reducing mod 64, unless the remainder is zero, in which case the second literal is used, as it stands, without reducing mod 64. In either case, 80 is added to the literal, giving the augmented exponent byte, e (the true exponent e' plus 128). The rest of the 5 bytes are stacked, including any zeros needed, and the subroutine returns.
|
||||||||||
stk_data | 13254 | LD H,D | This subroutine performs the manipulatory operation of adding a 'last value' to the calculator stack; hence HL is set to point one past the present 'last value' and hence point to the result. | |||||||
13255 | LD L,E | |||||||||
This entry point is used by the routines at SKIP_CONS and stk_con.
|
||||||||||
STK_CONST | 13256 | CALL TEST_5_SP | Now test that there is indeed room. | |||||||
13259 | EXX | Go to the alternate register set and stack the pointer to the next literal. | ||||||||
13260 | PUSH HL | |||||||||
13261 | EXX | |||||||||
13262 | EX (SP),HL | Switch over the result pointer and the next literal pointer. | ||||||||
13263 | PUSH BC | Save BC briefly. | ||||||||
13264 | LD A,(HL) | The first literal is put into A and divided by 64 to give the integer values 0, 1, 2 or 3. | ||||||||
13265 | AND 192 | |||||||||
13267 | RLCA | |||||||||
13268 | RLCA | |||||||||
13269 | LD C,A | The integer value is transferred to C and incremented, thereby giving the range 1, 2, 3 or 4 for the number of literals that will be needed. | ||||||||
13270 | INC C | |||||||||
13271 | LD A,(HL) | The literal is fetched anew, reduced mod 64 and discarded as inappropriate if the remainder if zero; in which case the next literal is fetched and used unreduced. | ||||||||
13272 | AND 63 | |||||||||
13274 | JR NZ,FORM_EXP | |||||||||
13276 | INC HL | |||||||||
13277 | LD A,(HL) | |||||||||
FORM_EXP | 13278 | ADD A,80 | The exponent, e, is formed by the addition of 80 and passed to the calculator stack as the first of the five bytes of the result. | |||||||
13280 | LD (DE),A | |||||||||
13281 | LD A,5 | The number of literals specified in C are taken from the source and entered into the bytes of the result. | ||||||||
13283 | SUB C | |||||||||
13284 | INC HL | |||||||||
13285 | INC DE | |||||||||
13286 | LD B,0 | |||||||||
13288 | LDIR | |||||||||
13290 | POP BC | Restore BC. | ||||||||
13291 | EX (SP),HL | Return the result pointer to HL and the next literal pointer to its usual position in HL'. | ||||||||
13292 | EXX | |||||||||
13293 | POP HL | |||||||||
13294 | EXX | |||||||||
13295 | LD B,A | The number of zero bytes required at this stage is given by 5-C-1, and this number of zeros is added to the result to make up the required five bytes. | ||||||||
13296 | XOR A | |||||||||
STK_ZEROS | 13297 | DEC B | ||||||||
13298 | RET Z | |||||||||
13299 | LD (DE),A | |||||||||
13300 | INC DE | |||||||||
13301 | JR STK_ZEROS |
Prev: 13248 | Up: Map | Next: 13303 |