Submitted by Steve Fewell
Description:
Get the next non-space character.
If the character is ']' (end assembly character) then [&891A] Decrement A (to #&FF), set the OPT flag (location
&28) to A (#&FF) and jump to &900B to process the next BASIC language statement.
Call &9BBC to add Y (the BASIC Text pointer A offset) to the BASIC text pointer address (&0A-&0B) and reset
the PTR A offset to 1; and then check whether an ESCAPE keypress condition has occurred, and process it if it has.
Decrement the PTR A offset to 0.
Call routine &89EB to analyse, validate and assemble the current Assembly Statement (pointed to by BASIC text pointer A).
Decrement the PTR A offset so that BASIC text pointer A points to the Statement terminator character.
If bit 0 of the OPT flag (&28) is clear then no listing is required, so skip the listing routine and jump to &89AE.
[&8936] Produce a listing for the Assembled statement
The line listing will have the following layout:
EXEC B1 B2 B3 LABEL---- TEXT
Where:
* EXEC is the execution address (4 hex digits)
* B1 is the first 6502 Machine Code byte (usually the Instruction Opcode (unless an EQU-command is used)) (2 hex digits)
(or 2 spaces if the statement doesn't assemble into any actual Machine Code bytes).
* B2 is the second 6502 Machine Code byte (or 2 spaces if no second byte is present) (2 hex digits)
* B3 is the third 6502 Machine Code byte (or 2 spaces if no third byte is present) (2 hex digits)
* LABEL is any label (e.g. '.xxx') that preceeded the assembly statement (minimum of 9 characters wide - right padded with
spaces, but the LABEL field will be longer if the label name is more than 9 characters wide).
* TEXT is the actual unassembled text (e.g. 'LDA#SIN(2.345)') (this field has no width limit).
Note that the EQUS and EQUD assembly mnemonics may use more than 3 bytes, and as such, the bytes will be listed in groups
of 3, each group being displayed on a new line. The execution address will only be output on the first line. The label and
text will be shown on the last line.
Set location &3F to the value of COUNT (&1E) + 5. This stores what the position on the current output line would be
after the execution address (below) has been printed.
The (EXEC) Execution address (&37-&38) is output as follows:
* Set A to the Execution address MSB (from location &38) and call routine &BD6C to output the 2-digit value (in A).
* Set A to the Execution address LSB (from location &37) and call routine &BD8F to output the 2-digit value (in A)
followed by a space.
Set X to #&FC.
Set location &38 to the length of the Assembly Mnemonic (in number of bytes); as follows:
* Set &38 to the value of &39 (number of bytes used by Assembly Statement (which is usually 1, 2, 3, 4 or &FF))
* If &39 is a negaive value then a the Mnemonic was a String value ('EQUS'), so set the length (&38) to the SWA
length (&36).
891A | : | 058 | 3A | DEC A |
891B | ( | 133 040 | 85 28 | STA &28 |
891D | L | 076 011 144 | 4C 0B 90 | JMP &900B Process next BASIC program statement |
8920 | 032 224 142 | 20 E0 8E | JSR &8EE0 Get next non-space character pointed to by Ptr A | |
8923 | I] | 073 093 | 49 5D | EOR#&5D |
8925 | 240 243 | F0 F3 | BEQ -13 --> &891A | |
8927 | 032 188 155 | 20 BC 9B | JSR &9BBC Add Y to Text pointer A & then reset offset to 1) & check for Escape condition | |
892A | 198 010 | C6 0A | DEC &0A | |
892C | 032 235 137 | 20 EB 89 | JSR &89EB Assemble Assembly instruction/statement | |
892F | 198 010 | C6 0A | DEC &0A | |
8931 | ( | 165 040 | A5 28 | LDA &28 |
8933 | J | 074 | 4A | LSR A |
8934 | x | 144 120 | 90 78 | BCC 120 --> &89AE |
8936 | 165 030 | A5 1E | LDA &1E | |
8938 | i | 105 004 | 69 04 | ADC#&04 |
893A | ? | 133 063 | 85 3F | STA &3F |
893C | 8 | 165 056 | A5 38 | LDA &38 |
893E | l | 032 108 189 | 20 6C BD | JSR &BD6C Output the 2-digit Hexadecimal number stored in A |
8941 | 7 | 165 055 | A5 37 | LDA &37 |
8943 | 032 143 189 | 20 8F BD | JSR &BD8F Output the 2-digit Hexadecimal number stored in A followed by a space | |
8946 | 162 252 | A2 FC | LDX#&FC | |
8948 | 9 | 164 057 | A4 39 | LDY &39 |
894A | 016 002 | 10 02 | BPL 2 --> &894E | |
894C | 6 | 164 054 | A4 36 | LDY &36 |
894E | 8 | 132 056 | 84 38 | STY &38 |
8950 | 240 025 | F0 19 | BEQ 25 --> &896B | |
8952 | 160 000 | A0 00 | LDY#&00 | |
8954 | 232 | E8 | INX | |
8955 | 208 010 | D0 0A | BNE 10 --> &8961 | |
8957 | 032 146 186 | 20 92 BA | JSR &BA92 Output a new line | |
895A | ? | 166 063 | A6 3F | LDX &3F |
895C | 032 191 189 | 20 BF BD | JSR &BDBF Output X number of Spaces | |
895F | 162 253 | A2 FD | LDX#&FD | |
8961 | : | 177 058 | B1 3A | LDA (&3A),Y |
8963 | 032 143 189 | 20 8F BD | JSR &BD8F Output the 2-digit Hexadecimal number stored in A followed by a space | |
8966 | 200 | C8 | INY | |
8967 | 8 | 198 056 | C6 38 | DEC &38 |
8969 | 208 233 | D0 E9 | BNE -23 --> &8954 | |
896B | 138 | 8A | TXA | |
896C | 168 | A8 | TAY | |
896D | 200 | C8 | INY | |
896E | 240 007 | F0 07 | BEQ 7 --> &8977 | |
8970 | 162 003 | A2 03 | LDX#&03 | |
8972 | 032 191 189 | 20 BF BD | JSR &BDBF Output X number of Spaces | |
8975 | 128 246 | 80 F6 | BRA -10 --> &896D | |
8977 | 162 010 | A2 0A | LDX#&0A | |
8979 | 178 011 | B2 0B | LDA (&0B) | |
897B | . | 201 046 | C9 2E | CMP#&2E |
897D | 208 015 | D0 0F | BNE 15 --> &898E | |
897F | 7 | 032 055 189 | 20 37 BD | JSR &BD37 Output Character/Token on screen |
8982 | 202 | CA | DEX | |
8983 | 208 002 | D0 02 | BNE 2 --> &8987 | |
8985 | 162 001 | A2 01 | LDX#&01 | |
8987 | 200 | C8 | INY | |
8988 | 177 011 | B1 0B | LDA (&0B),Y | |
898A | N | 196 078 | C4 4E | CPY &4E |
898C | 208 241 | D0 F1 | BNE -15 --> &897F | |
898E | 032 191 189 | 20 BF BD | JSR &BDBF Output X number of Spaces | |
8991 | 136 | 88 | DEY | |
8992 | 200 | C8 | INY | |
8993 | 209 011 | D1 0B | CMP (&0B),Y | |
8995 | 240 251 | F0 FB | BEQ -5 --> &8992 | |
8997 | 177 011 | B1 0B | LDA (&0B),Y | |
8999 | : | 201 058 | C9 3A | CMP#&3A |
899B | 240 010 | F0 0A | BEQ 10 --> &89A7 | |
899D | 201 013 | C9 0D | CMP#&0D | |
899F | 240 010 | F0 0A | BEQ 10 --> &89AB | |
89A1 | 7 | 032 055 189 | 20 37 BD | JSR &BD37 Output Character/Token on screen |
89A4 | 200 | C8 | INY | |
89A5 | 128 240 | 80 F0 | BRA -16 --> &8997 | |
89A7 | 196 010 | C4 0A | CPY &0A | |
89A9 | 144 246 | 90 F6 | BCC -10 --> &89A1 | |
89AB | 032 146 186 | 20 92 BA | JSR &BA92 Output a new line | |
89AE | 164 010 | A4 0A | LDY &0A | |
89B0 | 136 | 88 | DEY | |
89B1 | 200 | C8 | INY | |
89B2 | 177 011 | B1 0B | LDA (&0B),Y | |
89B4 | : | 201 058 | C9 3A | CMP#&3A |
89B6 | 240 004 | F0 04 | BEQ 4 --> &89BC | |
89B8 | 201 013 | C9 0D | CMP#&0D | |
89BA | 208 245 | D0 F5 | BNE -11 --> &89B1 | |
89BC | 032 168 155 | 20 A8 9B | JSR &9BA8 Check end of Statement | |
89BF | 178 011 | B2 0B | LDA (&0B) | |
89C1 | : | 201 058 | C9 3A | CMP#&3A |
89C3 | 240 012 | F0 0C | BEQ 12 --> &89D1 | |
89C5 | 165 012 | A5 0C | LDA &0C | |
89C7 | 201 007 | C9 07 | CMP#&07 | |
89C9 | 208 003 | D0 03 | BNE 3 --> &89CE | |
89CB | L | 076 134 143 | 4C 86 8F | JMP &8F86 Read & execute command line input |
89CE | 032 222 155 | 20 DE 9B | JSR &9BDE Skip Program Line Number | |
89D1 | L | 076 032 137 | 4C 20 89 | JMP &8920 Assemble next assembly statement |