Routines |
Prev: 3293 | Up: Map | Next: 32C5 |
Used by the routine at atn.
The routine at RE_ST_TWO continues here.
The address of this routine is found in the table of addresses. It is called via the calculator literal +3D by the routines at CIRCLE, DRAW, exp, ln and get_argt. The routine at RE_ST_TWO also continues here.
This subroutine is called to re-stack one number (which could be a 'small integer') in full five-byte floating-point form.
|
||||||||
re_stack | 3297 | LD A,(HL) | If the first byte is not zero, return - the number cannot be a 'small integer'. | |||||
3298 | AND A | |||||||
3299 | RET NZ | |||||||
329A | PUSH DE | Save the 'other' pointer in DE. | ||||||
329B | CALL INT_FETCH | Fetch the sign in C and the number in DE. | ||||||
329E | XOR A | Clear the A register. | ||||||
329F | INC HL | Point to the fifth location. | ||||||
32A0 | LD (HL),A | Set the fifth byte to zero. | ||||||
32A1 | DEC HL | Point to the fourth location. | ||||||
32A2 | LD (HL),A | Set the fourth byte to zero; bytes 2 and 3 will hold the mantissa. | ||||||
32A3 | LD B,$91 | Set B to +91 for the exponent, i.e. for up to 16 bits in the integer. | ||||||
32A5 | LD A,D | Test whether D is zero so that at most 8 bits would be needed. | ||||||
32A6 | AND A | |||||||
32A7 | JR NZ,RS_NRMLSE | Jump if more than 8 bits needed. | ||||||
32A9 | OR E | Now test E too. | ||||||
32AA | LD B,D | Save the zero in B (it will give zero exponent if E too is zero). | ||||||
32AB | JR Z,RS_STORE | Jump if E is indeed zero. | ||||||
32AD | LD D,E | Move E to D (D was zero, E not). | ||||||
32AE | LD E,B | Set E to zero now. | ||||||
32AF | LD B,$89 | Set B to +89 for the exponent - no more than 8 bits now. | ||||||
RS_NRMLSE | 32B1 | EX DE,HL | Pointer to DE, number to HL. | |||||
RSTK_LOOP | 32B2 | DEC B | Decrement the exponent on each shift. | |||||
32B3 | ADD HL,HL | Shift the number right one position. | ||||||
32B4 | JR NC,RSTK_LOOP | Until the carry is set. | ||||||
32B6 | RRC C | Sign bit to carry flag now. | ||||||
32B8 | RR H | Insert it in place as the number is shifted back one place normal now. | ||||||
32BA | RR L | |||||||
32BC | EX DE,HL | Pointer to byte 4 back to HL. | ||||||
RS_STORE | 32BD | DEC HL | Point to the third location. | |||||
32BE | LD (HL),E | Store the third byte. | ||||||
32BF | DEC HL | Point to the second location. | ||||||
32C0 | LD (HL),D | Store the second byte. | ||||||
32C1 | DEC HL | Point to the first location. | ||||||
32C2 | LD (HL),B | Store the exponent byte. | ||||||
32C3 | POP DE | Restore the 'other' pointer to DE. | ||||||
32C4 | RET | Finished. |
Prev: 3293 | Up: Map | Next: 32C5 |