×   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

Integer Reverse Order Complement (compliment Integer in FWA)

Submitted by Steve Fewell

Routine: icompFWA
Name: Test and Complement Integer in FWA
Starting Address: &82C4
Entry criteria: The FWA contains an Integer number.
Exit: The Integer Number in the FWA has been complemented (FWA = zero - FWA)

Description:
Complements an Integer  stored in the Floating-Point A Mantissa (which is stored the opposite way to Integers, that is: most significant byte first and least significant byte last; whereas Integers are stored least significant byte first, most significant byte last [as twos complement is used]).

If the FWA Sign Bit is positive, then no compliment is required (as we already have a positive Integer), so exit.

[82C8] As the FWA Sign Bit is negative (i.e. &FF), we need to complement the Integer, by subtracting each of the bytes (?&34 -> ?&31) from zero, using the carry flag to keep track of any borrows.

Disassembly for the Test and Compliment Integer in FWA routine

82C4 . 165 046 A5 2E LDA &2E
82C6   016 023 10 17 BPL 23 --> &82DF
82C8 8 056 38 SEC
82C9   160 000 A0 00 LDY#&00
82CB   152 98 TYA
82CC 4 229 052 E5 34 SBC &34
82CE 4 133 052 85 34 STA &34
82D0   152 98 TYA
82D1 3 229 051 E5 33 SBC &33
82D3 3 133 051 85 33 STA &33
82D5   152 98 TYA
82D6 2 229 050 E5 32 SBC &32
82D8 2 133 050 85 32 STA &32
82DA   152 98 TYA
82DB 1 229 049 E5 31 SBC &31
82DD 1 133 049 85 31 STA &31
82DF ` 096 60 RTS

 


 Back to 8BS
Or