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 the 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.