open-simh.simtools/tests/test-prec.lst.ok
Olaf Seibert e3042c9175 Remove dubious workaround in parse_unary().
The comment "eat first char of illegal label, else endless loop on
implied .WORD" was no longer true. It did reveal some other small
gotchas, which are corrected now as well.
2021-01-23 21:30:52 +01:00

131 lines
7.4 KiB
Plaintext

1 ;;;;;
2 ;
3 ; Test operator precedencce
4 ; or rather the lack thereof
5 ;
6 000000 000006 .word 1 + 2 + 3 ; 6
7 000002 000011 .word 1 + 2 * 3 ; 3*3 = 11
8 000004 000004 .word 1 & 2 ! 4 ; 0 ! 4 = 4
9 000006 000000 .word 1 ! 2 & 4 ; 3 & 4 = 0
10 000010 000003 .word 1 ! 2 & 7 ; 3 & 7 = 3
11 000012 000005 .word 1+1 ! 2+3 ; 2!2+3 = 2+3 = 5
12
13 ;;;;;
14 ;
15 ; Test all operators at least once
16 ;
17 000014 000007 .word 3 + 4 ; 000007
18 000016 000001 .word 4 - 3 ; 000001
19 000020 000014 .word 3 * 4 ; 000014
20 000022 000003 .word 12. / 4 ; 000003
21 000024 000121 .word 123 & 771 ; 000121
22 000026 123323 .word 123121 ! 322 ; 123323
23
24 000030 177401 .word - 377 ; 177401
25 000032 000377 .word + 377 ; 000377
26
27 000034 177400 .word ^C 377 ; 177400
28 000036 177400 .word ^c 377 ; 177400
29 000040 052525 .word ^B 0101010101010101 ; 052525
30 000042 125252 .word ^b 1010101010101010 ; 125252
31 000044 000144 .word ^d 100 ; 000144
32 000046 000144 .word 100. ; 000144
33 000050 000400 .word ^x 100 ; 000400 hexadecimal is an extension
34 000052 070254 .word ^rRAD ; 070254 up to 3 characters; no leading spaces
35 000054 003100 .word ^rA ; 003100 up to 3 characters
36 000056 000050 .word ^r A ; 000050 up to 3 characters
37 000060 000001 .word ^r A ; 000001 up to 3 characters
38 000062 000051 .word ^r AA ; 000051
39 000064 003101 .word ^rA A ; 003101
40 000066 003150 .word ^rAA ; 003150
41 000070 003151 .word ^r^/AAA/ ; bracketed strings are an extension
42 000072 070254 .word ^r<RAD> ; bracketed strings are an extension
43 000074 000054 .word ^r< AD> ; bracketed strings are an extension
44 000076 000004 .word ^r< D> ; bracketed strings are an extension
45 000100 070204 .word ^r<R D> ; bracketed strings are an extension
46 000102 070250 .word ^r<RA > ; bracketed strings are an extension
47 000104 157614 .word ^R50. ; 157614 there is no whitespace in between.
48 000106 040300 .word ^f 1.5 ; 040300
49
50 ;;;;;
51 ;
52 ; Test bracketing
53 ;
54 000110 000007 .word 1 + < 2 * 3 > ; 1 + 6 = 7
55 000112 000007 .word 1 + ^! 2 * 3 ! ; 1 + 6 = 7
56 000114 000007 .word 1 + ^/ 2 * 3 / ; 1 + 6 = 7
57 000116 000007 .word 1 + ^$ 2 * 3 $ ; 1 + 6 = 7
test-prec.mac:58: ***ERROR Invalid expression
58 000120 000003 000000 .word 1 + ^* 2 * 3 * ; Invalid expression
59
60 ;;;;;
61 ;
62 ; There was an obscure bug in parse_expr(), used to evaluate 'if df',
63 ; where it could skip past the end of the line marker.
64 ;
65 ; If this happened inside an expanded macro, then after that was the
66 ; next line...
67 ; In other cases it might be worse.
68 ;
69 .macro dirdef name, flags, cond
70 .rad50 /.'name/
71 .byte flags+0, 0
72 .if df cond
73 .globl opcerr
74 .word opcerr
75 .iff
76 .globl name
77 .word name
78 .endc
79 .endm
80
81 000124 dirdef name
1 000124 130461 051010 .rad50 /.name/
2 000130 000 000 .byte +0, 0
3 .if df
4 .globl opcerr
5 .word opcerr
6 .iff
7 .globl name
8 000132 000000G .word name
9 .endc
82
test-prec.mac:83: ***ERROR Invalid expression in .WORD
83 .word (
test-prec.mac:84: ***ERROR Invalid expression in .WORD
84 (
85
test-prec.mac:86: ***ERROR Invalid expression in .WORD
86 .word _,$
test-prec.mac:87: ***ERROR Invalid expression in .WORD
87 _
88 000134 000000G $
test-prec.mac:89: ***ERROR Invalid expression in .WORD
89 .word /
test-prec.mac:90: ***ERROR Invalid expression in .WORD
90 /
test-prec.mac:91: ***ERROR Invalid expression in .WORD
91 .word ^px
test-prec.mac:92: ***ERROR Invalid expression in .WORD
92 ^px
test-prec.mac:93: ***ERROR Invalid expression in .WORD
93 .word ^px / 256
test-prec.mac:94: ***ERROR Invalid expression in .WORD
94 ^px / 256
95
96 000136 000001 000002 000003 1,2,3
97 000144 000000G 000000G 000000G .1,.2,.3
97
Symbol table
$ = ****** GX .1 = ****** GX .3 = ****** GX
. ******R 001 .2 = ****** GX NAME = ****** G
Program sections:
. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV)
000152 001 (RW,I,LCL,REL,CON,NOSAV)