8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

B94D RESTORE

Submitted by Steve Fewell

Description:

Set locations &3D-&3E to PAGE (The Program Start address) [Where the LSB (&3D) is #&00].
This defaults the RESTORE Line Number to be PAGE - This &3D-&3E value will be overwritten by the Line Number
specified after the RESTORE Keyword (if a Line Number is specified).

Call &8EE0 to get the next non-space character pointed to by BASIC Text Pointer A.
Decrement the BASIC Text Pointer A offset [&0A] so that Text Pointer A points to the non-space character.

If the next non-space character is not the end of Statement (I.e. ':', '<cr>', 'ELSE-token') then we need to read
the Line Number to RESTORE from, by:
* [&B964] Calling routine &B82A to get the Line Number after the RESTORE keyword, Issue 'No such
    line' error if the Line doesn't exist and set &3D-&3E to the start address of the specified
    Program Line.
[&B967] Call routine &9BA6 to check that the statement terminates correctly with a ':', '<cr>'
or 'ELSE-token' character, issuing 'Syntax error' if it doesn't.

Set the DATA Pointer (&1C-&1D) to the DATA start address specified (the address stored in &3D-&3E,
i.e. either PAGE, or the start address of the Program Line specified).

Jump to &9005 to continue running the program by executing the next program statement.


Disassembly for the RESTORE routine

B94D d= 100 061 64 3D STZ &3D
B94F   164 024 A4 18 LDY &18
B951 > 132 062 84 3E STY &3E
B953   032 224 142 20 E0 8E JSR &8EE0 Get next non-space character pointed to by Ptr A
B956   198 010 C6 0A DEC &0A
B958 : 201 058 C9 3A CMP#&3A
B95A   240 011 F0 0B BEQ 11 --> &B967
B95C   201 013 C9 0D CMP#&0D
B95E   240 007 F0 07 BEQ 7 --> &B967
B960   201 139 C9 8B CMP#&8B
B962   240 003 F0 03 BEQ 3 --> &B967
B964 * 032 042 184 20 2A B8 JSR &B82A Get Line Number & find Program Address of the Line Number
B967   032 166 155 20 A6 9B JSR &9BA6 Check end of Statement
B96A = 165 061 A5 3D LDA &3D
B96C   133 028 85 1C STA &1C
B96E > 165 062 A5 3E LDA &3E
B970   133 029 85 1D STA &1D
B972 L 076 005 144 4C 05 90 JMP &9005 Continue running program (execute next statement)

 


 Back to 8BS
Or