8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

B707 RETURN

Submitted by Steve Fewell

Description:

Call routine &9BA6 to check that the statement terminates correctly with a ':', '<cr>' or 'ELSE-token' character,
issuing 'Syntax error' if it doesn't.

If the GOSUB Level value (at location &25) is zero, then no outstanding GOSUB calls have been executed, so issue
'No GOSUB' error.

Decrement the &25 GOSUB Level value (so that its value is the return address offset) to reduce the number of active
GOSUBs.
Retrieve the return address value from the GOSUB return address Stack (The LSB of the return address is retrieved from
location &05CC + ?&25. The MSB of the return address is retrieved from location &05E6 + ?&25).
Store the return address value in the BASIC Text Pointer A (&0B-&0C).

Jump to &9005 to continue executing from the program position after the original GOSUB statement.


Disassembly for the RETURN routine

B707   032 166 155 20 A6 9B JSR &9BA6 Check end of Statement
B70A % 166 037 A6 25 LDX &25
B70C   240 242 F0 F2 BEQ -14 --> &B700 No GOSUB error
B70E % 198 037 C6 25 DEC &25
B710   188 203 005 BC CB 05 LDY &05CB,X
B713   189 229 005 BD E5 05 LDA &05E5,X
B716   132 011 84 0B STY &0B
B718   133 012 85 0C STA &0C
B71A L 076 005 144 4C 05 90 JMP &9005 Continue running program (execute next statement)

 


 Back to 8BS
Or