Make operand parsing error messages more helpful

and add a test that is supposed to exercise them all.
This commit is contained in:
Olaf Seibert 2021-03-14 20:08:31 +01:00
parent d4c0520ac1
commit 0e373a8570
8 changed files with 558 additions and 75 deletions

View File

@ -1331,6 +1331,12 @@ static int assemble(
report(stack->top, "Instruction requires simple literal operand\n");
word = op->value;
} else {
unsigned int max = (op->value == I_MARK)? 077 : 0377;
if (value->data.lit > max) {
report(stack->top, "Literal operand too large (%d. > %d.)\n", value->data.lit, max);
value->data.lit = max;
}
word = op->value | value->data.lit;
}
@ -1345,7 +1351,7 @@ static int assemble(
unsigned word;
if (!get_mode(cp, &cp, &mode)) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode\n");
return 0;
}
@ -1368,19 +1374,19 @@ static int assemble(
unsigned word;
if (!get_mode(cp, &cp, &left)) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (1st operand)\n");
return 0;
}
cp = skipwhite(cp);
if (*cp++ != ',') {
report(stack->top, "Illegal syntax\n");
report(stack->top, "Invalid syntax (comma expected)\n");
free_addr_mode(&left);
return 0;
}
if (!get_mode(cp, &cp, &right)) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (2nd operand)\n");
free_addr_mode(&left);
return 0;
}
@ -1465,13 +1471,13 @@ static int assemble(
reg = get_register(value);
free_tree(value);
if (reg == NO_REG) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (register expected)\n");
return 0;
}
cp = skipwhite(cp);
if (*cp++ != ',') {
report(stack->top, "Illegal syntax\n");
report(stack->top, "Invalid syntax (comma expected)\n");
return 0;
}
@ -1525,13 +1531,13 @@ static int assemble(
unsigned word;
if (!get_mode(cp, &cp, &mode)) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (1st operand)\n");
return 0;
}
cp = skipwhite(cp);
if (*cp++ != ',') {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid syntax (comma expected)\n");
free_addr_mode(&mode);
return 0;
}
@ -1540,7 +1546,7 @@ static int assemble(
reg = get_register(value);
if (reg == NO_REG) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (2nd operand: register expected)\n");
free_tree(value);
free_addr_mode(&mode);
return 0;
@ -1566,19 +1572,19 @@ static int assemble(
reg = get_register(value);
if (reg == NO_REG) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (1st operand: register exected)\n");
free_tree(value);
return 0;
}
cp = skipwhite(cp);
if (*cp++ != ',') {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid syntax (comma expected)\n");
return 0;
}
if (!get_mode(cp, &cp, &mode)) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (2nd operand)\n");
free_tree(value);
return 0;
}
@ -1604,7 +1610,7 @@ static int assemble(
cp = value->cp;
reg = get_register(value);
if (reg == NO_REG) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (register expected)\n");
reg = 0;
}
@ -1646,13 +1652,13 @@ static int assemble(
unsigned word;
if (!get_fp_src_mode(cp, &cp, &mode)) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (1st operand)\n");
return 0;
}
cp = skipwhite(cp);
if (*cp++ != ',') {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid syntax (comma expected)\n");
free_addr_mode(&mode);
return 0;
}
@ -1690,19 +1696,19 @@ static int assemble(
reg = get_register(value);
if (reg == NO_REG || reg > 3) {
report(stack->top, "Illegal source fp register\n");
report(stack->top, "Invalid source fp register\n");
reg = 0;
}
cp = skipwhite(cp);
if (*cp++ != ',') {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid syntax (comma expected)\n");
free_tree(value);
return 0;
}
if (!get_mode(cp, &cp, &mode)) {
report(stack->top, "Illegal addressing mode\n");
report(stack->top, "Invalid addressing mode (2nd operand)\n");
free_tree(value);
return 0;
}
@ -1741,9 +1747,17 @@ static int assemble(
cis_common:
if (!EOL(*cp)) {
for (int i = 0; i < nwords; i++) {
if (i > 0)
cp = skipdelim(cp);
if (i > 0) {
cp = skipwhite(cp);
if (*cp++ != ',') {
report(stack->top, "Invalid syntax (operand %d: comma expected)\n", i+1);
cp--;
}
}
EX_TREE *ex = parse_expr(cp, 0);
if (!expr_ok(ex)) {
report(stack->top, "Invalid expression (operand %d)\n", i+1);
}
cp = ex->cp;
expr[i] = ex;
}

15
parse.c
View File

@ -211,7 +211,7 @@ int get_mode(
mode->offset = parse_expr(cp, 0);
if (endp)
*endp = mode->offset->cp;
return TRUE;
return expr_ok(mode->offset);
}
/* Check for -(Rn) */
@ -281,6 +281,9 @@ int get_mode(
mode->offset = parse_expr(cp, 0);
if (!expr_ok(mode->offset))
return FALSE;
cp = skipwhite(mode->offset->cp);
if (*cp == '(') {
@ -1177,3 +1180,13 @@ EX_TREE *parse_unary_expr(
return value;
}
/*
* expr_ok Returns TRUE if there was a valid expression parsed.
*/
int expr_ok(
EX_TREE *expr)
{
return expr != NULL && expr->type != EX_ERR;
}

View File

@ -51,6 +51,8 @@ EX_TREE *parse_expr(
EX_TREE *parse_unary_expr(
char *cp,
int undef);
int expr_ok(
EX_TREE *expr);
int parse_float(
char *cp,
char **endp,

View File

@ -25,6 +25,7 @@ TESTS="test-asciz \
test-macro-comma \
test-mcall-file \
test-opcodes \
test-operands \
test-prec \
test-psect \
test-rad50 \

View File

@ -1,6 +1,6 @@
1 ;;;;;
2 ;
3 ; Tests the addressing modes for JMP.
3 ; Tests various operand types for JMP, XOR, RTS.
4 ; JMP Rx is not allowed, all other modes are.
5 ;
6 ; XOR shares the instruction format with JSR
@ -8,10 +8,10 @@
8 ; but XOR Rx,Ry is allowed whereas JSR Rx,Ry is not.
9 ;
10
11 000000 000167 000152 start: jmp label ; rel(pc) jumps to label
12 000004 000177 000146 jmp @label ; @rel(pc) does something else!
13 000010 000127 000156' jmp #label ; (pc)+ does something else!
14 000014 000137 000156' jmp @#label ; @(pc)+ jumps to label
11 000000 000167 000162 start: jmp label ; rel(pc) jumps to label
12 000004 000177 000156 jmp @label ; @rel(pc) does something else!
13 000010 000127 000166' jmp #label ; (pc)+ does something else!
14 000014 000137 000166' jmp @#label ; @(pc)+ jumps to label
15
test-jmp.mac:16: ***ERROR JMP Rn is illegal
16 000020 000101 jmp r1 ; must fail
@ -24,60 +24,99 @@ test-jmp.mac:16: ***ERROR JMP Rn is illegal
23 000036 000161 001234 jmp 1234(r1)
24 000042 000171 001234 jmp @1234(r1)
25
26 000046 004067 000104 secnd: jsr r0,label ; rel(pc) jumps to label
27 000052 004077 000100 jsr r0,@label ; @rel(pc) does something else!
28 000056 004027 000156' jsr r0,#label ; (pc)+ does something else!
29 000062 004037 000156' jsr r0,@#label ; @(pc)+ jumps to label
30
test-jmp.mac:31: ***ERROR JSR Rn,Rm is illegal
31 000066 004201 jsr r2,r1 ; must fail
32 000070 004312 jsr r3,(r2)
33 000072 004421 jsr r4,(r1)+
34 000074 004531 jsr r5,@(r1)+
35 000076 004241 jsr r2,-(r1)
36 000100 004351 jsr r3,@-(r1)
37 000102 004461 001234 jsr r4,1234(r1)
38 000106 004571 001234 jsr r5,@1234(r1)
39
40 000112 074067 000040 third: xor r0,label ; rel(pc)
41 000116 074077 000034 xor r0,@label ; @rel(pc)
42 000122 074027 000156' xor r0,#label ; (pc)+
43 000126 074037 000156' xor r0,@#label ; @(pc)+
44
45 000132 074201 xor r2,r1 ; must succeed
46 000134 074312 xor r3,(r2) ; must succeed
47 000136 074421 xor r4,(r1)+ ; must succeed
48 000140 074531 xor r5,@(r1)+ ; must succeed
49 000142 074241 xor r2,-(r1) ; must succeed
50 000144 074351 xor r3,@-(r1) ; must succeed
51 000146 074461 001234 xor r4,1234(r1) ; must succeed
52 000152 074571 001234 xor r5,@1234(r1) ; must succeed
53
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 @-(r2),r1 ; must fail
test-jmp.mac:59: ***ERROR Illegal addressing mode
59 xor 1234(r2),r1 ; must fail
test-jmp.mac:60: ***ERROR Illegal addressing mode
60 xor @1234(r2),r1 ; must fail
61
62 000156 000207 label: rts pc
62
26 000046 004067 000114 secnd: jsr r0,label ; rel(pc) jumps to label
27 000052 004067 000110 jsr 0,label ; rel(pc) yes MACRO11 accepts this
28 000056 004077 000104 jsr r0,@label ; @rel(pc) does something else!
29 000062 004027 000166' jsr r0,#label ; (pc)+ does something else!
30 000066 004037 000166' jsr r0,@#label ; @(pc)+ jumps to label
31
test-jmp.mac:32: ***ERROR JSR Rn,Rm is illegal
32 000072 004201 jsr r2,r1 ; must fail
33 000074 004312 jsr r3,(r2)
34 000076 004421 jsr r4,(r1)+
35 000100 004531 jsr r5,@(r1)+
36 000102 004241 jsr r2,-(r1)
37 000104 004351 jsr r3,@-(r1)
38 000106 004461 001234 jsr r4,1234(r1)
39 000112 004571 001234 jsr r5,@1234(r1)
40
41 000116 074067 000044 third: xor r0,label ; rel(pc)
42 000122 074067 000040 xor 0,label ; rel(pc) yes MACRO11 accepts this
43 000126 074077 000034 xor r0,@label ; @rel(pc)
44 000132 074027 000166' xor r0,#label ; (pc)+
45 000136 074037 000166' xor r0,@#label ; @(pc)+
46
47 000142 074201 xor r2,r1 ; must succeed
48 000144 074312 xor r3,(r2) ; must succeed
49 000146 074421 xor r4,(r1)+ ; must succeed
50 000150 074531 xor r5,@(r1)+ ; must succeed
51 000152 074241 xor r2,-(r1) ; must succeed
52 000154 074351 xor r3,@-(r1) ; must succeed
53 000156 074461 001234 xor r4,1234(r1) ; must succeed
54 000162 074571 001234 xor r5,@1234(r1) ; must succeed
55
test-jmp.mac:56: ***ERROR Invalid addressing mode (1st operand: register exected)
56 xor (r2),r1 ; must fail
test-jmp.mac:57: ***ERROR Invalid addressing mode (1st operand: register exected)
57 xor (r2)+,r1 ; must fail
test-jmp.mac:58: ***ERROR Invalid addressing mode (1st operand: register exected)
58 xor @(r2)+,r1 ; must fail
test-jmp.mac:59: ***ERROR Invalid addressing mode (1st operand: register exected)
59 xor -(r2),r1 ; must fail
test-jmp.mac:60: ***ERROR Invalid addressing mode (1st operand: register exected)
60 xor @-(r2),r1 ; must fail
test-jmp.mac:61: ***ERROR Invalid addressing mode (1st operand: register exected)
61 xor 1234(r2),r1 ; must fail
test-jmp.mac:62: ***ERROR Invalid addressing mode (1st operand: register exected)
62 xor @1234(r2),r1 ; must fail
63
64 000003 three = 3
65 000166 000207 label: rts pc
66 000170 000201 rts r1
67 000172 000203 rts 3 ; yes MACRO11 accepts this
68 000174 000203 rts three
test-jmp.mac:69: ***ERROR Invalid addressing mode (register expected)
69 000176 000200 rts ; must fail
test-jmp.mac:70: ***ERROR Invalid addressing mode (register expected)
70 000200 000200 rts . ; must fail
test-jmp.mac:71: ***ERROR Invalid addressing mode (register expected)
test-jmp.mac:71: ***ERROR Junk at end of line ('(r1) ; mu')
71 000202 000200 rts (r1) ; must fail
72
73 000000 .psect abssec,abs
74 000000 . = 0
75 000000 000200 zero: rts zero ; dubious but ok
76 000002 000202 two: rts two ; dubious but ok
77 000004 000204 four: rts four ; dubious but ok
78 000006 000206 six: rts six ; dubious but ok
test-jmp.mac:79: ***ERROR Invalid addressing mode (register expected)
79 000010 000200 eight: rts eight ; bad
80
81 000000 .psect relsec,rel
test-jmp.mac:82: ***ERROR Invalid addressing mode (register expected)
82 000000 000200 rzero: rts rzero ; bad
test-jmp.mac:83: ***ERROR Invalid addressing mode (register expected)
83 000002 000200 rtwo: rts rtwo ; bad
test-jmp.mac:84: ***ERROR Invalid addressing mode (register expected)
84 000004 000200 rfour: rts rfour ; bad
test-jmp.mac:85: ***ERROR Invalid addressing mode (register expected)
85 000006 000200 rsix: rts rsix ; bad
test-jmp.mac:86: ***ERROR Invalid addressing mode (register expected)
86 000010 000200 reight: rts reight ; bad
86
Symbol table
. ******R 001 LABEL 000156R 001 SECND 000046R 001 START 000000R 001 THIRD 000112R 001
. ******R 003 REIGHT 000010R 003 RZERO 000000R 003 THIRD 000116R 001
EIGHT = 000010 002 RFOUR 000004R 003 SECND 000046R 001 THREE = 000003
FOUR = 000004 002 RSIX 000006R 003 SIX = 000006 002 TWO = 000002 002
LABEL 000166R 001 RTWO 000002R 003 START 000000R 001 ZERO = 000000 002
Program sections:
. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV)
000160 001 (RW,I,LCL,REL,CON,NOSAV)
000204 001 (RW,I,LCL,REL,CON,NOSAV)
ABSSEC 000012 002 (RW,I,LCL,ABS,OVR,NOSAV)
RELSEC 000012 003 (RW,I,LCL,REL,CON,NOSAV)

View File

@ -1,6 +1,6 @@
;;;;;
;
; Tests the addressing modes for JMP.
; Tests various operand types for JMP, XOR, RTS.
; JMP Rx is not allowed, all other modes are.
;
; XOR shares the instruction format with JSR
@ -24,6 +24,7 @@ start: jmp label ; rel(pc) jumps to label
jmp @1234(r1)
secnd: jsr r0,label ; rel(pc) jumps to label
jsr 0,label ; rel(pc) yes MACRO11 accepts this
jsr r0,@label ; @rel(pc) does something else!
jsr r0,#label ; (pc)+ does something else!
jsr r0,@#label ; @(pc)+ jumps to label
@ -38,6 +39,7 @@ secnd: jsr r0,label ; rel(pc) jumps to label
jsr r5,@1234(r1)
third: xor r0,label ; rel(pc)
xor 0,label ; rel(pc) yes MACRO11 accepts this
xor r0,@label ; @rel(pc)
xor r0,#label ; (pc)+
xor r0,@#label ; @(pc)+
@ -59,4 +61,26 @@ third: xor r0,label ; rel(pc)
xor 1234(r2),r1 ; must fail
xor @1234(r2),r1 ; must fail
three = 3
label: rts pc
rts r1
rts 3 ; yes MACRO11 accepts this
rts three
rts ; must fail
rts . ; must fail
rts (r1) ; must fail
.psect abssec,abs
. = 0
zero: rts zero ; dubious but ok
two: rts two ; dubious but ok
four: rts four ; dubious but ok
six: rts six ; dubious but ok
eight: rts eight ; bad
.psect relsec,rel
rzero: rts rzero ; bad
rtwo: rts rtwo ; bad
rfour: rts rfour ; bad
rsix: rts rsix ; bad
reight: rts reight ; bad

259
tests/test-operands.lst.ok Normal file
View File

@ -0,0 +1,259 @@
1 ;;;;;
2 ;
3 ; Test operand checking for various instructions and try to exercise
4 ; all operand parsing error messages.
5 ; Some cases are checked elsewhere (e.g. test-jmp.mac).
6 ;
7
8 ; OC_MARK
9
10 000000 006400 mark 0
11 000002 006401 mark 1
12 000004 006477 mark 77
test-operands.mac:13: ***ERROR Literal operand too large (64. > 63.)
13 000006 006477 mark 100 ; too large
test-operands.mac:14: ***ERROR Instruction requires simple literal operand
14 000010 006400 mark . ; must be literal
test-operands.mac:15: ***ERROR Junk at end of line (',0 ; bad')
15 000012 006400 mark 0,0 ; bad
16
17 000014 104000 emt 0
18 000016 104001 emt 1
19 000020 104377 emt 255.
test-operands.mac:20: ***ERROR Literal operand too large (256. > 255.)
20 000022 104377 emt 256. ; too large
test-operands.mac:21: ***ERROR Instruction requires simple literal operand
21 000024 104000 emt . ; must be literal
22
23 000026 104400 trap 0
24 000030 104401 trap 1
25 000032 104777 trap 255.
test-operands.mac:26: ***ERROR Literal operand too large (256. > 255.)
26 000034 104777 trap 256. ; too large
test-operands.mac:27: ***ERROR Instruction requires simple literal operand
27 000036 104400 trap . ; must be literal
28
29 ; OC_1GEN
30
31 000040 005700 tst r0
test-operands.mac:32: ***ERROR Junk at end of line (',(r0) ; bad
')
32 000042 005700 tst r0,(r0) ; bad
test-operands.mac:33: ***ERROR Invalid addressing mode
33 tst @ ; bad
test-operands.mac:34: ***ERROR Invalid addressing mode
34 tst %77 ; bad
test-operands.mac:35: ***ERROR Invalid addressing mode
35 tst <> ; bad
36
37 ; OC_2GEN
38
39 000044 060001 add r0,r1
test-operands.mac:40: ***ERROR Junk at end of line (',r2 ; bad
')
40 000046 060001 add r0,r1,r2 ; bad
test-operands.mac:41: ***ERROR Invalid addressing mode (1st operand)
41 add @ ; bad
test-operands.mac:42: ***ERROR Invalid syntax (comma expected)
42 add r0 r1 ; bad
test-operands.mac:43: ***ERROR Invalid addressing mode (2nd operand)
43 add r0,@ ; bad
44
45 ; OC_BR
46
47 ; branch offset is counted in words
48 ; from the address after instruction (. + 2)
49
test-operands.mac:50: ***ERROR Branch target out of range (distance=-402)
50 000050 000400 br .+2-258. ; bad
51 000052 000600 br .+2-256.
52 000054 000400 br .+2
53 000056 000577 br .+2+254.
test-operands.mac:54: ***ERROR Branch target out of range (distance=400)
54 000060 000400 br .+2+256. ; bad
55
56 ; OC_SOB
57
58 000062 077001 sob r0,.
59 000064 077001 sob 0,. ; yes MACRO11 accepts this
test-operands.mac:60: ***ERROR Junk at end of line (',3 ; bad
')
60 000066 077001 sob r0,.,3 ; bad
test-operands.mac:61: ***ERROR Invalid addressing mode (register expected)
61 sob ; bad
test-operands.mac:62: ***ERROR Invalid syntax (comma expected)
62 sob r0 ; bad
test-operands.mac:63: ***ERROR Invalid syntax (comma expected)
63 sob r0 . ; bad
test-operands.mac:64: ***ERROR Invalid addressing mode (register expected)
64 sob 10,. ; bad
65
66 ; OC_ASH
67
68 000070 072027 000003 ash #3,r0
69 000074 072027 000003 ash #3,0 ; yes MACRO11 accepts this
test-operands.mac:70: ***ERROR Junk at end of line (',r1 ; bad
')
70 000100 072027 000003 ash #3,r0,r1 ; bad
test-operands.mac:71: ***ERROR Invalid addressing mode (1st operand)
71 ash ; bad
test-operands.mac:72: ***ERROR Invalid syntax (comma expected)
72 ash #3 ; bad
test-operands.mac:73: ***ERROR Invalid syntax (comma expected)
73 ash #3 r0 ; bad
test-operands.mac:74: ***ERROR Invalid addressing mode (2nd operand: register expected)
74 ash #3,#0 ; bad
75
76 ; OC_JSR tested in test-jmp.mac
77
78 ; OC_FPPGENAC
79
80 000001 ac1 = %1
81 000005 ac5 = %5
82
83 000104 171111 mulf (r1),ac1
84 000106 171111 mulf (r1),1
test-operands.mac:85: ***ERROR Junk at end of line (',ac1 ; bad
')
85 000110 171111 mulf (r1),ac1,ac1 ; bad
test-operands.mac:86: ***ERROR Invalid addressing mode (1st operand)
86 mulf ; bad
test-operands.mac:87: ***ERROR Invalid addressing mode (1st operand)
87 mulf ( ; bad
test-operands.mac:88: ***ERROR Invalid syntax (comma expected)
88 mulf (r1) ; bad
test-operands.mac:89: ***ERROR Invalid syntax (comma expected)
89 mulf (r1) ac1 ; bad
test-operands.mac:90: ***ERROR Invalid destination fp register
90 000112 171011 mulf (r1),ac5 ; bad
91
92 ; OC_FPPACGEN
93
94 000114 174115 stf ac1,(r5)
95 000116 174115 stf 1,(r5)
test-operands.mac:96: ***ERROR Invalid source fp register
test-operands.mac:96: ***ERROR Invalid syntax (comma expected)
96 stf ; bad
test-operands.mac:97: ***ERROR Invalid syntax (comma expected)
97 stf ac1 ; bad
test-operands.mac:98: ***ERROR Invalid syntax (comma expected)
98 stf ac1 (r5) ; bad
test-operands.mac:99: ***ERROR Invalid source fp register
99 000120 174015 stf ac5,(r5) ; bad
100
101 ; OC_CIS2 operands are optional and an extension
102
103 000122 076152 cmpni
104 000124 076152 000001 000002 cmpni 1,2
test-operands.mac:105: ***ERROR Junk at end of line (',3 ; bad
')
105 000132 076152 000001 000002 cmpni 1,2,3 ; bad
test-operands.mac:106: ***ERROR Invalid syntax (operand 2: comma expected)
test-operands.mac:106: ***ERROR Invalid expression (operand 2)
test-operands.mac:106: ***ERROR Invalid expression
106 000140 076152 000003 000000 cmpni 3 ; bad
test-operands.mac:107: ***ERROR Invalid syntax (operand 2: comma expected)
107 000146 076152 000004 000005 cmpni 4 5 ; bad
test-operands.mac:108: ***ERROR Invalid expression (operand 1)
test-operands.mac:108: ***ERROR Invalid expression (operand 2)
test-operands.mac:108: ***ERROR Invalid expression
test-operands.mac:108: ***ERROR Invalid expression
108 000154 076152 000000 000000 cmpni <>,<> ; bad
109
110 ; OC_CIS3 operands are optional and an extension
111
112 000162 076150 addni
113 000164 076150 000001 000002 addni 1,2,3
000172 000003
114 000174 076150 000001 000002 addni 1,2,3,4 ; bad
test-operands.mac:114: ***ERROR Junk at end of line (',4 ; bad
')
000202 000003
test-operands.mac:115: ***ERROR Invalid syntax (operand 2: comma expected)
test-operands.mac:115: ***ERROR Invalid expression (operand 2)
test-operands.mac:115: ***ERROR Invalid syntax (operand 3: comma expected)
test-operands.mac:115: ***ERROR Invalid expression (operand 3)
test-operands.mac:115: ***ERROR Invalid expression
test-operands.mac:115: ***ERROR Invalid expression
115 000204 076150 000001 000000 addni 1 ; bad
000212 000000
test-operands.mac:116: ***ERROR Invalid syntax (operand 3: comma expected)
test-operands.mac:116: ***ERROR Invalid expression (operand 3)
test-operands.mac:116: ***ERROR Invalid expression
116 000214 076150 000001 000002 addni 1,2 ; bad
000222 000000
test-operands.mac:117: ***ERROR Invalid syntax (operand 2: comma expected)
test-operands.mac:117: ***ERROR Invalid syntax (operand 3: comma expected)
117 000224 076150 000001 000002 addni 1 2 3 ; bad
000232 000003
test-operands.mac:118: ***ERROR Invalid expression (operand 1)
test-operands.mac:118: ***ERROR Invalid expression (operand 2)
test-operands.mac:118: ***ERROR Invalid expression (operand 3)
test-operands.mac:118: ***ERROR Invalid expression
test-operands.mac:118: ***ERROR Invalid expression
test-operands.mac:118: ***ERROR Invalid expression
118 000234 076150 000000 000000 addni <>,<>,<> ; bad
000242 000000
119
120 ; OC_CIS4 operands are optional and an extension
121
122 000244 076132 movtci
123 000246 076132 000001 000002 movtci 1,2,3,4
000254 000003 000004
124 000260 076132 000001 000002 movtci 1,2,3,4,5
test-operands.mac:124: ***ERROR Junk at end of line (',5
')
000266 000003 000004
test-operands.mac:125: ***ERROR Invalid syntax (operand 2: comma expected)
test-operands.mac:125: ***ERROR Invalid expression (operand 2)
test-operands.mac:125: ***ERROR Invalid syntax (operand 3: comma expected)
test-operands.mac:125: ***ERROR Invalid expression (operand 3)
test-operands.mac:125: ***ERROR Invalid syntax (operand 4: comma expected)
test-operands.mac:125: ***ERROR Invalid expression (operand 4)
test-operands.mac:125: ***ERROR Invalid expression
test-operands.mac:125: ***ERROR Invalid expression
125 000272 076132 000001 000000 movtci 1 ; bad
test-operands.mac:125: ***ERROR Invalid expression
000300 000000 000000
test-operands.mac:126: ***ERROR Invalid syntax (operand 3: comma expected)
test-operands.mac:126: ***ERROR Invalid expression (operand 3)
test-operands.mac:126: ***ERROR Invalid syntax (operand 4: comma expected)
test-operands.mac:126: ***ERROR Invalid expression (operand 4)
test-operands.mac:126: ***ERROR Invalid expression
126 000304 076132 000001 000002 movtci 1,2 ; bad
test-operands.mac:126: ***ERROR Invalid expression
000312 000000 000000
test-operands.mac:127: ***ERROR Invalid syntax (operand 4: comma expected)
test-operands.mac:127: ***ERROR Invalid expression (operand 4)
127 000316 076132 000001 000002 movtci 1,2,3 ; bad
test-operands.mac:127: ***ERROR Invalid expression
000324 000003 000000
test-operands.mac:128: ***ERROR Invalid syntax (operand 2: comma expected)
test-operands.mac:128: ***ERROR Invalid syntax (operand 3: comma expected)
test-operands.mac:128: ***ERROR Invalid syntax (operand 4: comma expected)
128 000330 076132 000001 000002 movtci 1 2 3 4 ; bad
000336 000003 000004
test-operands.mac:129: ***ERROR Invalid expression (operand 1)
test-operands.mac:129: ***ERROR Invalid expression (operand 2)
test-operands.mac:129: ***ERROR Invalid expression (operand 3)
test-operands.mac:129: ***ERROR Invalid expression (operand 4)
test-operands.mac:129: ***ERROR Invalid expression
test-operands.mac:129: ***ERROR Invalid expression
test-operands.mac:129: ***ERROR Invalid expression
129 000342 076132 000000 000000 movtci <>,<>,<>,<> ; bad
test-operands.mac:129: ***ERROR Invalid expression
000350 000000 000000
130
131 .end
131
Symbol table
. ******R 001 AC1 =%000001 AC5 =%000005
Program sections:
. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV)
000354 001 (RW,I,LCL,REL,CON,NOSAV)

131
tests/test-operands.mac Normal file
View File

@ -0,0 +1,131 @@
;;;;;
;
; Test operand checking for various instructions and try to exercise
; all operand parsing error messages.
; Some cases are checked elsewhere (e.g. test-jmp.mac).
;
; OC_MARK
mark 0
mark 1
mark 77
mark 100 ; too large
mark . ; must be literal
mark 0,0 ; bad
emt 0
emt 1
emt 255.
emt 256. ; too large
emt . ; must be literal
trap 0
trap 1
trap 255.
trap 256. ; too large
trap . ; must be literal
; OC_1GEN
tst r0
tst r0,(r0) ; bad
tst @ ; bad
tst %77 ; bad
tst <> ; bad
; OC_2GEN
add r0,r1
add r0,r1,r2 ; bad
add @ ; bad
add r0 r1 ; bad
add r0,@ ; bad
; OC_BR
; branch offset is counted in words
; from the address after instruction (. + 2)
br .+2-258. ; bad
br .+2-256.
br .+2
br .+2+254.
br .+2+256. ; bad
; OC_SOB
sob r0,.
sob 0,. ; yes MACRO11 accepts this
sob r0,.,3 ; bad
sob ; bad
sob r0 ; bad
sob r0 . ; bad
sob 10,. ; bad
; OC_ASH
ash #3,r0
ash #3,0 ; yes MACRO11 accepts this
ash #3,r0,r1 ; bad
ash ; bad
ash #3 ; bad
ash #3 r0 ; bad
ash #3,#0 ; bad
; OC_JSR tested in test-jmp.mac
; OC_FPPGENAC
ac1 = %1
ac5 = %5
mulf (r1),ac1
mulf (r1),1
mulf (r1),ac1,ac1 ; bad
mulf ; bad
mulf ( ; bad
mulf (r1) ; bad
mulf (r1) ac1 ; bad
mulf (r1),ac5 ; bad
; OC_FPPACGEN
stf ac1,(r5)
stf 1,(r5)
stf ; bad
stf ac1 ; bad
stf ac1 (r5) ; bad
stf ac5,(r5) ; bad
; OC_CIS2 operands are optional and an extension
cmpni
cmpni 1,2
cmpni 1,2,3 ; bad
cmpni 3 ; bad
cmpni 4 5 ; bad
cmpni <>,<> ; bad
; OC_CIS3 operands are optional and an extension
addni
addni 1,2,3
addni 1,2,3,4 ; bad
addni 1 ; bad
addni 1,2 ; bad
addni 1 2 3 ; bad
addni <>,<>,<> ; bad
; OC_CIS4 operands are optional and an extension
movtci
movtci 1,2,3,4
movtci 1,2,3,4,5
movtci 1 ; bad
movtci 1,2 ; bad
movtci 1,2,3 ; bad
movtci 1 2 3 4 ; bad
movtci <>,<>,<>,<> ; bad
.end