×   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

AB8A INT

Submitted by Steve Fewell

Description:

Call routine &AD36 to get the Value at the BASIC Text pointer B location.
If the result is a String value then issue a Type mismatch error.
If the result is an Integer value (A = #&40) then exit as the value is already an Integer.

Push the FWA sign byte (6502 processor flags when &2E byte loaded) to the 6502 stack.
Call routine &8275 to move the fractional part of the FWA value out of the FWA and into the FWB mantissa and to convert
the FWA value to a two's complement format number (if the FWA sign bit is negative).

Retrieve the FWA sign byte status from the 6502 stack.
If the FWA was positive then copy the FWA mantissa to the IWA and exit with A = #&40 (as the result is an Integer);
now the IWA contaions the Integer FWA value.

If the FWA was negative then convert the value to Integer as follows:
* If the FWB Mantissa (bytes &3D to &40) is zero then there is no fractional part, so copy the FWA mantissa to
the IWA and exit with A = #&40 (as the result is an Integer).
* Call &82C8 to perform a reverse order complement of the FWA value (to make the value a positive Integer value).
* Call &830D to add 1 to the FWA Mantissa value.
* Call &82C8 to perform a reverse order complement of the FWA value to reverse the previous complement resulting in the
two's complement value.
* Copy the FWA Mantissa to the IWA and exit with A = #&40 (as the result is an Integer).


Disassembly for the INT routine

AB8A 6 032 054 173 20 36 AD JSR &AD36 Evaluate value
AB8D = 240 061 F0 3D BEQ 61 --> &ABCC   [JMP &9092   'Type mismatch' error]
AB8F ! 016 033 10 21 BPL 33 --> &ABB2   [RTS]
AB91 . 165 046 A5 2E LDA &2E
AB93   008 08 PHP
AB94 u 032 117 130 20 75 82 JSR &8275 Move fractional part of FWA to FWB
AB97 ( 040 28 PLP
AB98   016 019 10 13 BPL 19 --> &ABAD
AB9A = 165 061 A5 3D LDA &3D
AB9C > 005 062 05 3E ORA &3E
AB9E ? 005 063 05 3F ORA &3F
ABA0 @ 005 064 05 40 ORA &40
ABA2   240 009 F0 09 BEQ 9 --> &ABAD
ABA4   032 200 130 20 C8 82 JSR &82C8 Reverse order complement of FWA
ABA7   032 013 131 20 0D 83 JSR &830D Add 1 to the FWA Mantissa value
ABAA   032 200 130 20 C8 82 JSR &82C8 Reverse order complement of FWA
ABAD   032 198 150 20 C6 96 JSR &96C6 Copy the FWA Mantissa to the IWA
ABB0 @ 169 064 A9 40 LDA#&40
ABB2 ` 096 60 RTS

Disassembly for the Add 1.0 to the FWA Mantissa value routine

830D 4 230 052 E6 34 INC &34
830F   208 012 D0 0C BNE 12 --> &831D
8311 3 230 051 E6 33 INC &33
8313   208 008 D0 08 BNE 8 --> &831D
8315 2 230 050 E6 32 INC &32
8317   208 004 D0 04 BNE 4 --> &831D
8319 1 230 049 E6 31 INC &31
831B   240 160 F0 A0 BEQ -96 --> &82BD
831D ` 096 60 RTS

 


 Back to 8BS
Or