背景:
我正在编写一个程序,要求用户输入“1”或“2”,该值的ASCII值加-49,并且取决于总和是0还是1,将打印一个字符串
错误和冲突:
1E:
Line 18: Expected register operand, but found 'START' instead
Line 23: Expected register operand, but found 'START' instead
1C:
我很快从这个错误中了解到我不能将JMP作为标签。我的直觉是它只会通过START(第4行)进入指令。我想要这样,以便在case指令结束时,它会重新开始并询问另一个数字,但是我只能将JMP发送到寄存器。我该如何进行此更改?
2E:
Line 21: Unrecognized opcode or syntax error at or before 'CAS2I'
Line 26: Unrecognized opcode or syntax error at or before 'CAS2I'
2C:
我真的不确定第21行和第26行出了什么问题。这里分别是:
CAS1I LEA R1, CAS1S
CAS2I LEA R2, CAS2S
3E:
Line 21: Duplicate label 'START' found with label on line 4
Line 26: Duplicate label 'START' found with label on line 4
3C:
由于“重复”一词,这些错误让我失望。我只有START一次写入,而第21和26行都有相同的错误,它们的内容是不同的。他们分别在这里:
CAS2I LEA R2, CAS2S
CAS1S .STRINGZ "1100\n0110\n0011\n1001\n1100\n0110\n0011\n1001\n1100\n0110\n0011\n1001\n1100\n1001\n0011\n0110\n1100\n1001\n0011\n0110\n1100"
CODE:
.ORIG x3000
; INPUT REQUEST: Store input value into R0
START TRAP x23
; CASE CREATION: Add -49 (R4) to input value (R0)
ADD R3, R0, R4
; BRANCHES: If R3 = 0, execute Case 1 Instruction. If R3 > 0 (specifically if R3 = 1), execute Case 2 Instruction
BRz CAS1I
BRp CAS2I
; BRANCH CASES:
; CASE 1 INSTRUCTION: Load Case 1 String into R1. Print string in R1. Jump to START (input request).
CAS1I LEA R1, CAS1S
TRAP x22
JMP START
; CASE 2 INSTRUCTION: Load Case 2 String into R2. Print string in R2. Jump to START (input request).
CAS2I LEA R2, CAS2S
TRAP x22
JMP START
; STRING STORAGE: Store input patterns in Case 1 String and Case 2 String
CAS1S .STRINGZ "1100\n0110\n0011\n1001\n1100\n0110\n0011\n1001\n1100\n0110\n0011\n1001\n1100\n1001\n0011\n0110\n1100\n1001\n0011\n0110\n1100"
CAS2S .STRINGZ "1100\n1001\n0011\n0110\n1100"
; FILL PROCESS: Put value -49 in address of FN. Load value in FN address (-49) into R4
FN .FILL #-49
LD R4, FN
.END
结论:
我认为我对这个程序有正确的想法,但似乎我缺少正确执行此操作的信息。任何建议也将不胜感激。谢谢!