Submitted by Steve Fewell
Routine:bunp
Name: Unpack Floating-Point Variable to FWB
Starting Address: &A4E0
Entry criteria: &4A and &4B (the argp) point to a 5-byte Floating-Point variable to unpack.
Exit: The FWB contains the value of the variable.
Description:
Set FWB Rounding byte = 0.
Set FWB Overflow byte = 0.
FWB Mantissa 4 = 5th byte of the packed variable
FWB Mantissa 3 = 4th byte of the packed variable
FWB Mantissa 2 = 3rd byte of the packed variable
FWB Mantissa Sign = 2nd byte of the packed variable
FWB Exponent = 1st byte of the packed variable
If the Exponent is zero, then check whether the Mantissa byte 2, Mantissa byte 3
and Mantissa byte 4 are also zero. If so, then the FWB value = 0.0 so store zero in
FWB Mantissa 1 and exit.
Mantissa 1 is formed by ORing the 2nd byte of the packed variable with #&80 to ensure that
the top bit is set - as the top bit is replaced by the sign bit in the packed form.
A4E0 | dA | 100 065 | 64 41 | STZ &41 |
A4E2 | 160 004 | A0 04 | LDY#&04 | |
A4E4 | J | 177 074 | B1 4A | LDA (&4A),Y |
A4E6 | @ | 133 064 | 85 40 | STA &40 |
A4E8 | 136 | 88 | DEY | |
A4E9 | J | 177 074 | B1 4A | LDA (&4A),Y |
A4EB | ? | 133 063 | 85 3F | STA &3F |
A4ED | 136 | 88 | DEY | |
A4EE | J | 177 074 | B1 4A | LDA (&4A),Y |
A4F0 | > | 133 062 | 85 3E | STA &3E |
A4F2 | 136 | 88 | DEY | |
A4F3 | J | 177 074 | B1 4A | LDA (&4A),Y |
A4F5 | ; | 133 059 | 85 3B | STA &3B |
A4F7 | 168 | A8 | TAY | |
A4F8 | J | 178 074 | B2 4A | LDA (&4A) |
A4FA | < | 133 060 | 85 3C | STA &3C |
A4FC | 208 009 | D0 09 | BNE 9 --> &A507 | |
A4FE | 152 | 98 | TYA | |
A4FF | > | 005 062 | 05 3E | ORA &3E |
A501 | ? | 005 063 | 05 3F | ORA &3F |
A503 | @ | 005 064 | 05 40 | ORA &40 |
A505 | 240 003 | F0 03 | BEQ 3 --> &A50A | |
A507 | 152 | 98 | TYA | |
A508 | 009 128 | 09 80 | ORA#&80 | |
A50A | = | 133 061 | 85 3D | STA &3D |
A50C | ` | 096 | 60 | RTS |