×   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

B181 Load Variable & Push its value and address details to the BASIC Stack

Submitted by Steve Fewell

Description:

If the Variable type (location &2C) is less than #&05 (i.e. an Integer value) then retain the Variable's parameter
block (&2A-&2C) by temporarily storing the IWA value in locations &37-&3A.

Call routine &B1A0 to load the variable's value into either the IWA, FWA or SWA (depending on the variable type).
Store the 6502 flags on the 6502 stack (to retain the variable type details).

Call routine &BC22 to push the variable's value to the BASIC stack.
Retrieve the 6502 flags from the 6502 stack.

If the 6502 flags indicate that the variable is not a String (Zero flag not set) or a Floating-Point value (negative flag
not set), then it must be an Integer, so call &AA80 to restore the variable parameter block (&2A-&2C),
i.e. the IWA, from the zero-page locations &37-&3A.

Call routine &BC26 to push the IWA value to the BASIC Stack - this ensures that the variable's address and type
details are stored immediately after the variable's value - this enables the values to be matched back to the original
variable's once the subroutine has been executed.


Disassembly for the Load Variable & Push its value and address details to the BASIC Stack routine

B181 , 164 044 A4 2C LDY &2C
B183   192 005 C0 05 CPY#&05
B185   176 005 B0 05 BCS 5 --> &B18C
B187 7 162 055 A2 37 LDX#&37
B189   032 198 189 20 C6 BD JSR &BDC6 Store Integer (IWA) to zero page location (specified by X)
B18C   032 160 177 20 A0 B1 JSR &B1A0 Load Variable's value
B18F   008 08 PHP
B190 " 032 034 188 20 22 BC JSR &BC22 Push Variable to BASIC Stack (calls correct routine depending on flags)
B193 ( 040 28 PLP
B194   240 007 F0 07 BEQ 7 --> &B19D
B196 0 048 005 30 05 BMI 5 --> &B19D
B198 7 162 055 A2 37 LDX#&37
B19A   032 128 170 20 80 AA JSR &AA80 Set the IWA to an Integer value at a zero-page location [izpin]
B19D L& 076 038 188 4C 26 BC JMP &BC26 Push IWA value to the BASIC Stack [pushi]

 


 Back to 8BS
Or