bdff
Submitted by Steve Fewell
Description:
Get the next non-space character.
If the character is ']' (end assembly character) then [&89D7] 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 &9C80 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 &8AA8 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 &8A6B.
[&89F3] 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).
89D7 | : | 58 | 3A | DEC A |
89D8 | ( | 133 040 | 85 28 | STA &28 |
89DA | L | 076 208 144 | 4C D0 90 | JMP &90D0 Process next BASIC program statement |
89DD | 032 157 143 | 20 9D 8F | JSR &8F9D Get next non-space character pointed to by Ptr A | |
89E0 | I] | 073 093 | 49 5D | EOR#&5D |
89E2 | 240 243 | F0 F3 | BEQ -13 --> &89D7 | |
89E4 | 032 128 156 | 20 80 9C | JSR &9C80 Add Y to Text pointer A & then reset offset to 1) & check for Escape condition | |
89E7 | 198 010 | C6 0A | DEC &0A | |
89E9 | 032 168 138 | 20 A8 8A | JSR &8AA8 Assemble Assembly instruction/statement | |
89EC | 198 010 | C6 0A | DEC &0A | |
89EE | ( | 165 040 | A5 28 | LDA &28 |
89F0 | J | 74 | 4A | LSR A |
89F1 | x | 144 120 | 90 78 | BCC 120 --> &8A6B |
89F3 | 165 030 | A5 1E | LDA &1E | |
89F5 | i | 105 004 | 69 04 | ADC#&04 |
89F7 | ? | 133 063 | 85 3F | STA &3F |
89F9 | 8 | 165 056 | A5 38 | LDA &38 |
89FB | 032 172 189 | 20 AC BD | JSR &BDAC Output the 2-digit Hexadecimal number stored in A | |
89FE | 7 | 165 055 | A5 37 | LDA &37 |
8A00 | 032 207 189 | 20 CF BD | JSR &BDCF Output the 2-digit Hexadecimal number stored in A followed by a space | |
8A03 | 162 252 | A2 FC | LDX#&FC | |
8A05 | 9 | 164 057 | A4 39 | LDY &39 |
8A07 | 016 002 | 10 02 | BPL 2 --> &8A0B | |
8A09 | 6 | 164 054 | A4 36 | LDY &36 |
8A0B | 8 | 132 056 | 84 38 | STY &38 |
8A0D | 240 025 | F0 19 | BEQ 25 --> &8A28 | |
8A0F | 160 000 | A0 00 | LDY#&00 | |
8A11 | 232 | E8 | INX | |
8A12 | 208 010 | D0 0A | BNE 10 --> &8A1E | |
8A14 | 032 194 186 | 20 C2 BA | JSR &BAC2 Output a new line | |
8A17 | ? | 166 063 | A6 3F | LDX &3F |
8A19 | 032 255 189 | 20 FF BD | JSR &BDFF Output X number of Spaces | |
8A1C | 162 253 | A2 FD | LDX#&FD | |
8A1E | : | 177 058 | B1 3A | LDA (&3A),Y |
8A20 | 032 207 189 | 20 CF BD | JSR &BDCF Output the 2-digit Hexadecimal number stored in A followed by a space | |
8A23 | 200 | C8 | INY | |
8A24 | 8 | 198 056 | C6 38 | DEC &38 |
8A26 | 208 233 | D0 E9 | BNE -23 --> &8A11 | |
8A28 | 138 | 8A | TXA | |
8A29 | 168 | A8 | TAY | |
8A2A | 200 | C8 | INY | |
8A2B | 240 007 | F0 07 | BEQ 7 --> &8A34 | |
8A2D | 162 003 | A2 03 | LDX#&03 | |
8A2F | 032 255 189 | 20 FF BD | JSR &BDFF Output X number of Spaces | |
8A32 | 128 246 | 80 F6 | BRA -10 --> &8A2A | |
8A34 | 162 010 | A2 0A | LDX#&0A | |
8A36 | 178 011 | B2 0B | LDA (&0B) | |
8A38 | . | 201 046 | C9 2E | CMP#&2E |
8A3A | 208 015 | D0 0F | BNE 15 --> &8A4B | |
8A3C | w | 032 119 189 | 20 77 BD | JSR &BD77 Output Character/Token on screen |
8A3F | 202 | CA | DEX | |
8A40 | 208 002 | D0 02 | BNE 2 --> &8A44 | |
8A42 | 162 001 | A2 01 | LDX#&01 | |
8A44 | 200 | C8 | INY | |
8A45 | 177 011 | B1 0B | LDA (&0B),Y | |
8A47 | N | 196 078 | C4 4E | CPY &4E |
8A49 | 208 241 | D0 F1 | BNE -15 --> &8A3C | |
8A4B | 032 255 189 | 20 FF BD | JSR &BDFF Output X number of Spaces | |
8A4E | 136 | 88 | DEY | |
8A4F | 200 | C8 | INY | |
8A50 | 209 011 | D1 0B | CMP (&0B),Y | |
8A52 | 240 251 | F0 FB | BEQ -5 --> &8A4F | |
8A54 | 177 011 | B1 0B | LDA (&0B),Y | |
8A56 | : | 201 058 | C9 3A | CMP#&3A |
8A58 | 240 010 | F0 0A | BEQ 10 --> &8A64 | |
8A5A | 201 013 | C9 0D | CMP#&0D | |
8A5C | 240 010 | F0 0A | BEQ 10 --> &8A68 | |
8A5E | w | 032 119 189 | 20 77 BD | JSR &BD77 Output Character/Token on screen |
8A61 | 200 | C8 | INY | |
8A62 | 128 240 | 80 F0 | BRA -16 --> &8A54 | |
8A64 | 196 010 | C4 0A | CPY &0A | |
8A66 | 144 246 | 90 F6 | BCC -10 --> &8A5E | |
8A68 | 032 194 186 | 20 C2 BA | JSR &BAC2 Output a new line | |
8A6B | 164 010 | A4 0A | LDY &0A | |
8A6D | 136 | 88 | DEY | |
8A6E | 200 | C8 | INY | |
8A6F | 177 011 | B1 0B | LDA (&0B),Y | |
8A71 | : | 201 058 | C9 3A | CMP#&3A |
8A73 | 240 004 | F0 04 | BEQ 4 --> &8A79 | |
8A75 | 201 013 | C9 0D | CMP#&0D | |
8A77 | 208 245 | D0 F5 | BNE -11 --> &8A6E | |
8A79 | l | 032 108 156 | 20 6C 9C | JSR &9C6C Check end of Statement |
8A7C | 178 011 | B2 0B | LDA (&0B) | |
8A7E | : | 201 058 | C9 3A | CMP#&3A |
8A80 | 240 012 | F0 0C | BEQ 12 --> &8A8E | |
8A82 | 165 012 | A5 0C | LDA &0C | |
8A84 | 201 007 | C9 07 | CMP#&07 | |
8A86 | 208 003 | D0 03 | BNE 3 --> &8A8B | |
8A88 | LK | 076 075 144 | 4C 4B 90 | JMP &904B Read & execute command line input |
8A8B | 032 162 156 | 20 A2 9C | JSR &9CA2 Skip Program Line Number | |
8A8E | L | 076 221 137 | 4C DD 89 | JMP &89DD Assemble next assembly statement |