开发者

pdp 11 assembler - problems with sub command

开发者 https://www.devze.com 2023-03-02 20:01 出处:网络
so we are using a pdp 11 simulator and i am trying to subtract one register from another this way: sub r2, r4

so we are using a pdp 11 simulator and i am trying to subtract one register from another this way:

sub r2, r4

what i want is that r4 will contain the difference between the values kept in r2 and r4, instead i get a huge, unrelated number. i tried sub r2, r5 and its the same problem.

where am i wrong? here's the code:(the line is after the flag "kaka")

.=torg+1000
main:

mov n_cols, r0
mul n_rows, r0
mov r1, r0;     r0 is now the length of th开发者_StackOverflow中文版e array of the maze
mov #Board, r2
mov #Path,r3;
loop:
cmpb (r2),#'S
beq loop2
tst (r2)+
sob r0, loop ;Go to next iteration

loop2:
cmpb (r2), #1
beq illegal
mov #Board,r4
kaka:
sub r2, r4
waka:
bmi illegal

edit: this is not the complete code, the rest of the code is not related and the problem occurs even when the rest of the code is marked as comment.


Its been decades since I played with PDP 11 assembler; but sub r2, r4 subtracts r4 FROM r2. You should use sub r4, r2 and change the rest of the code accordingly.

0

精彩评论

暂无评论...
验证码 换一张
取 消