8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

8F2D Startup initialisations (part 2)

Submitted by Steve Fewell

Description:

Set the IWA to value #&F2.
Call &BEE2 to read the contents of memory location &000000F2. This value is the LSB value of the Operating Systems
Text pointer. Store this value in X.
Call &BEE2 to read the contents of memory location &000000F3. This value is the MSB value of the Operating Systems
Text pointer. Store the pointer's address in the IWA (&2A = X (contents of &F2); &2B = contents of &F3).
The *EDIT command uses the Operating system's text pointer (&F2-&F3) to point to the 2-byte code '@' followed by '<cr>'
and pointer (&00-&01) to store the address of the edited BASIC program (in ASCII text).

Set X to #&14 (the number of attempts to try finding the byte value that we are expecting).
[&8F3F] Decrement X. If X has reached zero then [&8F80] create a NEW empty program and jump to the command line
prompt as startup initialisation is now complete.

Call &BEE2 to read the byte at the memory location pointed to by the address in the IWA, and then increment the IWA
address.
If the byte is '<cr>' then no program text found at the IWA location, so [&8F80] create a NEW empty program and
jump to the command line prompt as startup initialisation is now complete.

If the byte is not #&40 ('@'), then jump back to &8F3F to check the next byte at the IWA address.

Otherwise, we have found byte #&40 ('@'), which indicates that BASIC has been called from *EDIT (or possibly another
application).
[&8F4D] Call &BEE2 to read the byte at the memory location pointed to by the address in the IWA, and then increment
the IWA address. This is the next byte after the '@' character.

If the byte is not '<cr>' then no program text found at the IWA location, so [&8F80] create a NEW empty program
and jump to the command line prompt as startup initialisation is now complete.

Now we have found the byte sequence #&40 ('@') followed by #&0D ('<cr>').
Call &BEFE (NEW) to create an empty program that consists of the following bytes:
* #&0D ('<cr>') - to indicate the start of the program
* #&FF - to indicate the end of the program

[&8F57] Set BASIC Text pointer A (&0B-&0C) value to &0700.
Set Y (pointer offset) to 0.
[&8F5F] Load the next character pointed to by pointer (&00-&01). *EDIT places the start address of the BASIC
program (in ASCII text) in locations (&00-&01).

If the character is &00 (or 'null', ASCII 0) then this indicates the end of the BASIC program, so jump to &8F83
to initialise variable workspace (etc...) and prompt for the command line entry as the startup initialisations and
tokenisation of the *EDIT program are now complete.

Otherwise store the character in the command line buffer (&0700, pointed to by (&0B, &0C) at offset Y and
increment Y to next next character in the command line buffer).
If Y has now rolled over from &FF to 0, then the BASIC program ASCII text line is too long, and cannot have been
created from the *EDIT application, so [&8F80] create a new empty program and jump to &8F83 to initialise
variable workspace (etc...) and prompt for the command line entry as the startup initialisations are now complete.
Note: This wipes out the entire program (all lines entered so far), as they were not the *EDIT ASCII text program lines
(that we had thought they were).

Increment the (&00-&01) pointer (to the next character on the program line).
If the character that we have just stored at the end of the command line buffer is not '<cr>', then we haven't reached
the end of the line yet, so jump back to &8F5F to copy the next character to the command line buffer.

Otherwise, the end of the libne has been reached, so we now need to tokenise the line and insert it into the BASIC program
as follows:
* Check whether the *EDIT program text pointer MSB (&01) is more than or equal to the HIMEM MSB address (&07).
If it is then do not insert the current line into the program, and do not insert any further lines from the *EDIT text
pointer. Instead, jump to &8F83 to initialise variable workspace (etc...) and prompt for the command line entry as
the startup initialisations (and tokenisation of the *EDIT program) tasks are now complete.
* Call routine &BAEB to tokenise the ASCII program line text contained within the command line buffer (&0700)
and insert the tokenised program line into the program (at the line number specified at the start of the line text).
* Jump back to &8F57 to copy and tokenise the next *EDIT program line.


Disassembly for the Startup initialisations (part 2) routine

8F2D   169 242 A9 F2 LDA#&F2
8F2F   032 024 174 20 18 AE JSR &AE18 Set IWA to the 8-bit value in A
8F32   032 226 190 20 E2 BE JSR &BEE2 Read byte from I/O processor (at the address in IWA) & increment IWA
8F35   170 AA TAX
8F36   032 226 190 20 E2 BE JSR &BEE2 Read byte from I/O processor (at the address in IWA) & increment IWA
8F39 + 133 043 85 2B STA &2B
8F3B * 134 042 86 2A STX &2A
8F3D   162 020 A2 14 LDX#&14
8F3F   202 CA DEX
8F40 > 240 062 F0 3E BEQ 62 --> &8F80 NEW (create null program)
8F42   032 226 190 20 E2 BE JSR &BEE2 Read byte from I/O processor (at the address in IWA) & increment IWA
8F45   201 013 C9 0D CMP#&0D
8F47 7 240 055 F0 37 BEQ 55 --> &8F80 NEW (create null program)
8F49 @ 201 064 C9 40 CMP#&40
8F4B   208 242 D0 F2 BNE -14 --> &8F3F
8F4D   032 226 190 20 E2 BE JSR &BEE2 Read byte from I/O processor (at the address in IWA) & increment IWA
8F50   201 013 C9 0D CMP#&0D
8F52 , 208 044 D0 2C BNE 44 --> &8F80 NEW (create null program)
8F54   032 254 190 20 FE BE JSR &BEFE NEW - reset the current program to an empty program
8F57   160 000 A0 00 LDY#&00
8F59 d 100 011 64 0B STZ &0B
8F5B   169 007 A9 07 LDA#&07
8F5D   133 012 85 0C STA &0C
8F5F   178 000 B2 00 LDA (&00)
8F61   240 032 F0 20 BEQ 32 --> &8F83 Initialise & prompt for (and execute) command line input
8F63   145 011 91 0B STA (&0B),Y
8F65   200 C8 INY
8F66   240 024 F0 18 BEQ 24 --> &8F80 NEW (create null program)
8F68   230 000 E6 00 INC &00
8F6A   208 002 D0 02 BNE 2 --> &8F6E
8F6C   230 001 E6 01 INC &01
8F6E   201 013 C9 0D CMP#&0D
8F70   208 237 D0 ED BNE -19 --> &8F5F
8F72   165 001 A5 01 LDA &01
8F74   197 007 C5 07 CMP &07
8F76   176 011 B0 0B BCS 11 --> &8F83 Prompt for command line and execute the entered command(s)
8F78   032 235 186 20 EB BA JSR &BAEB Tokenise Line of program text and Insert Line into Program
8F7B   128 218 80 DA BRA -38 --> &8F57

 


 Back to 8BS
Or