Merge branch 'master' into mlb2

This commit is contained in:
Olaf Seibert 2017-05-04 23:02:08 +02:00
commit e42bc827ff
4 changed files with 220 additions and 1 deletions

View File

@ -859,7 +859,7 @@ static int assemble(
/* FIXME I don't know if the following
is portable enough. */
if (tvalue->data.lit & 0x8000)
sword |= ~0xFFFF; /* Render negative */
sword |= ~0x7FFF; /* Render negative */
/* Reduce unsigned value to 16 bits */
uword = tvalue->data.lit & 0xffff;

View File

@ -12,6 +12,7 @@ TESTS="test-asciz \
test-bsl-mac-arg \
test-complex-reloc \
test-endm \
test-if \
test-impword \
test-include \
test-jmp \

115
tests/test-if.lst.ok Normal file
View File

@ -0,0 +1,115 @@
1 ;;;;;
2 ;
3 ; Test various conditions of the condition directive
4 ;
5
6 000000 zero = 0
7 000001 one = 1
8 000002 defd = 2
9 177777 min1 = -1
10
11 ; defined
12 000000 001 .iif df defd .byte 1
13 .iif df undf .byte 0
14 .iif ndf defd .byte 0
15 000001 001 .iif ndf undf .byte 1
16
17 .ifdf defd
18 000002 001 .byte 1
19 .endc
20 .ifdf undf
21 .byte 0
22 .endc
23 .ifndf defd
24 .byte 0
25 .endc
26 .ifndf undf
27 000003 001 .byte 1
28 .endc
29
30 ; blank (string)
31 000004 001 .iif b ^// .byte 1
32 .iif b <x> .byte 0
33 .iif nb <> .byte 0
34 000005 001 .iif nb ^/x/ .byte 1
35
36 ; identical (strings)
37 000006 001 .iif idn ^/a/ <a> .byte 1
38 .iif idn ^/a/ <b> .byte 0
39 .iif dif ^/a/ <a> .byte 0
40 000007 001 .iif dif ^/a/ <b> .byte 1
41
42 ; skip P1 and P2
43
44 ; equal to zero (value)
45 000000 001 .iif eq zero .byte 1
46 000001 .iif eq one .byte 0
47 000000 .iif ne zero .byte 0
48 000001 001 .iif ne one .byte 1
49
50 000000 001 .iif z zero .byte 1
51 000001 .iif z one .byte 0
52 000000 .iif nz zero .byte 0
53 000001 001 .iif nz one .byte 1
54
55 ; greater than zero (value)
56 177777 .iif gt min1 .byte 0
57 000000 .iif gt zero .byte 0
58 000001 001 .iif gt one .byte 1
59
60 177777 .iif g min1 .byte 0
61 000000 .iif g zero .byte 0
62 000001 001 .iif g one .byte 1
63
64 ; greater than or equal to zero (value)
65 177777 .iif ge min1 .byte 0
66 000000 001 .iif ge zero .byte 1
67 000001 001 .iif ge one .byte 1
68
69 ; less than zero (value)
70 177777 001 .iif lt min1 .byte 1
71 000000 .iif lt zero .byte 0
72 000001 .iif lt one .byte 0
73
74 177777 001 .iif l min1 .byte 1
75 000000 .iif l zero .byte 0
76 000001 .iif l one .byte 0
77
78 ; less than or equal to zero (value)
79 177777 001 .iif le min1 .byte 1
80 000000 001 .iif le zero .byte 1
81 000001 .iif le one .byte 0
82
83
84 ; multiline conditions
85 000001 .if ne one
86 000024 001 .byte 1
87 .iff
88 .byte 0
89 .ift
90 000025 001 .byte 1
91 .iftf
92 000026 001 .byte 1
93 .endc
94
95 000001 .if eq one
96 .byte 0
97 .iff
98 000027 001 .byte 1
99 .ift
100 .byte 0
101 .iftf
102 000030 001 .byte 1
103 .endc
103
Symbol table
. ******R 001 DEFD =000002 MIN1 =177777 ONE =000001 ZERO =000000
Program sections:
. ABS. 000000 000 (RW,I,GBL,ABS,OVR,NOSAV)
000031 001 (RW,I,LCL,REL,CON,NOSAV)

103
tests/test-if.mac Normal file
View File

@ -0,0 +1,103 @@
;;;;;
;
; Test various conditions of the condition directive
;
zero = 0
one = 1
defd = 2
min1 = -1
; defined
.iif df defd .byte 1
.iif df undf .byte 0
.iif ndf defd .byte 0
.iif ndf undf .byte 1
.ifdf defd
.byte 1
.endc
.ifdf undf
.byte 0
.endc
.ifndf defd
.byte 0
.endc
.ifndf undf
.byte 1
.endc
; blank (string)
.iif b ^// .byte 1
.iif b <x> .byte 0
.iif nb <> .byte 0
.iif nb ^/x/ .byte 1
; identical (strings)
.iif idn ^/a/ <a> .byte 1
.iif idn ^/a/ <b> .byte 0
.iif dif ^/a/ <a> .byte 0
.iif dif ^/a/ <b> .byte 1
; skip P1 and P2
; equal to zero (value)
.iif eq zero .byte 1
.iif eq one .byte 0
.iif ne zero .byte 0
.iif ne one .byte 1
.iif z zero .byte 1
.iif z one .byte 0
.iif nz zero .byte 0
.iif nz one .byte 1
; greater than zero (value)
.iif gt min1 .byte 0
.iif gt zero .byte 0
.iif gt one .byte 1
.iif g min1 .byte 0
.iif g zero .byte 0
.iif g one .byte 1
; greater than or equal to zero (value)
.iif ge min1 .byte 0
.iif ge zero .byte 1
.iif ge one .byte 1
; less than zero (value)
.iif lt min1 .byte 1
.iif lt zero .byte 0
.iif lt one .byte 0
.iif l min1 .byte 1
.iif l zero .byte 0
.iif l one .byte 0
; less than or equal to zero (value)
.iif le min1 .byte 1
.iif le zero .byte 1
.iif le one .byte 0
; multiline conditions
.if ne one
.byte 1
.iff
.byte 0
.ift
.byte 1
.iftf
.byte 1
.endc
.if eq one
.byte 0
.iff
.byte 1
.ift
.byte 0
.iftf
.byte 1
.endc