0001 ;;; 0002 ;;; 6301/6303 assembler for MCFS 0003 ;;; By: Daniel Tufvesson 2017-2022 0004 ;;; 0005 d003 sys_return: equ $d003 0006 d006 sys_call: equ $d006 0007 7fe5 console_status: equ $7fe5 0008 7fe8 console_output: equ $7fe8 0009 0010 a100 org $a100 0011 ;;; Go to first argument (file name) 0012 * ldx #tstargs ; DEBUG: static file name 0013 a100 ff b4 55 stx args 0014 a103 bd a8 1a jsr str_skp_next 0015 a106 ff b4 57 stx args_file ; save pointer to file name argument 0016 a109 a6 00 ldaa ,x ; check for empty arg string 0017 a10b 26 03 bne *+5 0018 a10d 7e a2 75 jmp program_help 0019 a110 bd a9 e5 jsr parse_args 0020 0021 ;;; 0022 ;;; Pass ONE 0023 ;;; 0024 a113 7f b4 4c clr pass2_flag ; this is not pass 2 0025 a116 ce 00 00 ldx #0 0026 a119 ff b5 67 stx program_counter 0027 a11c ff b4 4d stx errors 0028 a11f fe b5 63 ldx label_table 0029 a122 6f 00 clr ,x 0030 a124 ff b5 65 stx label_table_position 0031 pass1_load_file: 0032 a127 fe b4 57 ldx args_file ; open file 0033 a12a bd aa 2c jsr fopen 0034 a12d 27 03 beq *+5 0035 a12f 7e a2 72 jmp exit_program 0036 a132 ce 00 01 ldx #1 0037 a135 ff b5 61 stx line_counter 0038 pass1_loop: 0039 a138 7f b5 71 clr assembly_length 0040 a13b 7f b5 69 clr program_counter_bump 0041 a13e 7f b5 6a clr program_counter_bump+1 0042 a141 bd aa b6 jsr fgetline ; read line from file 0043 a144 24 03 bcc *+5 0044 a146 7e a1 a3 jmp pass1_read_eof ; end of file? 0045 a149 bd a5 f1 jsr segment_line ; identify line segments (label,opcode,operand) 0046 ;;; Check if line has a valid label 0047 a14c 7d b5 5b tst line_pointer_label 0048 a14f 27 14 beq pass1_no_label ; there is no label 0049 a151 fe b5 5b ldx line_pointer_label 0050 a154 bd a6 63 jsr find_label ; check if label already is registered 0051 a157 25 06 bcs pass1_label_ok 0052 a159 bd a2 8e jsr report_duplicate_label 0053 a15c 7e a2 72 jmp exit_program 0054 pass1_label_ok: 0055 a15f fe b5 5b ldx line_pointer_label 0056 a162 bd a6 2c jsr read_label 0057 pass1_no_label: 0058 ;;; Check if line has a valid op-code 0059 a165 7d b5 5d tst line_pointer_opcode 0060 a168 27 1c beq pass1_line_done ; there is no op-code 0061 a16a fe b5 5d ldx line_pointer_opcode 0062 a16d bd a6 b6 jsr read_opcode 0063 a170 bd a6 ff jsr lookup_opcode 0064 a173 24 06 bcc pass1_opcode_ok 0065 ;;; Handle invalid op-code 0066 a175 bd a2 7e jsr report_invalid_opcode 0067 a178 7e a2 72 jmp exit_program 0068 ;;; Assemble op-code and operand 0069 pass1_opcode_ok: 0070 a17b bd a3 c8 jsr assemble ; assemble line 0071 a17e 24 06 bcc pass1_line_done 0072 ;;; Handle invalid op-code 0073 a180 bd a2 7e jsr report_invalid_opcode 0074 a183 7e a2 72 jmp exit_program 0075 ;;; Print input line line and loop 0076 pass1_line_done: 0077 * jsr print_current_line ; uncomment to print pass 1 listing 0078 a186 fe b5 67 ldx program_counter ; adjust program counter according to the generated assembly length 0079 a189 f6 b5 71 ldab assembly_length 0080 a18c 3a abx 0081 a18d ff b5 67 stx program_counter 0082 a190 fc b5 67 ldd program_counter 0083 a193 f3 b5 69 addd program_counter_bump 0084 a196 fd b5 67 std program_counter 0085 a199 fe b5 61 ldx line_counter ; increase line counter 0086 a19c 08 inx 0087 a19d ff b5 61 stx line_counter 0088 a1a0 7e a1 38 jmp pass1_loop 0089 pass1_read_eof: 0090 a1a3 81 00 cmpa #0 0091 a1a5 27 06 beq pass1_end ; EOF 0092 a1a7 ce b1 97 ldx #txt_read_error 0093 a1aa bd a7 8a jsr str_print 0094 pass1_end: 0095 * jsr print_labels ; uncomment to print pass 1 lable table 0096 ;;; Check if there are more files to read 0097 a1ad fe b4 57 ldx args_file 0098 a1b0 bd a8 1a jsr str_skp_next 0099 a1b3 a6 00 ldaa ,x 0100 a1b5 27 0a beq pass1_complete 0101 a1b7 81 2d cmpa #'- 0102 a1b9 27 06 beq pass1_complete 0103 a1bb ff b4 57 stx args_file 0104 a1be 7e a1 27 jmp pass1_load_file 0105 pass1_complete: 0106 0107 ;;; 0108 ;;; Pass TWO 0109 ;;; 0110 a1c1 fe b4 55 ldx args 0111 a1c4 bd a8 1a jsr str_skp_next 0112 a1c7 ff b4 57 stx args_file ; save pointer to file name argument 0113 a1ca 7c b4 4c inc pass2_flag ; this is pass 2 0114 a1cd ce 00 00 ldx #0 0115 a1d0 ff b5 67 stx program_counter 0116 a1d3 ff b4 4d stx errors 0117 pass2_load_file: 0118 a1d6 fe b4 57 ldx args_file ; open file 0119 a1d9 bd aa 2c jsr fopen 0120 a1dc 27 03 beq *+5 0121 a1de 7e a2 72 jmp exit_program 0122 a1e1 ce 00 01 ldx #1 0123 a1e4 ff b5 61 stx line_counter 0124 pass2_loop: 0125 a1e7 7f b5 71 clr assembly_length 0126 a1ea 7f b5 69 clr program_counter_bump 0127 a1ed 7f b5 6a clr program_counter_bump+1 0128 a1f0 bd aa b6 jsr fgetline ; read line from file 0129 a1f3 24 03 bcc *+5 0130 a1f5 7e a2 49 jmp pass2_read_eof ; end of file? 0131 a1f8 bd a5 f1 jsr segment_line ; identify line segments (label,opcode,operand) 0132 ;;; Check if line has a valid op-code 0133 a1fb 7d b5 5d tst line_pointer_opcode 0134 a1fe 27 1c beq pass2_line_done ; there is no op-code 0135 a200 fe b5 5d ldx line_pointer_opcode 0136 a203 bd a6 b6 jsr read_opcode 0137 a206 bd a6 ff jsr lookup_opcode 0138 a209 24 06 bcc pass2_opcode_ok 0139 ;;; Handle invalid op-code 0140 a20b bd a2 7e jsr report_invalid_opcode 0141 a20e 7e a2 72 jmp exit_program 0142 ;;; Assemble op-code and operand 0143 pass2_opcode_ok: 0144 a211 bd a3 c8 jsr assemble ; assemble line 0145 a214 24 06 bcc pass2_line_done 0146 ;;; Handle invalid op-code 0147 a216 bd a2 7e jsr report_invalid_opcode 0148 a219 7e a2 72 jmp exit_program 0149 ;;; Print input line line and loop 0150 pass2_line_done: 0151 a21c 7d b5 71 tst assembly_length ; any assembly bytes generated? 0152 a21f 27 03 beq *+5 0153 a221 bd a9 ca jsr store_line_bytes ; save assembled bytes 0154 a224 7d b4 4f tst listing_flag 0155 a227 27 03 beq *+5 0156 a229 bd a3 10 jsr print_current_line ; print listing line 0157 a22c fe b5 67 ldx program_counter ; adjust program counter according to the generated assembly length 0158 a22f f6 b5 71 ldab assembly_length 0159 a232 3a abx 0160 a233 ff b5 67 stx program_counter 0161 a236 fc b5 67 ldd program_counter 0162 a239 f3 b5 69 addd program_counter_bump 0163 a23c fd b5 67 std program_counter 0164 a23f fe b5 61 ldx line_counter ; increase line counter 0165 a242 08 inx 0166 a243 ff b5 61 stx line_counter 0167 a246 7e a1 e7 jmp pass2_loop 0168 pass2_read_eof: 0169 a249 81 00 cmpa #0 0170 a24b 27 06 beq pass2_end ; EOF 0171 a24d ce b1 97 ldx #txt_read_error 0172 a250 bd a7 8a jsr str_print 0173 pass2_end: 0174 ;;; Check if there are more files to read 0175 a253 fe b4 57 ldx args_file 0176 a256 bd a8 1a jsr str_skp_next 0177 a259 a6 00 ldaa ,x 0178 a25b 27 0a beq pass2_complete 0179 a25d 81 2d cmpa #'- 0180 a25f 27 06 beq pass2_complete 0181 a261 ff b4 57 stx args_file 0182 a264 7e a1 d6 jmp pass2_load_file 0183 pass2_complete: 0184 a267 7d b4 4f tst listing_flag 0185 a26a 27 03 beq *+5 0186 a26c bd a6 99 jsr print_labels ; print lable table 0187 a26f bd a2 de jsr report_errors ; print error count 0188 ;;; Program ends here 0189 exit_program: 0190 a272 7e d0 03 jmp sys_return 0191 0192 ;;; 0193 ;;; Print program help 0194 ;;; 0195 program_help: 0196 a275 ce b0 5b ldx #txt_help 0197 a278 bd a7 8a jsr str_print 0198 a27b 7e a2 72 jmp exit_program 0199 0200 ;;; 0201 ;;; Errors 0202 ;;; 0203 report_invalid_opcode: 0204 a27e 7d b4 50 tst noerr_flag 0205 a281 26 53 bne report_end 0206 a283 bd a2 fd jsr report_file_line 0207 a286 ce b1 c0 ldx #txt_invalid_opcode 0208 a289 bd a7 8a jsr str_print 0209 a28c 20 48 bra report_end 0210 report_duplicate_label: 0211 a28e 7d b4 50 tst noerr_flag 0212 a291 26 43 bne report_end 0213 a293 bd a2 fd jsr report_file_line 0214 a296 ce b1 d2 ldx #txt_duplicate_label 0215 a299 bd a7 8a jsr str_print 0216 a29c 20 38 bra report_end 0217 report_label_not_found: 0218 a29e 7d b4 50 tst noerr_flag 0219 a2a1 26 33 bne report_end 0220 a2a3 bd a2 fd jsr report_file_line 0221 a2a6 ce b1 e4 ldx #txt_label_not_found 0222 a2a9 bd a7 8a jsr str_print 0223 a2ac 20 28 bra report_end 0224 report_invalid_expr: 0225 a2ae 7d b4 4c tst pass2_flag 0226 a2b1 27 23 beq report_end 0227 a2b3 7d b4 50 tst noerr_flag 0228 a2b6 26 1e bne report_end 0229 a2b8 bd a2 fd jsr report_file_line 0230 a2bb ce b1 f6 ldx #txt_invalid_expression 0231 a2be bd a7 8a jsr str_print 0232 a2c1 20 13 bra report_end 0233 report_branch_range: 0234 a2c3 7d b4 4c tst pass2_flag 0235 a2c6 27 0e beq report_end 0236 a2c8 7d b4 50 tst noerr_flag 0237 a2cb 26 09 bne report_end 0238 a2cd bd a2 fd jsr report_file_line 0239 a2d0 ce b2 0b ldx #txt_branch_range 0240 a2d3 bd a7 8a jsr str_print 0241 report_end: 0242 a2d6 fe b4 4d ldx errors 0243 a2d9 08 inx 0244 a2da ff b4 4d stx errors 0245 a2dd 39 rts 0246 report_errors: 0247 a2de fe b4 4d ldx errors 0248 a2e1 27 13 beq report_no_errors 0249 a2e3 ce b1 6c ldx #txt_errors 0250 a2e6 bd a7 8a jsr str_print 0251 a2e9 ce b4 4d ldx #errors 0252 a2ec bd a7 ca jsr outdec 0253 a2ef bd a7 95 jsr pcrlf 0254 a2f2 bd a7 95 jsr pcrlf 0255 a2f5 39 rts 0256 report_no_errors: 0257 a2f6 ce b1 77 ldx #txt_no_errors 0258 a2f9 bd a7 8a jsr str_print 0259 a2fc 39 rts 0260 report_file_line: 0261 a2fd fe b4 57 ldx args_file 0262 a300 bd a7 78 jsr str_print_word 0263 * ldaa #': 0264 * jsr console_output 0265 a303 bd a7 c2 jsr outs 0266 a306 ce b5 61 ldx #line_counter 0267 a309 bd a7 ca jsr outdec 0268 a30c bd a7 c2 jsr outs 0269 a30f 39 rts 0270 0271 ;;; 0272 ;;; Print current line 0273 ;;; 0274 print_current_line: 0275 a310 ce b5 61 ldx #line_counter 0276 a313 bd a7 ca jsr outdec 0277 a316 bd a7 c2 jsr outs 0278 a319 ce b5 67 ldx #program_counter 0279 a31c bd a7 be jsr out4hs 0280 a31f 7f b4 3f clr temp 0281 a322 bd a3 64 jsr print_assembly ; print resulting assembly bytes 0282 a325 bd a7 c2 jsr outs 0283 a328 bd a7 c2 jsr outs 0284 a32b ce b4 59 ldx #line_buffer 0285 a32e bd a7 8a jsr str_print 0286 a331 bd a7 95 jsr pcrlf 0287 a334 b6 b5 71 ldaa assembly_length ; assembly bytes left to print? 0288 a337 b1 b4 3f cmpa temp 0289 a33a 27 27 beq print_current_line_done 0290 a33c bd a7 c2 jsr outs 0291 a33f bd a7 c2 jsr outs 0292 a342 bd a7 c2 jsr outs 0293 a345 bd a7 c2 jsr outs 0294 a348 bd a7 c2 jsr outs 0295 a34b bd a7 c2 jsr outs 0296 a34e bd a7 c2 jsr outs 0297 a351 bd a7 c2 jsr outs 0298 a354 bd a7 c2 jsr outs 0299 a357 bd a7 c2 jsr outs 0300 a35a bd a7 c2 jsr outs 0301 a35d bd a3 8b jsr print_remaining_ass 0302 a360 bd a7 95 jsr pcrlf 0303 print_current_line_done: 0304 a363 39 rts 0305 ;;; Print contents of assembly_bytes 0306 print_assembly: 0307 a364 5f clrb 0308 a365 ce b5 72 ldx #assembly_bytes 0309 print_assembly_loop: 0310 a368 f1 b5 71 cmpb assembly_length 0311 a36b 27 0d beq print_assembly_fill 0312 a36d c1 04 cmpb #4 0313 a36f 27 19 beq print_assembly_end 0314 a371 bd a7 c0 jsr out2hs 0315 a374 5c incb 0316 a375 f7 b4 3f stab temp ; save number of printed bytes 0317 a378 20 ee bra print_assembly_loop 0318 print_assembly_fill: 0319 a37a c1 04 cmpb #4 0320 a37c 27 0c beq print_assembly_end 0321 a37e bd a7 c2 jsr outs 0322 a381 bd a7 c2 jsr outs 0323 a384 bd a7 c2 jsr outs 0324 a387 5c incb 0325 a388 20 f0 bra print_assembly_fill 0326 print_assembly_end: 0327 a38a 39 rts 0328 ;;; Print remaining assembly_bytes 0329 print_remaining_ass: 0330 a38b f6 b4 3f ldab temp 0331 a38e ce b5 72 ldx #assembly_bytes 0332 a391 3a abx 0333 print_remaining_ass_loop: 0334 a392 f1 b5 71 cmpb assembly_length 0335 a395 27 0a beq print_remaining_ass_end 0336 a397 bd a7 c0 jsr out2hs 0337 a39a 5c incb 0338 a39b c5 03 bitb #$03 0339 a39d 27 03 beq print_remaining_ass_nl 0340 a39f 20 f1 bra print_remaining_ass_loop 0341 print_remaining_ass_end: 0342 a3a1 39 rts 0343 print_remaining_ass_nl: 0344 a3a2 bd a7 95 jsr pcrlf 0345 a3a5 bd a7 c2 jsr outs 0346 a3a8 bd a7 c2 jsr outs 0347 a3ab bd a7 c2 jsr outs 0348 a3ae bd a7 c2 jsr outs 0349 a3b1 bd a7 c2 jsr outs 0350 a3b4 bd a7 c2 jsr outs 0351 a3b7 bd a7 c2 jsr outs 0352 a3ba bd a7 c2 jsr outs 0353 a3bd bd a7 c2 jsr outs 0354 a3c0 bd a7 c2 jsr outs 0355 a3c3 bd a7 c2 jsr outs 0356 a3c6 20 ca bra print_remaining_ass_loop 0357 0358 ;;; 0359 ;;; Assemble op-code and operand based on opcode_pointer and line_pointer_operand 0360 ;;; Result in assembly_bytes and assembly_length 0361 ;;; 0362 assemble: 0363 a3c8 7f b5 71 clr assembly_length 0364 a3cb fe b5 6f ldx opcode_pointer ; get pointer to entry in op-code table 0365 a3ce a6 09 ldaa 9,x ; get op-code type (last byte of entry) 0366 a3d0 2a 03 bpl *+5 0367 a3d2 7e a4 f8 jmp assemble_pseudo ; is it a pseudo op-code? 0368 a3d5 81 05 cmpa #OP5 ; is op-code implied? 0369 a3d7 27 45 beq assemble_implied 0370 a3d9 81 04 cmpa #OP4 ; is op-code branch? 0371 a3db 27 4d beq assemble_branch 0372 a3dd fe b5 5f ldx line_pointer_operand 0373 a3e0 a6 00 ldaa ,x 0374 a3e2 81 23 cmpa #'# ; is it an immediate operand? 0375 a3e4 26 03 bne *+5 0376 a3e6 7e a4 57 jmp assemble_immediate 0377 a3e9 81 2c cmpa #', ; is it an indexed operand? 0378 a3eb 26 03 bne *+5 0379 a3ed 7e a4 8d jmp assemble_indexed 0380 a3f0 a6 01 ldaa 1,x 0381 a3f2 81 2c cmpa #', ; is it an indexed operand? 0382 a3f4 26 03 bne *+5 0383 a3f6 7e a4 8d jmp assemble_indexed 0384 a3f9 a6 02 ldaa 2,x 0385 a3fb 81 2c cmpa #', ; is it an indexed operand? 0386 a3fd 26 03 bne *+5 0387 a3ff 7e a4 8d jmp assemble_indexed 0388 a402 a6 03 ldaa 3,x 0389 a404 81 2c cmpa #', ; is it an indexed operand? 0390 a406 26 03 bne *+5 0391 a408 7e a4 8d jmp assemble_indexed 0392 a40b fe b5 5f ldx line_pointer_operand 0393 a40e a6 00 ldaa ,x 0394 a410 81 3c cmpa #'< ; is direct addressing forced? 0395 a412 27 03 beq *+5 0396 a414 7e a4 b2 jmp assemble_extended 0397 a417 08 inx 0398 a418 ff b5 5f stx line_pointer_operand 0399 a41b 7e a4 d4 jmp assemble_direct 0400 assemble_implied: 0401 a41e a6 08 ldaa 8,x 0402 a420 b7 b5 72 staa assembly_bytes 0403 a423 86 01 ldaa #1 0404 a425 b7 b5 71 staa assembly_length 0405 a428 0c clc 0406 a429 39 rts 0407 assemble_branch: 0408 a42a a6 04 ldaa 4,x 0409 a42c b7 b5 72 staa assembly_bytes 0410 a42f 86 02 ldaa #2 0411 a431 b7 b5 71 staa assembly_length 0412 a434 fe b5 5f ldx line_pointer_operand 0413 a437 bd a8 39 jsr read_expression 0414 a43a 24 03 bcc *+5 0415 a43c 7e a5 ec jmp assemble_expr_fail 0416 a43f fc b4 4a ldd exp_result 0417 a442 b3 b5 67 subd program_counter 0418 a445 83 00 02 subd #2 ; subtract operation itself 0419 a448 f7 b5 73 stab assembly_bytes+1 0420 a44b 4d tsta ; check branch limits 0421 a44c 27 07 beq assemble_branch_ok 0422 a44e 81 ff cmpa #$ff 0423 a450 27 03 beq assemble_branch_ok 0424 a452 bd a2 c3 jsr report_branch_range 0425 assemble_branch_ok: 0426 a455 0c clc 0427 a456 39 rts 0428 assemble_immediate: 0429 a457 fe b5 6f ldx opcode_pointer 0430 a45a a6 04 ldaa 4,x 0431 a45c 26 03 bne *+5 0432 a45e 7e a4 f6 jmp assemble_error ; does this op-code have an immediate version? 0433 a461 b7 b5 72 staa assembly_bytes 0434 a464 a6 09 ldaa 9,x 0435 a466 4c inca 0436 a467 b7 b5 71 staa assembly_length 0437 a46a fe b5 5f ldx line_pointer_operand 0438 a46d 08 inx ; skip "#" 0439 a46e bd a8 39 jsr read_expression 0440 a471 24 03 bcc *+5 0441 a473 7e a5 ec jmp assemble_expr_fail 0442 a476 b6 b5 71 ldaa assembly_length 0443 a479 81 02 cmpa #$02 0444 a47b 27 08 beq assemble_immediate1 0445 a47d fe b4 4a ldx exp_result 0446 a480 ff b5 73 stx assembly_bytes+1 0447 a483 0c clc 0448 a484 39 rts 0449 assemble_immediate1: 0450 a485 b6 b4 4b ldaa exp_result+1 0451 a488 b7 b5 73 staa assembly_bytes+1 0452 a48b 0c clc 0453 a48c 39 rts 0454 assemble_indexed: 0455 a48d fe b5 6f ldx opcode_pointer 0456 a490 a6 06 ldaa 6,x 0457 a492 27 62 beq assemble_error ; does this op-code have an immediate version? 0458 a494 b7 b5 72 staa assembly_bytes 0459 a497 86 02 ldaa #2 0460 a499 b7 b5 71 staa assembly_length 0461 a49c fe b5 5f ldx line_pointer_operand 0462 a49f bd a8 39 jsr read_expression 0463 a4a2 b6 b4 4b ldaa exp_result+1 ; truncate value to 8 bits 0464 a4a5 b7 b5 73 staa assembly_bytes+1 0465 a4a8 7d b4 4a tst exp_result ; check offset limit 0466 a4ab 27 03 beq assemble_indexed_ok 0467 a4ad bd a2 ae jsr report_invalid_expr 0468 assemble_indexed_ok: 0469 a4b0 0c clc 0470 a4b1 39 rts 0471 assemble_extended: 0472 a4b2 fe b5 6f ldx opcode_pointer 0473 a4b5 a6 07 ldaa 7,x 0474 a4b7 27 3d beq assemble_error ; does this op-code have an extended version? 0475 a4b9 b7 b5 72 staa assembly_bytes 0476 a4bc 86 03 ldaa #3 0477 a4be b7 b5 71 staa assembly_length 0478 a4c1 fe b5 5f ldx line_pointer_operand 0479 a4c4 bd a8 39 jsr read_expression 0480 a4c7 24 03 bcc *+5 0481 a4c9 7e a5 ec jmp assemble_expr_fail 0482 a4cc fe b4 4a ldx exp_result 0483 a4cf ff b5 73 stx assembly_bytes+1 0484 a4d2 0c clc 0485 a4d3 39 rts 0486 assemble_direct: 0487 a4d4 fe b5 6f ldx opcode_pointer 0488 a4d7 a6 05 ldaa 5,x 0489 a4d9 27 1b beq assemble_error ; does this op-code have a direct version? 0490 a4db b7 b5 72 staa assembly_bytes 0491 a4de 86 02 ldaa #2 0492 a4e0 b7 b5 71 staa assembly_length 0493 a4e3 fe b5 5f ldx line_pointer_operand 0494 a4e6 bd a8 39 jsr read_expression 0495 a4e9 24 03 bcc *+5 0496 a4eb 7e a5 ec jmp assemble_expr_fail 0497 a4ee b6 b4 4b ldaa exp_result+1 0498 a4f1 b7 b5 73 staa assembly_bytes+1 0499 a4f4 0c clc 0500 a4f5 39 rts 0501 assemble_error: 0502 a4f6 0d sec 0503 a4f7 39 rts 0504 assemble_pseudo: 0505 a4f8 81 80 cmpa #PS_ORG 0506 a4fa 26 03 bne *+5 0507 a4fc 7e a5 2b jmp assemble_pseudo_org 0508 a4ff 81 84 cmpa #PS_RMB 0509 a501 26 03 bne *+5 0510 a503 7e a5 3e jmp assemble_pseudo_rmb 0511 a506 81 85 cmpa #PS_EQU 0512 a508 26 03 bne *+5 0513 a50a 7e a5 51 jmp assemble_pseudo_equ 0514 a50d 81 81 cmpa #PS_FCB 0515 a50f 26 03 bne *+5 0516 a511 7e a5 75 jmp assemble_pseudo_fcb 0517 a514 81 82 cmpa #PS_FDB 0518 a516 26 03 bne *+5 0519 a518 7e a5 9b jmp assemble_pseudo_fdb 0520 a51b 81 83 cmpa #PS_FCC 0521 a51d 26 03 bne *+5 0522 a51f 7e a5 c4 jmp assemble_pseudo_fcc 0523 a522 81 86 cmpa #PS_NUL 0524 a524 26 03 bne *+5 0525 a526 7e a5 ea jmp assemble_pseudo_null 0526 a529 0d sec 0527 a52a 39 rts 0528 assemble_pseudo_org: 0529 a52b fe b5 5f ldx line_pointer_operand 0530 a52e bd a8 39 jsr read_expression 0531 a531 24 03 bcc *+5 0532 a533 7e a5 ec jmp assemble_expr_fail 0533 a536 fe b4 4a ldx exp_result 0534 a539 ff b5 67 stx program_counter 0535 a53c 0c clc 0536 a53d 39 rts 0537 assemble_pseudo_rmb: 0538 a53e fe b5 5f ldx line_pointer_operand 0539 a541 bd a8 39 jsr read_expression 0540 a544 24 03 bcc *+5 0541 a546 7e a5 ec jmp assemble_expr_fail 0542 a549 fc b4 4a ldd exp_result 0543 a54c fd b5 69 std program_counter_bump 0544 a54f 0c clc 0545 a550 39 rts 0546 assemble_pseudo_equ: 0547 a551 fe b5 5f ldx line_pointer_operand ; Parse expression 0548 a554 bd a8 39 jsr read_expression 0549 a557 24 03 bcc *+5 0550 a559 7e a5 ec jmp assemble_expr_fail 0551 a55c fe b5 5b ldx line_pointer_label ; Find line label in table 0552 a55f bd a6 63 jsr find_label 0553 a562 24 03 bcc *+5 0554 a564 7e a2 9e jmp report_label_not_found 0555 a567 fe b4 43 ldx str2 ; Label table search result 0556 a56a bd a8 1a jsr str_skp_next 0557 a56d 08 inx 0558 a56e fc b4 4a ldd exp_result 0559 a571 ed 00 std ,x 0560 a573 0c clc 0561 a574 39 rts 0562 assemble_pseudo_fcb: 0563 a575 fe b5 5f ldx line_pointer_operand 0564 assemble_pseudo_fcb_next: 0565 a578 bd a8 39 jsr read_expression 0566 a57b 24 03 bcc *+5 0567 a57d 7e a5 ec jmp assemble_expr_fail 0568 a580 b6 b4 4b ldaa exp_result+1 0569 a583 ce b5 72 ldx #assembly_bytes 0570 a586 f6 b5 71 ldab assembly_length 0571 a589 3a abx 0572 a58a a7 00 staa ,x 0573 a58c 7c b5 71 inc assembly_length 0574 a58f fe b4 48 ldx exp_pointer ; are there more data to read? 0575 a592 a6 00 ldaa ,x 0576 a594 08 inx 0577 a595 81 2c cmpa #', 0578 a597 27 df beq assemble_pseudo_fcb_next 0579 a599 0c clc 0580 a59a 39 rts 0581 assemble_pseudo_fdb: 0582 a59b fe b5 5f ldx line_pointer_operand 0583 assemble_pseudo_fdb_next: 0584 a59e bd a8 39 jsr read_expression 0585 a5a1 24 03 bcc *+5 0586 a5a3 7e a5 ec jmp assemble_expr_fail 0587 a5a6 ce b5 72 ldx #assembly_bytes 0588 a5a9 f6 b5 71 ldab assembly_length 0589 a5ac 3a abx 0590 a5ad fc b4 4a ldd exp_result 0591 a5b0 ed 00 std ,x 0592 a5b2 7c b5 71 inc assembly_length 0593 a5b5 7c b5 71 inc assembly_length 0594 a5b8 fe b4 48 ldx exp_pointer ; are there more data to read? 0595 a5bb a6 00 ldaa ,x 0596 a5bd 08 inx 0597 a5be 81 2c cmpa #', 0598 a5c0 27 dc beq assemble_pseudo_fdb_next 0599 a5c2 0c clc 0600 a5c3 39 rts 0601 assemble_pseudo_fcc: 0602 a5c4 fe b5 5f ldx line_pointer_operand 0603 a5c7 a6 00 ldaa ,x 0604 a5c9 b7 b4 3f staa temp ; save string delimiter 0605 assemble_pseudo_fcc_loop: 0606 a5cc 08 inx 0607 a5cd a6 00 ldaa ,x 0608 a5cf 27 17 beq assemble_pseudo_fcc_end ; unexpected end on line 0609 a5d1 b1 b4 3f cmpa temp ; compare with delimiter 0610 a5d4 27 12 beq assemble_pseudo_fcc_end ; end of string? 0611 a5d6 3c pshx 0612 a5d7 ce b5 72 ldx #assembly_bytes 0613 a5da f6 b5 71 ldab assembly_length 0614 a5dd 3a abx 0615 a5de a7 00 staa ,x 0616 a5e0 7c b5 71 inc assembly_length 0617 a5e3 38 pulx 0618 a5e4 27 02 beq assemble_pseudo_fcc_end ; assembly line overflow 0619 a5e6 20 e4 bra assemble_pseudo_fcc_loop 0620 assemble_pseudo_fcc_end: 0621 a5e8 0c clc 0622 a5e9 39 rts 0623 assemble_pseudo_null: 0624 a5ea 0c clc 0625 a5eb 39 rts 0626 assemble_expr_fail: 0627 a5ec bd a2 ae jsr report_invalid_expr 0628 a5ef 0c clc ; assembly OK but expression failed 0629 a5f0 39 rts 0630 0631 ;;; 0632 ;;; Parse line_buffer and create pointers to opcode and operand (if they exist) 0633 ;;; Updates line_pointer_label, line_pointer_opcode and line_pointer_operand 0634 ;;; 0635 segment_line: 0636 a5f1 ce 00 00 ldx #0 0637 a5f4 ff b5 5b stx line_pointer_label 0638 a5f7 ff b5 5d stx line_pointer_opcode 0639 a5fa ff b5 5f stx line_pointer_operand 0640 a5fd ce b4 59 ldx #line_buffer 0641 a600 a6 00 ldaa ,x ; empty line? 0642 a602 27 27 beq segment_line_end 0643 a604 81 2a cmpa #'* ; comment? 0644 a606 27 23 beq segment_line_end 0645 a608 81 3b cmpa #'; ; comment? 0646 a60a 27 1f beq segment_line_end 0647 a60c 81 20 cmpa #$20 ; space? 0648 a60e 27 07 beq segment_line_nolabel 0649 a610 81 09 cmpa #$09 ; tab? 0650 a612 27 03 beq segment_line_nolabel 0651 a614 ff b5 5b stx line_pointer_label 0652 segment_line_nolabel: 0653 a617 bd a8 1a jsr str_skp_next ; go to opcode 0654 a61a 6d 00 tst ,x ; end of line? 0655 a61c 27 0d beq segment_line_end 0656 a61e ff b5 5d stx line_pointer_opcode 0657 a621 bd a8 1a jsr str_skp_next ; go to operand 0658 a624 6d 00 tst ,x ; end of line? 0659 a626 27 03 beq segment_line_end 0660 a628 ff b5 5f stx line_pointer_operand 0661 segment_line_end: 0662 a62b 39 rts 0663 0664 ;;; 0665 ;;; Read label from string at X poiner and store in label table 0666 ;;; 0667 read_label: 0668 a62c a6 00 ldaa ,x 0669 a62e bd a9 b5 jsr char_is_alpha ; first char must be alpha a-z or A-Z 0670 a631 25 1e bcs read_label_end 0671 read_label_loop: 0672 a633 a6 00 ldaa ,x 0673 a635 27 1a beq read_label_end 0674 a637 81 20 cmpa #$20 0675 a639 27 16 beq read_label_end 0676 a63b 81 09 cmpa #$09 0677 a63d 27 12 beq read_label_end 0678 a63f 81 3a cmpa #': 0679 a641 27 0e beq read_label_end 0680 a643 3c pshx 0681 a644 fe b5 65 ldx label_table_position 0682 a647 a7 00 staa ,x 0683 a649 08 inx 0684 a64a ff b5 65 stx label_table_position 0685 a64d 38 pulx 0686 a64e 08 inx 0687 a64f 20 e2 bra read_label_loop 0688 read_label_end: 0689 a651 fe b5 65 ldx label_table_position 0690 a654 6f 00 clr ,x 0691 a656 fc b5 67 ldd program_counter 0692 a659 ed 01 std 1,x 0693 a65b 08 inx 0694 a65c 08 inx 0695 a65d 08 inx 0696 a65e 6f 00 clr 0,x ; mark end of table 0697 a660 ff b5 65 stx label_table_position 0698 rts 0699 0700 ;;; 0701 ;;; Find label 0702 ;;; Search string given by X 0703 ;;; Carry clear on found 0704 ;;; Label value in variable 'number' 0705 ;;; Pointer to label name in 'str2' 0706 ;;; 0707 find_label: 0708 a663 ff b4 41 stx str1 0709 a666 fe b5 63 ldx label_table 0710 a669 ff b4 43 stx str2 0711 find_label_loop: 0712 a66c 6d 00 tst ,x ; end of table? 0713 a66e 27 21 beq find_label_end 0714 a670 bd a7 17 jsr str_cmp 0715 a673 24 0e bcc find_label_found 0716 a675 fe b4 43 ldx str2 0717 a678 bd a8 1a jsr str_skp_next 0718 a67b 08 inx ; skip string termination 0719 a67c 08 inx ; skip label value 0720 a67d 08 inx 0721 a67e ff b4 43 stx str2 0722 a681 20 e9 bra find_label_loop 0723 find_label_found: 0724 a683 fe b4 43 ldx str2 0725 a686 bd a8 1a jsr str_skp_next 0726 a689 08 inx 0727 a68a ee 00 ldx ,x 0728 a68c ff b4 45 stx number 0729 a68f 0c clc 0730 a690 39 rts 0731 find_label_end: 0732 a691 7f b4 45 clr number 0733 a694 7f b4 46 clr number+1 0734 a697 0d sec 0735 a698 39 rts 0736 0737 ;;; 0738 ;;; Print all labels 0739 ;;; 0740 print_labels: 0741 a699 ce b1 60 ldx #txt_labels 0742 a69c bd a7 8a jsr str_print 0743 a69f fe b5 63 ldx label_table 0744 print_labels_loop: 0745 a6a2 6d 00 tst ,x 0746 a6a4 27 0f beq print_labels_end 0747 a6a6 bd a7 8a jsr str_print 0748 a6a9 08 inx ; skip string terminator 0749 a6aa bd a7 c2 jsr outs 0750 a6ad bd a7 be jsr out4hs ; print label value 0751 a6b0 bd a7 95 jsr pcrlf 0752 a6b3 20 ed bra print_labels_loop 0753 print_labels_end: 0754 a6b5 39 rts 0755 0756 ;;; 0757 ;;; Read op-code from string at X poiner and store in op-code buffer 0758 ;;; 0759 read_opcode: 0760 a6b6 a6 00 ldaa 0,x 0761 a6b8 84 df anda #$df 0762 a6ba b7 b5 6b staa opcode_buffer+0 0763 a6bd a6 01 ldaa 1,x 0764 a6bf 84 df anda #$df 0765 a6c1 b7 b5 6c staa opcode_buffer+1 0766 a6c4 a6 02 ldaa 2,x 0767 a6c6 84 df anda #$df 0768 a6c8 b7 b5 6d staa opcode_buffer+2 0769 a6cb a6 03 ldaa 3,x 0770 a6cd 81 40 cmpa #$40 0771 a6cf 23 0a bls read_opcode2 0772 a6d1 81 7a cmpa #$7a 0773 a6d3 22 06 bhi read_opcode2 0774 a6d5 84 df anda #$df 0775 read_opcode1: 0776 a6d7 b7 b5 6e staa opcode_buffer+3 0777 a6da 39 rts 0778 read_opcode2: 0779 a6db 86 20 ldaa #$20 0780 a6dd 20 f8 bra read_opcode1 0781 0782 0783 ;;; 0784 ;;; Compare op-code at X with opcode in buffer 0785 ;;; Carry clear if found 0786 ;;; 0787 cmp_opcode: 0788 a6df a6 00 ldaa 0,x 0789 a6e1 b1 b5 6b cmpa opcode_buffer+0 0790 a6e4 26 17 bne cmp_opcode_nomatch 0791 a6e6 a6 01 ldaa 1,x 0792 a6e8 b1 b5 6c cmpa opcode_buffer+1 0793 a6eb 26 10 bne cmp_opcode_nomatch 0794 a6ed a6 02 ldaa 2,x 0795 a6ef b1 b5 6d cmpa opcode_buffer+2 0796 a6f2 26 09 bne cmp_opcode_nomatch 0797 a6f4 a6 03 ldaa 3,x 0798 a6f6 b1 b5 6e cmpa opcode_buffer+3 0799 a6f9 26 02 bne cmp_opcode_nomatch 0800 a6fb 0c clc 0801 a6fc 39 rts 0802 cmp_opcode_nomatch: 0803 a6fd 0d sec 0804 a6fe 39 rts 0805 0806 ;;; 0807 ;;; Lookup op-code in table 0808 ;;; Carry clear if found 0809 ;;; 0810 lookup_opcode: 0811 a6ff c6 0a ldab #10 ; table entry length is 10 bytes 0812 a701 ce aa ec ldx #opcode_table 0813 lookup_opcode_loop: 0814 a704 6d 00 tst ,x ; end of table? 0815 a706 27 0d beq lookup_opcode_notfound 0816 a708 bd a6 df jsr cmp_opcode 0817 a70b 24 03 bcc lookup_opcode_found 0818 a70d 3a abx 0819 a70e 20 f4 bra lookup_opcode_loop 0820 lookup_opcode_found: 0821 a710 ff b5 6f stx opcode_pointer 0822 a713 0c clc 0823 a714 39 rts 0824 lookup_opcode_notfound: 0825 a715 0d sec 0826 a716 39 rts 0827 0828 ;;; 0829 ;;; Compare two alphanumeric strings given by str1 and str2 0830 ;;; Carry clear on match 0831 ;;; 0832 str_cmp: 0833 a717 fe b4 41 ldx str1 0834 a71a 3c pshx 0835 a71b fe b4 43 ldx str2 0836 a71e 3c pshx 0837 a71f fe b4 43 ldx str2 0838 str_cmp_loop: 0839 a722 a6 00 ldaa ,x 0840 a724 8d 30 bsr str_cmp_eos ; special end of string routine 0841 a726 27 1b beq str_cmp_end 0842 a728 3c pshx 0843 a729 fe b4 41 ldx str1 0844 a72c e6 00 ldab ,x 0845 a72e 08 inx 0846 a72f ff b4 41 stx str1 0847 a732 38 pulx 0848 a733 11 cba 0849 a734 26 03 bne str_cmp_end_mismatch 0850 a736 08 inx 0851 a737 20 e9 bra str_cmp_loop 0852 str_cmp_end_mismatch: 0853 a739 38 pulx 0854 a73a ff b4 43 stx str2 0855 a73d 38 pulx 0856 a73e ff b4 41 stx str1 0857 a741 0d sec 0858 a742 39 rts 0859 str_cmp_end: 0860 a743 fe b4 41 ldx str1 0861 a746 a6 00 ldaa ,x 0862 a748 8d 0c bsr str_cmp_eos ; special end of string routine 0863 a74a 26 ed bne str_cmp_end_mismatch 0864 a74c 38 pulx 0865 a74d ff b4 43 stx str2 0866 a750 38 pulx 0867 a751 ff b4 41 stx str1 0868 a754 0c clc 0869 a755 39 rts 0870 0871 str_cmp_eos: 0872 a756 4d tsta 0873 a757 27 1d beq str_cmp_eos_force ; end of string 0874 a759 81 20 cmpa #$20 0875 a75b 27 19 beq str_cmp_eos_force ; end of word 0876 a75d 81 09 cmpa #$09 0877 a75f 27 15 beq str_cmp_eos_force ; end of word 0878 a761 81 20 cmpa #$20 0879 a763 27 11 beq str_cmp_eos_force ; end of word 0880 a765 81 3a cmpa #': 0881 a767 27 0d beq str_cmp_eos_force ; end of word 0882 a769 81 2c cmpa #', 0883 a76b 27 09 beq str_cmp_eos_force ; end of word 0884 a76d 81 2b cmpa #'+ 0885 a76f 27 05 beq str_cmp_eos_force ; end of word 0886 a771 81 2d cmpa #'- 0887 a773 27 01 beq str_cmp_eos_force ; end of word 0888 a775 39 rts 0889 str_cmp_eos_force: 0890 a776 4f clra 0891 a777 39 rts 0892 0893 ;;; 0894 ;;; Print string at X 0895 ;;; 0896 str_print_word: 0897 a778 a6 00 ldaa ,x 0898 a77a 27 18 beq str_print_end 0899 a77c 81 20 cmpa #$20 0900 a77e 27 14 beq str_print_end 0901 a780 81 09 cmpa #$09 0902 a782 27 10 beq str_print_end 0903 a784 bd 7f e8 jsr console_output 0904 a787 08 inx 0905 a788 20 ee bra str_print_word 0906 0907 ;;; 0908 ;;; Print string at X 0909 ;;; 0910 str_print: 0911 a78a a6 00 ldaa ,x 0912 a78c 27 06 beq str_print_end 0913 a78e bd 7f e8 jsr console_output 0914 a791 08 inx 0915 a792 20 f6 bra str_print 0916 str_print_end: 0917 a794 39 rts 0918 0919 ;;; 0920 ;;; Print CR + LF 0921 ;;; 0922 pcrlf: 0923 a795 36 psha 0924 a796 86 0d ldaa #$0d 0925 a798 bd 7f e8 jsr console_output 0926 a79b 86 0a ldaa #$0a 0927 a79d bd 7f e8 jsr console_output 0928 a7a0 32 pula 0929 a7a1 39 rts 0930 0931 ;;; 0932 ;;; Print hex values 0933 ;;; 0934 outhl: 0935 a7a2 44 lsra 0936 a7a3 44 lsra 0937 a7a4 44 lsra 0938 a7a5 44 lsra 0939 outhr: 0940 a7a6 84 0f anda #$0f 0941 a7a8 8b 30 adda #$30 0942 a7aa 81 39 cmpa #$39 0943 a7ac 23 02 bls outhe 0944 a7ae 8b 27 adda #$27 ; $07=lower case & $27=upper case 0945 outhe: 0946 a7b0 7e 7f e8 jmp console_output 0947 out2h: 0948 a7b3 a6 00 ldaa 0,x 0949 a7b5 bd a7 a2 jsr outhl 0950 a7b8 a6 00 ldaa 0,x 0951 a7ba 08 inx 0952 a7bb 7e a7 a6 jmp outhr 0953 out4hs: 0954 a7be 8d f3 bsr out2h 0955 out2hs: 0956 a7c0 8d f1 bsr out2h 0957 0958 ;;; 0959 ;;; Print space 0960 ;;; 0961 outs: 0962 a7c2 36 psha 0963 a7c3 86 20 ldaa #$20 0964 a7c5 bd 7f e8 jsr console_output 0965 a7c8 32 pula 0966 a7c9 39 rts 0967 0968 ;;; 0969 ;;; Decimal output routine borrowed from FLEX. Modified to make use of D-reg. 0970 ;;; IN: X = pointer to 16-bit unsigned binary number 0971 ;;; 0972 outdec: 0973 a7ca 7f b4 52 clr outdec_digit 0974 a7cd 86 04 ldaa #4 0975 a7cf b7 b4 53 staa outdec_loop1 0976 a7d2 ec 00 ldd 0,x 0977 a7d4 ce a8 12 ldx #decimal_table 0978 ;;; Iterate over table for each position 0979 outdec_1: 0980 a7d7 8d 0b bsr outdec_2 0981 a7d9 08 inx 0982 a7da 08 inx 0983 a7db 7a b4 53 dec outdec_loop1 0984 a7de 26 f7 bne outdec_1 0985 a7e0 17 tba 0986 a7e1 7e a7 a6 jmp outhr 0987 ;;; Binary to decimal conversion 0988 outdec_2: 0989 a7e4 7f b4 54 clr outdec_loop2 0990 outdec_3: 0991 a7e7 a1 00 cmpa 0,x 0992 a7e9 25 0d bcs outdec_5 0993 a7eb 22 04 bhi outdec_4 0994 a7ed e1 01 cmpb 1,x 0995 a7ef 25 07 bcs outdec_5 0996 outdec_4: 0997 a7f1 a3 00 subd 0,x 0998 a7f3 7c b4 54 inc outdec_loop2 0999 a7f6 20 ef bra outdec_3 1000 ;;; Print digit or leading zero 1001 outdec_5: 1002 a7f8 36 psha 1003 a7f9 b6 b4 54 ldaa outdec_loop2 1004 a7fc 26 0c bne outdec_6 1005 a7fe 7d b4 52 tst outdec_digit 1006 a801 26 07 bne outdec_6 1007 a803 86 30 ldaa #'0 1008 a805 bd 7f e8 jsr console_output 1009 a808 20 06 bra outdec_7 1010 outdec_6: 1011 a80a 7c b4 52 inc outdec_digit 1012 a80d bd a7 a6 jsr outhr 1013 outdec_7: 1014 a810 32 pula 1015 a811 39 rts 1016 ;;; Decimal table 1017 decimal_table: 1018 a812 27 10 fdb 10000 1019 a814 03 e8 fdb 1000 1020 a816 00 64 fdb 100 1021 a818 00 0a fdb 10 1022 1023 ;;; 1024 ;;; Skip to next word in string at X 1025 ;;; 1026 str_skp_next: 1027 a81a a6 00 ldaa ,x 1028 a81c 27 17 beq str_skp_next_e ; end of string? 1029 a81e 81 20 cmpa #$20 ; space 1030 a820 27 07 beq str_skp_next_1 1031 a822 81 09 cmpa #$09 ; tab 1032 a824 27 03 beq str_skp_next_1 1033 a826 08 inx 1034 a827 20 f1 bra str_skp_next 1035 str_skp_next_1: 1036 a829 a6 00 ldaa ,x 1037 a82b 27 08 beq str_skp_next_e ; end of string? 1038 a82d 81 20 cmpa #$20 ; space 1039 a82f 27 05 beq str_skp_next_2 1040 a831 81 09 cmpa #$09 ; tab 1041 a833 27 01 beq str_skp_next_2 1042 str_skp_next_e: 1043 a835 39 rts 1044 str_skp_next_2: 1045 a836 08 inx 1046 a837 20 f0 bra str_skp_next_1 1047 1048 ;;; 1049 ;;; Read expression from string at X 1050 ;;; Resolve labels and handle add/sub of two values 1051 ;;; Result in variable 'number' 1052 ;;; Carry clear on valid expression 1053 ;;; 1054 read_expression: 1055 a839 7f b4 4a clr exp_result 1056 a83c 7f b4 4b clr exp_result+1 1057 read_expression_cont: 1058 a83f 86 2b ldaa #'+ 1059 a841 b7 b4 47 staa exp_sign ; default sign is + 1060 a844 a6 00 ldaa ,x 1061 ;;; Check if there is a sign in string 1062 a846 81 2b cmpa #'+ 1063 a848 26 06 bne read_expression_nplus 1064 a84a b7 b4 47 staa exp_sign 1065 a84d 08 inx 1066 a84e 20 08 bra read_expression_read 1067 read_expression_nplus: 1068 a850 81 2d cmpa #'- 1069 a852 26 04 bne read_expression_read 1070 a854 b7 b4 47 staa exp_sign 1071 a857 08 inx 1072 read_expression_read: 1073 ;;; Eventual sign has been extracted - read value 1074 a858 ff b4 48 stx exp_pointer 1075 a85b a6 00 ldaa ,x 1076 a85d 81 24 cmpa #'$ ; is it a hex value? 1077 a85f 27 29 beq read_expression_hex 1078 a861 81 25 cmpa #'% ; is it a binary value? 1079 a863 27 2f beq read_expression_bin 1080 a865 81 27 cmpa #'' ; is it a char value? 1081 a867 27 30 beq read_expression_chr 1082 a869 81 2a cmpa #'* ; is it a program counter reference? 1083 a86b 27 37 beq read_expression_pc 1084 a86d bd a9 b5 jsr char_is_alpha ; is it decimal value? 1085 a870 25 1d bcs read_expression_dec 1086 ;;; If non of the above - try to resolve as label 1087 a872 7d b4 4c tst pass2_flag ; ignore labels for pass1 (speed improvement) 1088 a875 27 0a beq read_expression_dummy 1089 a877 bd a6 63 jsr find_label 1090 a87a 24 03 bcc *+5 1091 a87c bd a2 9e jsr report_label_not_found 1092 a87f 20 2c bra read_expression_end 1093 read_expression_dummy: 1094 a881 7f b4 4a clr exp_result ; set 0 as dummy value 1095 a884 7f b4 4b clr exp_result+1 1096 a887 0c clc 1097 a888 20 23 bra read_expression_end 1098 read_expression_hex: 1099 a88a bd a8 f7 jsr parse_hex 1100 a88d 20 1e bra read_expression_end 1101 read_expression_dec: 1102 a88f bd a9 27 jsr parse_dec 1103 a892 20 19 bra read_expression_end 1104 read_expression_bin: 1105 a894 bd a9 6a jsr parse_bin 1106 a897 20 14 bra read_expression_end 1107 read_expression_chr: 1108 a899 08 inx ; skip "'" 1109 a89a a6 00 ldaa ,x ; get char value 1110 a89c b7 b4 4b staa exp_result+1 1111 a89f 7f b4 4a clr exp_result 1112 a8a2 20 38 bra read_expression_stop 1113 read_expression_pc: 1114 a8a4 fc b5 67 ldd program_counter 1115 a8a7 fd b4 45 std number 1116 a8aa 0c clc 1117 a8ab 20 00 bra read_expression_end 1118 read_expression_end: 1119 ;;; Expression number/part complete - add together and check for more 1120 a8ad 25 32 bcs read_expression_abort ; error in processing expression 1121 a8af b6 b4 47 ldaa exp_sign ; check sign of operation 1122 a8b2 81 2d cmpa #'- 1123 a8b4 26 08 bne read_expression_add 1124 a8b6 fc b4 4a ldd exp_result 1125 a8b9 b3 b4 45 subd number 1126 a8bc 20 06 bra read_expression_res 1127 read_expression_add: 1128 a8be fc b4 4a ldd exp_result 1129 a8c1 f3 b4 45 addd number 1130 read_expression_res: 1131 a8c4 fd b4 4a std exp_result 1132 a8c7 bd a8 e6 jsr exp_next 1133 a8ca a6 00 ldaa ,x 1134 a8cc 27 0e beq read_expression_stop 1135 a8ce 81 2b cmpa #'+ ; there is more of the expression to do 1136 a8d0 26 03 bne *+5 1137 a8d2 7e a8 3f jmp read_expression_cont 1138 a8d5 81 2d cmpa #'- ; there is more of the expression to do 1139 a8d7 26 03 bne *+5 1140 a8d9 7e a8 3f jmp read_expression_cont 1141 read_expression_stop: 1142 a8dc ff b4 48 stx exp_pointer ; save end of expression 1143 a8df 0c clc 1144 a8e0 39 rts 1145 read_expression_abort: 1146 a8e1 ff b4 48 stx exp_pointer ; save end of expression 1147 a8e4 0d sec 1148 a8e5 39 rts 1149 1150 ;;; 1151 ;;; Go to next part of expression 1152 ;;; 1153 exp_next: 1154 a8e6 fe b4 48 ldx exp_pointer 1155 exp_next_loop: 1156 a8e9 a6 00 ldaa ,x 1157 a8eb bd a7 56 jsr str_cmp_eos 1158 a8ee 27 03 beq exp_next_end 1159 a8f0 08 inx 1160 a8f1 20 f6 bra exp_next_loop 1161 exp_next_end: 1162 a8f3 ff b4 48 stx exp_pointer 1163 a8f6 39 rts 1164 1165 ;;; 1166 ;;; Parse hexadecimal value from ASCII string at X 1167 ;;; Result in variable 'number' 1168 ;;; 1169 parse_hex: 1170 a8f7 7f b4 45 clr number 1171 a8fa 7f b4 46 clr number+1 1172 a8fd a6 00 ldaa ,x 1173 a8ff 81 24 cmpa #'$ ; skip eventual $ in the beginning 1174 a901 26 01 bne parse_hex_loop 1175 a903 08 inx 1176 parse_hex_loop: 1177 a904 a6 00 ldaa ,x 1178 a906 bd a7 56 jsr str_cmp_eos 1179 a909 27 18 beq parse_hex_end 1180 a90b bd a9 9b jsr char_to_hex 1181 a90e 24 15 bcc parse_hex_err 1182 a910 fd b4 3f std temp 1183 a913 fc b4 45 ldd number 1184 a916 05 asld 1185 a917 05 asld 1186 a918 05 asld 1187 a919 05 asld 1188 a91a fa b4 3f orab temp 1189 a91d fd b4 45 std number 1190 a920 08 inx 1191 a921 20 e1 bra parse_hex_loop 1192 parse_hex_end: 1193 a923 0c clc 1194 a924 39 rts 1195 parse_hex_err: 1196 a925 0d sec 1197 a926 39 rts 1198 1199 ;;; 1200 ;;; Parse decimal value from ASCII string at X 1201 ;;; Result in variable 'number' 1202 ;;; 1203 parse_dec: 1204 a927 7f b4 45 clr number 1205 a92a 7f b4 46 clr number+1 1206 parse_dec_loop: 1207 a92d a6 00 ldaa ,x 1208 a92f bd a7 56 jsr str_cmp_eos 1209 a932 27 1e beq parse_dec_end 1210 a934 bd a9 9b jsr char_to_hex 1211 a937 24 1b bcc parse_dec_err 1212 a939 81 09 cmpa #$09 1213 a93b 2e 17 bgt parse_dec_err 1214 a93d bd a9 56 jsr mult10 1215 a940 7f b4 3f clr temp ; add value 1216 a943 b7 b4 40 staa temp+1 1217 a946 fc b4 45 ldd number 1218 a949 f3 b4 3f addd temp 1219 a94c fd b4 45 std number 1220 a94f 08 inx 1221 a950 20 db bra parse_dec_loop 1222 parse_dec_end: 1223 a952 0c clc 1224 a953 39 rts 1225 parse_dec_err: 1226 a954 0d sec 1227 a955 39 rts 1228 1229 ;;; 1230 ;;; Multiply variable 'number' by 10 1231 ;;; 1232 mult10: 1233 a956 36 psha 1234 a957 37 pshb 1235 a958 fc b4 45 ldd number 1236 a95b 05 asld ; * 2 1237 a95c fd b4 3f std temp 1238 a95f 05 asld ; * 4 1239 a960 05 asld ; * 8 1240 a961 f3 b4 3f addd temp ; D = D*8+D*2 1241 a964 fd b4 45 std number 1242 a967 33 pulb 1243 a968 32 pula 1244 a969 39 rts 1245 1246 ;;; 1247 ;;; Parse binary value from ASCII string at X 1248 ;;; Result in variable 'number' 1249 ;;; 1250 parse_bin: 1251 a96a 7f b4 45 clr number 1252 a96d 7f b4 46 clr number+1 1253 a970 a6 00 ldaa ,x 1254 a972 81 25 cmpa #'% ; skip eventual % in the beginning 1255 a974 26 01 bne parse_bin_loop 1256 a976 08 inx 1257 parse_bin_loop: 1258 a977 a6 00 ldaa ,x 1259 a979 bd a7 56 jsr str_cmp_eos 1260 a97c 27 19 beq parse_bin_end 1261 a97e bd a9 9b jsr char_to_hex 1262 a981 24 d1 bcc parse_dec_err 1263 a983 81 01 cmpa #$01 1264 a985 2e 12 bgt parse_bin_err 1265 a987 b7 b4 3f staa temp 1266 a98a fc b4 45 ldd number 1267 a98d 05 asld 1268 a98e fa b4 3f orab temp 1269 a991 fd b4 45 std number 1270 a994 08 inx 1271 a995 20 e0 bra parse_bin_loop 1272 parse_bin_end: 1273 a997 0c clc 1274 a998 39 rts 1275 parse_bin_err: 1276 a999 0d sec 1277 a99a 39 rts 1278 1279 ;;; 1280 ;;; Convert ASCII char to hex 1281 ;;; IN: Character in A 1282 ;;; OUT: Value in A. Carry set on OK 1283 ;;; 1284 char_to_hex: 1285 a99b 27 16 beq char_to_hex_fail ; end of string 1286 a99d 80 30 suba #$30 1287 a99f 2b 12 bmi char_to_hex_fail ; not hex 1288 a9a1 81 09 cmpa #$09 1289 a9a3 2f 0c ble char_to_hex_ok ; $9 and below 1290 a9a5 84 df anda #$df ; to upper case 1291 a9a7 81 11 cmpa #$11 1292 a9a9 2d 08 blt char_to_hex_fail ; not hex 1293 a9ab 81 16 cmpa #$16 1294 a9ad 2e 04 bgt char_to_hex_fail ; not hex 1295 a9af 80 07 suba #7 1296 char_to_hex_ok: 1297 a9b1 0d sec 1298 a9b2 39 rts 1299 char_to_hex_fail: 1300 a9b3 0c clc 1301 a9b4 39 rts 1302 1303 ;;; 1304 ;;; Check if char in A is _, a-z or A-Z 1305 ;;; Carry clear on true 1306 ;;; 1307 char_is_alpha: 1308 a9b5 36 psha 1309 char_is_alpha1: 1310 a9b6 81 5f cmpa #'_ 1311 a9b8 27 0a beq char_is_alpha_ok 1312 a9ba 84 df anda #$df ; to uppe case 1313 a9bc 81 40 cmpa #$40 ; below 'A 1314 a9be 23 07 bls char_is_alpha_false 1315 a9c0 81 5a cmpa #$5a ; above 'Z 1316 a9c2 2e 03 bgt char_is_alpha_false 1317 char_is_alpha_ok: 1318 a9c4 32 pula 1319 a9c5 0c clc 1320 a9c6 39 rts 1321 char_is_alpha_false: 1322 a9c7 32 pula 1323 a9c8 0d sec 1324 a9c9 39 rts 1325 1326 ;;; 1327 ;;; Store generated bytes from current line 1328 ;;; 1329 store_line_bytes: 1330 a9ca 7d b4 51 tst direct_mem_flag 1331 a9cd 27 15 beq store_line_bytes_end 1332 a9cf 5f clrb 1333 store_direct_loop: 1334 a9d0 f1 b5 71 cmpb assembly_length 1335 a9d3 27 0f beq store_line_bytes_end 1336 a9d5 ce b5 72 ldx #assembly_bytes 1337 a9d8 3a abx 1338 a9d9 a6 00 ldaa ,x 1339 a9db fe b5 67 ldx program_counter 1340 a9de 3a abx 1341 a9df a7 00 staa ,x 1342 a9e1 5c incb 1343 a9e2 20 ec bra store_direct_loop 1344 store_line_bytes_end: 1345 a9e4 39 rts 1346 1347 ;;; 1348 ;;; Parse command line arguments 1349 ;;; 1350 parse_args: 1351 a9e5 ce 01 00 ldx #$0100 ;set label_table default position 1352 a9e8 ff b5 63 stx label_table 1353 a9eb fe b4 55 ldx args 1354 parse_args_loop: 1355 a9ee a6 00 ldaa ,x 1356 a9f0 27 2c beq parse_args_end ; end of line 1357 a9f2 81 2d cmpa #'- ; look for flags 1358 a9f4 27 05 beq parse_arg_flag 1359 parse_args_next: 1360 a9f6 bd a8 1a jsr str_skp_next ; go to next argument 1361 a9f9 20 f3 bra parse_args_loop 1362 parse_arg_flag: 1363 a9fb 08 inx ; skip "-" 1364 a9fc a6 00 ldaa ,x 1365 a9fe 84 df anda #$df ; to upper case 1366 aa00 81 4c cmpa #'L ; print linting 1367 aa02 26 03 bne *+5 1368 aa04 7c b4 4f inc listing_flag 1369 aa07 81 45 cmpa #'E ; hide errors 1370 aa09 26 03 bne *+5 1371 aa0b 7c b4 50 inc noerr_flag 1372 aa0e 81 44 cmpa #'D ; write directly to memory 1373 aa10 26 03 bne *+5 1374 aa12 7c b4 51 inc direct_mem_flag 1375 aa15 81 54 cmpa #'T ; move label table 1376 aa17 26 03 bne *+5 1377 aa19 bd aa 1f jsr parse_args_label_table 1378 aa1c 20 d8 bra parse_args_next 1379 parse_args_end: 1380 aa1e 39 rts 1381 parse_args_label_table: 1382 aa1f 08 inx 1383 aa20 bd a8 f7 jsr parse_hex 1384 aa23 25 f9 bcs parse_args_end 1385 aa25 fc b4 45 ldd number 1386 aa28 fd b5 63 std label_table 1387 aa2b 39 rts 1388 1389 ;;; 1390 ;;; Open file for reading 1391 ;;; In: X - pointer to file name 1392 ;;; Out: Z set on success, error code in A 1393 ;;; 1394 aa2c ff b2 23 fopen: stx fname0 1395 aa2f ff b2 35 stx fname1 1396 ;;; Get file info 1397 aa32 ce b2 21 ldx #fcb0 1398 aa35 bd d0 06 jsr sys_call 1399 aa38 7d b2 22 tst fcb0+1 ; read error code 1400 aa3b 26 15 bne fopen_not_found 1401 ;;; Check if directory 1402 aa3d b6 b2 25 ldaa fcb0+4 ; get flags 1403 aa40 85 40 bita #$40 1404 aa42 26 18 bne fopen_is_directory 1405 ;;; Setup file for reading 1406 aa44 ce 00 00 ldx #0 1407 aa47 ff b2 3b stx fcnth 1408 aa4a ff b2 3d stx fcntl 1409 aa4d ff b2 39 stx fsect 1410 aa50 4f clra 1411 aa51 39 rts 1412 fopen_not_found: 1413 aa52 ce b1 86 ldx #txt_not_found 1414 aa55 bd a7 8a jsr str_print 1415 aa58 b6 b2 22 ldaa fcb0+1 ; read error code 1416 aa5b 39 rts 1417 fopen_is_directory: 1418 aa5c ce b1 a9 ldx #txt_is_directory 1419 aa5f bd a7 8a jsr str_print 1420 aa62 86 ff ldaa #$ff 1421 aa64 39 rts 1422 1423 ;;; 1424 ;;; Read one byte from file (must call fopen first) 1425 ;;; Out: Byte in A, carry set on error or eof 1426 ;;; 1427 fread: 1428 ;;; Check if we have reached end of file 1429 aa65 fe b2 3b ldx fcnth 1430 aa68 bc b2 28 cpx fsizeh 1431 aa6b 22 46 bhi fread_eof 1432 aa6d fe b2 3d ldx fcntl 1433 aa70 bc b2 2a cpx fsizel 1434 aa73 27 3e beq fread_eof 1435 ;;; We have bytes to read - check if first byte i sector 1436 aa75 18 xgdx 1437 aa76 84 01 anda #$01 ; mask away upper 7 bits from LOW file byte bointer 1438 aa78 18 xgdx 1439 aa79 8c 00 00 cpx #0 ; first byte of new sector? 1440 aa7c 26 12 bne fread_getbyte 1441 ;;; Load a new sector into buffer 1442 aa7e ce b2 33 ldx #fcb1 1443 aa81 bd d0 06 jsr sys_call 1444 aa84 7d b2 34 tst fcb1+1 ; read error code 1445 aa87 26 2b bne fread_error 1446 aa89 fe b2 39 ldx fsect 1447 aa8c 08 inx 1448 aa8d ff b2 39 stx fsect 1449 ;;; Pull one byte from buffer 1450 fread_getbyte: 1451 aa90 fc b2 3d ldd fcntl 1452 aa93 84 01 anda #$01 ; mask away upper 7 bits from D 1453 aa95 c3 b2 3f addd #secbuf ; calculate 1454 aa98 18 xgdx 1455 aa99 a6 00 ldaa ,x ; load byte from sector buffer 1456 aa9b 18 xgdx 1457 ;;; Increase file byte counter 1458 aa9c fc b2 3d ldd fcntl 1459 aa9f c3 00 01 addd #1 1460 aaa2 fd b2 3d std fcntl 1461 aaa5 24 09 bcc fread_getbyte1 1462 aaa7 fc b2 3b ldd fcnth 1463 aaaa c3 00 01 addd #1 1464 aaad fd b2 3b std fcnth 1465 fread_getbyte1: 1466 aab0 18 xgdx 1467 aab1 0c clc 1468 aab2 39 rts 1469 fread_eof: 1470 aab3 4f clra 1471 fread_error: 1472 aab4 0d sec 1473 aab5 39 rts 1474 1475 ;;; 1476 ;;; Get line from file and put in line buffer 1477 ;;; Carry set = EOF 1478 ;;; 1479 fgetline: 1480 aab6 ce b4 59 ldx #line_buffer 1481 aab9 ff b5 59 stx line_pointer 1482 fgetline_loop: 1483 aabc bd aa 65 jsr fread ; get byte from file 1484 aabf 25 1f bcs fgetline_eof 1485 aac1 81 0a cmpa #$0a ; end of line? 1486 aac3 27 14 beq fgetline_end 1487 aac5 81 0d cmpa #$0d ; ignore return 1488 aac7 27 f3 beq fgetline_loop 1489 aac9 fe b5 59 ldx line_pointer 1490 aacc a7 00 staa ,x 1491 aace 08 inx 1492 aacf 8c b5 58 cpx #line_buffer+255 1493 aad2 22 05 bhi fgetline_end 1494 aad4 ff b5 59 stx line_pointer 1495 aad7 20 e3 bra fgetline_loop 1496 fgetline_end: 1497 aad9 fe b5 59 ldx line_pointer 1498 aadc 6f 00 clr ,x ; end of string 1499 aade 0c clc 1500 aadf 39 rts 1501 fgetline_eof: 1502 aae0 fe b5 59 ldx line_pointer 1503 aae3 8c b4 59 cpx #line_buffer 1504 aae6 26 f1 bne fgetline_end 1505 aae8 6f 00 clr ,x 1506 aaea 0d sec 1507 aaeb 39 rts 1508 1509 ;;; 1510 ;;; Op code table 1511 ;;; 1512 ;;; Name 1513 ;;; Immediate,Direct,Indexed,Extended,Implied,Argtype 1514 ;;; NUL = no op-code exist 1515 ;;; 1516 0000 NUL: equ $00 ; No op-code exists 1517 0000 OP0: equ $00 ; Operand type 0 - no immediate operand 1518 0001 OP1: equ $01 ; Operand type 1 - one byte immediate operand 1519 0002 OP2: equ $02 ; Operand type 2 - two byte immediate operand 1520 0003 OP3: equ $03 ; Operand type 3 - one+addr byte immediate operand 1521 0004 OP4: equ $04 ; Operand type 4 - branch 1522 0005 OP5: equ $05 ; Operand type 5 - no operand 1523 0080 PS_ORG: equ $80 ; Pseudo op-code - org 1524 0081 PS_FCB: equ $81 ; Pseudo op-code - fcb 1525 0082 PS_FDB: equ $82 ; Pseudo op-code - fdb 1526 0083 PS_FCC: equ $83 ; Pseudo op-code - fcc 1527 0084 PS_RMB: equ $84 ; Pseudo op-code - rmb 1528 0085 PS_EQU: equ $85 ; Pseudo op-code - equ 1529 0086 PS_NUL: equ $86 ; Pseudo op-code - end 1530 opcode_table: 1531 ;;; Accumulator and memory manipulation instructions 1532 aaec 41 44 44 41 fcc "ADDA" 1533 aaf0 8b 9b ab bb 00 01 fcb $8b,$9b,$ab,$bb,NUL,OP1 1534 aaf6 41 44 44 42 fcc "ADDB" 1535 aafa cb db eb fb 00 01 fcb $cb,$db,$eb,$fb,NUL,OP1 1536 ab00 41 44 44 44 fcc "ADDD" 1537 ab04 c3 d3 e3 f3 00 02 fcb $c3,$d3,$e3,$f3,NUL,OP2 1538 ab0a 41 42 41 20 fcc "ABA " 1539 ab0e 00 00 00 00 1b 05 fcb NUL,NUL,NUL,NUL,$1b,OP5 1540 ab14 41 44 43 41 fcc "ADCA" 1541 ab18 89 99 a9 b9 00 01 fcb $89,$99,$a9,$b9,NUL,OP1 1542 ab1e 41 44 43 42 fcc "ADCB" 1543 ab22 c9 d9 e9 f9 00 01 fcb $c9,$d9,$e9,$f9,NUL,OP1 1544 ab28 41 4e 44 41 fcc "ANDA" 1545 ab2c 84 94 a4 b4 00 01 fcb $84,$94,$a4,$b4,NUL,OP1 1546 ab32 41 4e 44 42 fcc "ANDB" 1547 ab36 c4 d4 e4 f4 00 01 fcb $c4,$d4,$e4,$f4,NUL,OP1 1548 ab3c 42 49 54 41 fcc "BITA" 1549 ab40 85 95 a5 b5 00 01 fcb $85,$95,$a5,$b5,NUL,OP1 1550 ab46 42 49 54 42 fcc "BITB" 1551 ab4a c5 d5 e5 f5 00 01 fcb $c5,$d5,$e5,$f5,NUL,OP1 1552 ab50 43 4c 52 20 fcc "CLR " 1553 ab54 00 00 6f 7f 00 00 fcb NUL,NUL,$6f,$7f,NUL,OP0 1554 ab5a 43 4c 52 41 fcc "CLRA" 1555 ab5e 00 00 00 00 4f 05 fcb NUL,NUL,NUL,NUL,$4f,OP5 1556 ab64 43 4c 52 42 fcc "CLRB" 1557 ab68 00 00 00 00 5f 05 fcb NUL,NUL,NUL,NUL,$5f,OP5 1558 ab6e 43 4d 50 41 fcc "CMPA" 1559 ab72 81 91 a1 b1 00 01 fcb $81,$91,$a1,$b1,NUL,OP1 1560 ab78 43 4d 50 42 fcc "CMPB" 1561 ab7c c1 d1 e1 f1 00 01 fcb $c1,$d1,$e1,$f1,NUL,OP1 1562 ab82 43 42 41 20 fcc "CBA " 1563 ab86 00 00 00 00 11 05 fcb NUL,NUL,NUL,NUL,$11,OP5 1564 ab8c 43 4f 4d 20 fcc "COM " 1565 ab90 00 00 63 73 00 00 fcb NUL,NUL,$63,$73,NUL,OP0 1566 ab96 43 4f 4d 41 fcc "COMA" 1567 ab9a 00 00 00 00 43 05 fcb NUL,NUL,NUL,NUL,$43,OP5 1568 aba0 43 4f 4d 42 fcc "COMB" 1569 aba4 00 00 00 00 53 05 fcb NUL,NUL,NUL,NUL,$53,OP5 1570 abaa 4e 45 47 20 fcc "NEG " 1571 abae 00 00 60 70 00 00 fcb NUL,NUL,$60,$70,NUL,OP0 1572 abb4 4e 45 47 41 fcc "NEGA" 1573 abb8 00 00 00 00 40 05 fcb NUL,NUL,NUL,NUL,$40,OP5 1574 abbe 4e 45 47 42 fcc "NEGB" 1575 abc2 00 00 00 00 50 05 fcb NUL,NUL,NUL,NUL,$50,OP5 1576 abc8 44 41 41 20 fcc "DAA " 1577 abcc 00 00 00 00 19 05 fcb NUL,NUL,NUL,NUL,$19,OP5 1578 abd2 44 45 43 20 fcc "DEC " 1579 abd6 00 00 6a 7a 00 00 fcb NUL,NUL,$6a,$7a,NUL,OP0 1580 abdc 44 45 43 41 fcc "DECA" 1581 abe0 00 00 00 00 4a 05 fcb NUL,NUL,NUL,NUL,$4a,OP5 1582 abe6 44 45 43 42 fcc "DECB" 1583 abea 00 00 00 00 5a 05 fcb NUL,NUL,NUL,NUL,$5a,OP5 1584 abf0 45 4f 52 41 fcc "EORA" 1585 abf4 88 98 a8 b8 00 00 fcb $88,$98,$a8,$b8,NUL,OP0 1586 abfa 45 4f 52 42 fcc "EORB" 1587 abfe c8 d8 e8 f8 00 00 fcb $c8,$d8,$e8,$f8,NUL,OP0 1588 ac04 49 4e 43 20 fcc "INC " 1589 ac08 00 00 6c 7c 00 00 fcb NUL,NUL,$6c,$7c,NUL,OP0 1590 ac0e 49 4e 43 41 fcc "INCA" 1591 ac12 00 00 00 00 4c 05 fcb NUL,NUL,NUL,NUL,$4c,OP5 1592 ac18 49 4e 43 42 fcc "INCB" 1593 ac1c 00 00 00 00 5c 05 fcb NUL,NUL,NUL,NUL,$5c,OP5 1594 ac22 4c 44 41 41 fcc "LDAA" 1595 ac26 86 96 a6 b6 00 01 fcb $86,$96,$a6,$b6,NUL,OP1 1596 ac2c 4c 44 41 42 fcc "LDAB" 1597 ac30 c6 d6 e6 f6 00 01 fcb $c6,$d6,$e6,$f6,NUL,OP1 1598 ac36 4c 44 44 20 fcc "LDD " 1599 ac3a cc dc ec fc 00 02 fcb $cc,$dc,$ec,$fc,NUL,OP2 1600 ac40 4d 55 4c 20 fcc "MUL " 1601 ac44 00 00 00 00 3d 05 fcb NUL,NUL,NUL,NUL,$3d,OP5 1602 ac4a 4f 52 41 41 fcc "ORAA" 1603 ac4e 8a 9a aa ba 00 01 fcb $8a,$9a,$aa,$ba,NUL,OP1 1604 ac54 4f 52 41 42 fcc "ORAB" 1605 ac58 ca da ea fa 00 01 fcb $ca,$da,$ea,$fa,NUL,OP1 1606 ac5e 50 53 48 41 fcc "PSHA" 1607 ac62 00 00 00 00 36 05 fcb NUL,NUL,NUL,NUL,$36,OP5 1608 ac68 50 53 48 42 fcc "PSHB" 1609 ac6c 00 00 00 00 37 05 fcb NUL,NUL,NUL,NUL,$37,OP5 1610 ac72 50 55 4c 41 fcc "PULA" 1611 ac76 00 00 00 00 32 05 fcb NUL,NUL,NUL,NUL,$32,OP5 1612 ac7c 50 55 4c 42 fcc "PULB" 1613 ac80 00 00 00 00 33 05 fcb NUL,NUL,NUL,NUL,$33,OP5 1614 ac86 52 4f 4c 20 fcc "ROL " 1615 ac8a 00 00 69 79 00 00 fcb NUL,NUL,$69,$79,NUL,OP0 1616 ac90 52 4f 4c 41 fcc "ROLA" 1617 ac94 00 00 00 00 49 05 fcb NUL,NUL,NUL,NUL,$49,OP5 1618 ac9a 52 4f 4c 42 fcc "ROLB" 1619 ac9e 00 00 00 00 59 05 fcb NUL,NUL,NUL,NUL,$59,OP5 1620 aca4 52 4f 52 20 fcc "ROR " 1621 aca8 00 00 66 76 00 00 fcb NUL,NUL,$66,$76,NUL,OP0 1622 acae 52 4f 52 41 fcc "RORA" 1623 acb2 00 00 00 00 46 05 fcb NUL,NUL,NUL,NUL,$46,OP5 1624 acb8 52 4f 52 42 fcc "RORB" 1625 acbc 00 00 00 00 56 05 fcb NUL,NUL,NUL,NUL,$56,OP5 1626 acc2 41 53 4c 20 fcc "ASL " 1627 acc6 00 00 68 78 00 00 fcb NUL,NUL,$68,$78,NUL,OP0 1628 accc 41 53 4c 41 fcc "ASLA" 1629 acd0 00 00 00 00 48 05 fcb NUL,NUL,NUL,NUL,$48,OP5 1630 acd6 41 53 4c 42 fcc "ASLB" 1631 acda 00 00 00 00 58 05 fcb NUL,NUL,NUL,NUL,$58,OP5 1632 ace0 41 53 4c 44 fcc "ASLD" 1633 ace4 00 00 00 00 05 05 fcb NUL,NUL,NUL,NUL,$05,OP5 1634 acea 41 53 52 20 fcc "ASR " 1635 acee 00 00 67 77 00 00 fcb NUL,NUL,$67,$77,NUL,OP0 1636 acf4 41 53 52 41 fcc "ASRA" 1637 acf8 00 00 00 00 47 05 fcb NUL,NUL,NUL,NUL,$47,OP5 1638 acfe 41 53 52 42 fcc "ASRB" 1639 ad02 00 00 00 00 57 05 fcb NUL,NUL,NUL,NUL,$57,OP5 1640 ad08 4c 53 52 20 fcc "LSR " 1641 ad0c 00 00 64 74 00 00 fcb NUL,NUL,$64,$74,NUL,OP0 1642 ad12 4c 53 52 41 fcc "LSRA" 1643 ad16 00 00 00 00 44 05 fcb NUL,NUL,NUL,NUL,$44,OP5 1644 ad1c 4c 53 52 42 fcc "LSRB" 1645 ad20 00 00 00 00 54 05 fcb NUL,NUL,NUL,NUL,$54,OP5 1646 ad26 4c 53 52 44 fcc "LSRD" 1647 ad2a 00 00 00 00 04 05 fcb NUL,NUL,NUL,NUL,$04,OP5 1648 ad30 53 54 41 41 fcc "STAA" 1649 ad34 00 97 a7 b7 00 00 fcb NUL,$97,$a7,$b7,NUL,OP0 1650 ad3a 53 54 41 42 fcc "STAB" 1651 ad3e 00 d7 e7 f7 00 00 fcb NUL,$d7,$e7,$f7,NUL,OP0 1652 ad44 53 54 44 20 fcc "STD " 1653 ad48 00 dd ed fd 00 00 fcb NUL,$dd,$ed,$fd,NUL,OP0 1654 ad4e 53 55 42 41 fcc "SUBA" 1655 ad52 80 90 a0 b0 00 01 fcb $80,$90,$a0,$b0,NUL,OP1 1656 ad58 53 55 42 42 fcc "SUBB" 1657 ad5c c0 d0 e0 f0 00 01 fcb $c0,$d0,$e0,$f0,NUL,OP1 1658 ad62 53 55 42 44 fcc "SUBD" 1659 ad66 83 93 a3 b3 00 02 fcb $83,$93,$a3,$b3,NUL,OP2 1660 ad6c 53 42 41 20 fcc "SBA " 1661 ad70 00 00 00 00 10 05 fcb NUL,NUL,NUL,NUL,$10,OP5 1662 ad76 53 42 43 41 fcc "SBCA" 1663 ad7a 82 92 a2 b2 00 01 fcb $82,$92,$a2,$b2,NUL,OP1 1664 ad80 53 42 43 42 fcc "SBCB" 1665 ad84 c2 d2 e2 f2 00 01 fcb $c2,$d2,$e2,$f2,NUL,OP1 1666 ad8a 54 41 42 20 fcc "TAB " 1667 ad8e 00 00 00 00 16 05 fcb NUL,NUL,NUL,NUL,$16,OP5 1668 ad94 54 42 41 20 fcc "TBA " 1669 ad98 00 00 00 00 17 05 fcb NUL,NUL,NUL,NUL,$17,OP5 1670 ad9e 54 53 54 20 fcc "TST " 1671 ada2 00 00 6d 7d 00 00 fcb NUL,NUL,$6d,$7d,NUL,OP0 1672 ada8 54 53 54 41 fcc "TSTA" 1673 adac 00 00 00 00 4d 05 fcb NUL,NUL,NUL,NUL,$4d,OP5 1674 adb2 54 53 54 42 fcc "TSTB" 1675 adb6 00 00 00 00 5d 05 fcb NUL,NUL,NUL,NUL,$5d,OP5 1676 adbc 41 49 4d 20 fcc "AIM " 1677 adc0 00 71 61 00 00 03 fcb NUL,$71,$61,NUL,NUL,OP3 1678 adc6 4f 49 4d 20 fcc "OIM " 1679 adca 00 71 61 00 00 03 fcb NUL,$71,$61,NUL,NUL,OP3 1680 add0 45 49 4d 20 fcc "EIM " 1681 add4 00 75 65 00 00 03 fcb NUL,$75,$65,NUL,NUL,OP3 1682 adda 54 49 4d 20 fcc "TIM " 1683 adde 00 7b 6b 00 00 03 fcb NUL,$7b,$6b,NUL,NUL,OP3 1684 ;;; Index register and stack manipulation instructions 1685 ade4 43 50 58 20 fcc "CPX " 1686 ade8 8c 9c ac bc 00 02 fcb $8c,$9c,$ac,$bc,NUL,OP2 1687 adee 44 45 58 20 fcc "DEX " 1688 adf2 00 00 00 00 09 05 fcb NUL,NUL,NUL,NUL,$09,OP5 1689 adf8 44 45 53 20 fcc "DES " 1690 adfc 00 00 00 00 34 05 fcb NUL,NUL,NUL,NUL,$34,OP5 1691 ae02 49 4e 58 20 fcc "INX " 1692 ae06 00 00 00 00 08 05 fcb NUL,NUL,NUL,NUL,$08,OP5 1693 ae0c 49 4e 53 20 fcc "INS " 1694 ae10 00 00 00 00 31 05 fcb NUL,NUL,NUL,NUL,$31,OP5 1695 ae16 4c 44 58 20 fcc "LDX " 1696 ae1a ce de ee fe 00 02 fcb $ce,$de,$ee,$fe,NUL,OP2 1697 ae20 4c 44 53 20 fcc "LDS " 1698 ae24 8e 9e ae be 00 02 fcb $8e,$9e,$ae,$be,NUL,OP2 1699 ae2a 53 54 58 20 fcc "STX " 1700 ae2e 00 df ef ff 00 00 fcb NUL,$df,$ef,$ff,NUL,OP0 1701 ae34 53 54 53 20 fcc "STS " 1702 ae38 00 9f af bf 00 00 fcb NUL,$9f,$af,$bf,NUL,OP0 1703 ae3e 54 58 53 20 fcc "TXS " 1704 ae42 00 00 00 00 35 05 fcb NUL,NUL,NUL,NUL,$35,OP5 1705 ae48 54 53 58 20 fcc "TSX " 1706 ae4c 00 00 00 00 30 05 fcb NUL,NUL,NUL,NUL,$30,OP5 1707 ae52 41 42 58 20 fcc "ABX " 1708 ae56 00 00 00 00 3a 05 fcb NUL,NUL,NUL,NUL,$3a,OP5 1709 ae5c 50 53 48 58 fcc "PSHX" 1710 ae60 00 00 00 00 3c 05 fcb NUL,NUL,NUL,NUL,$3c,OP5 1711 ae66 50 55 4c 58 fcc "PULX" 1712 ae6a 00 00 00 00 38 05 fcb NUL,NUL,NUL,NUL,$38,OP5 1713 ae70 58 47 44 58 fcc "XGDX" 1714 ae74 00 00 00 00 18 05 fcb NUL,NUL,NUL,NUL,$18,OP5 1715 ;;; Jump and branch instructions 1716 ae7a 42 52 41 20 fcc "BRA " 1717 ae7e 20 00 00 00 00 04 fcb $20,NUL,NUL,NUL,NUL,OP4 1718 ae84 42 52 4e 20 fcc "BRN " 1719 ae88 21 00 00 00 00 04 fcb $21,NUL,NUL,NUL,NUL,OP4 1720 ae8e 42 43 43 20 fcc "BCC " 1721 ae92 24 00 00 00 00 04 fcb $24,NUL,NUL,NUL,NUL,OP4 1722 ae98 42 43 53 20 fcc "BCS " 1723 ae9c 25 00 00 00 00 04 fcb $25,NUL,NUL,NUL,NUL,OP4 ; same as BLO 1724 aea2 42 4c 4f 20 fcc "BLO " 1725 aea6 25 00 00 00 00 04 fcb $25,NUL,NUL,NUL,NUL,OP4 ; same as BCS 1726 aeac 42 45 51 20 fcc "BEQ " 1727 aeb0 27 00 00 00 00 04 fcb $27,NUL,NUL,NUL,NUL,OP4 1728 aeb6 42 47 45 20 fcc "BGE " 1729 aeba 2c 00 00 00 00 04 fcb $2c,NUL,NUL,NUL,NUL,OP4 1730 aec0 42 47 54 20 fcc "BGT " 1731 aec4 2e 00 00 00 00 04 fcb $2e,NUL,NUL,NUL,NUL,OP4 1732 aeca 42 48 49 20 fcc "BHI " 1733 aece 22 00 00 00 00 04 fcb $22,NUL,NUL,NUL,NUL,OP4 1734 aed4 42 4c 45 20 fcc "BLE " 1735 aed8 2f 00 00 00 00 04 fcb $2f,NUL,NUL,NUL,NUL,OP4 1736 aede 42 4c 53 20 fcc "BLS " 1737 aee2 23 00 00 00 00 04 fcb $23,NUL,NUL,NUL,NUL,OP4 1738 aee8 42 4c 54 20 fcc "BLT " 1739 aeec 2d 00 00 00 00 04 fcb $2d,NUL,NUL,NUL,NUL,OP4 1740 aef2 42 4d 49 20 fcc "BMI " 1741 aef6 2b 00 00 00 00 04 fcb $2b,NUL,NUL,NUL,NUL,OP4 1742 aefc 42 4e 45 20 fcc "BNE " 1743 af00 26 00 00 00 00 04 fcb $26,NUL,NUL,NUL,NUL,OP4 1744 af06 42 56 43 20 fcc "BVC " 1745 af0a 28 00 00 00 00 04 fcb $28,NUL,NUL,NUL,NUL,OP4 1746 af10 42 56 53 20 fcc "BVS " 1747 af14 29 00 00 00 00 04 fcb $29,NUL,NUL,NUL,NUL,OP4 1748 af1a 42 50 4c 20 fcc "BPL " 1749 af1e 2a 00 00 00 00 04 fcb $2a,NUL,NUL,NUL,NUL,OP4 1750 af24 42 53 52 20 fcc "BSR " 1751 af28 8d 00 00 00 00 04 fcb $8d,NUL,NUL,NUL,NUL,OP4 1752 af2e 4a 4d 50 20 fcc "JMP " 1753 af32 00 00 6e 7e 00 00 fcb NUL,NUL,$6e,$7e,NUL,OP0 1754 af38 4a 53 52 20 fcc "JSR " 1755 af3c 00 9d ad bd 00 00 fcb NUL,$9d,$ad,$bd,NUL,OP0 1756 af42 4e 4f 50 20 fcc "NOP " 1757 af46 00 00 00 00 01 05 fcb NUL,NUL,NUL,NUL,$01,OP5 1758 af4c 52 54 49 20 fcc "RTI " 1759 af50 00 00 00 00 3b 05 fcb NUL,NUL,NUL,NUL,$3b,OP5 1760 af56 52 54 53 20 fcc "RTS " 1761 af5a 00 00 00 00 39 05 fcb NUL,NUL,NUL,NUL,$39,OP5 1762 af60 53 57 49 20 fcc "SWI " 1763 af64 00 00 00 00 3f 05 fcb NUL,NUL,NUL,NUL,$3f,OP5 1764 af6a 57 41 49 20 fcc "WAI " 1765 af6e 00 00 00 00 3e 05 fcb NUL,NUL,NUL,NUL,$3e,OP5 1766 af74 53 4c 50 20 fcc "SLP " 1767 af78 00 00 00 00 1a 05 fcb NUL,NUL,NUL,NUL,$1a,OP5 1768 ;;; Condition code register manipulation 1769 af7e 43 4c 43 20 fcc "CLC " 1770 af82 00 00 00 00 0c 05 fcb NUL,NUL,NUL,NUL,$0c,OP5 1771 af88 43 4c 49 20 fcc "CLI " 1772 af8c 00 00 00 00 0e 05 fcb NUL,NUL,NUL,NUL,$0e,OP5 1773 af92 43 4c 56 20 fcc "CLV " 1774 af96 00 00 00 00 0a 05 fcb NUL,NUL,NUL,NUL,$0a,OP5 1775 af9c 53 45 43 20 fcc "SEC " 1776 afa0 00 00 00 00 0d 05 fcb NUL,NUL,NUL,NUL,$0d,OP5 1777 afa6 53 45 49 20 fcc "SEI " 1778 afaa 00 00 00 00 0f 05 fcb NUL,NUL,NUL,NUL,$0f,OP5 1779 afb0 53 45 56 20 fcc "SEV " 1780 afb4 00 00 00 00 0b 05 fcb NUL,NUL,NUL,NUL,$0b,OP5 1781 afba 54 41 50 20 fcc "TAP " 1782 afbe 00 00 00 00 06 05 fcb NUL,NUL,NUL,NUL,$06,OP5 1783 afc4 54 50 41 20 fcc "TPA " 1784 afc8 00 00 00 00 07 05 fcb NUL,NUL,NUL,NUL,$07,OP5 1785 ;;; Pseudo op-codes 1786 afce 4f 52 47 20 fcc "ORG " 1787 afd2 00 00 00 00 00 80 fcb NUL,NUL,NUL,NUL,NUL,PS_ORG 1788 afd8 46 43 42 20 fcc "FCB " 1789 afdc 00 00 00 00 00 81 fcb NUL,NUL,NUL,NUL,NUL,PS_FCB 1790 afe2 46 44 42 20 fcc "FDB " 1791 afe6 00 00 00 00 00 82 fcb NUL,NUL,NUL,NUL,NUL,PS_FDB 1792 afec 46 43 43 20 fcc "FCC " 1793 aff0 00 00 00 00 00 83 fcb NUL,NUL,NUL,NUL,NUL,PS_FCC 1794 aff6 52 4d 42 20 fcc "RMB " 1795 affa 00 00 00 00 00 84 fcb NUL,NUL,NUL,NUL,NUL,PS_RMB 1796 b000 45 51 55 20 fcc "EQU " 1797 b004 00 00 00 00 00 85 fcb NUL,NUL,NUL,NUL,NUL,PS_EQU 1798 b00a 45 4e 44 20 fcc "END " 1799 b00e 00 00 00 00 00 86 fcb NUL,NUL,NUL,NUL,NUL,PS_NUL ; do nothing 1800 b014 53 50 43 20 fcc "SPC " 1801 b018 00 00 00 00 00 86 fcb NUL,NUL,NUL,NUL,NUL,PS_NUL ; do nothing 1802 b01e 4e 41 4d 20 fcc "NAM " 1803 b022 00 00 00 00 00 86 fcb NUL,NUL,NUL,NUL,NUL,PS_NUL ; do nothing 1804 b028 4e 41 4d 45 fcc "NAME" 1805 b02c 00 00 00 00 00 86 fcb NUL,NUL,NUL,NUL,NUL,PS_NUL ; do nothing 1806 b032 54 54 4c 20 fcc "TTL " 1807 b036 00 00 00 00 00 86 fcb NUL,NUL,NUL,NUL,NUL,PS_NUL ; do nothing 1808 b03c 4f 50 54 20 fcc "OPT " 1809 b040 00 00 00 00 00 86 fcb NUL,NUL,NUL,NUL,NUL,PS_NUL ; do nothing 1810 b046 50 41 47 20 fcc "PAG " 1811 b04a 00 00 00 00 00 86 fcb NUL,NUL,NUL,NUL,NUL,PS_NUL ; do nothing 1812 b050 50 41 47 45 fcc "PAGE" 1813 b054 00 00 00 00 00 86 fcb NUL,NUL,NUL,NUL,NUL,PS_NUL ; do nothing 1814 ;;; End of table 1815 b05a 00 fcb $00 1816 1817 ;;; 1818 ;;; Text strings 1819 ;;; 1820 txt_help: 1821 b05b 36 33 30 31 2f 36 fcc "6301/6303 assembler v1.0.2" 33 30 33 20 61 73 73 65 6d 62 6c 65 72 20 76 31 2e 30 2e 32 1822 b075 0d 0a fcb $0d,$0a 1823 b077 44 61 6e 69 65 6c fcc "Daniel Tufvesson 2017-2022" 20 54 75 66 76 65 73 73 6f 6e 20 32 30 31 37 2d 32 30 32 32 1824 b091 0d 0a fcb $0d,$0a 1825 b093 53 79 6e 74 61 78 fcc "Syntax: asm [files] [-l] [-e] [-d] [-tXXXX]" 3a 20 61 73 6d 20 5b 66 69 6c 65 73 5d 20 5b 2d 6c 5d 20 5b 2d 65 5d 20 5b 2d 64 5d 20 5b 2d 74 58 58 58 58 5d 1826 b0be 0d 0a fcb $0d,$0a 1827 b0c0 4f 70 74 69 6f 6e fcc "Options:" 73 3a 1828 b0c8 0d 0a fcb $0d,$0a 1829 b0ca 20 20 2d 6c 20 20 fcc " -l Print listing" 20 20 20 20 50 72 69 6e 74 20 6c 69 73 74 69 6e 67 1830 b0e1 0d 0a fcb $0d,$0a 1831 b0e3 20 20 2d 65 20 20 fcc " -e Hide errors" 20 20 20 20 48 69 64 65 20 65 72 72 6f 72 73 1832 b0f8 0d 0a fcb $0d,$0a 1833 b0fa 20 20 2d 64 20 20 fcc " -d Assemble directly to memory" 20 20 20 20 41 73 73 65 6d 62 6c 65 20 64 69 72 65 63 74 6c 79 20 74 6f 20 6d 65 6d 6f 72 79 1834 b11f 0d 0a fcb $0d,$0a 1835 b121 20 20 2d 74 58 58 fcc " -tXXXX Move symbol table to address $XXXX (default $0100)" 58 58 20 20 4d 6f 76 65 20 73 79 6d 62 6f 6c 20 74 61 62 6c 65 20 74 6f 20 61 64 64 72 65 73 73 20 24 58 58 58 58 20 28 64 65 66 61 75 6c 74 20 24 30 31 30 30 29 1836 b15d 0d 0a 00 fcb $0d,$0a,$00 1837 txt_labels: 1838 b160 0d 0a fcb $0d,$0a 1839 b162 4c 61 62 65 6c 73 fcc "Labels:" 3a 1840 b169 0d 0a 00 fcb $0d,$0a,$00 1841 txt_errors: 1842 b16c 0d 0a fcb $0d,$0a 1843 b16e 45 72 72 6f 72 73 fcc "Errors: " 3a 20 1844 b176 00 fcb $00 1845 txt_no_errors: 1846 b177 0d 0a fcb $0d,$0a 1847 b179 4e 6f 20 65 72 72 fcc "No errors" 6f 72 73 1848 b182 0d 0a 0a 00 fcb $0d,$0a,$0a,$00 1849 txt_not_found: 1850 b186 46 69 6c 65 20 6e fcc "File not found" 6f 74 20 66 6f 75 6e 64 1851 b194 0d 0a 00 fcb $0d,$0a,$00 1852 txt_read_error: 1853 b197 46 69 6c 65 20 72 fcc "File read error" 65 61 64 20 65 72 72 6f 72 1854 b1a6 0d 0a 00 fcb $0d,$0a,$00 1855 txt_is_directory: 1856 b1a9 45 6e 74 72 79 20 fcc "Entry is a directory" 69 73 20 61 20 64 69 72 65 63 74 6f 72 79 1857 b1bd 0d 0a 00 fcb $0d,$0a,$00 1858 txt_invalid_opcode: 1859 b1c0 49 6e 76 61 6c 69 fcc "Invalid op-code" 64 20 6f 70 2d 63 6f 64 65 1860 b1cf 0d 0a 00 fcb $0d,$0a,$00 1861 txt_duplicate_label: 1862 b1d2 44 75 70 6c 69 63 fcc "Duplicate label" 61 74 65 20 6c 61 62 65 6c 1863 b1e1 0d 0a 00 fcb $0d,$0a,$00 1864 txt_label_not_found: 1865 b1e4 4c 61 62 65 6c 20 fcc "Label not found" 6e 6f 74 20 66 6f 75 6e 64 1866 b1f3 0d 0a 00 fcb $0d,$0a,$00 1867 txt_invalid_expression: 1868 b1f6 49 6e 76 61 6c 69 fcc "Invalid expression" 64 20 65 78 70 72 65 73 73 69 6f 6e 1869 b208 0d 0a 00 fcb $0d,$0a,$00 1870 txt_branch_range: 1871 b20b 42 72 61 6e 63 68 fcc "Branch out of range" 20 6f 75 74 20 6f 66 20 72 61 6e 67 65 1872 b21e 0d 0a 00 fcb $0d,$0a,$00 1873 1874 ;;; 1875 ;;; File system variables 1876 ;;; 1877 b221 01 fcb0: fcb $01 ; command 1878 b222 00 fcb 0 ; error code 1879 b223 00 00 fname0: fdb 0 ; file name 1880 b225 00 fcb 0 ; flags 1881 b226 00 00 fdb 0 ; sectors 1882 b228 00 00 fsizeh: fdb 0 ; size MSB 1883 b22a 00 00 fsizel: fdb 0 ; size LSB 1884 b22c 00 00 fdb 0 ; year 1885 b22e 00 fcb 0 ; month 1886 b22f 00 fcb 0 ; day 1887 b230 00 fcb 0 ; hours 1888 b231 00 fcb 0 ; minutes 1889 b232 00 fcb 0 ; seconds 1890 * 1891 b233 11 fcb1: fcb $11 ; command 1892 b234 00 fcb 0 ; error code 1893 b235 00 00 fname1: fdb 0 ; file name 1894 b237 b2 3f fdb secbuf ; destination address 1895 b239 00 00 fsect: fdb 0 ; sector number 1896 * 1897 b23b 00 00 fcnth: fdb 0 ; bytes read MSB 1898 b23d 00 00 fcntl: fdb 0 ; bytes read LSB 1899 * 1900 b23f secbuf: rmb 512 1901 1902 ;;; 1903 ;;; Program variables 1904 ;;; 1905 temp: 1906 b43f 00 00 fdb 0 ; general temp storage 1907 str1: 1908 b441 00 00 fdb 0 ; string compare string 1 1909 str2: 1910 b443 00 00 fdb 0 ; string compare string 2 1911 number: 1912 b445 00 00 fdb 0 ; result of numeric operation 1913 exp_sign: 1914 b447 00 fcb 0 ; sign of current expression operation 1915 exp_pointer: 1916 b448 00 00 fdb 0 ; pointer to current part of expression 1917 exp_result: 1918 b44a 00 00 fdb 0 ; result of expression 1919 pass2_flag: 1920 b44c 00 fcb 0 ; set on assembly pass 2 1921 errors: 1922 b44d 00 00 fdb 0 ; number of reported errors 1923 listing_flag: 1924 b44f 00 fcb 0 ; set for output listing 1925 noerr_flag: 1926 b450 00 fcb 0 ; set to hide errors 1927 direct_mem_flag: 1928 b451 00 fcb 0 ; set to write result directly to memory 1929 outdec_digit: 1930 b452 rmb 1 ; decimal print digit counter 1931 outdec_loop1: 1932 b453 rmb 1 ; decimal print loop1 counter 1933 outdec_loop2: 1934 b454 rmb 1 ; decimal print loop2 counter 1935 1936 * 1937 *tstargs: fcc "asm test.asm -l" 1938 * fcb 0 1939 * 1940 args: 1941 b455 rmb 2 ; pointer to input argument string 1942 args_file: 1943 b457 rmb 2 ; pointer to input file name argument 1944 line_buffer: 1945 b459 rmb 256 ; buffer containing current assembly line 1946 line_pointer: 1947 b559 rmb 2 ; pointer within current assembly line 1948 line_pointer_label: 1949 b55b rmb 2 ; pointer to label in assembly line (set to zero if no label) 1950 line_pointer_opcode: 1951 b55d rmb 2 ; pointer to op-code in assembly line (set to zero if no op-code) 1952 line_pointer_operand: 1953 b55f rmb 2 ; pointer to operand in assembly line (set to zero if no operand) 1954 line_counter: 1955 b561 rmb 2 ; assembly line number 1956 label_table: 1957 b563 rmb 2 ; pointer to beginning of label table (default $0100) 1958 label_table_position: 1959 b565 rmb 2 ; pointer to next free space in label table 1960 program_counter: 1961 b567 rmb 2 ; assembly program counter 1962 program_counter_bump: 1963 b569 rmb 2 ; assembly program counter bump by pseudo instructions 1964 opcode_buffer: 1965 b56b rmb 4 ; op-code from current line 1966 opcode_pointer: 1967 b56f rmb 2 ; pointer to current op-code in table 1968 assembly_length: 1969 b571 rmb 1 ; length of assembly 1970 assembly_bytes: 1971 b572 rmb 256 ; result of assembly 1972 1973 ;;; 1974 ;;; Label table 1975 ;;; Format: 00|00|...|00|00 1976 ;;; Number of errors 0