试图让这段代码运行它是LC3的地址簿,但我不断收到以下错误:
第21行:指令引用无法用9位有符号PC偏移量表示的标签'BOOK'
第22行:指令引用标签'CURRENT',它不能用9位有符号PC偏移量表示
第67行:指令引用标签'CURRENT'无法用9位有符号PC偏移量表示
第69行:指令引用标签'CURRENT',无法用9位有符号PC偏移量表示
第77行:指令引用标签'CURRENT',它不能用9位有符号PC偏移量表示
第79行:指令引用无法用9位有符号PC偏移量表示的标签“CURRENT”
第90行:指令引用标签'PROMPT5',无法用9位有符号PC偏移量表示
代码在这里 - > http://pastebin.com/8nZk3Dfd
任何帮助表示赞赏,在线发现此代码但希望使其正常工作。
答案 0 :(得分:0)
您收到这些错误的原因是因为您在大量字符串后面有这些变量。请记住,.STRINGZ
中的每个字符占用一块内存,当您的变量离想要使用它们的代码太远时,就会出现PC偏移错误。
如果在字符串提示之前移动变量,那么这些错误就会消失。
答案 1 :(得分:0)
这里修复了一些错误,你的程序现在将组装并至少打印所有字符串,但我会将运行时错误修复给你。
.ORIG X3000 ;INITIALIZE PROGRAM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;REGISTER DATA
;REGISTER 0 IS USED FOR INPUTTING INFORMATION BY THE USER
;REGISTER 1 IS USED AS THE MENU TESTER (CAN BE USED, ALWAYS INITIALIZED)
;REGISTER 2 IS COUNTER WITH R5 (CAN BE USED, ALWAYS REINITIALIZED)
;REGISTER 3 IS ASCII CONVERTER (CAN BE USED, ALWAYS REINITIALIZED)
;REGISTER 4 IS USED TO STORE MEMORY LOCATION OF BOOK (DO NOT USE)
;REGISTER 5 IS USED TO COUNT HOW MANY FILES HAVE BEEN STORED (DO NOT USE)
;REGISTER 6 IS USED AS A COUNTER IN STORING AND FINDING INFORMATION (DO NOT USE)
;REGISTER 7 IS UNUSED
;DO NOT USE R4, R5, R6, R7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;START OF MAIN CODE
BRnzp MAIN
PROMPT .STRINGZ "Enter 1 to add a new record and 2 to find a record and 0 to exit:"
FULLBK .STRINGZ "Address book is full. Would you like to find a record?"
MAIN
AND R5, R5, #0 ;INITIALIZES REGISTER
LD R0, BOOK
LDI R0, CURRENT
MENU ;MENU FUNCTION
LEA R0, PROMPT ;PROMPT THEM TO ADD OR FIND
PUTs
IN
LD R3, NTHIRTY ;LOADS NEGATIVE THIRTY INTO R3
ADD R0,R0,R3 ;CONVERTS R0 INTO DECIMAL FROM ASCII
BRnz SKIP ;CONTINUE IF NOT A 0 OR NEGATIVE NUMBER
FNDLOOP LD R1, TWO ;LOAD R2 WITH 2
ADD R1, R1, #-4 ;MAKES 2 INTO -2
ADD R1, R0, R1 ;TESTS TO SEE IF USER INPUT WAS A 1 TO FIND AN ADDRESS
BRn ADDLOOP ;LEAVE FIND LOOP
BRz FIND ;CALLS THE FIND FUNCTION
BRp MENU ;INVALID NUMBER, GOT BACK TO MENU
ADDLOOP LD R1, ONE ;LOAD R1 WITH 1
ADD R1, R1, #-2 ;MAKES 1 INTO -1
ADD R1, R0, R1 ;TESTS TO SEE IF USER INPUT WAS A 1 TO ADD AN ADDRESS
BRnp SKIP ;LEAVE ADD LOOP TO A HALT
BRz ADDRESS ;CALLS THE ADD FUNCTION
HOWFULL AND R2, R2, #0 ;INITIALIZES R2
ADD R2, R2, #-9 ;MAKES R2 -10
ADD R5, R5, #1 ;INCREMENTS R5 BY 1
ADD R2, R2, R5 ;ADDS R2 AND R5 TOGETHER, IF R5 BECOMES 10 IT WILL EQUAL 0
BRz BKFULL ;IF R2 IS ZERO, ADDRESS BOOK IS FULL
BRnzp MENU ;BACK TO THE BEGINNING
SKIP
LEA R0, GBYE ;PROMPTS A GOODBYE MESSAGE
PUTs
HALT ;CALL PROGRAM TO A HALT
BKFULL
LEA R0, FULLBK ;PROMPTS A FULL BOOK MESSAGE
PUTs
IN
LD R1, TWO ;LOAD R2 WITH 2
ADD R1, R1, #-4 ;MAKES 2 INTO -2
ADD R1, R0, R1 ;TESTS TO SEE IF USER INPUT WAS A 1 TO FIND AN ADDRESS
BRz FIND ;IF 0 CONTINUES TO FIND FUNCTION
HALT ;CALL PROGRAM TO A HALT
ADDRESS
LD R6, EIGHT ;INITIALIZES R6 TO BE 8 SO IT CAN LOOP 8 TIMES
LEA R0, PROMPT2 ;PROMPTS QUESTION TO ENTER A NAME
PUTs
LOOP1 IN ;GET CHARACTER OF NAME
LD R4, CURRENT ;LOAD ADDRESS OF NAME LOCATION
ADD R4, R4, #1 ;STORE RECORD INTO THE PLACE
ST R4, CURRENT
STR R0, R4, #0
ADD R6, R6, #-1 ;DECREASES COUNTER R6 BY 1
BRp LOOP1 ;IF IT IS STILL POSITIVE IT LOOPS TO COMPLETE THE NAME
LD R6, EIGHT ;INITIALIZES R6 TO BE 8 SO IT CAN LOOP 8 TIMES
LEA R0, PROMPT3 ;PROMPTS QUESTION TO ENTER A PHONE NUMBER
PUTs
LOOP2 IN ;GET CHARACTER OF RECORD
LD R4, CURRENT ;LOAD ADDRESS OF NAME LOCATION
ADD R4, R4, #1 ;STORE RECORD INTO THE PLACE
ST R4, CURRENT
STR R0, R4, #0
ADD R6, R6, #-1 ;DECREASES COUNTER R6 BY 1
BRp LOOP2 ;IF IT IS STILL POSITIVE IT LOOPS TO COMPLETE THE PHONE NUMBER
LEA R0, THANKYOU
PUTs
BRNZP MENU ;BACK TO MENU
FIND
LEA R0, PROMPT2
IN
LEA R0, PROMPT3
IN
BRNZP MENU ;BACK TO MENU
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;START OF .FILL DATA
NTHIRTY .FILL x-30
TEN .FILL #10
ONE .FILL #1
TWO .FILL #2
EIGHT .FILL #8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;START OF STRING PROMPTS
THANKYOU .STRINGZ "Thank you!"
GBYE .STRINGZ "Goodbye!"
PROMPT2 .STRINGZ "Enter in an 8 character or less name:"
PROMPT3 .STRINGZ "Enter in an 8 character or less number:"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;START OF ADDRESS BOOK DATA
CURRENT .BLKW #1
BOOK .BLKW #160
.END ;END PROGRAM