-
Notifications
You must be signed in to change notification settings - Fork 5
/
E-VO.S
35483 lines (33079 loc) · 655 KB
/
E-VO.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
; ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ;
; Amiga E Compiler/Assembler/Linker by $#%! in 1991/92/93/94/95 ;
; ;
; GRIO Amiga E Compiler/Assembler/Linker by grio ;
; in 1999-2003 ;
; E-VO Amiga E Compiler/Assembler/Linker by Darren Coles ;
; in 2021-2024
; ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ;
;debug=1
ifd __VASM
output EVO
ifd debug
opt o-,w+
else
opt d-,s-,o-,w+
endif
machine mc68000
else
SETCPU 000
endif
CPU040: MACRO
ifd __VASM
machine mc68040
else
SETCPU 040
endif
ENDM
CPU020: MACRO
ifd __VASM
machine mc68020
else
SETCPU 020
endif
ENDM
CPU000: MACRO
ifd __VASM
machine mc68000
else
SETCPU 000
endif
ENDM
MAKEWARN: MACRO
MOVEM.L D0/D1,-(A7)
MOVEQ #\1-1,D0
MOVEQ #\2,D1
JSR makewarn
MOVEM.L (A7)+,D0/D1
ENDM
FAKESTACK33=1
S: MOVE.L A7,INITSTACK
JSR INITALL
BSR INITBUFFERS
CLR.L ConstsList
CLR.L ConstTemp
BSR SETVARS
BSR MAKEKEYHASH
BSR MAKEASMHASH
JSR SETUPLIBS
JSR INITFUNCS
JSR ADDGLOBVARS
BSR GETCACHE
BSR CHECKCOOKIES
JSR DOARGMACROS
BSR TOKENIZE
BSR CHECKCOOKIES
BSR SECONDARYLOAD
BSR CHECKIDENTS
BSR SWAPVALUES
JSR MAKEINITCODE
BSR CHECKCOOKIES
JSR PASS1
BSR CHECKCOOKIES
JSR LINKDELEGATECONSTRUCTORS
JSR MAKEEXITCODE
JSR MATHEXITETC
JSR LINKFUNCS
JSR APPEND_LISTS
JSR CALCADR
JSR WRITEEXE
JSR WRITELIBMOD
BSR CHECKCOOKIES
BSR NOERROR
JSR WRITEBUFFERS
JSR CLEANUPALL
JSR FIXRETVALUE
RTS
K: BSET #6,CODEPREFS+3 ; -w
BRA S
SC: MOVE.L #CLINE,A0
MOVEQ #CLEND-CLINE,D0
BRA S
CLINE: DC.B " ",10
CLEND:
EVEN
EXAMPLE:
DC.B " ",10
EXAMPLEEND:
DC.B 10,10
EVEN
UNDEF = 0 ; ident types
LOCV = 1
GLOBV = 2
LAB = 3
EOI = 0 ; interimcodes
VALUE = 1
LIBC = 2
COM = 3
ASSGN = 4
IDENT = 5
STR = 6
ONEXT = -4 ; M O OBJECT STRUCTURE OFFSETS
OOFF = 0 ; M
ODEL = 0 ; O
OFLAGS = 2 ; M O
OSIZE = 4 ; M O
OID = 6 ; M O
OASCII = 8 ; M O
PTRREPCOUNT=12 ; M
DIMDATA=14 ; M
OPTRTYPE= 18 ; M
OMEMB = 12 ; O
OMETHOD = 16 ; O
OSUPER = 20 ; O
ODCODE = 24 ; O
OACC = 28 ; O
ODELOFF = 32 ; O
ODESTR = 34 ; O
;*-*
;; Hunklist structure
H_NEXT = -4 ; ptr to hunk
H_ADDR = 0 ; where it begins..
H_TYPE = 4 ; its type
H_END = 8 ; where it ends..
H_PREV = 12 ; previous
H_RELO = 16 ; relocs (longs!)
H_SYM = 20 ; symbols for hunk
H_SEND = 24 ;end of symbols
R_NEXT = -4 ; reloc next
R_HUNK = 0 ; destination hunk number
R_OFF = 2 ; source hunk offset
;*-*
M_NEXT = 0 ; METHOD
M_PROC = 4
M_TYPE = 8
M_FLAGS = 9
M_OFF = 10
M_NAME = 12
MT_METHOD = 0 ; METHODFLAGS
MT_FROZEN = 1
MT_SHARED = 2
MT_EMPTY = 3
MI_NEXT = 0 ; MODULEINFO
MI_FLAGS = 4
MI_NAMELEN = 6
MI_MOD = 10
MI_LIST = 14
MI_NAMEPTR = 18
;MI_NAME = 22 ; ARRAY FROM HERE...
PC_NEXT = 0 ; PROC_OR_CLASS
PC_TYPE = 4
PC_INFO = 6
PC_ACC = 10
CNEXT = 0 ; CONST STRUCTURE OFFSETS
CASCII = 4
CVAL = 8
CFLAGS = 12
LEGACYVERSION = 10
CURVERSION = 14 ; IMPORTANT, MODULE VERSION!!
MAXVERSION = 14 ; max supported module version
SKIPMARK = $8000
MAXREGVARS = 5 ; NOTE: DEPENDS ALSO ON EFUNCS!
MAXMULTRET = 3 ; NOTE: DEPENDS ON REGVARS!
MIDHEAVY = $100
VARFLAGS=5
VARLINENO = 12 ; OFFSET AT WHICH LINENUM IN ID
VARHEAVY = 14 ; OFFSET AT WHICH HEAVYINFOS IN ID
VAR_NAME = 18
VAR_PTRREPCOUNT = 22 ; OFFSET USED TO COUNT PTR TO PTR
VAR_DIMDATA = 24 ; OFFSET RESERVED FOR ARRAY MULTI-DIMENSION DATA
MINSTACKSIZE = 10000 ; van gen. code
MINSTACKSIZELIB = 1500
MAXOBJSIZE = 5000
CHOPMEM = -100
CHOPLEFT = -104
FMEMSIZE = 5000
GLOBOFF = -512
GLOBOFFNEWTAB = GLOBOFF+16 ; 16..256+16
NEWTABMAX = 256
IOFF = 100
KB = 1024
MAXIDENT = 1000 ; size of *one* identifier
MAXSTACK = 150000 ; each rec.step=6-10b+rec.databuffer
MAXLIBRAISE = 200 ; EACH = 10 BYTES
MINIMUM_ACODE = 200*KB ; GENERATED CODE-BUF
; MACRO SECTION
TSTMOD: MACRO
BTST #4,CODEPREFS+2
ENDM
; RANGE CHECK MACROS
CHKB: MACRO ; \1=REG, \2=TRREG, \3=ERLAB
MOVE.L \1,\2
BTST #31,\2
BEQ.S *+4
NEG.L \2 ; BAD: RANGE=(-255,255)=>(-128,255)
AND.L #$FFFFFF00,\2
TST.L \2
BNE \3
ENDM
CHKW: MACRO ; \1=REG, \2=TRREG, \3=ERLAB
MOVE.L \1,\2
BTST #31,\2
BEQ.S *+4
NEG.L \2
AND.L #$FFFF0000,\2
TST.L \2
BNE \3
ENDM
; HASHING MACROS
HASHC: MACRO ; \1=HASHREG, \2=CHAR
LSL.W #4,\1
ADD.B \2,\1
ENDM
HASHE: MACRO ; \1=HASHREG
DIVU #211,\1
SWAP \1
EXT.L \1
ENDM
HASH: MACRO ; \1=ASCREG, \2=DATREG, \3=TRASHREG
MOVEQ #0,\2
.H1: MOVE.B (\1)+,\3
BEQ.S .H2
HASHC \2,\3
BRA.S .H1
.H2: HASHE \2
ENDM
; APART VAR ACCESS: ASM_GETLABEL
; GEN GLOB INFO: A4=MID INS.
GENGI: MACRO ; \1=IDENTREC, \2=TRASHDX
MOVE.L 6(\1),\2 ; SEE IF WE HAVE TO ADD A GLOBINFO ENTRY
BEQ.S .GVNGI
MOVEM.L \1/A3,-(A7)
MOVE.L \2,\1
MOVE.L 4(\1),\2
MOVE.L \1,A3
GETML \1
MOVE.L \1,4(A3)
MOVE.L \2,(\1)+
MOVE.L A4,(\1)+
MOVE.W OPERSIZE,(\1)+
DONEM \1
MOVEM.L (A7)+,\1/A3
.GVNGI:
ENDM
OPLONG: MACRO
MOVE.W #4,OPERSIZE
ENDM
OPINT: MACRO
MOVE.W #2,OPERSIZE
ENDM
OPCHAR: MACRO
MOVE.W #1,OPERSIZE
ENDM
; OFF_1:IMM, IDENT_2:Ax, OFFSET_3:EA.W, THRASH_4:Dx
; NOT A3-A5!!
;GENVAR: MACRO
; MOVE.B 4(\2),\4
; BEQ ERROR22 ; TEST FOR UNIDENT
; CMP.B #GLOBV,\4
; BNE.S .GV1
; MOVE.W -2(A4),\4
; BCLR #\1,\4 ; ADJUSTMODE
; MOVE.W \4,-2(A4)
;
; GENGI \2,\4
;
;.GV1: BTST #3,5(\2) ; SEE IF REGVAR
; BNE.S .GV2
; MOVE.W \3,(A4)+
; BRA.S .GV3
;.GV2: MOVE.W 10(\2),\4
; IF \1=0
; ANDI.W #%1111111111000000,-2(A4)
; ELSE
; AND.W #%1111000000111111,-2(A4)
; LSL.W #8,\4
; LSL.W #1,\4
; ENDIF
; OR.W \4,-2(A4)
;.GV3: ; END
; ENDM
GENVARL: MACRO
MOVE.B 4(\2),\4
BNE.S .1
JMP ERROR22 ; TEST FOR UNIDENT
.1: CMP.B #GLOBV,\4
BNE.S .GV1
MOVE.W -2(A4),\4
BCLR #\1,\4 ; ADJUSTMODE
MOVE.W \4,-2(A4)
GENGI \2,\4
.GV1: BTST #3,5(\2) ; SEE IF REGVAR
BNE.S .GV2
MOVE.W \3,(A4)+
BRA.S .GV3
.GV2: MOVE.W 10(\2),\4
IF \1=0
ANDI.W #%1111111111000000,-2(A4)
ELSE
AND.W #%1111000000111111,-2(A4)
LSL.W #8,\4
LSL.W #1,\4
ENDIF
OR.W \4,-2(A4)
.GV3: ; END
ENDM
MOVEMS: MOVEM.L D0/D1,-(A7)
MOVEMR: MOVEM.L (A7)+,D0/D1
SMASK: DC.W 0
BITM: MACRO ; \1=BITNUM, \2=REG
BTST #\1,\2
BEQ.S .SR\1
BSET #15-\1,\2
.SR\1:
ENDM
LSAVER: MACRO ; \1=SAVEMASK.EA.W, \2=RETURN_SMASK.DX
MOVE.W \1,\2
AND.W #%11111000,\2 ; diffr. from SAVER
MOVE.W \2,SMASK
BEQ.S .NOSR
MOVE.W MOVEMS,(A4)+
BITM 7,\2
BITM 6,\2
BITM 5,\2
BITM 4,\2
BITM 3,\2
CLR.B \2
MOVE.W \2,(A4)+
MOVE.W SMASK,\2
.NOSR: ; \2 IS HERE ATLEAST BOOL
ENDM
SAVER: MACRO ; \1=SAVEMASK.EA.W, \2=RETURN_SMASK.DX
MOVE.W \1,\2
AND.W PROCMASK,\2
MOVE.W \2,SMASK
BEQ.S .NOSR
MOVE.W MOVEMS,(A4)+
BITM 7,\2
BITM 6,\2
BITM 5,\2
BITM 4,\2
BITM 3,\2
CLR.B \2
MOVE.W \2,(A4)+
MOVE.W SMASK,\2
.NOSR: ; \2 IS HERE ATLEAST BOOL
ENDM
RESTR: MACRO ; \1=SMASK.EA
TST.W \1
BEQ.S .NORR
MOVE.W MOVEMR,(A4)+
MOVE.W \1,(A4)+
.NORR:
ENDM
LOWER: MACRO ; \1=AX (STRING,TRASH), \2=(TRASH)
.LOWL: MOVE.B (\1),\2
BEQ.S .LOWO
CMP.B #"A",\2
BMI.S .LOWN
CMP.B #"Z"+1,\2
BPL.S .LOWN
ADD.B #32,\2
.LOWN: MOVE.B \2,(\1)+
BRA.S .LOWL
.LOWO: ; ax points at 0-byte at end string
ENDM
; FAST MEMORY ALLOCATION MACROS
GETM: MACRO ; \1=Ax (START USING MEM)
MOVE.L HEAP(PC),\1
ENDM
GETML: MACRO
MOVE.L HEAP,\1
ENDM
DONEM: MACRO ; \1=Ax (DONE WITH MEM (LIGHT VERSION))
MOVE.L \1,HEAP
SUBQ.W #1,CHECKHEAP
BNE.S *+16
JSR EXPAND5
MOVE.W #5,CHECKHEAP ; MAX 200 BYTES EACH = IDENT OR STRUCT
ENDM ; does not trash \1 !!!!
DONEH: MACRO ; \1=Ax (HEAVY VERSION)
MOVE.L \1,HEAP
JSR EXPAND5
ENDM
; CREATE GLOBINFO STRUCTURE FOR IDENT
GINFO: MACRO ; \1=ASCIIPTR.EA, \2=TRASH.AX, \3=IDENTPTR.AX
TSTMOD
BEQ.S .NGINF
GETML \2 ; BUILD "GLOBINFO"
BTST #1,5(\3)
BNE.S .NGINF
MOVE.L \2,6(\3)
MOVE.L \1,(\2)+
CLR.L (\2)+
DONEM \2
BRA.S .NGOUT
.NGINF: CLR.L 6(\3)
.NGOUT:
ENDM
CHESTB: MACRO ; CHeckEStackBuf \1=CURBUF.EA, \2=TR.DX
SUBQ.W #1,.BC ; \3=DIST, \4=ERROR
BNE.S .NC
MOVE.W #\3,.BC
MOVE.L CSTACK_BUF,\2
ADD.L CSTACK_SIZE,\2
SUB.L #1000,\2
CMP.L \1,\2
BMI \4
BRA.S .NC
.BC: DC.W \3
.NC:
ENDM
INTERN: MACRO ; \1=ERRNUM
MOVE.W #\1,GURUNUM
JMP DAMAGEDCOOKIES
ENDM
DODEBUG: MACRO
MOVEM.L D0-A6,-(a7)
MOVE.L \1,dval
MOVE.L \2,dval+4
LEA dtext,A0
LEA dval,A1
JSR WRITEFORMAT
MOVEM.L (A7)+,D0-A6
ENDM
DODEBUG2: MACRO
MOVEM.L D0-A6,-(a7)
MOVE.L \1,dval
MOVE.L \2,dval+4
LEA dtext2,A0
LEA dval,A1
JSR WRITEFORMAT
MOVEM.L (A7)+,D0-A6
ENDM
PUTOUT: MACRO
MOVEM.L D0-D7/A0-A6,-(A7)
MOVE.L \2,-(A7)
MOVE.L \1,-(A7)
MOVEM.L (A7)+,A0/A1
JSR WRITEFORMAT
MOVEM.L (A7)+,D0-D7/A0-A6
ENDM
;;PREP
; ************************************************************* ;
; The (Macro) PreProcessor ;
; ************************************************************* ;
; - recursive macros
; - check end_of_source at each "\n" skipped.
MAC_NEXT = 0
MAC_NAME = 4
MAC_BODY = 8
MAC_NARGS = 12
MAC_FLAGS = 14 ; .B
PREPCHARS:
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 ; 0
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 ; 16
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 ; 32
DC.B 4,4,4,4,4,4,4,4, 4,4,0,0,0,0,0,0 ; 48
DC.B 0,5,5,5,5,5,5,5, 5,5,5,5,5,5,5,5 ; 64
DC.B 5,5,5,5,5,5,5,5, 5,5,5,0,0,0,0,5 ; 80
DC.B 0,5,5,5,5,5,5,5, 5,5,5,5,5,5,5,5 ; 96
DC.B 5,5,5,5,5,5,5,5, 5,5,5,0,0,0,0,0
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0 ; 128
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
DC.B 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0
; IN TOKENIZE CONTEXT: A0=SOURCE, A1=INTERIM, A2=IDENT WORK, D4=LAST TOKEN
PREPTA: MACRO ; \1=AX
LEA PREPCHARS(PC),\1
ENDM
PREPTAL: MACRO ; \1=AX
LEA PREPCHARS,\1
ENDM
PREPID: MACRO ; \1=TAB.AX, \2=CHAR.L.DX
CMP.B #5,0(\1,\2.L)
ENDM
PREPIDR:MACRO ; \1=TAB.AX, \2=CHAR.L.DX
CMP.B #4,0(\1,\2.L)
ENDM
PREP: ; JUST READ A "#"
ADDQ.L #1,A0
CMP.B #"d",D6
BNE.S .1
CMP.B #"e",(A0)
BEQ.S PREPDEF
CMP.B #"a",(A0)
BEQ PREPDATE
BRA iERROR63
.1: CMP.B #"i",D6
BEQ.W PREPIF
CMP.B #"u",D6
BEQ.W PREPUNDEF
CMP.B #"e",D6
BNE iERROR63
CMP.B #"l",(A0)
BEQ.W PREPELSE
CMP.B #"n",(A0)
BEQ.W PREPENDIF
PREPDATE: JSR DOPREPDATE
BRA.W PREPDONE
; format:
; 32-255: normal chars
; "\t" and "\\\n" translated to " "
; "\n" is end of macro (0)
; chars 1-31 are args.
; ";" not allowed
PREPDEF: ; #define
LEA .1(PC),A6
BSR PREPKCMP
BSR PREPWHITE
BSR.W DEFMAIN
BRA.W PREPDONE
.1: DC.B "efine",0
DEFMAIN:
GETML A5 ; A5=MEM
MOVE.L A5,A4 ; A4=IDENT
PREPTA A6 ; A6=TABLE
MOVEQ #0,D0
MOVE.B (A0)+,D0 ; D0=CHAR
MOVEQ #0,D1 ; D1=HASH
PREPID A6,D0
BMI iERROR64
.L: HASHC D1,D0
MOVE.B D0,(A5)+
MOVE.B (A0)+,D0
PREPIDR A6,D0
BPL.S .L
SUBQ.L #1,A0
CLR.B (A5)+
MOVE.L A5,D0
BTST #0,D0
BEQ.S .2
CLR.B (A5)+
.2: HASHE D1
LSL.L #2,D1
ADD.L #MACROHASH,D1
MOVE.L D1,A6
BSR PREPFINDMACRO
TST.L D0
BNE iERROR66
MOVE.L D1,A6
MOVE.L (A6),(A5) ; MAC_NEXT
MOVE.L A5,(A6)
MOVE.L A5,A6 ; A6=MACOBJ
ADDQ.L #4,A5
MOVE.L A4,(A5)+ ; MAC_NAME
CLR.L (A5)+ ; MAC_BODY
CLR.L (A5) ; MAC_NARGS + MAC_FLAGS
TST.W EVODEFFLAG
BEQ .noevodef
BSET #0,MAC_FLAGS(A6) ; set imported flag for EVO_x_x_x defs
.noevodef:
ADDQ.L #4,A5
CLR.L (A5)+ ; MAC_NARGS + MAC_FLAGS
DONEH A5 ; -->FOR MACBODY NEEDS HEAVY
;BSR PREPWHITE
MOVE.L WORK,A2
MOVE.L A2,D7 ; A2,D7=ARGSASC
CMP.B #"(",(A0)
BNE.S .NARGS
ADDQ.L #1,A0
PREPTA A5 ; A5=TAB
MOVEQ #0,D0
MOVEQ #0,D1 ; D1=NARG
.AL: BSR PREPWHITE
ADDQ.L #1,D1
MOVE.B (A0)+,D0
PREPID A5,D0
BMI iERROR64
.ALC: MOVE.B D0,(A2)+
MOVE.B (A0)+,D0
PREPIDR A5,D0
BPL.S .ALC
SUBQ.L #1,A0
CLR.B (A2)+
; ; -->CHECK FOR DOUBLARGS?
BSR PREPWHITE
CMP.B #",",(A0)+
BEQ.S .AL
CMP.B #")",-1(A0)
BNE iERROR64
MOVE.W D1,MAC_NARGS(A6)
.NARGS: BSR PREPWHITE
CLR.B (A2)+
GETML A3 ; A3,D6=PRE_ANA_MACBODY
MOVE.L A3,MAC_BODY(A6)
MOVE.L A3,D6
PREPTA A6 ; A6=TAB
MOVEQ #0,D0
.MBL: MOVE.B (A0)+,D0
BEQ.W .MBX
CMP.B #10,D0
BEQ.W .MBX
CMP.B #"\",D0
BEQ.W .BSL
CMP.B #" ",D0
BEQ.W .SP
CMP.B #9,D0
BEQ.W .TAB
CMP.B #";",D0
BEQ iERROR64
CMP.W #32,D0
BMI iERROR64
PREPID A6,D0
BMI.S .CH
MOVE.L D7,A2 ; A2=ASCIIARGS
SUBQ.L #1,A0
MOVE.L A0,D5 ; D5=START ID IN TEXT
MOVEQ #0,D2 ; D2=NTH ARG
.FAL: TST.B (A2)
BEQ.S .CRI
ADDQ.L #1,D2
MOVE.L D5,A0
.FALI: CMPM.B (A2)+,(A0)+
BEQ.S .FALI
TST.B -(A2)
BEQ.S .MA
.FAN: TST.B (A2)+
BNE.S .FAN
BRA.S .FAL
.MA: ADDQ.L #1,A2
MOVE.B -(A0),D0
PREPIDR A6,D0
BPL.S .FAL
MOVE.B D2,D0
BRA.S .CH ; INSERT ARGNUM AS CHAR
.CRI: MOVE.L D5,A0
.CRIL: MOVE.B (A0)+,D0
MOVE.B D0,(A3)+
PREPIDR A6,D0
BPL.S .CRIL
SUBQ.L #2,A0
SUBQ.L #2,A3
MOVE.B (A0)+,D0 ; LAST AS CH FOR CHECK
.CH: MOVE.B D0,(A3)+
MOVE.L A3,D1
SUB.L D6,D1
CMP.L #1000,D1
BPL iERROR64
BRA.W .MBL
.MBX: SUBQ.L #1,A0
CLR.B (A3)+
MOVE.L A3,D0
BTST #0,D0
BEQ.S .3
CLR.B (A3)+
.3: DONEH A3
RTS
.BSL: CMP.B #10,(A0)
BNE.S .CH
ADDQ.L #1,A0
ADDQ.W #1,LINENUM
CMPA.L ENDECODE,A0
BPL iERROR64
MOVEQ #" ",D0
BRA.S .CH
.SP: CMP.B #" ",(A0)+
BEQ.S .SP
SUBQ.L #1,A0
BRA.S .CH
.TAB: CMP.B #9,(A0)+
BEQ.S .TAB
SUBQ.L #1,A0
MOVEQ #" ",D0
BRA.S .CH
PREPIF: ; #ifdef, #ifndef
MOVE.W #1,PREPCODE
CMP.B #"f",(A0)+
BNE iERROR63
MOVEQ #-1,D7 ; D7=TRUTHFLAG
CMP.B #"n",(A0)
BNE.S .2
MOVEQ #0,D7
ADDQ.L #1,A0
.2: LEA .1(PC),A6
BSR PREPKCMP
BSR PREPWHITE
MOVE.L WORK,A2
MOVE.L A2,D6 ; A2,D6=IDENT
PREPTA A6 ; A6=TAB
MOVEQ #0,D0
MOVEQ #0,D1 ; D1=HASH
MOVE.B (A0)+,D0
PREPID A6,D0
BMI iERROR67
.CL: MOVE.B D0,(A2)+
HASHC D1,D0
MOVE.B (A0)+,D0
PREPIDR A6,D0
BPL.S .CL
CLR.B (A2)+
SUBQ.L #1,A0
BSR PREPWHITE
CMP.B #10,(A0)
BNE iERROR67
MOVE.L D6,A2
HASHE D1
LSL.L #2,D1
ADD.L #MACROHASH,D1
MOVE.L D1,A6
MOVE.L D6,A4
BSR PREPFINDMACRO
TST.L D0
BEQ.S .3
MOVEQ #-1,D0
.3: EOR.L D0,D7 ; NEW TRUTH
NOT.L D7
MOVE.W PREPSTACKSIZE(PC),D0
LEA PREPIFSTACK(PC),A4
MOVE.B D7,0(A4,D0.W)
ADDQ.W #1,D0
MOVE.W D0,PREPSTACKSIZE
CMP.W #PREPMAXSTACK,D0
BPL iERROR65
TST.L D7
BNE.W .4
MOVEQ #0,D6 ; NESTED LEVEL
ADDQ.L #1,A0
.EL: ADDQ.W #1,LINENUM ; NOW EAT LF
CMPA.L ENDECODE,A0
BPL iERROR65
BSR PREPWHITE
CMP.B #"#",(A0)
BNE.W .ER
ADDQ.L #1,A0
MOVE.L A0,A4
MOVE.B (A0),D0
CMP.W #"i",D0
BNE.S .E1
ADDQ.L #1,D6
MOVE.W #1,PREPCODE
BRA.W .ER
.E1: CMP.W #"e",D0
BNE .ER
ADDQ.L #1,A0
MOVE.B (A0),D0
CMP.W #"l",D0
BNE.S .notelse
ADDQ.L #1,A0
MOVE.B (A0),D0
CMP.W #"i",D0 ;#elifdef or #elifndef
BNE.S .testelse
ADDQ.L #1,A0
MOVE.B (A0),D0
CMP.W #"f",D0 ;#elifdef or #elifndef
BNE iERROR63
CMP.W #3,PREPCODE
BEQ.W iERROR65
MOVE.W #1,PREPCODE
TST.L D6
BNE.S .ER
SUB.W #1,PREPSTACKSIZE
BRA.W PREPIF
.testelse:
CMP.W #"s",D0
BNE.S .notelse
ADDQ.L #1,A0
MOVE.B (A0),D0
CMP.W #"e",D0
BNE.S .notelse
ADDQ.L #1,A0
CMP.W #3,PREPCODE
BEQ.W iERROR65
MOVE.W #3,PREPCODE
TST.W D6
BNE.S .ER
BRA.S PREPDONE
.notelse
TST.L D6
BEQ.S .EX
MOVE.L A4,A0
SUBQ.L #1,D6
MOVE.W #2,PREPCODE
.ER: MOVEQ #10,D0
.ERL: CMP.B (A0)+,D0
BNE.S .ERL
BRA.W .EL
.EX: BRA.S PREPENDIF
.4: BRA.S PREPDONE
.1: DC.B "def",0
PREPMAXSTACK = 10
PREPIFSTACK: DS.B PREPMAXSTACK
PREPSTACKSIZE: DC.W 0
PREPENDIF: ; #endif
MOVE.W #2,PREPCODE
LEA .1(PC),A6
BSR PREPKCMP
MOVE.W PREPSTACKSIZE(PC),D0
SUBQ.W #1,D0
BMI iERROR65
MOVE.W D0,PREPSTACKSIZE
;LEA PREPIFSTACK(PC),A4
;TST.B 0(A4,D0.W)
;BEQ ERROR65
BRA.S PREPDONE
.1: DC.B "ndif",0,0
PREPDONE:
MOVE.L STARTINTERIM,A6
SUBQ.L #2,A6
CMPA.L A6,A1
BNE.S .1
MOVE.L WORK,A2
BRA PARSELOOP
.1: INTERN 105
PREPUNDEF: ; #undef
LEA .1(PC),A6
BSR PREPKCMP
BSR PREPWHITE
BSR.S UNDEFMAIN
BRA.S PREPDONE
.1: DC.B "ndef",0
EVEN
UNDEFMAIN:
MOVE.L WORK,A2
MOVE.L A2,D6 ; A2,D6=IDENT
PREPTA A6 ; A6=TAB
MOVEQ #0,D0
MOVEQ #0,D1 ; D1=HASH
MOVE.B (A0)+,D0
PREPID A6,D0
BMI iERROR67
.CL: MOVE.B D0,(A2)+
HASHC D1,D0
MOVE.B (A0)+,D0
PREPIDR A6,D0
BPL.S .CL
CLR.B (A2)+
SUBQ.L #1,A0
BSR PREPWHITE
CMP.B #10,(A0)
BNE iERROR67
MOVE.L D6,A2
HASHE D1
LSL.L #2,D1
ADD.L #MACROHASH,D1
MOVE.L D1,A6
MOVE.L D6,A4
BSR.W PREPFINDMACRO
TST.L D0
BEQ.S .1
BSR.W UNDEFMACRO
.1: RTS
PREPELSE: ; #else/#elifdef/#elifndef
ADDQ.L #1,A0
MOVE.B (A0),D0
CMP.B #"i",D0
BEQ.W PREPELIF
CMP.W #3,PREPCODE
BEQ.W iERROR65
MOVE.W #3,PREPCODE
LEA .1(PC),A6
MOVE.W PREPSTACKSIZE(PC),D0
SUBQ.W #1,D0
BMI iERROR65
MOVEQ #0,D6 ; NESTED LEVEL
ADDQ.L #1,A0
.EL:
CMPA.L ENDECODE,A0
BPL iERROR65
BSR PREPWHITE
CMP.B #"#",(A0)
BNE.S .ER
ADDQ.L #1,A0
MOVE.B (A0),D0
CMP.W #"i",D0
BNE.S .E1
ADDQ.L #1,D6