8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

Pop Integer from the BASIC Stack (Zp)

Submitted by Steve Fewell

Routine: popi0
Name: Pop Integer from the BASIC Stack into the Zero page location pointed to by X
Starting Address: &BD08 (or BD06 to pop Integer to location &37-&3A)
Entry criteria: X contains the first byte of a 4-byte zero page memory location where the Integer from the Stack will be saved.
Exit: The 4-byte zero page memory location pointed to by X (i.e. ?X, ?X+1, ?X+2 and ?X+3) contains the most recent Integer number on the BASIC Stack. The Basic Stack Pointer is moved up.

Description:
If called at address &BD06, then set X to #&37 (this will the starting byte of the
4-byte location that the Integer value on the stack will be retrived to.

Loads the Zero page location pointed to by X with the 32-bit Integer pointed to by the BASIC Stack Pointer. Then move the Stack Pointer up 4 bytes so that is points to the previous item pushed onto the stack.

Disassembly for the Pop Integer from the BASIC Stack (Zp) routine

BD06 7 162 055 A2 37 LDX#&37
BD08   160 003 A0 03 LDY#&03
BD0A   177 004 B1 04 LDA (&04),Y
BD0C   149 003 95 03 STA &03,X
BD0E   136 88 DEY
BD0F   177 004 B1 04 LDA (&04),Y
BD11   149 002 95 02 STA &02,X
BD13   136 88 DEY
BD14   177 004 B1 04 LDA (&04),Y
BD16   149 001 95 01 STA &01,X
BD18   178 004 B2 04 LDA (&04)
BD1A   149 000 95 00 STA &00,X
BD1C   128 220 80 DC BRA -36 --> &BCFA   Move SP up 4 bytes

 


 Back to 8BS
Or