×   Main Menu ALL The 8BS News Manuals (New menu) Links Worth a Look Tools Disc and Basic Webring Site Map 8BS Guestbook Old Guest Book Me The Barnsley Rovers   
8-Bit Software

The BBC and Master Computer Public Domain Library

B1C7 Load FWA with Float Variable

Submitted by Steve Fewell

Routine:ain
Name: Copy Float Variable to the FWA
Starting Address: &B1C7
Entry criteria: &2A and &2B point to a 5-byte Floating-Point variable to unpack and load.
        Y = 5 (size of variable).
Exit: The FWA contains the value of the variable.

Description:

Zero the FWA Rounding and FWA Overflow bytes.
Store the 5th byte of the variable (pointed to by (&2A, &2B)) in FWA Mantissa byte 4.
Store the 4th byte of the variable (pointed to by (&2A, &2B)) in FWA Mantissa byte 3.
Store the 3rd byte of the variable (pointed to by (&2A, &2B)) in FWA Mantissa byte 2.
Store the 2nd byte of the variable (pointed to by (&2A, &2B)) in FWA Sign byte.
Store the 1st byte of the variable (pointed to by (&2A, &2B)) in FWA Exponent byte.

If exponent = 0 and sign = 0 and FWA Man 2 = 0 and FWA Man 3 = 0 and FWA Man 4 = 0 then
the number is zero so jump to end of routine (B1F2) to store zero in FWA Mantissa 1 and
exit with A = #&FF (indicating a float result).

If exponent is non-zero, copy sign byte to FWA Mantissa byte 1 (setting the top
bit, as the sign is now unpacked and held separately from the top byte of the mantissa).
Exit with A=#&FF.


Disassembly for the Load FWA with Float Variable routine

B1C7 d5 100 053 64 35 STZ &35
B1C9 d/ 100 047 64 2F STZ &2F
B1CB   136 88 DEY
B1CC * 177 042 B1 2A LDA (&2A),Y
B1CE 4 133 052 85 34 STA &34
B1D0   136 88 DEY
B1D1 * 177 042 B1 2A LDA (&2A),Y
B1D3 3 133 051 85 33 STA &33
B1D5   136 88 DEY
B1D6 * 177 042 B1 2A LDA (&2A),Y
B1D8 2 133 050 85 32 STA &32
B1DA   136 88 DEY
B1DB * 177 042 B1 2A LDA (&2A),Y
B1DD . 133 046 85 2E STA &2E
B1DF   168 A8 TAY
B1E0 * 178 042 B2 2A LDA (&2A)
B1E2 0 133 048 85 30 STA &30
B1E4   208 009 D0 09 BNE 9 --> &B1EF
B1E6   152 98 TYA
B1E7 2 005 050 05 32 ORA &32
B1E9 3 005 051 05 33 ORA &33
B1EB 4 005 052 05 34 ORA &34
B1ED   240 003 F0 03 BEQ 3 --> &B1F2
B1EF   152 98 TYA
B1F0   009 128 09 80 ORA#&80
B1F2 1 133 049 85 31 STA &31
B1F4   169 255 A9 FF LDA#&FF
B1F6 ` 096 60 RTS

 


 Back to 8BS
Or