×   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

9B9A ENDPROC

Submitted by Steve Fewell

Description:

If the 6502 Stack pointer address is more than or equal to #&FC (i.e. Stack physical address &01FC), then a
subroutine is not currently active, as when a subroutine is called, 4 bytes are pushed to the 6502 stack [Those
bytes are as follows: 1) the Keyword token for either FN or PROC (1 byte); 2) the current program location and offset
(&0A-&0C) (3 bytes)], so issue 'No PROC' error.

If the first byte pushed to the 6502 stack (at address &01FF) is not the PROC-Keyword token (#&F2), then the most
recent subroutine called is not a PROCedure (it must be a FuNction instead), so issue 'No PROC' error.

Otherwise, we have correctly found the end of the PROCedure definition, so continue to routine &9BA6 to check that
the ENDPROC statement is valid (and is followed by either a carriage return, ELSE-token or ':' character) and to return
(RTS) to the code within the PROC-Statement routine (at address &B08C) to process the return from the subroutine call
and handle the transfer of program control back to the statement following the procedure call (PROC) statement.


Disassembly for the ENDPROC routine

9B9A   186 BA TSX
9B9B   224 252 E0 FC CPX#&FC
9B9D   176 216 B0 D8 BCS -40 --> &9B77 'No PROC' error
9B9F   173 255 001 AD FF 01 LDA &01FF
9BA2   201 242 C9 F2 CMP#&F2
9BA4   208 209 D0 D1 BNE -47 --> &9B77 'No PROC' error
9BA6   ...Check for End of Statement...

 


 Back to 8BS
Or