Rev 111 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
131 | diamond | 1 | ; language for programs |
2 | lang fix en ; ru en fr ge fi |
||
3 | |||
4 | @^ fix macro comment { |
||
5 | ^@ fix } |
||
6 | |||
7 | |||
8 | macro m2m dest,src { |
||
9 | push src |
||
10 | pop dest |
||
11 | } |
||
12 | |||
31 | halyavin | 13 | ; new application structure |
14 | macro meos_app_start |
||
15 | { |
||
16 | use32 |
||
17 | org 0x0 |
||
18 | |||
19 | db 'MENUET01' |
||
20 | dd 0x01 |
||
21 | dd __start |
||
22 | dd __end |
||
23 | dd __memory |
||
24 | dd __stack |
||
25 | |||
26 | if used __params & ~defined __params |
||
27 | dd __params |
||
28 | else |
||
29 | dd 0x0 |
||
30 | end if |
||
31 | |||
32 | dd 0x0 |
||
33 | } |
||
34 | MEOS_APP_START fix meos_app_start |
||
35 | |||
36 | macro code |
||
37 | { |
||
38 | __start: |
||
39 | } |
||
40 | CODE fix code |
||
41 | |||
42 | macro data |
||
43 | { |
||
44 | __data: |
||
45 | } |
||
46 | DATA fix data |
||
47 | |||
48 | macro udata |
||
49 | { |
||
50 | if used __params & ~defined __params |
||
51 | __params: |
||
52 | db 0 |
||
53 | __end: |
||
54 | rb 255 |
||
55 | else |
||
56 | __end: |
||
57 | end if |
||
58 | __udata: |
||
59 | } |
||
60 | UDATA fix udata |
||
61 | |||
62 | macro meos_app_end |
||
63 | { |
||
64 | align 32 |
||
65 | rb 2048 |
||
66 | __stack: |
||
67 | __memory: |
||
68 | } |
||
69 | MEOS_APP_END fix meos_app_end |
||
70 | |||
71 | |||
72 | ; macro for defining multiline text data |
||
73 | struc mstr [sstring] |
||
74 | { |
||
75 | forward |
||
76 | local ssize |
||
77 | virtual at 0 |
||
78 | db sstring |
||
79 | ssize = $ |
||
80 | end virtual |
||
81 | dd ssize |
||
82 | db sstring |
||
83 | common |
||
84 | dd -1 |
||
85 | } |
||
86 | |||
87 | |||
88 | ; strings |
||
131 | diamond | 89 | macro sz name,[data] { ; from MFAR [mike.dld] |
90 | common |
||
91 | if used name |
||
92 | name db data |
||
93 | .size = $-name |
||
94 | end if |
||
95 | } |
||
96 | |||
97 | macro lsz name,[lng,data] { ; from MFAR [mike.dld] |
||
98 | common |
||
99 | if used name |
||
100 | label name |
||
101 | forward |
||
102 | if lang eq lng |
||
103 | db data |
||
104 | end if |
||
105 | common |
||
106 | .size = $-name |
||
107 | end if |
||
108 | } |
||
109 | |||
110 | macro szc name,elsz,[data] { ; from MFAR [mike.dld] |
||
111 | common |
||
112 | local s,m |
||
113 | m = 0 |
||
114 | if used name |
||
115 | label name |
||
116 | virtual at 0 |
||
31 | halyavin | 117 | db data |
131 | diamond | 118 | s = $ |
119 | end virtual |
||
120 | d#elsz s |
||
121 | if m < s |
||
122 | m = s |
||
31 | halyavin | 123 | end if |
131 | diamond | 124 | db data |
125 | .size = $-name |
||
126 | .maxl = m |
||
127 | end if |
||
31 | halyavin | 128 | } |
129 | |||
131 | diamond | 130 | macro lszc name,elsz,[lng,data] { ; from MFAR [mike.dld] |
131 | common |
||
132 | local s,m,c |
||
133 | m = 0 |
||
134 | c = 0 |
||
135 | if used name |
||
136 | label name |
||
137 | forward |
||
138 | if lang eq lng |
||
139 | virtual at 0 |
||
31 | halyavin | 140 | db data |
131 | diamond | 141 | s = $ |
142 | end virtual |
||
143 | d#elsz s |
||
144 | if m < s |
||
145 | m = s |
||
31 | halyavin | 146 | end if |
131 | diamond | 147 | db data |
148 | c = c+1 |
||
149 | end if |
||
150 | common |
||
151 | .size = $-name |
||
152 | .maxl = m |
||
153 | .count = c |
||
154 | end if |
||
31 | halyavin | 155 | } |
156 | |||
157 | |||
158 | ; easy system call macro |
||
159 | macro mpack dest, hsrc, lsrc |
||
160 | { |
||
161 | if (hsrc eqtype 0) & (lsrc eqtype 0) |
||
162 | mov dest, (hsrc) shl 16 + lsrc |
||
163 | else |
||
164 | if (hsrc eqtype 0) & (~lsrc eqtype 0) |
||
165 | mov dest, (hsrc) shl 16 |
||
166 | add dest, lsrc |
||
167 | else |
||
168 | mov dest, hsrc |
||
169 | shl dest, 16 |
||
170 | add dest, lsrc |
||
171 | end if |
||
172 | end if |
||
173 | } |
||
174 | |||
131 | diamond | 175 | ;macro __mov reg,a { ; mike.dld |
176 | ; if ~a eq |
||
177 | ; mov reg,a |
||
178 | ; end if |
||
179 | ;} |
||
180 | |||
181 | macro __mov reg,a,b { ; mike.dld |
||
182 | if (~a eq)&(~b eq) |
||
183 | mpack reg,a,b |
||
184 | else if (~a eq)&(b eq) |
||
31 | halyavin | 185 | mov reg,a |
186 | end if |
||
187 | } |
||
188 | |||
189 | macro mcall a,b,c,d,e,f { ; mike.dld |
||
190 | __mov eax,a |
||
191 | __mov ebx,b |
||
192 | __mov ecx,c |
||
193 | __mov edx,d |
||
194 | __mov esi,e |
||
195 | __mov edi,f |
||
196 | int 0x40 |
||
197 | } |
||
198 | |||
199 | |||
131 | diamond | 200 | ; ------------------------- |
201 | macro header a,[b] { |
||
202 | common |
||
203 | use32 |
||
204 | org 0 |
||
205 | db 'MENUET',a |
||
206 | forward |
||
207 | if b eq |
||
208 | dd 0 |
||
209 | else |
||
210 | dd b |
||
211 | end if } |
||
212 | macro section name { align 16 |
||
213 | label name } |
||
214 | macro func name { |
||
215 | if ~used name |
||
216 | display 'FUNC NOT USED: ',`name,13,10 |
||
217 | else |
||
218 | align 4 |
||
219 | name: |
||
220 | ;pushad |
||
221 | ;pushfd |
||
222 | ;dps `name |
||
223 | ;newline |
||
224 | ;mcall 5,1 |
||
225 | ;popfd |
||
226 | ;popad |
||
227 | } |
||
228 | macro endf { end if } |
||
31 | halyavin | 229 | |
131 | diamond | 230 | macro diff16 title,l1,l2 |
231 | { |
||
232 | local s,d |
||
233 | s = l2-l1 |
||
234 | display title,': 0x' |
||
235 | repeat 8 |
||
236 | d = '0' + s shr ((8-%) shl 2) and $0F |
||
237 | if d > '9' |
||
238 | d = d + 'A'-'9'-1 |
||
239 | end if |
||
240 | display d |
||
241 | end repeat |
||
242 | display 13,10 |
||
243 | } |
||
31 | halyavin | 244 | |
131 | diamond | 245 | macro diff10 title,l1,l2 |
246 | { |
||
247 | local s,d,z,m |
||
248 | s = l2-l1 |
||
249 | z = 0 |
||
250 | m = 1000000000 |
||
251 | display title,': ' |
||
252 | repeat 10 |
||
253 | d = '0' + s / m |
||
254 | s = s - (s/m)*m |
||
255 | m = m / 10 |
||
256 | if d <> '0' |
||
257 | z = 1 |
||
258 | end if |
||
259 | if z <> 0 |
||
260 | display d |
||
261 | end if |
||
262 | end repeat |
||
263 | display 13,10 |
||
264 | } |
||
31 | halyavin | 265 | |
266 | ; optimize the code for size |
||
267 | __regs fix |
||
268 | |||
269 | macro add arg1,arg2 |
||
270 | { |
||
271 | if (arg2 eqtype 0) |
||
272 | if (arg2) = 1 |
||
131 | diamond | 273 | inc arg1 |
31 | halyavin | 274 | else |
131 | diamond | 275 | add arg1,arg2 |
31 | halyavin | 276 | end if |
277 | else |
||
278 | add arg1,arg2 |
||
279 | end if |
||
280 | } |
||
281 | |||
282 | macro sub arg1,arg2 |
||
283 | { |
||
284 | if (arg2 eqtype 0) |
||
285 | if (arg2) = 1 |
||
131 | diamond | 286 | dec arg1 |
31 | halyavin | 287 | else |
131 | diamond | 288 | sub arg1,arg2 |
31 | halyavin | 289 | end if |
290 | else |
||
291 | sub arg1,arg2 |
||
292 | end if |
||
293 | } |
||
294 | |||
295 | macro mov arg1,arg2 |
||
296 | { |
||
297 | if (arg1 in __regs) & (arg2 eqtype 0) |
||
298 | if (arg2) = 0 |
||
131 | diamond | 299 | xor arg1,arg1 |
31 | halyavin | 300 | else if (arg2) = 1 |
131 | diamond | 301 | xor arg1,arg1 |
302 | inc arg1 |
||
31 | halyavin | 303 | else if (arg2) = -1 |
131 | diamond | 304 | or arg1,-1 |
31 | halyavin | 305 | else if (arg2) > -128 & (arg2) < 128 |
131 | diamond | 306 | push arg2 |
307 | pop arg1 |
||
31 | halyavin | 308 | else |
131 | diamond | 309 | mov arg1,arg2 |
31 | halyavin | 310 | end if |
311 | else |
||
312 | mov arg1,arg2 |
||
313 | end if |
||
314 | } |
||
315 | |||
316 | |||
131 | diamond | 317 | macro RGB [a] { |
318 | common |
||
319 | match (r=,g=,b),a \{ |
||
320 | \dd ((r) shl 16) or ((g) shl 8) or (b) |
||
321 | \} |
||
322 | } |
||
323 | |||
324 | |||
325 | struc POINT _t,_dx,_dy { |
||
326 | .x _t _dx |
||
327 | .y _t _dy |
||
328 | } |
||
329 | |||
330 | |||
331 | ; Macroinstructions for defining data structures |
||
332 | |||
31 | halyavin | 333 | macro struct name |
131 | diamond | 334 | { fields@struct equ name |
335 | match child parent, name \{ fields@struct equ child,fields@\#parent \} |
||
336 | sub@struct equ |
||
337 | struc db [val] \{ \common fields@struct equ fields@struct,.,db, |
||
338 | struc dw [val] \{ \common fields@struct equ fields@struct,.,dw, |
||
339 | struc du [val] \{ \common fields@struct equ fields@struct,.,du, |
||
340 | struc dd [val] \{ \common fields@struct equ fields@struct,.,dd, |
||
341 | struc dp [val] \{ \common fields@struct equ fields@struct,.,dp, |
||
342 | struc dq [val] \{ \common fields@struct equ fields@struct,.,dq, |
||
343 | struc dt [val] \{ \common fields@struct equ fields@struct,.,dt, |
||
344 | struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \} |
||
345 | struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \} |
||
346 | struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \} |
||
347 | struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \} |
||
348 | struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \} |
||
349 | struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \} |
||
350 | macro db [val] \{ \common \local anonymous |
||
351 | fields@struct equ fields@struct,anonymous,db, |
||
352 | macro dw [val] \{ \common \local anonymous |
||
353 | fields@struct equ fields@struct,anonymous,dw, |
||
354 | macro du [val] \{ \common \local anonymous |
||
355 | fields@struct equ fields@struct,anonymous,du, |
||
356 | macro dd [val] \{ \common \local anonymous |
||
357 | fields@struct equ fields@struct,anonymous,dd, |
||
358 | macro dp [val] \{ \common \local anonymous |
||
359 | fields@struct equ fields@struct,anonymous,dp, |
||
360 | macro dq [val] \{ \common \local anonymous |
||
361 | fields@struct equ fields@struct,anonymous,dq, |
||
362 | macro dt [val] \{ \common \local anonymous |
||
363 | fields@struct equ fields@struct,anonymous,dt, |
||
364 | macro rb count \{ \local anonymous |
||
365 | fields@struct equ fields@struct,anonymous,db,count dup (?) \} |
||
366 | macro rw count \{ \local anonymous |
||
367 | fields@struct equ fields@struct,anonymous,dw,count dup (?) \} |
||
368 | macro rd count \{ \local anonymous |
||
369 | fields@struct equ fields@struct,anonymous,dd,count dup (?) \} |
||
370 | macro rp count \{ \local anonymous |
||
371 | fields@struct equ fields@struct,anonymous,dp,count dup (?) \} |
||
372 | macro rq count \{ \local anonymous |
||
373 | fields@struct equ fields@struct,anonymous,dq,count dup (?) \} |
||
374 | macro rt count \{ \local anonymous |
||
375 | fields@struct equ fields@struct,anonymous,dt,count dup (?) \} |
||
376 | macro union \{ fields@struct equ fields@struct,,union,< |
||
377 | sub@struct equ union \} |
||
378 | macro struct \{ fields@struct equ fields@struct,,substruct,< |
||
379 | sub@struct equ substruct \} |
||
380 | virtual at 0 } |
||
31 | halyavin | 381 | |
131 | diamond | 382 | macro ends |
383 | { match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt |
||
384 | restruc rb,rw,rd,rp,rq,rt |
||
385 | purge db,dw,du,dd,dp,dq,dt |
||
386 | purge rb,rw,rd,rp,rq,rt |
||
387 | purge union,struct |
||
388 | match name=,fields,fields@struct \\{ fields@struct equ |
||
389 | make@struct name,fields |
||
390 | fields@\\#name equ fields \\} |
||
391 | end virtual \} |
||
392 | match any, sub@struct \{ fields@struct equ fields@struct> \} |
||
393 | restore sub@struct } |
||
394 | |||
395 | macro make@struct name,[field,type,def] |
||
396 | { common |
||
397 | if $ |
||
398 | display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah |
||
399 | err |
||
400 | end if |
||
401 | local define |
||
402 | define equ name |
||
403 | forward |
||
404 | local sub |
||
405 | match , field \{ make@substruct type,name,sub def |
||
406 | define equ define,.,sub, \} |
||
407 | match any, field \{ define equ define,.#field,type, |
||
408 | common |
||
409 | match fields, define \{ define@struct fields \} } |
||
410 | |||
411 | macro define@struct name,[field,type,def] |
||
412 | { common |
||
413 | local list |
||
414 | list equ |
||
415 | forward |
||
416 | if ~ field eq . |
||
417 | name#field type def |
||
418 | sizeof.#name#field = $ - name#field |
||
419 | else |
||
420 | rb sizeof.#type |
||
421 | end if |
||
422 | local value |
||
423 | match any, list \{ list equ list, \} |
||
424 | list equ list |
||
425 | common |
||
426 | sizeof.#name = $ |
||
427 | restruc name |
||
428 | match values, list \{ |
||
429 | struc name value \\{ |
||
430 | match any, fields@struct \\\{ fields@struct equ fields@struct,.,name, |
||
431 | match , fields@struct \\\{ label . |
||
432 | forward |
||
433 | match , value \\\\{ field type def \\\\} |
||
434 | match any, value \\\\{ field type value |
||
435 | if ~ field eq . |
||
436 | rb sizeof.#name#field - ($-field) |
||
437 | end if \\\\} |
||
438 | common \\\} \\} \} } |
||
439 | |||
440 | macro enable@substruct |
||
441 | { macro make@substruct substruct,parent,name,[field,type,def] |
||
442 | \{ \common |
||
443 | \local define |
||
444 | define equ parent,name |
||
445 | \forward |
||
446 | \local sub |
||
447 | match , field \\{ match any, type \\\{ enable@substruct |
||
448 | make@substruct type,name,sub def |
||
449 | purge make@substruct |
||
450 | define equ define,.,sub, \\\} \\} |
||
451 | match any, field \\{ define equ define,.\#field,type, |
||
452 | \common |
||
453 | match fields, define \\{ define@\#substruct fields \\} \} } |
||
454 | |||
455 | enable@substruct |
||
456 | |||
457 | macro define@union parent,name,[field,type,def] |
||
458 | { common |
||
459 | virtual at 0 |
||
460 | forward |
||
461 | if ~ field eq . |
||
462 | virtual at 0 |
||
463 | parent#field type def |
||
464 | sizeof.#parent#field = $ - parent#field |
||
465 | end virtual |
||
466 | if sizeof.#parent#field > $ |
||
467 | rb sizeof.#parent#field - $ |
||
468 | end if |
||
469 | else if sizeof.#type > $ |
||
470 | rb sizeof.#type - $ |
||
471 | end if |
||
472 | common |
||
473 | sizeof.#name = $ |
||
474 | end virtual |
||
475 | struc name [value] \{ \common |
||
476 | label .\#name |
||
477 | last@union equ |
||
478 | forward |
||
479 | match any, last@union \\{ virtual at .\#name |
||
480 | field type def |
||
481 | end virtual \\} |
||
482 | match , last@union \\{ match , value \\\{ field type def \\\} |
||
483 | match any, value \\\{ field type value \\\} \\} |
||
484 | last@union equ field |
||
485 | common rb sizeof.#name - ($ - .\#name) \} } |
||
486 | |||
487 | macro define@substruct parent,name,[field,type,def] |
||
488 | { common |
||
489 | virtual at 0 |
||
490 | forward |
||
491 | if ~ field eq . |
||
492 | parent#field type def |
||
493 | sizeof.#parent#field = $ - parent#field |
||
494 | else |
||
495 | rb sizeof.#type |
||
496 | end if |
||
497 | local value |
||
498 | common |
||
499 | sizeof.#name = $ |
||
500 | end virtual |
||
501 | struc name value \{ |
||
502 | label .\#name |
||
503 | forward |
||
504 | match , value \\{ field type def \\} |
||
505 | match any, value \\{ field type value |
||
506 | if ~ field eq . |
||
507 | rb sizeof.#parent#field - ($-field) |
||
508 | end if \\} |
||
509 | common \} } |
||
510 | |||
31 | halyavin | 511 | ; structures used in MeOS |
131 | diamond | 512 | struct process_information |
513 | cpu_usage dd ? ; +0 |
||
514 | window_stack_position dw ? ; +4 |
||
515 | window_stack_value dw ? ; +6 |
||
516 | not_used1 dw ? ; +8 |
||
517 | process_name rb 12 ; +10 |
||
518 | memory_start dd ? ; +22 |
||
519 | used_memory dd ? ; +26 |
||
520 | PID dd ? ; +30 |
||
521 | x_start dd ? ; +34 |
||
522 | y_start dd ? ; +38 |
||
523 | x_size dd ? ; +42 |
||
524 | y_size dd ? ; +46 |
||
525 | slot_state dw ? ; +50 |
||
31 | halyavin | 526 | rb (1024-52) |
131 | diamond | 527 | ends |
31 | halyavin | 528 | |
529 | struct system_colors |
||
131 | diamond | 530 | frame dd ? |
531 | grab dd ? |
||
532 | grab_button dd ? |
||
533 | grab_button_text dd ? |
||
534 | grab_text dd ? |
||
535 | work dd ? |
||
536 | work_button dd ? |
||
537 | work_button_text dd ? |
||
538 | work_text dd ? |
||
539 | work_graph dd ? |
||
540 | ends |
||
31 | halyavin | 541 | |
542 | |||
543 | ; constants |
||
544 | |||
545 | ; events |
||
546 | EV_IDLE = 0 |
||
547 | EV_TIMER = 0 |
||
548 | EV_REDRAW = 1 |
||
131 | diamond | 549 | EV_KEY = 2 |
31 | halyavin | 550 | EV_BUTTON = 3 |
551 | EV_EXIT = 4 |
||
552 | EV_BACKGROUND = 5 |
||
553 | EV_MOUSE = 6 |
||
131 | diamond | 554 | EV_IPC = 7 |
31 | halyavin | 555 | EV_STACK = 8 |
556 | |||
557 | ; event mask bits for function 40 |
||
131 | diamond | 558 | EVM_REDRAW = 1b |
31 | halyavin | 559 | EVM_KEY = 10b |
560 | EVM_BUTTON = 100b |
||
561 | EVM_EXIT = 1000b |
||
562 | EVM_BACKGROUND = 10000b |
||
563 | EVM_MOUSE = 100000b |
||
564 | EVM_IPC = 1000000b |
||
131 | diamond | 565 | EVM_STACK = 10000000b |