summaryrefslogtreecommitdiff
path: root/v4.0/src/INC/STRUC.INC
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/INC/STRUC.INC')
-rw-r--r--v4.0/src/INC/STRUC.INC702
1 files changed, 702 insertions, 0 deletions
diff --git a/v4.0/src/INC/STRUC.INC b/v4.0/src/INC/STRUC.INC
new file mode 100644
index 0000000..f024a9a
--- /dev/null
+++ b/v4.0/src/INC/STRUC.INC
@@ -0,0 +1,702 @@
1;;STRUC--Stucture Macro Library
2;;Optimizing Version 2.30 03/31/87
3
4if1
5$NoConj equ 0
6$And equ 1
7$Or equ 2
8$Short equ 3
9$Near equ 4
10$NearToShort equ 5
11$ncxz equ 6
12$AndOr = 0
13$Temp = 0
14$Temp2 = 0
15$Dist = 0
16
17$NoType equ 10
18$ConjIfType equ 11
19$IfType equ 12
20$ElseType equ 13
21$WhileType equ 14
22$ConjWhileType equ 15
23$RepeatType equ 16
24$ConjUntilType equ 17
25$ForType equ 18
26$ConjLeaveType equ 19
27$SelectType equ 20
28$WhenType equ 21
29$ConjWhenType equ 22
30$OtherwiseType equ $ElseType
31
32$StrucError macro text
33 Structure error -- text
34endm
35
36J macro
37endm
38JN macro
39endm
40
41$BuildJump macro j1,j2
42 j1 macro t
43 .xcref j1
44 j2 t
45 endm
46endm
47
48irp x,<<jeq,je>,<jlt,jl>,<jgt,jg>,<jneq,jne>,<jnlt,jnl>,<jngt,jng>,<jnpe,jpo>,<jnpo,jpe>>
49 $BuildJump x
50endm
51irp x,<<jzero,jz>,<jnzero,jnz>,<jnonzero,jnz>,<jnnonzero,jz>,<jand,jnz>,<jnand,jz>,<jnnand,jnz>>
52 $BuildJump x
53endm
54irp x,<a,ae,b,be,c,e,g,ge,l,le,o,p,s,z,cxz>
55 $BuildJump jnn&x,j&x
56endm
57
58jncxz macro t
59 if $Dist eq $NearToShort
60 jcxz $+5
61 jmp t
62 else
63 jcxz $+4
64 jmp short t
65 endif
66endm
67
68purge $BuildJump
69
70$GetConj macro p1,p2
71 $AndOr = $NoConj
72 irp parm,<p1,p2>
73 ifnb <&parm>
74 irp x,<and,AND,or,OR>
75 ifidn <parm>,<x>
76 $AndOr = $&&&x
77 exitm
78 endif
79 endm
80 endif
81 endm
82endm
83
84$GetDist macro p1,p2
85 irp parm,<p1,p2>
86 ifnb <parm>
87 irp x,<short,SHORT,near,NEAR>
88 ifidn <parm>,<x>
89 $Dist = $&&&x
90 exitm
91 endif
92 endm
93 endif
94 endm
95endm
96
97
98$Poke macro n,m
99 $st&n = m
100.xcref $st&n
101endm
102
103$Peek macro x,n
104 x = $st&n
105endm
106
107$Push macro n
108 $st = $st+1
109 $Poke %$st,n
110endm
111
112$Pop macro x
113 if $st gt 0
114 $Peek x,%$st
115 $st = $st-1
116 else
117 $StrucError <open structure>
118 endif
119endm
120
121$EquateLabel macro last,this
122 if $LastLabelOrg eq $
123 $ll&last = this
124 .xcref $ll&last
125 endif
126endm
127
128$TraceLabel macro n,a,b
129 if $ll&a eq $ll&b
130 $ll&n = b
131 .xcref $ll&n
132 else
133 $TraceLabel n,%$ll&a,%$ll&b
134 endif
135endm
136
137$Label macro n
138 if1
139 $EquateLabel %$LastLabel,n
140 $ll&n = n
141 .xcref $ll&n
142 $LastLabel = n
143 $LastLabelOrg = $
144$l&n:
145 else
146 if $ll&n eq n
147$l&n:
148 else
149 .xcref $l&n
150 .xcref $ll&n
151 endif
152 endif
153endm
154
155$CondJump macro l,tf,c
156 if1
157 ifb <c>
158 $EquateLabel %$LastLabel,l
159 endif
160 ifndef <$ll&l>
161 $ll&l = l
162 .xcref $ll&l
163 endif
164 else
165 $TraceLabel l,l,%$ll&l
166 endif
167 $CondJump2 %$ll&l,tf,c
168endm
169
170$CondJump2 macro l,tf,c
171 if $Dist eq $Short
172 ifb <c>
173 jmp short $l&l
174 else
175 ifidn <tf>,<f>
176 jn&c $l&l
177 else
178 j&c $l&l
179 endif
180 endif
181 else
182 ifnb <c>
183 ifdef $l&l
184 if (($ - $l&l) le 126) and (($l&l - $) le 129)
185 $Dist = $NearToShort
186 $nops = 3
187 ifidn <tf>,<f>
188 jn&c $l&l
189 ifdef $n&c
190 if $n&c eq $ncxz
191 $nops = 0
192 endif
193 endif
194 ifdef $&c
195 if $&c eq $ncxz
196 $nops = 5
197 endif
198 endif
199 else
200 j&c $l&l
201 ifdef $n&c
202 if $n&c eq $ncxz
203 $nops = 5
204 endif
205 endif
206 ifdef $&c
207 if $&c eq $ncxz
208 $nops = 0
209 endif
210 endif
211 endif
212 rept $nops
213 nop
214 endm
215 else
216 ifidn <tf>,<f>
217 j&c $+5
218 else
219 jn&c $+5
220 endif
221 jmp $l&l
222 endif
223 else
224 ifidn <tf>,<f>
225 j&c $+5
226 else
227 jn&c $+5
228 endif
229 jmp $l&l
230 endif
231 else
232 ifdef $l&l
233 ifidn <tf>,<NoFold>
234 jmp $l&l
235 else
236 if (($ - $l&l) le 126) and (($l&l - $) le 129)
237 jmp short $l&l
238 nop
239 else
240 jmp $l&l
241 endif
242 endif
243 else
244 jmp $l&l
245 endif
246 endif
247 endif
248endm
249
250
251$CondLoop macro l,c
252 loop&c $l&l
253endm
254
255$Test macro tgt,a1,a2,a3,a4,x
256 ifb <a1>
257 $StrucError <invalid condition>
258 else
259 ifb <a2>
260 $CondJump %&tgt,a1
261 else
262 ifb <a3>
263 ifdif <a1>,<zero>
264 ifdif <a1>,<nonzero>
265 ifdif <a1>,<ZERO>
266 ifdif <a1>,<NONZERO>
267 $StrucError <invalid condition>
268 exitm
269 endif
270 endif
271 endif
272 endif
273 or a2,a2
274 $CondJump %&tgt,a1
275 else
276 ifb <a4>
277 cmp a1,a3
278 $CondJump %&tgt,a2
279 else
280 ifb <x>
281 ifdif <a1>,<bit>
282 ifdif <a1>,<BIT>
283 $StrucError <invalid condition>
284 exitm
285 endif
286 endif
287 test a2,a4
288 $CondJump %&tgt,a3
289 else
290 $StrucError <invalid condition>
291 endif
292 endif
293 endif
294 endif
295 endif
296endm
297
298$TopTest macro args,n,c,p4,p5
299 $GetConj p4,p5
300 $Dist = $DefDist
301 $GetDist p4,p5
302 if $AndOr eq $NoConj
303 $Test <$sn-1,f>,args
304 $Pop $Temp
305 if $OrFound
306 $Label %$Temp
307 endif
308 $Push n
309 else
310 if $AndOr eq $And
311 $Test <$sn-1,f>,args
312 else
313 $OrFound = 1
314 $Test <$sn,t>,args
315 endif
316 $Push c
317 endif
318endm
319;;*****************************************************************************
320.if macro t,p2,p3
321 $Peek $Temp,%$st
322 if $Temp eq $ConjIfType
323 $Pop $Temp
324 else
325 $OrFound = 0
326 $sn = $sn+1
327 $Push $sn
328 $sn = $sn+1
329 $Push $sn
330 $sn = $sn+1
331 $Push $sn
332 endif
333 $TopTest <t>,$IfType,$ConjIfType,p2,p3
334endm
335;;*****************************************************************************
336.then macro
337 $Peek $Temp,%$st
338 if $Temp ne $IfType
339 if $Temp ne $WhenType
340 $StrucError <then without if or when>
341 endif
342 endif
343endm
344;;*****************************************************************************
345.elseif macro t,p2,p3
346 $Pop $Temp
347 if $Temp ne $IfType
348 $StrucError <elseif without if>
349 exitm
350 endif
351 $OrFound = 0
352 $Pop $Temp
353 $Peek $Temp2,%$st
354 $Dist = $Near
355 $CondJump %$Temp2
356 $Label %$Temp
357 $sn = $sn+1
358 $Push $sn
359 $sn = $sn+1
360 $Push $sn
361 $TopTest <t>,$IfType,$ConjIfType,p2,p3
362endm
363;;*****************************************************************************
364.else macro dist
365 $Pop $Temp
366 if $Temp ne $IfType
367 if $Temp ne $WhenType
368 if $Temp ne $SelectType
369 $StrucError <else without if, when or select>
370 exitm
371 endif
372 endif
373 endif
374 $sn = $sn+1
375 if $Temp eq $SelectType
376 $Push $sn
377 else
378 $Dist = $DefDist
379 $GetDist dist
380 $CondJump %$sn
381 $Pop $Temp
382 $Label %$Temp
383 $Push $sn
384 endif
385 $push $ElseType
386endm
387;;*****************************************************************************
388.endif macro
389 $Pop $Temp
390 if $Temp ne $IfType
391 if $Temp ne $ElseType
392 $StrucError <endif without if>
393 exitm
394 endif
395 endif
396 $Pop $Temp
397 $Label %$Temp
398 $Pop $Temp
399 $Label %$Temp
400endm
401;;*****************************************************************************
402.select macro x
403 $OrFound = 0
404 $sn = $sn+1
405 $Push $sn
406 $Push $SelectType
407endm
408;;*****************************************************************************
409.when macro tst,p2,p3
410 $Pop $Temp
411 if $Temp ne $SelectType
412 if $Temp ne $WhenType
413 if $Temp ne $ConjWhenType
414 $StrucError <when without select>
415 exitm
416 endif
417 endif
418 endif
419 if $Temp ne $ConjWhenType
420 $Dist = $Near
421 $OrFound = 0
422 if $Temp eq $WhenType
423 $Pop $Temp2
424 $Peek $Temp,%$st
425 $CondJump %$Temp
426 $Label %$Temp2
427 endif
428 $sn = $sn+1
429 $Push $sn
430 $sn = $sn+1
431 $Push $sn
432 endif
433 $TopTest <tst>,$WhenType,$ConjWhenType,p2,p3
434endm
435;;*****************************************************************************
436.otherwise macro dist
437 $Pop $Temp
438 if $Temp ne $WhenType
439 if $Temp ne $SelectType
440 if $Temp ne $IfType
441 $StrucError <otherwise without if, when or select>
442 exitm
443 endif
444 endif
445 endif
446 $sn = $sn+1
447 if $Temp eq $SelectType
448 $Push $sn
449 else
450 $Dist = $DefDist
451 $GetDist dist
452 $CondJump %$sn
453 $Pop $Temp
454 $Label %$Temp
455 $Push $sn
456 endif
457 $push $OtherwiseType
458endm
459;;*****************************************************************************
460.endselect macro
461 $Pop $Temp
462 if $Temp ne $WhenType
463 if $Temp ne $OtherwiseType
464 if $Temp ne $SelectType
465 $StrucError <endselect without select>
466 exitm
467 endif
468 endif
469 endif
470 $pop $Temp2
471 if $Temp ne $SelectType
472 $Label %$Temp2
473 $Pop $Temp2
474 $Label %$Temp2
475 endif
476endm
477;;*****************************************************************************
478.while macro t,p2,p3
479 $Peek $Temp,%$st
480 if $Temp eq $ConjWhileType
481 $Pop $Temp
482 else
483 $Push $LoopEnd
484 $OrFound = 0
485 $sn = $sn + 1
486 $Push $sn
487 $Label %$sn
488 $sn = $sn + 2
489 $Push $sn
490 $LoopEnd = $sn - 1
491 endif
492 $TopTest <t>,$WhileType,$ConjWhileType,p2,p3
493endm
494;;*****************************************************************************
495.endwhile macro p1
496 $Pop $Temp
497 if $Temp ne $WhileType
498 $StrucError <endwhile without while>
499 exitm
500 endif
501 $Dist = $Near
502 $Pop $Temp
503 $CondJump %$Temp,NoFold
504 $Label %$Temp+1
505 $Pop $LoopEnd
506endm
507;;*****************************************************************************
508.repeat macro
509 $Push $LoopEnd
510 $Push $LeaveFound
511 $sn = $sn+1
512 $Label %$sn
513 $Push $sn
514 $Push $RepeatType
515 $sn = $sn+1
516 $LoopEnd = $sn
517 $LeaveFound = 0
518endm
519;;*****************************************************************************
520.until macro t,p2,p3
521 $until2 p2,p3,t
522endm
523$until2 macro p2,p3,a1,a2,a3,a4,x
524 $Pop $Temp
525 if $Temp ne $RepeatType
526 if $Temp ne $ConjUntilType
527 $StrucError <until without repeat>
528 exitm
529 endif
530 else
531 $OrFound = 0
532 endif
533 $Dist = $DefDist
534 $GetDist p2,p3
535 $GetConj p2,p3
536
537 if $AndOr eq $NoConj
538 $Pop $Temp
539 ifb <a1>
540 $Dist = $Near
541 $CondJump %$Temp,NoFold
542 else
543 $Test <$Temp,f>,<a1>,<a2>,<a3>,<a4>,<x>
544 endif
545 if $OrFound or $LeaveFound
546 $Label %$Temp+1
547 endif
548 $Pop $LeaveFound
549 $Pop $LoopEnd
550 else
551 $Peek $Temp,%$st
552 if $AndOr eq $And
553 $Test <$Temp,f>,<a1>,<a2>,<a3>,<a4>,<x>
554 else
555 $OrFound = 1
556 $Test <$Temp+1,t>,<a1>,<a2>,<a3>,<a4>,<x>
557 endif
558 $Push $ConjUntilType
559 endif
560endm
561;;*****************************************************************************
562.loop macro cond
563 $Pop $Temp
564 if $Temp ne $RepeatType
565 $StrucError <loop without repeat>
566 exitm
567 endif
568 $Pop $Temp
569 $CondLoop %$Temp,cond
570 if $LeaveFound
571 $Label %$Temp+1
572 endif
573 $Pop $LeaveFound
574 $Pop $LoopEnd
575endm
576;;*****************************************************************************
577.for macro index,equals,start,to,stop,by,step,dist
578 mov index,start
579 $Push $LoopEnd
580 $sn = $sn+1
581 $Push $sn
582 $Label %$sn
583 $sn = $sn+1
584 $LoopEnd = $sn
585 cmp index,stop
586 $Dist = $DefDist
587 ifb <step>
588 $Push 1
589 $GetDist by
590 $CondJump %$sn,t,gt
591 else
592 $GetDist dist
593 $Push %(step)
594 if step lt 0
595 $CondJump %$sn,t,lt
596 else
597 $CondJump %$sn,t,gt
598 endif
599 endif
600 $Push $ForType
601endm
602;;*****************************************************************************
603.next macro index,dist
604 $Pop $Temp
605 if $Temp ne $ForType
606 $StrucError <next without for>
607 exitm
608 endif
609 $Pop $Temp
610 if $Temp eq 1
611 inc index
612 else
613 if $Temp eq -1
614 dec index
615 else
616 add index,$Temp
617 endif
618 endif
619 $Pop $Temp
620 $Dist = $Near
621 $CondJump %$Temp,NoFold
622 $Label %$Temp+1
623 $Pop $LoopEnd
624endm
625;;*****************************************************************************
626.leave macro t,p2,p3
627 $leave2 p2,p3,t
628endm
629$leave2 macro p2,p3,a1,a2,a3,a4,x
630 ife $LoopEnd
631 $StrucError <leave outside a loop>
632 exitm
633 endif
634 $LeaveFound = 1
635 $Peek $Temp,%$st
636 if $Temp eq $ConjLeaveType
637 $Pop $Temp
638 else
639 $OrFound = 0
640 $sn = $sn + 1
641 endif
642 $Dist = 0
643 $GetDist <a1>
644 if $Dist
645 $CondJump %$LoopEnd
646 if $OrFound
647 $Label %$sn
648 endif
649 else
650 $Dist = $DefDist
651 $GetDist p2,p3
652 $GetConj p2,p3
653 if $AndOr eq $NoConj
654 ifb <a1>
655 $CondJump %$LoopEnd,t
656 else
657 $Test <$LoopEnd,t>,<a1>,<a2>,<a3>,<a4>,<x>
658 endif
659 if $OrFound
660 $Label %$sn
661 endif
662 else
663 if $AndOr eq $And
664 $OrFound = 1
665 $Test <$sn,f>,<a1>,<a2>,<a3>,<a4>,<x>
666 else
667 $Test <$LoopEnd,t>,<a1>,<a2>,<a3>,<a4>,<x>
668 endif
669 $Push $ConjLeaveType
670 endif
671 endif
672endm
673;;*****************************************************************************
674else ;else for if1
675$Pop $Temp
676;;if $Temp ne $NoType
677if $st ne 0
678 $StrucError <open structure(s)>
679endif
680.xcref $NoConj,$And,$Or,$Short,$Near,$NearToShort,$AndOr,$Temp,$Temp2,$Dist
681.xcref $NoType,$ConjIfType,$IfType,$ElseType,$WhileType,$ConjWhileType
682.xcref $RepeatType,$ConjUntilType,$ForType,$ConjLeaveType,jncxz
683.xcref $SelectType,$WhenType,$OtherwiseType,$ConjWhenType
684.xcref jeq,jgt,jlt,jneq,jngt,jnlt,jnna,jnnae,jnnb,jnnbe,jnnc,jnncxz
685.xcref jnne,jnng,jnnge,jnnl,jnnle,jnno,jnnp,jnns,jnnz,jnpe,jnpo,$BuildJump
686.xcref $GetConj,$GetDist,$Poke,$Peek,$Push,$Pop,$Label,$CondJump,$CondLoop,$Test
687.xcref $TopTest,$leave2,$until2,$StrucError,j,jn,jand,jnand,jnnand
688.xcref jnnonzero,jnonzero,jnzero,jzero
689.xcref $st,$sn,$OrFound,$LoopEnd,$LeaveFound,$DefDist
690.xcref $LastLabel,$LastLabelOrg,$EquateLabel,$TraceLabel,$CondJump2,$ncxz
691endif
692
693
694$st = 0
695$sn = 0
696$OrFound = 0
697$LoopEnd = 0
698$LeaveFound = 0
699$LastLabel = -1
700$LastLabelOrg = $
701$DefDist= $Short
702$Push %$NoType