×   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

9489 AUTO

Submitted by Steve Fewell

Description:

Call routine &934D to read the Starting Line Number and Line increment parameters (if any were specified) as follows:
* Set the IWA to 10 (the default program starting Line Number)
* Call routine &9B1E to detokenise and extract the line number at BASIC text pointer A location and store it
    in the IWA. If no line number was found at BASIC text pointer A then the IWA will retain
    the default value of 10.
* Push the IWA value (the starting line number) to the BASIC stack
* Set the IWA to 10 (the default line number increment)
* If the next non-space character is not comma ',', then no line increment parameter has been specified, so call &9BB0
    to check that the statement is terminated correctly (with a ':', '<cr>' or 'ELSE-token'
    terminator character), [if not then a 'Syntax error' will be issued] and exit routine &934D.
* Otherwise, call routine &9B1E to detokenise and extract the Line number value from the BASIC Text pointer A
    location and store it in the IWA. The IWA now contains the specified Line increment value.
* If byte &2B of the IWA contains a non-zero value, then the increment value is more than 255, so issue error
    'Silly', as the line increment cannot be more than 255.
* If byte &2A (the LSB) of the IWA contains a zero value, then the increment value is zero, so issue error
    'Silly', as the line increment cannot be zero.
* Call &9BA6 to skip any space characters and check that the statement is terminated correctly (with a ':',
    '<cr>' or 'ELSE-token' terminator character), [if not then a 'Syntax error' will be
    issued] and exit routine &934D.
Store the step size (the line increment value) to the 6502 stack.

Retrieve the Starting Line number from the BASIC Stack (and store in the IWA).

[&BC26] Push the IWA Line Number value to the BASIC stack.
Call routine &A085 to display the Line Number (in the IWA) on the screen.

Call routine &BA74 to use OSWORD 0 to read the input line entered by the user.
If Escape is pressed during routine &BA74 then it will be detected and the 'Escape' error will be issued.
Retrieve the Line Number from the BASIC Stack (and store it in the IWA).

Call routine &8DE7 to tokenise the input line.
Set Y (pointer offset) to 0.
Call routine &BB08 to Add the tokenised input line (at the line number position denoted by the IWA value) in the
BASIC program (replacing any previous line of the same number).

Call routine &BBAC to initialise page &7 variables and the program non-resident variable pointer tables
(as a program line change means that all current variables should be lost - due to the Stack location changing).

Retrieve the Step size from the 6502 stack and push the value back to the 6502 stack.
Add the step size (line increment value) to the IWA value.
If the IWA &2B value is positive (i.e. less than &8000) then jump back to &9492 for entry of the next program
line; otherwise, the maximum line number (32767) has been exceeded, so jump to &8F83 to initialise variable space and
prompt for the user to enter another command line input.


Disassembly for the AUTO routine

9489 M 032 077 147 20 4D 93 JSR &934D Read Start line and line increment parameters
948C * 165 042 A5 2A LDA &2A
948E H 072 48 PHA
948F   032 230 188 20 E6 BC JSR &BCE6 Retrieve IWA value from the BASIC Stack [popi]
9492 & 032 038 188 20 26 BC JSR &BC26 Push IWA value to the BASIC Stack [pushi]
9495   032 133 160 20 85 A0 JSR &A085 Print Line Number on screen (width 5)
9498 t 032 116 186 20 74 BA JSR &BA74 Prompt for & get the User's input line (storing it in buffer &0700-&07FF)
949B   032 230 188 20 E6 BC JSR &BCE6 Retrieve IWA value from the BASIC Stack [popi]
949E   032 231 141 20 E7 8D JSR &8DE7 Tokenise the input line
94A1   160 000 A0 00 LDY#&00
94A3   032 008 187 20 08 BB JSR &BB08 Insert tokenised input line & insert it into the program
94A6   032 172 187 20 AC BB JSR &BBAC Initialise Page 7 & reset Variable pointers, etc...
94A9 h 104 68 PLA
94AA H 072 48 PHA
94AB   024 18 CLC
94AC e* 101 042 65 2A ADC &2A
94AE * 133 042 85 2A STA &2A
94B0   144 224 90 E0 BCC -32 --> &9492
94B2 + 230 043 E6 2B INC &2B
94B4   016 220 10 DC BPL -36 --> &9492
94B6 L 076 131 143 4C 83 8F JMP &8F83 Initialise & prompt for next command line

 


 Back to 8BS
Or