8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

Floating-point Sign

Submitted by Steve Fewell

Routine: Asign
Name: Return the sign of the number in the FWA
Starting Address: &A3F2
Entry criteria: None
Exit: A = 0 if the FWA contains zero, A = 1 if the FWA contains a positive number, A = -1 if the FWA contains a negative number.

Description:
Load A with FWA Mantissa Byte 1, OR this value with the other Mantissa bytes (byte 2 to byte 5), If the result is zero, then the whole of the FWA Mantissa is zero, this signifies that the number in the FWA is zero, if this is so, then store zero in the FWA Sign, FWA Exponent and FWA overflow bytes and return with A = 0.

Otherwise, Load A with the FWA Sign Byte, if it isn't zero, then the FWA is negative, and the top bit of the sign byte must be set. So exit with A containing the sign byte (-1).

Otherwise, increment A (to get a result of 1) and return.

Disassembly for the Floating-point Sign routine

A3F2 1 165 049 A5 31 LDA &31
A3F4 2 005 050 05 32 ORA &32
A3F6 3 005 051 05 33 ORA &33
A3F8 4 005 052 05 34 ORA &34
A3FA 5 005 053 05 35 ORA &35
A3FC   240 006 F0 06 BEQ 6 --> &A404
A3FE . 165 046 A5 2E LDA &2E
A400   208 008 D0 08 BNE 8 --> &A40A
A402   026 1A INC A
A403 ` 096 60 RTS
A404 d. 100 046 64 2E STZ &2E
A406 d0 100 048 64 30 STZ &30
A408 d/ 100 047 64 2F STZ &2F
A40A ` 096 60 RTS

 


 Back to 8BS
Or