Add addressing mode check for JSR, and a test.

This commit is contained in:
Olaf Seibert 2015-06-01 00:28:49 +02:00
parent a24e3ba3ea
commit ff5179743c
2 changed files with 27 additions and 3 deletions

View File

@ -1474,6 +1474,12 @@ static int assemble(
free_tree(value);
return 0;
}
if ((mode.type & 070) == 0) {
report(stack->top, "JSR Rn,Rm is illegal\n");
/* But encode it anyway... */
}
word = op->value | mode.type | (reg << 6);
store_word(stack->top, tr, 2, word);
mode_extension(tr, &mode, stack->top);

View File

@ -4,9 +4,13 @@
; JMP Rx is not allowed, all other modes are.
;
start: jmp end
start: jmp label ; rel(pc) jumps to label
jmp @label ; @rel(pc) does something else!
jmp #label ; (pc)+ does something else!
jmp @#label ; @(pc)+ jumps to label
jmp r1 ; must fail
jmp (r1)
jmp (r2)
jmp (r1)+
jmp @(r1)+
jmp -(r1)
@ -14,4 +18,18 @@ start: jmp end
jmp 1234(r1)
jmp @1234(r1)
end:
secnd: jsr r0,label ; rel(pc) jumps to label
jsr r0,@label ; @rel(pc) does something else!
jsr r0,#label ; (pc)+ does something else!
jsr r0,@#label ; @(pc)+ jumps to label
jsr r2,r1 ; must fail
jsr r3,(r2)
jsr r4,(r1)+
jsr r5,@(r1)+
jsr r2,-(r1)
jsr r3,@-(r1)
jsr r4,1234(r1)
jsr r5,@1234(r1)
label: rts pc