Assembler in GNU as syntax, objdump-style disassembly, UCASE$ and LCASE$
The monitor's assembler takes GNU as directives (.org, .equ, .byte, .half, .word, .ascii, .string, .space, .align, .balign ...), # comments, 0x/0b numbers, '\n' constants, . for the current address, << >> ^ ~, %hi/%lo and the FP CSR short forms; the old ORG/DB/EQU/0FFH forms remain as aliases. The disassembler prints lower case and 0x hex as objdump does. The monitor is built with -msave-restore and puts .rodata first, to fit its ROM. BASIC gains UCASE$ and LCASE$. Manual, README and tests updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
25c8286cf2
commit
fa4752fd7a
16 files changed
+7921
-7615
No files matched your search
+12
-10
@@ -208,6 +208,7 @@ module tb_terminal;
|
||||
ch = cellraw(rr, cc);
|
||||
if (go && ch >= "0" && ch <= "9") hex_at = hex_at * 16 + (ch - "0");
|
||||
else if (go && ch >= "A" && ch <= "F") hex_at = hex_at * 16 + (ch - "A" + 10);
|
||||
else if (go && ch >= "a" && ch <= "f") hex_at = hex_at * 16 + (ch - "a" + 10);
|
||||
else go = 0;
|
||||
end
|
||||
end
|
||||
@@ -559,7 +560,7 @@ module tb_terminal;
|
||||
pc_a = screen_pc(0);
|
||||
wait_at(9, 0, ">");
|
||||
jp_txt = {cellraw(9, 19), cellraw(9, 20)};
|
||||
jp_to = hex_at(9, 21);
|
||||
jp_to = hex_at(9, 23); // "j 0x54a4"
|
||||
dump_screen;
|
||||
// the float registers, in place of the memory window, and setting one
|
||||
uart_str("F\015");
|
||||
@@ -573,9 +574,9 @@ module tb_terminal;
|
||||
wait_at(0, 50, "STOPPED BY STEP");
|
||||
wait_at(29, 0, "> ");
|
||||
pc_b = screen_pc(0);
|
||||
// MONITOR stops on a J (to the end of BASIC's statement routine): one
|
||||
// MONITOR stops on a j (to the end of BASIC's statement routine): one
|
||||
// step must land exactly on its target
|
||||
if (jp_txt == "J " && pc_b == jp_to) $display("PASS step: PC %h -> %h", pc_a, pc_b);
|
||||
if (jp_txt == "j " && pc_b == jp_to) $display("PASS step: PC %h -> %h", pc_a, pc_b);
|
||||
else begin $display("FAIL step: PC %h -> %h, wanted %h (%0s)", pc_a, pc_b, jp_to, jp_txt); errors = errors + 1; end
|
||||
// a breakpoint where the step stopped (the end of BASIC's statement
|
||||
// routine), hit again by OUT; leaving from it steps off it first
|
||||
@@ -632,16 +633,17 @@ module tb_terminal;
|
||||
wait_row(0, " 72 73");
|
||||
|
||||
// ---- the assembler: source typed into BASIC, saved, assembled by the monitor
|
||||
uart_str({"NEW\01510 ORG 12000H\01520 START: LA A1,MSG\01530 LOOP: LBU A0,0(A1)\015",
|
||||
"40 BEQZ A0,DONE\01550 WAIT: LBU T0,-256(ZERO)\01560 ANDI T0,T0,2\015"});
|
||||
uart_str({"70 BEQZ T0,WAIT\01580 SB A0,-255(ZERO)\01590 ADDI A1,A1,1\015100 J LOOP\015",
|
||||
"110 DONE: RET\015"});
|
||||
uart_str({"120 MSG: DB \"ASM OK\",0 ; THE MESSAGE\015SAVE \"HELLO\"\015MONITOR\015"});
|
||||
// GNU as syntax, typed in lower case (BASIC stores it in capitals)
|
||||
uart_str({"NEW\01510 .org 0x12000\01520 start: la a1, msg\01530 loop: lbu a0, 0(a1)\015",
|
||||
"40 beqz a0, done\01550 wait: lbu t0, -256(zero)\01560 andi t0, t0, 2\015"});
|
||||
uart_str({"70 beqz t0, wait\01580 sb a0, -255(zero)\01590 addi a1, a1, 1\015100 j loop\015",
|
||||
"110 done: ret\015"});
|
||||
uart_str({"120 msg: .string \"ASM OK\" # the message\015SAVE \"HELLO\"\015MONITOR\015"});
|
||||
wait_at(29, 0, "> ");
|
||||
uart_str("ASM \"HELLO\"\015");
|
||||
wait_at(29, 40, "ASSEMBLED 12000-12032");
|
||||
uart_str("A 12100\015LI A0,66\015\015");
|
||||
wait_at(9, 2, "12100 04200513 LI A0,66");
|
||||
uart_str("A 12100\015LI A0,'B'\015\015"); // the line assembler, in capitals
|
||||
wait_at(9, 2, "12100 04200513 li a0,66");
|
||||
// an Intel HEX record above 64K (an extended address first) and the end record
|
||||
uart_str(":020000040001F9\015:03210000AABBCCAB\015:00000001FF\015");
|
||||
wait_at(29, 40, "HEX LOADED 12100-12102");
|
||||
|
||||
Reference in new issue
Block a user