背景:
我正在编写一个程序,要求用户输入“1”或“2”,该值的ASCII值加-49,并且取决于总和是0还是1,将打印一个字符串
冲突:
当我模拟我的代码时,我注意到下图中突出显示了一条奇怪的指令。我不知道它来自哪里,但是当它被执行时它会给我错误A trap was executed with an illegal vector number.
它来自哪里,我该如何解决这个问题?
谢谢!
CODE:
.ORIG x3000
; INPUT REQUEST: Store input value into R0
START TRAP x23
; FILL PROCESS: Put value -49 in address of FN. Load value in FN address (-49) into R4
LD R4, FN
FN .FILL #-49
; 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
BRnzp 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
BRnzp 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"
.END