Rev 485 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 485 | Rev 4039 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; Macroinstructions for defining data structures |
1 | ; Macroinstructions for defining data structures |
Line 2... | Line 2... | ||
2 | 2 | ||
- | 3 | macro struct name |
|
3 | macro struct name |
4 | { virtual at 0 |
4 | { fields@struct equ name |
5 | fields@struct equ name |
5 | match child parent, name \{ fields@struct equ child,fields@\#parent \} |
6 | match child parent, name \{ fields@struct equ child,fields@\#parent \} |
6 | sub@struct equ |
7 | sub@struct equ |
- | 8 | struc db [val] \{ \common define field@struct .,db, |
|
7 | struc db [val] \{ \common fields@struct equ fields@struct,.,db, |
9 | fields@struct equ fields@struct,field@struct \} |
- | 10 | struc dw [val] \{ \common define field@struct .,dw, |
|
8 | struc dw [val] \{ \common fields@struct equ fields@struct,.,dw, |
11 | fields@struct equ fields@struct,field@struct \} |
- | 12 | struc du [val] \{ \common define field@struct .,du, |
|
9 | struc du [val] \{ \common fields@struct equ fields@struct,.,du, |
13 | fields@struct equ fields@struct,field@struct \} |
- | 14 | struc dd [val] \{ \common define field@struct .,dd, |
|
10 | struc dd [val] \{ \common fields@struct equ fields@struct,.,dd, |
15 | fields@struct equ fields@struct,field@struct \} |
- | 16 | struc dp [val] \{ \common define field@struct .,dp, |
|
11 | struc dp [val] \{ \common fields@struct equ fields@struct,.,dp, |
17 | fields@struct equ fields@struct,field@struct \} |
- | 18 | struc dq [val] \{ \common define field@struct .,dq, |
|
12 | struc dq [val] \{ \common fields@struct equ fields@struct,.,dq, |
19 | fields@struct equ fields@struct,field@struct \} |
- | 20 | struc dt [val] \{ \common define field@struct .,dt, |
|
13 | struc dt [val] \{ \common fields@struct equ fields@struct,.,dt, |
21 | fields@struct equ fields@struct,field@struct \} |
- | 22 | struc rb count \{ define field@struct .,db,count dup (?) |
|
14 | struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \} |
23 | fields@struct equ fields@struct,field@struct \} |
- | 24 | struc rw count \{ define field@struct .,dw,count dup (?) |
|
15 | struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \} |
25 | fields@struct equ fields@struct,field@struct \} |
- | 26 | struc rd count \{ define field@struct .,dd,count dup (?) |
|
16 | struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \} |
27 | fields@struct equ fields@struct,field@struct \} |
- | 28 | struc rp count \{ define field@struct .,dp,count dup (?) |
|
17 | struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \} |
29 | fields@struct equ fields@struct,field@struct \} |
- | 30 | struc rq count \{ define field@struct .,dq,count dup (?) |
|
18 | struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \} |
31 | fields@struct equ fields@struct,field@struct \} |
- | 32 | struc rt count \{ define field@struct .,dt,count dup (?) |
|
19 | struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \} |
33 | fields@struct equ fields@struct,field@struct \} |
- | 34 | macro db [val] \{ \common \local anonymous |
|
20 | macro db [val] \{ \common \local anonymous |
35 | define field@struct anonymous,db, |
21 | fields@struct equ fields@struct,anonymous,db, |
36 | fields@struct equ fields@struct,field@struct \} |
- | 37 | macro dw [val] \{ \common \local anonymous |
|
22 | macro dw [val] \{ \common \local anonymous |
38 | define field@struct anonymous,dw, |
23 | fields@struct equ fields@struct,anonymous,dw, |
39 | fields@struct equ fields@struct,field@struct \} |
- | 40 | macro du [val] \{ \common \local anonymous |
|
24 | macro du [val] \{ \common \local anonymous |
41 | define field@struct anonymous,du, |
25 | fields@struct equ fields@struct,anonymous,du, |
42 | fields@struct equ fields@struct,field@struct \} |
- | 43 | macro dd [val] \{ \common \local anonymous |
|
26 | macro dd [val] \{ \common \local anonymous |
44 | define field@struct anonymous,dd, |
27 | fields@struct equ fields@struct,anonymous,dd, |
45 | fields@struct equ fields@struct,field@struct \} |
- | 46 | macro dp [val] \{ \common \local anonymous |
|
28 | macro dp [val] \{ \common \local anonymous |
47 | define field@struct anonymous,dp, |
29 | fields@struct equ fields@struct,anonymous,dp, |
48 | fields@struct equ fields@struct,field@struct \} |
- | 49 | macro dq [val] \{ \common \local anonymous |
|
30 | macro dq [val] \{ \common \local anonymous |
50 | define field@struct anonymous,dq, |
31 | fields@struct equ fields@struct,anonymous,dq, |
51 | fields@struct equ fields@struct,field@struct \} |
- | 52 | macro dt [val] \{ \common \local anonymous |
|
32 | macro dt [val] \{ \common \local anonymous |
53 | define field@struct anonymous,dt, |
33 | fields@struct equ fields@struct,anonymous,dt, |
54 | fields@struct equ fields@struct,field@struct \} |
34 | macro rb count \{ \local anonymous |
55 | macro rb count \{ \local anonymous |
- | 56 | define field@struct anonymous,db,count dup (?) |
|
35 | fields@struct equ fields@struct,anonymous,db,count dup (?) \} |
57 | fields@struct equ fields@struct,field@struct \} |
36 | macro rw count \{ \local anonymous |
58 | macro rw count \{ \local anonymous |
- | 59 | define field@struct anonymous,dw,count dup (?) |
|
37 | fields@struct equ fields@struct,anonymous,dw,count dup (?) \} |
60 | fields@struct equ fields@struct,field@struct \} |
38 | macro rd count \{ \local anonymous |
61 | macro rd count \{ \local anonymous |
- | 62 | define field@struct anonymous,dd,count dup (?) |
|
39 | fields@struct equ fields@struct,anonymous,dd,count dup (?) \} |
63 | fields@struct equ fields@struct,field@struct \} |
40 | macro rp count \{ \local anonymous |
64 | macro rp count \{ \local anonymous |
- | 65 | define field@struct anonymous,dp,count dup (?) |
|
41 | fields@struct equ fields@struct,anonymous,dp,count dup (?) \} |
66 | fields@struct equ fields@struct,field@struct \} |
42 | macro rq count \{ \local anonymous |
67 | macro rq count \{ \local anonymous |
- | 68 | define field@struct anonymous,dq,count dup (?) |
|
43 | fields@struct equ fields@struct,anonymous,dq,count dup (?) \} |
69 | fields@struct equ fields@struct,field@struct \} |
44 | macro rt count \{ \local anonymous |
70 | macro rt count \{ \local anonymous |
- | 71 | define field@struct anonymous,dt,count dup (?) |
|
45 | fields@struct equ fields@struct,anonymous,dt,count dup (?) \} |
72 | fields@struct equ fields@struct,field@struct \} |
46 | macro union \{ fields@struct equ fields@struct,,union,< |
73 | macro union \{ fields@struct equ fields@struct,,union,< |
47 | sub@struct equ union \} |
74 | sub@struct equ union \} |
48 | macro struct \{ fields@struct equ fields@struct,,substruct,< |
75 | macro struct \{ fields@struct equ fields@struct,,substruct,< |
49 | sub@struct equ substruct \} |
- | |
Line 50... | Line 76... | ||
50 | virtual at 0 } |
76 | sub@struct equ substruct \} } |
51 | 77 | ||
52 | macro ends |
78 | macro ends |
53 | { match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
79 | { match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
54 | restruc rb,rw,rd,rp,rq,rt |
80 | restruc rb,rw,rd,rp,rq,rt |
55 | purge db,dw,du,dd,dp,dq,dt |
81 | purge db,dw,du,dd,dp,dq,dt |
- | 82 | purge rb,rw,rd,rp,rq,rt |
|
- | 83 | purge union,struct |
|
- | 84 | match name tail,fields@struct, \\{ if $ |
|
- | 85 | display 'Error: definition of ',\\`name,' contains illegal instructions.',0Dh,0Ah |
|
56 | purge rb,rw,rd,rp,rq,rt |
86 | err |
57 | purge union,struct |
87 | end if \\} |
58 | match name=,fields,fields@struct \\{ fields@struct equ |
88 | match name=,fields,fields@struct \\{ fields@struct equ |
59 | make@struct name,fields |
89 | make@struct name,fields |
60 | fields@\\#name equ fields \\} |
90 | define fields@\\#name fields \\} |
61 | end virtual \} |
91 | end virtual \} |
Line 62... | Line 92... | ||
62 | match any, sub@struct \{ fields@struct equ fields@struct> \} |
92 | match any, sub@struct \{ fields@struct equ fields@struct> \} |
63 | restore sub@struct } |
93 | restore sub@struct } |
64 | - | ||
65 | macro make@struct name,[field,type,def] |
- | |
66 | { common |
- | |
67 | if $ |
- | |
68 | display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah |
94 | |
69 | err |
95 | macro make@struct name,[field,type,def] |
70 | end if |
96 | { common |
71 | local define |
97 | local define |
72 | define equ name |
98 | define equ name |
Line 79... | Line 105... | ||
79 | match fields, define \{ define@struct fields \} } |
105 | match fields, define \{ define@struct fields \} } |
80 | 106 | ||
Line 81... | Line 107... | ||
81 | macro define@struct name,[field,type,def] |
107 | macro define@struct name,[field,type,def] |
82 | { common |
108 | { common |
- | 109 | virtual |
|
- | 110 | db `name |
|
- | 111 | load initial@struct byte from 0 |
|
- | 112 | if initial@struct = '.' |
|
- | 113 | display 'Error: name of structure should not begin with a dot.',0Dh,0Ah |
|
- | 114 | err |
|
- | 115 | end if |
|
- | 116 | end virtual |
|
83 | local list |
117 | local list |
84 | list equ |
118 | list equ |
85 | forward |
119 | forward |
86 | if ~ field eq . |
120 | if ~ field eq . |
87 | name#field type def |
121 | name#field type def |
88 | sizeof.#name#field = $ - name#field |
122 | sizeof.#name#field = $ - name#field |
89 | else |
123 | else |
- | 124 | label name#.#type |
|
90 | rb sizeof.#type |
125 | rb sizeof.#type |
91 | end if |
126 | end if |
92 | local value |
127 | local value |
93 | match any, list \{ list equ list, \} |
128 | match any, list \{ list equ list, \} |
94 | list equ list |
129 | list equ list |
95 | common |
130 | common |
96 | sizeof.#name = $ |
131 | sizeof.#name = $ |
97 | restruc name |
132 | restruc name |
98 | match values, list \{ |
133 | match values, list \{ |
99 | struc name value \\{ |
134 | struc name value \\{ \\local \\..base |
100 | match any, fields@struct \\\{ fields@struct equ fields@struct,.,name, |
135 | match any, fields@struct \\\{ fields@struct equ fields@struct,.,name, |
101 | match , fields@struct \\\{ label . |
136 | match , fields@struct \\\{ label \\..base |
102 | forward |
137 | forward |
103 | match , value \\\\{ field type def \\\\} |
138 | match , value \\\\{ field type def \\\\} |
104 | match any, value \\\\{ field type value |
139 | match any, value \\\\{ field type value |
105 | if ~ field eq . |
140 | if ~ field eq . |
106 | rb sizeof.#name#field - ($-field) |
141 | rb sizeof.#name#field - ($-field) |
107 | end if \\\\} |
142 | end if \\\\} |
- | 143 | common label . at \\..base \\\} |
|
- | 144 | \\} |
|
- | 145 | macro name value \\{ |
|
- | 146 | match any, fields@struct \\\{ \\\local anonymous |
|
- | 147 | fields@struct equ fields@struct,anonymous,name, |
|
- | 148 | match , fields@struct \\\{ |
|
- | 149 | forward |
|
- | 150 | match , value \\\\{ type def \\\\} |
|
- | 151 | match any, value \\\\{ \\\\local ..field |
|
- | 152 | ..field = $ |
|
- | 153 | type value |
|
- | 154 | if ~ field eq . |
|
- | 155 | rb sizeof.#name#field - ($-..field) |
|
- | 156 | end if \\\\} |
|
108 | common \\\} \\} \} } |
157 | common \\\} \\} \} } |
Line 109... | Line 158... | ||
109 | 158 | ||
110 | macro enable@substruct |
159 | macro enable@substruct |
111 | { macro make@substruct substruct,parent,name,[field,type,def] |
160 | { macro make@substruct substruct,parent,name,[field,type,def] |
112 | \{ \common |
161 | \{ \common |
113 | \local define |
162 | \local define |
114 | define equ parent,name |
163 | define equ parent,name |
115 | \forward |
164 | \forward |
116 | \local sub |
165 | \local sub |
117 | match , field \\{ match any, type \\\{ enable@substruct |
166 | match , field \\{ match any, type \\\{ enable@substruct |
118 | make@substruct type,name,sub def |
167 | make@substruct type,parent,sub def |
119 | purge make@substruct |
168 | purge make@substruct |
120 | define equ define,.,sub, \\\} \\} |
169 | define equ define,.,sub, \\\} \\} |
121 | match any, field \\{ define equ define,.\#field,type, |
170 | match any, field \\{ define equ define,.\#field,type, |
122 | \common |
171 | \common |
Line 123... | Line 172... | ||
123 | match fields, define \\{ define@\#substruct fields \\} \} } |
172 | match fields, define \\{ define@\#substruct fields \\} \} } |
Line 124... | Line 173... | ||
124 | 173 | ||
125 | enable@substruct |
174 | enable@substruct |
126 | 175 | ||
127 | macro define@union parent,name,[field,type,def] |
176 | macro define@union parent,name,[field,type,def] |
128 | { common |
177 | { common |
129 | virtual at 0 |
178 | virtual at parent#.#name |
130 | forward |
179 | forward |
131 | if ~ field eq . |
180 | if ~ field eq . |
132 | virtual at 0 |
181 | virtual at parent#.#name |
133 | parent#field type def |
182 | parent#field type def |
134 | sizeof.#parent#field = $ - parent#field |
183 | sizeof.#parent#field = $ - parent#field |
- | 184 | end virtual |
|
- | 185 | if sizeof.#parent#field > $ - parent#.#name |
|
- | 186 | rb sizeof.#parent#field - ($ - parent#.#name) |
|
- | 187 | end if |
|
- | 188 | else |
|
- | 189 | virtual at parent#.#name |
|
- | 190 | label parent#.#type |
|
- | 191 | type def |
|
- | 192 | end virtual |
|
135 | end virtual |
193 | label name#.#type at parent#.#name |
136 | if sizeof.#parent#field > $ |
- | |
137 | rb sizeof.#parent#field - $ |
- | |
138 | end if |
194 | if sizeof.#type > $ - parent#.#name |
139 | else if sizeof.#type > $ |
195 | rb sizeof.#type - ($ - parent#.#name) |
140 | rb sizeof.#type - $ |
196 | end if |
141 | end if |
197 | end if |
142 | common |
198 | common |
143 | sizeof.#name = $ |
199 | sizeof.#name = $ - parent#.#name |
144 | end virtual |
200 | end virtual |
145 | struc name [value] \{ \common |
201 | struc name [value] \{ \common |
Line 151... | Line 207... | ||
151 | end virtual \\} |
207 | end virtual \\} |
152 | match , last@union \\{ match , value \\\{ field type def \\\} |
208 | match , last@union \\{ match , value \\\{ field type def \\\} |
153 | match any, value \\\{ field type value \\\} \\} |
209 | match any, value \\\{ field type value \\\} \\} |
154 | last@union equ field |
210 | last@union equ field |
155 | common rb sizeof.#name - ($ - .\#name) \} } |
211 | common rb sizeof.#name - ($ - .\#name) \} |
156 | 212 | macro name [value] \{ \common \local ..anonymous |
|
- | 213 | ..anonymous name value \} } |
|
- | 214 | ||
Line 157... | Line 215... | ||
157 | macro define@substruct parent,name,[field,type,def] |
215 | macro define@substruct parent,name,[field,type,def] |
158 | { common |
216 | { common |
159 | virtual at 0 |
217 | virtual at parent#.#name |
160 | forward |
218 | forward |
161 | if ~ field eq . |
219 | if ~ field eq . |
162 | parent#field type def |
220 | parent#field type def |
163 | sizeof.#parent#field = $ - parent#field |
221 | sizeof.#parent#field = $ - parent#field |
164 | else |
222 | else |
- | 223 | label parent#.#type |
|
165 | rb sizeof.#type |
224 | rb sizeof.#type |
166 | end if |
225 | end if |
167 | local value |
- | |
168 | common |
226 | common |
169 | sizeof.#name = $ |
227 | sizeof.#name = $ - parent#.#name |
170 | end virtual |
228 | end virtual |
171 | struc name value \{ |
229 | struc name value \{ |
172 | label .\#name |
230 | label .\#name |
173 | forward |
231 | forward |
174 | match , value \\{ field type def \\} |
232 | match , value \\{ field type def \\} |
175 | match any, value \\{ field type value |
233 | match any, value \\{ field type value |
176 | if ~ field eq . |
234 | if ~ field eq . |
177 | rb sizeof.#parent#field - ($-field) |
235 | rb sizeof.#parent#field - ($-field) |
178 | end if \\} |
236 | end if \\} |
179 | common \} } |
237 | common \} |
- | 238 | macro name value \{ \local ..anonymous |
|
- | 239 | ..anonymous name \} } |