当前在PDP-11中使用代码,但是我会收到此错误"奇数adress",因此我在Internet中搜索并找到了以下错误:奇数地址错误:如果单词自动启动或自动编写指令中使用的寄存器会发生奇数。我不明白他们的意思!有人可以帮我吗?
main: mov #0,r0 ; r0 is the index of the Moves array
mov #0,r1 ; r1 is the index of the Cols of the Board
mov nCols,r3 ; r3 is the label of the Rows of the Board
mul nRows-1,r3
.even
add #Board,r3
movb r3,FR ;FR is the first row in board
even: movb r1,r5 ; here we are in even row
add Moves(r0),r5
movb #0,r4
div nCols,r4
mov r5,sharet
mul nCols,r4
sub r4,r3
br chick_row
chick_row:mov r3,help ;here we gonne chick if the row is even or uneven
mov FR,r5
sub help,r5
mov #0,r4
div nCols,r4
mov r4,r5
mov #0,r4
div #2,r4
cmpb #0,r5
beq Reven
br Runeven
uneven: mov nCols,r5 ;now we are in uneeven row and we want to add the moves and see if it leads us to even or uneven
sub r1,r5
sub #1,r5
add Moves(r0),r5
mov #0,r4
div nCols,r4
mov r5,sharet
mul nCols,r4
sub r4,r3
br chick_row
Reven: mov sharet,r1
br findC
Runeven:mov nCols,r1
sub sharet,r1
sub #1,r1
br findC
loopEnd:add #1,r0 ;we increased r0 and now we are going to chick if the current row is even or not
mov r3,help ;here we gonne chick if the row is even or uneven
mov FR,r5
sub help,r5
mov #0,r4
div nCols,r4
mov r4,r5
mov #0,r4
div #2,r4
cmpb #0,r5
beq even
br uneven
findC: mov r3,currentCell ; find the current cell after adding the current move
add r1,currentCell
; check the value of the current cell
cmpb currentCell,'L
beq isLadder
cmpb currentCell,'S
beq isSnake
cmpb #currentCell,#Board
blo errorC
add currentCell,Score
br loopEnd
isLadder:mov r3,FR
sub #Board,FR
cmpb FR,nCols
blo errorLadder
sub nCols,r3
mov r3,currentCell
add r1,currentCell
cmpb currentCell,'L
beq isLadder
add currentCell,Score
br loopEnd
isSnake:mov r3,r4
mov nCols,r5
mul nRows-1,r5
add #Board,r5
sub r5,r4
cmpb r4,nCols
blo errorSnake
add nCols,r3
mov r3,currentCell
add r1,currentCell
cmpb currentCell,'S
beq isSnake
add currentCell,Score
br loopEnd
errorLadder:mov #1,Score
br Failure
errorSnake: mov #0,Score
br Failure
errorC: mov #2,Score
br Failure
gameEnd: mov #Board,r4 ; check if the game ended successfully..
add nCols,r5
sub #1,r5
cmpb currentCell,r5
beq Success
mov #3,Score
br Failure
Failure: mov #'F,Output
halt
Success: mov #'S,Output
halt
.=torg + 2000
currentCell: .word 0
lastRow: .word 0
FR: .word 0
help: .word 0
sharet: .word 0
.=torg + 5000
nCols: .word 5
nRows: .word 3
Board: .byte 2, 3, 'S, 'L, 0
.byte 5, 'L, 6, 'S, 6
.byte 1, 'L, 'S, 1, 'L
Moves: .byte 4, 5, 4, '@
; Outputs
.even
Output: .blkw 1
Score: .blkw 1
numMoves: .blkw 1
pdp-11整数指令处理8bit字节或16个单词。所有单词访问都必须在地址上。奇数地址上的单词访问将导致odd address trap
并中止说明。
在其他术语中:必须在PDP-11上进行单词访问。
所以在示例中
mov #1000,r0 ; r0 set to 1000
tstb (r0)+ ; r0 incremented to 1001
tst (r0) ; <-- odd address trap here
处理器将陷阱在tst
指令上,因为在奇数地址上完成了单词访问。
对于寄存器,R0至R5 A字节自动插件或减少地址模式将通过一个更改寄存器,而单词自动插入或降低地址模式将以两个更改。
对于寄存器R6,堆栈指针,也是字节自动启动或减少地址模式将通过两个更改堆栈指针,以确保始终进行单词访问。