Routines 
Prev: 33C0  Up: Map 
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 +34 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 floatingpoint number supplied to it as 2, 3, 4 or 5 literals.
When called by using offset '+34' the literals follow the '+34' 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 +40, 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 5byte floatingpoint number are set to zero. The first literal is also used to determine the exponent, after reducing mod +40, unless the remainder is zero, in which case the second literal is used, as it stands, without reducing mod +40. In either case, +50 is added to the literal, giving the augmented exponent byte, e (the true exponent e' plus +80). The rest of the 5 bytes are stacked, including any zeros needed, and the subroutine returns.


stk_data  33C6  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.  
33C7  LD L,E  
This entry point is used by the routines at SKIP_CONS and stk_con.


STK_CONST  33C8  CALL TEST_5_SP  Now test that there is indeed room.  
33CB  EXX  Go to the alternate register set and stack the pointer to the next literal.  
33CC  PUSH HL  
33CD  EXX  
33CE  EX (SP),HL  Switch over the result pointer and the next literal pointer.  
33CF  PUSH BC  Save BC briefly.  
33D0  LD A,(HL)  The first literal is put into A and divided by +40 to give the integer values 0, 1, 2 or 3.  
33D1  AND $C0  
33D3  RLCA  
33D4  RLCA  
33D5  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.  
33D6  INC C  
33D7  LD A,(HL)  The literal is fetched anew, reduced mod +40 and discarded as inappropriate if the remainder if zero; in which case the next literal is fetched and used unreduced.  
33D8  AND $3F  
33DA  JR NZ,FORM_EXP  
33DC  INC HL  
33DD  LD A,(HL)  
FORM_EXP  33DE  ADD A,$50  The exponent, e, is formed by the addition of +50 and passed to the calculator stack as the first of the five bytes of the result.  
33E0  LD (DE),A  
33E1  LD A,$05  The number of literals specified in C are taken from the source and entered into the bytes of the result.  
33E3  SUB C  
33E4  INC HL  
33E5  INC DE  
33E6  LD B,$00  
33E8  LDIR  
33EA  POP BC  Restore BC.  
33EB  EX (SP),HL  Return the result pointer to HL and the next literal pointer to its usual position in HL'.  
33EC  EXX  
33ED  POP HL  
33EE  EXX  
33EF  LD B,A  The number of zero bytes required at this stage is given by 5C1, and this number of zeros is added to the result to make up the required five bytes.  
33F0  XOR A  
STK_ZEROS  33F1  DEC B  
33F2  RET Z  
33F3  LD (DE),A  
33F4  INC DE  
33F5  JR STK_ZEROS 
Prev: 33C0  Up: Map 