Fix operand check for XOR which is shared with JSR.

Fixes issue #1.
This commit is contained in:
Olaf Seibert
2016-07-11 22:10:15 +02:00
parent a685d341c5
commit b8a955792c
3 changed files with 96 additions and 37 deletions

View File

@@ -3,47 +3,80 @@
3 ; Tests the addressing modes for JMP.
4 ; JMP Rx is not allowed, all other modes are.
5 ;
6
7 000000 000167 000104 start: jmp label ; rel(pc) jumps to label
8 000004 000177 000100 jmp @label ; @rel(pc) does something else!
9 000010 000127 000110' jmp #label ; (pc)+ does something else!
10 000014 000137 000110' jmp @#label ; @(pc)+ jumps to label
11
test-jmp.mac:12: ***ERROR JMP Rn is illegal
12 000020 000101 jmp r1 ; must fail
13 000022 000112 jmp (r2)
14 000024 000121 jmp (r1)+
15 000026 000131 jmp @(r1)+
16 000030 000141 jmp -(r1)
17 000032 000151 jmp @-(r1)
18 000034 000161 001234 jmp 1234(r1)
19 000040 000171 001234 jmp @1234(r1)
20
21 000044 004067 000040 secnd: jsr r0,label ; rel(pc) jumps to label
22 000050 004077 000034 jsr r0,@label ; @rel(pc) does something else!
23 000054 004027 000110' jsr r0,#label ; (pc)+ does something else!
24 000060 004037 000110' jsr r0,@#label ; @(pc)+ jumps to label
25
test-jmp.mac:26: ***ERROR JSR Rn,Rm is illegal
26 000064 004201 jsr r2,r1 ; must fail
27 000066 004312 jsr r3,(r2)
28 000070 004421 jsr r4,(r1)+
29 000072 004531 jsr r5,@(r1)+
30 000074 004241 jsr r2,-(r1)
31 000076 004351 jsr r3,@-(r1)
32 000100 004461 001234 jsr r4,1234(r1)
33 000104 004571 001234 jsr r5,@1234(r1)
34
35 000110 000207 label: rts pc
35
6 ; XOR shares the instruction format with JSR
7 ; (their source operand can only be a register),
8 ; but XOR Rx,Ry is allowed whereas JSR Rx,Ry is not.
9 ;
10
11 000000 000167 000150 start: jmp label ; rel(pc) jumps to label
12 000004 000177 000144 jmp @label ; @rel(pc) does something else!
13 000010 000127 000154' jmp #label ; (pc)+ does something else!
14 000014 000137 000154' jmp @#label ; @(pc)+ jumps to label
15
test-jmp.mac:16: ***ERROR JMP Rn is illegal
16 000020 000101 jmp r1 ; must fail
17 000022 000112 jmp (r2)
18 000024 000121 jmp (r1)+
19 000026 000131 jmp @(r1)+
20 000030 000141 jmp -(r1)
21 000032 000151 jmp @-(r1)
22 000034 000161 001234 jmp 1234(r1)
23 000040 000171 001234 jmp @1234(r1)
24
25 000044 004067 000104 secnd: jsr r0,label ; rel(pc) jumps to label
26 000050 004077 000100 jsr r0,@label ; @rel(pc) does something else!
27 000054 004027 000154' jsr r0,#label ; (pc)+ does something else!
28 000060 004037 000154' jsr r0,@#label ; @(pc)+ jumps to label
29
test-jmp.mac:30: ***ERROR JSR Rn,Rm is illegal
30 000064 004201 jsr r2,r1 ; must fail
31 000066 004312 jsr r3,(r2)
32 000070 004421 jsr r4,(r1)+
33 000072 004531 jsr r5,@(r1)+
34 000074 004241 jsr r2,-(r1)
35 000076 004351 jsr r3,@-(r1)
36 000100 004461 001234 jsr r4,1234(r1)
37 000104 004571 001234 jsr r5,@1234(r1)
38
39 000110 074067 000040 third: xor r0,label ; rel(pc)
40 000114 074077 000034 xor r0,@label ; @rel(pc)
41 000120 074027 000154' xor r0,#label ; (pc)+
42 000124 074037 000154' xor r0,@#label ; @(pc)+
43
44 000130 074201 xor r2,r1 ; must succeed
45 000132 074312 xor r3,(r2) ; must succeed
46 000134 074421 xor r4,(r1)+ ; must succeed
47 000136 074531 xor r5,@(r1)+ ; must succeed
48 000140 074241 xor r2,-(r1) ; must succeed
49 000142 074351 xor r3,@-(r1) ; must succeed
50 000144 074461 001234 xor r4,1234(r1) ; must succeed
51 000150 074571 001234 xor r5,@1234(r1) ; must succeed
52
test-jmp.mac:53: ***ERROR Illegal addressing mode
53 xor (r2),r1 ; must fail
test-jmp.mac:54: ***ERROR Illegal addressing mode
54 xor (r2)+,r1 ; must fail
test-jmp.mac:55: ***ERROR Illegal addressing mode
55 xor @(r2)+,r1 ; must fail
test-jmp.mac:56: ***ERROR Illegal addressing mode
56 xor -(r2),r1 ; must fail
test-jmp.mac:57: ***ERROR Illegal addressing mode
57 xor @-(r2),r1 ; must fail
test-jmp.mac:58: ***ERROR Illegal addressing mode
58 xor 1234(r2),r1 ; must fail
test-jmp.mac:59: ***ERROR Illegal addressing mode
59 xor @1234(r2),r1 ; must fail
60
61 000154 000207 label: rts pc
61
Symbol table
. ******R 001 LABEL 000110R 001 SECND 000044R 001 START 000000R 001
. ******R 001 LABEL 000154R 001 SECND 000044R 001 START 000000R 001 THIRD 000110R 001
Program sections:
. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV)
000112 001 (RW,I,LCL,REL,CON,NOSAV)
000156 001 (RW,I,LCL,REL,CON,NOSAV)

View File

@@ -3,6 +3,10 @@
; Tests the addressing modes for JMP.
; JMP Rx is not allowed, all other modes are.
;
; XOR shares the instruction format with JSR
; (their source operand can only be a register),
; but XOR Rx,Ry is allowed whereas JSR Rx,Ry is not.
;
start: jmp label ; rel(pc) jumps to label
jmp @label ; @rel(pc) does something else!
@@ -32,4 +36,26 @@ secnd: jsr r0,label ; rel(pc) jumps to label
jsr r4,1234(r1)
jsr r5,@1234(r1)
third: xor r0,label ; rel(pc)
xor r0,@label ; @rel(pc)
xor r0,#label ; (pc)+
xor r0,@#label ; @(pc)+
xor r2,r1 ; must succeed
xor r3,(r2) ; must succeed
xor r4,(r1)+ ; must succeed
xor r5,@(r1)+ ; must succeed
xor r2,-(r1) ; must succeed
xor r3,@-(r1) ; must succeed
xor r4,1234(r1) ; must succeed
xor r5,@1234(r1) ; must succeed
xor (r2),r1 ; must fail
xor (r2)+,r1 ; must fail
xor @(r2)+,r1 ; must fail
xor -(r2),r1 ; must fail
xor @-(r2),r1 ; must fail
xor 1234(r2),r1 ; must fail
xor @1234(r2),r1 ; must fail
label: rts pc