目前正在处理pdp-11中的代码,但我得到了这个错误“奇数字地址”,所以我在互联网上搜索并发现了这个:奇数地址错误:如果在字自动递增或自动递减指令中使用的寄存器变成奇数,就会发生这种错误。我不明白他们是什么意思!有人能帮帮我吗?
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发布于 2016-12-13 04:05:40
pdp-11整数指令处理8位字节或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,字节自动递增或递减地址模式将使寄存器更改1,字自动递增或递减地址模式将更改2。
对于寄存器r6,堆栈指针,也是字节自动递增或递减地址模式,会将堆栈指针更改2,以确保始终可以进行字访问。
https://stackoverflow.com/questions/41070998
复制相似问题