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