×   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

Push Integer to BASIC Stack

Submitted by Steve Fewell

Routine: pushi
Name: Push Integer to BASIC Stack
Starting Address: &BC26
Entry criteria: The IWA contains the 32-bit Integer to store on the BASIC Stack.
Exit: A copy of the IWA has been pushed to the Stack or a "No Room" error occurs if insufficient memory.

Description:
[If called from BC22 then the type of value will be tested and if the value is a String
or Float then the appropriate Push routine will be called; otherwise push Integer (as below)].


Subtract the required number of bytes (that is 4, as we are about to push an Integer number) from the Stack Pointer Low Byte. Leaving the result in A, call the routine to Check for Stack clash with Heap (which will decrement the high byte of the Stack Pointer, if a page boundary is crossed). Store the IWA on the Stack.

Disassembly for the Push Integer to BASIC Stack routine

BC22 - 240 045 F0 2D BEQ 45 --> &BC51 Push String to Stack
BC24 0 048 212 30 D4 BMI -44 --> &BBFA Push FWA to Stack
BC26   165 004 A5 04 LDA &04
BC28 8 056 38 SEC
BC29   233 004 E9 04 SBC#&04
BC2B   032 030 189 20 1E BD JSR &BD1E   Check Stack clash with Heap
BC2E   160 003 A0 03 LDY#&03
BC30 - 165 045 A5 2D LDA &2D
BC32   145 004 91 04 STA (&04),Y
BC34   136 88 DEY
BC35 , 165 044 A5 2C LDA &2C
BC37   145 004 91 04 STA (&04),Y
BC39   136 88 DEY
BC3A + 165 043 A5 2B LDA &2B
BC3C   145 004 91 04 STA (&04),Y
BC3E * 165 042 A5 2A LDA &2A
BC40   146 004 92 04 STA (&04)
BC42 ` 096 60 RTS

 


 Back to 8BS
Or