8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

A695 Round FWA Mantissa to 4 bytes (loose rounding byte)

Submitted by Steve Fewell

Description:

If FWA Mantissa rounding byte is less than #&80 then jump to A6AE.

Otherwise we need to round-up the current 4-byte Mantissa value.
If the Mantissa rounding byte is equal to #&80 then, the LSB of the FWA Mantissa
byte 4 will be set to 1 (if it was zero). No other rounding is done.
[Note: the ROL A instruction in this code will change value 1000 0000 to 0000 0001].
Otherwise (rounding > #&80) to round up the value we increment the FWA Mantissa byte 4 by 1 (if
necessary, &A4D3 will be called to follow through the increment (to the rest of the Mantissa)
if the increment caused the value of Mantissa byte 4 to overflow (from &FF to &00).
Continue with &A6AE (described below).

&A6AE checks the FWA Exponent overflow byte. If it is zero then the number
is fine, so clear FWA Mantissa rounding byte and exit.
Otherwise, FWA exponent overflow byte is positive, so generate a "Too Big" error.


Disassembly for the Round FWA Mantissa to 4 bytes routine

A695 5 165 053 A5 35 LDA &35
A697   201 128 C9 80 CMP#&80
A699   144 019 90 13 BCC 19 --> &A6AE
A69B   240 014 F0 0E BEQ 14 --> &A6AB
A69D 4 230 052 E6 34 INC &34
A69F   208 013 D0 0D BNE 13 --> &A6AE
A6A1   032 211 164 20 D3 A4 JSR &A4D3
A6A4   128 008 80 08 BRA 8 --> &A6AE
A6A6-A6AA   Not used by this routine
A6AB * 042 2A ROL A
A6AC 4 004 052 04 34 TSB &34
A6AE / 165 047 A5 2F LDA &2F
A6B0   240 016 F0 10 BEQ 16 --> &A6C2 [STZ &35:RTS] from aclear
A6B2   016 017 10 11 BPL 17 --> &A6C5 Too Big Error

 


 Back to 8BS
Or