×   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

BBFA Push FWA to Stack

Submitted by Steve Fewell

Routine:pushFWA
Name: Push FWA to Stack
Starting Address: &BBFA
Entry criteria: The FWA contains a floating-point value.

Description:

Check whether the Stack has room for 5 bytes. If no space, then generate 'No Room' error;
otherwise, update the Stack Pointer to point to the next free location on the Stack.

Store the FWA Exponent byte on the Stack (1st Byte).
Load FWA Sign, EOR with FWA Mantissa byte 1, AND with &80 (to restore the top bit)
and EOR with the FWA Mantissa byte 1 again to set the Mantissa byte 1 value. Store result on
stack (2nd byte). This is done to pack the FWA Mantissa, as the FWA is pushed to the Stack
in its 5-byte packed variable format to save on Stack space.
Store the FWA Mantissa Byte 2 on the stack (3rd byte of Stack Value).
Store the FWA Mantissa Byte 3 on the stack (4th byte of Stack Value).
Store the FWA Mantissa Byte 4 on the stack (5th byte of Stack Value).
all done, so return.


Disassembly for the Push FWA to Stack routine

BBFA   165 004 A5 04 LDA &04
BBFC 8 056 38 SEC
BBFD   233 005 E9 05 SBC#&05
BBFF   032 030 189 20 1E BD JSR &BD1E Check for Stack Clash with Heap
BC02 0 165 048 A5 30 LDA &30
BC04   146 004 92 04 STA (&04)
BC06   160 001 A0 01 LDY#&01
BC08 . 165 046 A5 2E LDA &2E
BC0A E1 069 049 45 31 EOR &31
BC0C ) 041 128 29 80 AND#&80
BC0E E1 069 049 45 31 EOR &31
BC10   145 004 91 04 STA (&04),Y
BC12   200 C8 INY
BC13 2 165 050 A5 32 LDA &32
BC15   145 004 91 04 STA (&04),Y
BC17   200 C8 INY
BC18 3 165 051 A5 33 LDA &33
BC1A   145 004 91 04 STA (&04),Y
BC1C   200 C8 INY
BC1D 4 165 052 A5 34 LDA &34
BC1F   145 004 91 04 STA (&04),Y
BC21 ` 096 60 RTS

 


 Back to 8BS
Or