-
Notifications
You must be signed in to change notification settings - Fork 1
/
prep.s
4869 lines (4717 loc) · 89.7 KB
/
prep.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
XREF IncbinSize,GetIncBin,UsrTxt
XREF get_drive,get_path,get_wd,TestFile,LstOpen,LstClose
XREF FpuEval,LValAlloc,FpuConv,IsAbsFname
XDEF OutType,SecSizes,TextSize,DataSize,BssSize
XDEF _text,_data,SecSize,SrcOrgName,OutSetFlg
XDEF SrcCurStart,SrcCurName,CurLNb,CurLPtr
XDEF MacStuff,PrefTbl,OutName
XDEF DbgType,SrcType,EquFFlg,WarnFlg,CorrFlg,SMemFlg
XDEF CorSaveA6,CoringFlg,FPUcr,FPUk,GDbgType,MPUType
XDEF OptiLAbs2WFlg,OptiZD16Flg,OptiBdFlg,OptiOdFlg,OptiNopFlg,OptiFBccFlg
XDEF WOptLAbs2WFlg,WOptZD16Flg,WOptBdFlg,WOptOdFlg,WOptNopFlg,WOptFBccFlg
XDEF SlowFlg,VarRamFlg,FstTime,TotTime,StopFlg,LstCnt,OptiNb,OptiSz
XDEF LstPgFlg,LstMttl,LstSttl,LstLnNb,LstPgNb,LstLnLen,LstPgLen,LstSymFlg,LstName,LstHand
XDEF CurSection,CurSecType,SecPokeFlg
XDEF StartRoutines,Ligne,FieldsPtr,maflags,_fail,prepnocor
IFNE AMIGA
XREF AddSection,InitSections,ExitSections
ENDC
section TEXT
; #[ A voir:
;Condition: refaire recherche d'instructions
;- reconnaitre macro en decl de macro (nested macros)
;rept 0 pas compatible avec Devpac
;rept/include/endr en mode Slow
;EXITR
;self-inclusion
; #] A voir:
; #[ Rs:
STRUCTINIT
WORD IFccNestCnt
WORD IFccCant
WORD IFccCondValue
PTR IFccContext
PTR IFccCurBuf
SIZEOF IFCC_STUFF_SIZEOF
MACCTXT_BLK_SIZE equ 1000
; #] Rs:
; #[ Err routines:
; #[ oper errors:
Errbad_opernb:
bgt.s Erroper_2many
Erroper_exp:
moveq #oper_exp_errno,d0
bra preperror
Erroper_2many:
moveq #oper_2many_errno,d0
bra preperror
Errstartq_exp:
moveq #startq_exp_errno,d0
bra preperror
Errendq_exp:
moveq #endq_exp_errno,d0
bra preperror
; #] oper errors:
; #] Err routines:
; #[ Prep Routines:
; #[ ASCIIx: string
_ascii: subq.w #1,d3
bmi.s .roper
tst.w SrcType
bne.s .src
.asrc: moveq #TOKENQUOTE,d7
.nxt: move.l FIELDPTR,a0 ;@ 1st field
cmp.b (a0)+,d7
bne.s .rquote
move.l LINE_tokend(FIELDPTR),d0
sub.l a0,d0
subq.l #1,d0
beq.s .inc ;ligne vide
bsr PokeBinBuffer
.inc: INCFIELD
dbf d3,.nxt
rts
.roper: bra Errbad_opernb
.rquote: bra Errquote_exp
.src: bsr LinnAlloc ;petit bloc src
bra.s .asrc
_asciil: subq.w #1,d3
bmi.s .roper
tst.w SrcType
bne.s .src
.asrc: moveq #TOKENQUOTE,d7
.nxt: move.l FIELDPTR,a0 ;@ 1st field
cmp.b (a0)+,d7
bne.s .rquote
move.l LINE_tokend(FIELDPTR),d4
sub.l a0,d4
subq.l #1,d4
beq.s .inc ;ligne vide
bsr BPokeBin
move.l d4,d0
bsr PokeBinBuffer
.inc: INCFIELD
dbf d3,.nxt
rts
.roper: bra Errbad_opernb
.rquote: bra Errquote_exp
.src: bsr LinnAlloc ;petit bloc src
bra.s .asrc
_asciiz: subq.w #1,d3
bmi.s .roper
tst.w SrcType
bne.s .src
.asrc: moveq #TOKENQUOTE,d7
.nxt: move.l FIELDPTR,a0 ;@ 1st field
cmp.b (a0)+,d7
bne.s .rquote
move.l LINE_tokend(FIELDPTR),d0
sub.l a0,d0
subq.l #1,d0
beq.s .0 ;ligne vide
bsr PokeBinBuffer
.0: moveq #0,d4
bsr BPokeBin
.inc: INCFIELD
dbf d3,.nxt
rts
.roper: bra Errbad_opernb
.rquote: bra Errquote_exp
.src: bsr LinnAlloc ;petit bloc src
bra.s .asrc
; #] ASCIIx:
; #[ BSS: void
_bss:
do_bss: bsr doweven
bsr end_locals ;a virer
sf SecPokeFlg
moveq #SEC_bss,d2
IFNE AMIGA
jmp AddSection
ENDC
IFNE ATARI
lea SecSizes,a0
move.w CurSection,d0
bmi.s .new ;old section=offset
cmp.w d2,d0
beq.s .end ;deja bss
lea BinNumbers,a1
move.w CurBinNb,0(a1,d0.w)
move.l SecSize,0(a0,d0.w)
.new: move.l SEC_bss(a0),SecSize
move.w d2,CurSection
move.w d2,CurSecType
.end: rts
ENDC ;ATARI
; #] BSS:
; #[ CARGS/PARGS: names
_pargs: move.w d3,d4
subq.w #1,d4
bmi.s .roper
moveq #4,d6 ;default offset (4)
move.w d4,d0
mulu #LINE_SIZEOF,d0
add.w d0,FIELDPTR
.l1: lea LINE_field(FIELDPTR),a0
cmp.b #'#',(a0)
bne.s .nooff
addq.w #1,a0
FEVAL
bmi.s .reval
add.l d0,d6
bra.s .nxt
.nooff: moveq #2,d5 ;default is word
cmp.b #'.',(a0)
beq.s .rloc
move.l LINE_tokend(FIELDPTR),a0
move.l a0,d3
sub.l FIELDPTR,d3 ;label len
beq.s .nxt
moveq #0,d1
move.b -(a0),d1
sub.b #TOKENB,d1
bmi.s .rinp
cmp.b #TOKENL-TOKENB,d1
bgt.s .nosz
add.w d1,d1
add.w d1,d1
move.l .t(pc,d1.w),d5
subq.l #1,d3
.nosz: move.w d3,d0 ;length
moveq #EQU_EQU,d1 ;type
move.l d6,d2 ;value
st d3 ;section
move.l LINE_srcstart(FIELDPTR),a0 ;label start in source
bsr stock_rs
bsr stock_equate ;a0=pointeur sur struct a inserer dans EquPtr
add.l d5,d6
.nxt: DECFIELD
dbf d4,.l1
.end: rts
.roper: bra Errbad_opernb
.reval: bra ErrEv_immed
.rloc: bra Errlocal_forb
.rinp: bra Errcant_input
.t: dc.l 2,2,4
_cargs: move.w d3,d4
subq.w #1,d4
bmi.s .roper
moveq #4,d6 ;default offset (4)
.l1: lea LINE_field(FIELDPTR),a0
cmp.b #'#',(a0)
bne.s .nooff
addq.w #1,a0
FEVAL
bmi.s .reval
add.l d0,d6
bra.s .nxt
.nooff: moveq #2,d5 ;default is word
cmp.b #'.',(a0)
beq.s .rloc
move.l LINE_tokend(FIELDPTR),a0
move.l a0,d3
sub.l FIELDPTR,d3 ;label len
beq.s .nxt
moveq #0,d1
move.b -(a0),d1
sub.b #TOKENB,d1
bmi.s .rinp
cmp.b #TOKENL-TOKENB,d1
bgt.s .nosz
add.w d1,d1
add.w d1,d1
move.l .t(pc,d1.w),d5
subq.l #1,d3
.nosz: move.w d3,d0 ;label len
moveq #EQU_EQU,d1 ;type
move.l d6,d2 ;value
st d3 ;section
move.l LINE_srcstart(FIELDPTR),a0 ;label start in source
bsr stock_rs
bsr stock_equate ;a0=pointeur sur struct a inserer dans EquPtr
add.l d5,d6
.nxt: INCFIELD
dbf d4,.l1
.end: rts
.roper: bra Errbad_opernb
.reval: bra ErrEv_immed
.rloc: bra Errlocal_forb
.rinp: bra Errcant_input
.t: dc.l 2,2,4
; #] CARGS/PARGS:
; #[ CNOP: value,value
_cnop: subq.w #2,d3
bne.s .roper
move.l FIELDPTR,a0
FEVAL
bmi.s .errev
tst.b d1
bne.s .errrel
swap d1
tst.b d1
bne.s .errmi
move.l d0,d3
lea FIELDNEXT(FIELDPTR),FIELDPTR
move.l FIELDPTR,a0
FEVAL
bmi.s .errev
swap d1
tst.b d1
bne.s .errmi
move.l d0,d4
beq.s .end
move.l d4,d1
move.l SecSize,d5
move.l d5,d0
bsr.s .ldiv ;d0/d1->d2
move.l d2,d0
move.l d4,d1
bsr.s .lmul ;d0*d1->d2
sub.l d2,d5 ;reste
beq.s .end
sub.l d5,d4
move.l d4,d5
tst.b SecPokeFlg
beq.s .nopoke
moveq #0,d4
add.w d3,d5
subq.w #1,d5
bmi.s .end
.pad: bsr BPokeBin
dbf d5,.pad
.end: rts
.nopoke: ext.l d5
add.l d3,d5
add.l d5,SecSize
rts
.roper: bra Errbad_opernb
.errev: bra ErrEv_immed
.errrel: bra Errrel_forb
.errmi: bra Errmin_forb
.ldiv: ;d0/d1->d2
movem.l d5-d6,-(sp)
moveq #0,d2
moveq #0,d5
moveq #31,d6
.loop: add.l d2,d2
roxl.l d0
roxl.l d5
cmp.l d1,d5
blt.s .clrbt
addq.l #1,d2
sub.l d1,d5
.clrbt: dbf d6,.loop
movem.l (sp)+,d5-d6
rts
.lmul: ;d0*d1->d2
movem.l d3-d6,-(sp)
move.l d0,d6
move.l d1,d3
move.l d6,d5
swap d5
move.w d3,d0
move.w d3,d1
swap d3
mulu d6,d1
mulu d5,d0
swap d0
add.l d0,d1
move.w d3,d0
mulu d6,d0
swap d0
add.l d0,d1
move.l d1,d2
movem.l (sp)+,d3-d6
rts
; #] CNOP:
; #[ DC.x:+F value,
_dc_b: move.l #$ff,d5
moveq #-128,d6
moveq #TOKENQUOTE,d7
.next: move.l FIELDPTR,a0 ;@ 1st field
move.b (a0),d1
bmi.s .nx
cmp.b d7,d1
beq.s .string
NEVAL
bmi.s .errev
beq.s .nopatch
moveq #0,d4
bsr BPokeBin
; move.l FIELDPTR,a0
move.l LINE_srcstart(FIELDPTR),a1
moveq #P_DCB,d2
jsr StoreEXP
bra.s .nx
.nopatch: move.l d0,d4
bsr BPokeBin
cmp.l d5,d0
bls.s .nx
tst.b d2
beq.s .errsize
cmp.l d6,d0
blt.s .errsize
.nx: INCFIELD
dbf d3,.next
.end: rts
.errsize: bra Errsz_ge_b
.errev: bra ErrEv_immed
.string: move.l LINE_tokend(FIELDPTR),d0
sub.l a0,d0
subq.l #2,d0
beq.s .nx ;ligne vide
addq.w #1,a0
bsr PokeBinBuffer
bra.s .nx
_dc_l: move.l FIELDPTR,a0
NEVAL
bmi.s .errev
bgt.s .patch
move.l d0,d4
bsr LPokeBin
.nx: INCFIELD
dbf d3,_dc_l
.end: rts
.patch: moveq #0,d4
bsr LPokeBin
; move.l FIELDPTR,a0
move.l LINE_srcstart(FIELDPTR),a1
moveq #P_DCL,d2
jsr StoreEXP
bra.s .nx
.errev: bra ErrEv_immed
_dc_w: subq.w #1,d3
bmi.s .no_args
tst.w SrcType
bne.s .src
.asrc: move.w OpSize,d0
bmi.s .word
beq _dc_b
subq.w #1,d0
bne.s _dc_l
.word: move.l #$ffff,d5
move.l #-32768,d6
.next: move.l FIELDPTR,a0
NEVAL
beq.s .nopatch
bmi.s .errev
moveq #0,d4
bsr WPokeBin
; move.l FIELDPTR,a0
move.l LINE_srcstart(FIELDPTR),a1
moveq #P_DCW,d2
jsr StoreEXP
bra.s .nx
.src: bsr LinnAlloc ;petit bloc src
bra.s .asrc
.nopatch: move.l d0,d4
bsr WPokeBin
cmp.l d5,d0
bls.s .nx
tst.b d2
beq.s .errsize
cmp.l d6,d0
blt.s .errsize
.nx: INCFIELD
dbf d3,.next
rts
.no_args: bra Erroper_exp
.errsize: bra Errsz_ge_w
.errev: bra ErrEv_immed
; #] DC.x:
; #[ DS.x:+F value,
_ds_w: subq.w #1,d3
bne Errbad_opernb
move.w OpSize,d3
bpl.s .sizeset
neg.w d3
.sizeset: move.l FIELDPTR,a0 ;@ 1st field
FEVAL
bmi.s .errev
tst.b d1
bne.s .errrel
swap d1
tst.b d1
bne.s .errmi
tst.b SecPokeFlg
bne.s .poke
lea SecSize,a0
tst.w d3
beq.s .add
btst #0,3(a0)
beq.s .pair
addq.l #1,(a0)
bsr Err_even
.pair: lsl.l d3,d0
.add: add.l d0,(a0)
rts
.poke: tst.w SrcType
bne.s .src
.asrc: moveq #0,d1
subq.w #1,d3
bmi FillBBinBuffer
btst #0,SecSize+3
beq.s .pair2
moveq #0,d4
bsr BPokeBin
bsr Err_even
.pair2: subq.w #1,d3
bmi FillWBinBuffer
bra FillLBinBuffer
.errev: bra ErrEv_immed
.errrel: bra Errrel_forb
.errmi: bra Errmin_forb
.src: bsr LinnAlloc
bra.s .asrc
; #] DS.x:
; #[ DCB.x:+F value[,value]
_dcb_b: tst.b d1
bne.s .neg
cmp.l #$ff,d0
bhi.s .errsize
.fill: move.l d0,d1
move.l d4,d0
bra FillBBinBuffer
.neg: cmp.l #128,d0
bhi.s .errsize
neg.l d0
bra.s .fill
.errsize: bra Errsz_ge_b
_dcb: moveq #0,d4
subq.w #1,d3
bmi.s .roper
subq.w #1,d3
bgt.s .roper
tst.w SrcType
bne.s .src
.asrc: move.l FIELDPTR,a0 ;@ 1st field
FEVAL
bmi.s .rev
tst.b d1
bne.s .rrel
swap d1
tst.b d1
bne.s .rmi
move.l d0,d4
moveq #0,d0
moveq #0,d1
addq.w #1,d3
beq.s .got
lea FIELDNEXT(FIELDPTR),FIELDPTR
move.l FIELDPTR,a0
FEVAL
bmi.s .rev
tst.b d1
bne.s .rrel
swap d1
.got: move.w OpSize,d2
bmi.s _dcb_w
beq.s _dcb_b
subq.w #1,d2
beq.s _dcb_w
bra.s _dcb_l
.roper: bra Errbad_opernb
.rmi: bra Errmin_forb
.rev: bra ErrEv_immed
.rrel: bra Errrel_forb
.src: bsr LinnAlloc
bra.s .asrc
_dcb_w: tst.b d1
bne.s .neg
cmp.l #$ffff,d0
bhi.s .rsize
.fill: move.l d0,d1
move.l d4,d0
bra FillWBinBuffer
.neg: cmp.l #32768,d0
bhi.s .rsize
neg.l d0
bra.s .fill
.rsize: bra Errsz_ge_w
_dcb_l: tst.b d1
beq.s .pos
neg.l d0
.pos: move.l d0,d1
move.l d4,d0
bra FillLBinBuffer
; #] DCB.x:
; #[ TEXT: void
_text: moveq #SEC_text,d2
bra.s swapsec
; #] TEXT:
; #[ DATA: void
_data: moveq #SEC_data,d2
;In: d2=SEC_text ou SEC_data uniquement
swapsec: IFNE ATARI
tst.w SrcType
beq.s .nosrc
bsr LinrEnd
ENDC
.nosrc: bsr doweven
st SecPokeFlg
bsr end_locals ;a virer
IFNE AMIGA
jmp AddSection
ENDC ;AMIGA
IFNE ATARI
lea SecSizes,a0
lea SecSize,a1
move.w CurSection,d0
bmi.s .newsz ;cursection=offset
cmp.w d2,d0
beq.s .end
move.l (a1),0(a0,d0.w)
.newsz: move.l 0(a0,d2.w),(a1)
move.w d2,CurSection
move.w d2,CurSecType
; bsr update_bin_sec
.end: ;rts
;In: d0=old section, d2=new section (SEC_text ou SEC_data)
update_bin_sec:
lea BinNumbers,a0
cmp.w #SEC_data,d0
bhi.s .l2
move.w CurBinNb,0(a0,d0.w)
.l2: move.w 0(a0,d2.w),CurBinNb
move.l CurBinPtr,d0 ;current(text)
beq.s .end ;none
move.l d0,a0
move.l BinBuffer,BIN_cur(a0) ;update end (text) addr
move.l LstBinPtr,a0 ;last
bra.s .comp
.l1: move.l BIN_prev(a0),d0 ;get last prev
beq.s .clr ;no old from same section
move.l d0,a0
.comp: cmp.w BIN_sec(a0),d2
bne.s .l1
move.l a0,CurBinPtr ;new cur
move.l BIN_start(a0),FstBinBuffer
move.l BIN_cur(a0),BinBuffer
move.l BIN_end(a0),EndBinBuffer
.end: rts
.clr: clr.l CurBinPtr
clr.l FstBinBuffer
clr.l BinBuffer
clr.l EndBinBuffer
rts
ENDC ;ATARI
; #] DATA:
; #[ END: void
_end: addq.w #4,sp
jmp EndAsm
; #] END:
; #[ ENDC: void
_endc: lea IfccStuff,a2
tst.w IFccCant(a2)
beq.s .can
subq.w #1,IFccCant(a2)
rts
.can: subq.w #1,IFccNestCnt(a2)
bmi.s .unexp
tst.b IFccCondValue(a2)
bne.s .true
subq.w #1,PrepSkipCnt
.true: move.l IFccContext(a2),a4
move.l IFCC_backptr(a4),a0
move.l a0,IFccContext(a2)
bsr.s .free
; move.w IFCC_canteval(a0),IFccCant(a2)
move.l a0,d0
beq.s .end
move.b IFCC_result(a0),IFccCondValue(a2)
.end: rts
.unexp: addq.w #1,IFccNestCnt(a2)
bra Errunexp_endc
.free: movem.l a0/a1,-(sp)
IFNE BLINDOS
tst.l IFccCurBuf(a2)
beq.s .err
ENDC
move.l IFccCurBuf(a2),a0
moveq #IFCC_SIZEOF,d0
sub.l d0,IFCCBUF_cur(a0)
subq.w #1,IFCCBUF_nb(a0)
bmi.s .back
.out: movem.l (sp)+,a0/a1
rts
.back: move.l IFCCBUF_prev(a0),IFccCurBuf(a2)
IFNE BLINDOS
beq.s .err
ENDC
bsr MyMfree
bra.s .out
IFNE BLINDOS
.err: _Debugger
ENDC
; #] ENDC:
; #[ ENDM: void
_endm: lea MacStuff,a5
tst.b InMacFlg(a5)
beq.s end_mac_exp
sf InMacFlg(a5)
subq.w #1,PrepSkipCnt ;fin de declaration macro
rts
;fin d'expansion de macro
;a5=@MacStuff
end_mac_exp:
move.l MacStackPtr(a5),a2
tst.w ReptNestCnt
bne .cross
.depile: subq.w #1,MacNestCnt(a5)
bmi .error
tst.b MacAroUsedFlg(a5)
bne.s .used
subq.l #1,GloMacAroCnt(a5)
.used: move.b MACCTXT_aroused(a2),MacAroUsedFlg(a5)
move.l MACCTXT_arocnt(a2),LocMacAroCnt(a5)
move.l MACCTXT_cur(a2),MacCurPtr(a5)
move.w MACCTXT_nbargs(a2),MacNbArgs(a5)
move.w MACCTXT_argshift(a2),MacShift(a5)
move.l MACCTXT_lnb(a2),CurLNb
move.l MACCTXT_incnum(a2),incnum
move.w MACCTXT_ifcc(a2),MacIfccCnt(a5)
move.l MACCTXT_edblock(a2),CurEditBlock
move.l MACCTXT_backsrc(a2),a6
move.w ReptNestCnt,d0
cmp.w MACCTXT_rept(a2),d0
beq.s .same
move.l ReptContext,a0
move.l a6,REPT_macsrc(a0)
.same: move.l MACCTXT_mod(a2),a0
move.l a0,CurModPtr
move.l MOD_addr(a0),SrcCurStart
move.l MOD_num(a0),CurModNb
bsr UpdVarRamFlg
move.l a6,MacCurExpPtr(a5)
bsr FreeMacLine
move.l MACCTXT_curbuf(a2),MacCurBufPtr(a5)
move.l a2,a0
move.l MACCTXT_prev(a0),d2
bsr FreeMacCtxt
move.l d2,MacStackPtr(a5)
tst.w MacNestCnt(a5)
bne.s .end
move.l #RetNor,(sp)
tst.w PrepSkipCnt ;
beq.s .end ;ALEX IFNE non ferme en macro
jmp Condition ;
.end: rts
.cross: ;REPT/ENDM
move.l ReptContext,a0
move.l REPT_value(a0),d0
cmp.l REPT_count(a0),d0 ;1ere occurence du REPT?
beq .depile ;oui->encore ds la macro
move.l REPT_macsrc(a0),d0
beq .depile
move.l d0,a6
move.l d0,MacCurExpPtr(a5)
rts
.error: addq.w #1,MacNestCnt(a5)
.err: bra Errmac_unexp_endm
; #] ENDM:
; #[ ENDR: void
_endr: move.w ReptNestCnt,d0
beq.s .unexp
move.l ReptContext,a1
move.l a1,a0
subq.l #1,REPT_count(a0)
beq.s .depile
move.l REPT_srcaddr(a0),a6
move.l a6,MacStuff+MacCurExpPtr
move.l REPT_mod(a0),CurModPtr
lea incnum,a1
move.l REPT_incnum(a0),(a1)+
move.l REPT_lnb(a0),(a1)
move.l REPT_edblock(a0),CurEditBlock
rts
.unexp: bra Errunexp_endr
.depile: subq.w #1,d0
move.w d0,ReptNestCnt
move.l REPT_backptr(a1),ReptContext
move.l a1,a0
bra MyMfree
; #] ENDR:
; #[ EQU: value
_fequ: jsr IsFPU
bmi.s .rfpu
move.w #5,OpSize
move.w length_variable,d5
beq.s .rlabel
clr.w length_variable
tst.b loc_flag
bne.s .rdot
subq.w #1,d3
bne.s .roper
move.l FIELDPTR,a0 ;@ 1st field
lea -4*3(sp),sp
move.l sp,a1
jsr FpuEval
bpl.s .evalok
lea 4*3(sp),sp
bra ErrEv_fpu
.evalok: move.l sp,a1
move.l a1,a2
move.w OpSize,d0
jsr FpuConv
; alloue la valeur
moveq #14,d0
jsr LValAlloc
beq.s .nomem
move.l d0,a4
move.w OpSize,(a4)+
move.l (a2)+,(a4)+
move.l (a2)+,(a4)+
move.l (a2)+,(a4)+
move.l a2,sp
moveq #EQU_FEQU,d1
move.l d0,d2 ;VAR_value
move.w d5,d0 ;VAR_len
move.l start_variable,a0
moveq #-1,d3 ;VAR_sec
jsr stock_rs
bra stock_equate ;a0=ptr sur struct a inserer dans EquPtr
.rfpu: bra Errfpu_req
.roper: bra Errbad_opernb
.rev: bra ErrEv_immed
.rdot: bra Errlocal_forb
.rlabel: bra Errlabel_exp
.nomem: bra Errglo_ram
_equ: move.w length_variable,d5
beq.s .rlabel
clr.w length_variable
tst.b loc_flag
bne.s .rdot
subq.w #1,d3
bne.s .roper
move.l FIELDPTR,a0 ;@ 1st field
FEVAL
bmi.s .rev
move.l d0,d2 ;VAR_value
subq.b #1,d1
move.b d1,d3 ;VAR_seq
swap d1
move.w d1,d0
moveq #EQU_EQU,d1
tst.w d0
beq.s .plus
bset #VAR_MINUS,d1 ;VAR_type
.plus: move.w d5,d0
move.l start_variable,a0
jsr stock_rs
bra stock_equate ;a0=ptr sur struct a inserer dans EquPtr
.rlabel: bra Errlabel_exp
.roper: bra Errbad_opernb
.rev: bra ErrEv_immed
.rdot: bra Errlocal_forb
; #] EQU:
; #[ FEQUR: fregister
_fequr: subq.w #1,d3
bne.s .roper
move.l FIELDPTR,a0 ;@ 1st field
move.w (a0)+,d2 ;VAR_value
bmi.s .reqr
andi.w #$dfdf,d2
cmp.w #'FP',d2
bne.s .reqr
moveq #0,d2
move.b (a0)+,d2
sub.b #'0',d2
bmi.s .reqr
cmp.b #7,d2
bhi.s .reqr
moveq #EQU_FEQUR,d1 ;VAR_type
tst.b (a0) ;TOKENEOL
bmi _puteqr
.roper: bra Errbad_opernb
.reqr: bra Errreg_equr
; #] FEQUR:
; #[ EQUR: register
_equr: subq.w #1,d3
bne.s .roper
move.l FIELDPTR,a0 ;@ 1st field
moveq #0,d2
move.b (a0)+,d2 ;VAR_value
bmi.s .reqr
cmp.b #TOKENA7,d2
bhi.s .reqr
moveq #EQU_EQUR,d1 ;VAR_type
tst.b (a0) ;TOKENEOL
bmi.s _puteqr
.roper: bra Errbad_opernb
.reqr: bra Errreg_equr
_puteqr: lea length_variable,a0
move.w (a0),d0
beq.s .rlabel
clr.w (a0)
tst.b loc_flag
bne.s .rdot
st d3 ;VAR_sec
move.l start_variable,a0
jsr stock_rs
bra stock_equate ;a0=pointeur sur struct a inserer dans EquPtr
.rlabel: bra Errlabel_exp
.rdot: bra Errlocal_forb
; #] EQUR:
; #[ FREG: freglist
_freg: subq.w #1,d3
bne.s .roper
move.l FIELDPTR,a0 ;@ 1st field
bsr getfreglist
bmi.s .rlist
moveq #EQU_FREG,d1
move.l d0,d2 ;VAR_value
bra.s _putreg
.roper: bra Errbad_opernb
.rlist: bra Errreglist_exp
; #] FREG:
; #[ REG: reglist
_reg: subq.w #1,d3
bne.s .roper
move.l FIELDPTR,a0 ;@ 1st field
bsr getreglist
bmi.s .rlist
move.l d0,d2 ;VAR_value
moveq #EQU_REG,d1
bra.s _putreg
.roper: bra Errbad_opernb
.rlist: bra Errreglist_exp
_putreg: lea length_variable,a0
move.w (a0),d0
beq.s .rlabel
clr.w (a0)
tst.b loc_flag
bne.s .rdot
st d3 ;VAR_sec
move.l start_variable,a0
jsr stock_rs
bra stock_equate ;a0=pointeur sur struct a inserer dans EquPtr
.rlabel: bra Errlabel_exp
.rdot: bra Errlocal_forb
; #] REG:
; #[ RS: b,w,l,f,rsreset,rsset,rseven+F
_rs_w: move.w OpSize,d0
bpl.s .ok
neg.w d0
.ok: moveq #1,d5
lsl.l d0,d5
subq.w #1,d3
bne.s .roper
move.l FIELDPTR,a0 ;@ 1st field
FEVAL
bmi.s .reval
tst.b d1
bne.s .rrel
swap d1
tst.w d1
bne.s .rmin
mulu d5,d0
move.l RsCountPtr,a0
move.l VAR_value(a0),d3
subq.l #1,d5
beq.s .add
btst #0,d3
beq.s .add
addq.l #1,d3
addq.l #1,d0
.add: add.l d0,VAR_value(a0)
lea length_variable,a0
move.w (a0),d0
beq.s .end
clr.w (a0)
tst.b loc_flag
bne.s .rloc
move.l start_variable,a0
lea StrcName,a1
move.w (a1),d1
bne.s .addstrc
.asstrc: move.l d3,d2 ;value
st d3
moveq #EQU_EQU,d1
jsr stock_rs
bra stock_equate ;a0=pointeur sur struct a inserer dans EquPtr
.roper: bra Errbad_opernb
.reval: moveq #0,d2
bra ErrEv_prep
.rrel: bra Errrel_forb
.rmin: bra Errmin_forb
.end: rts
.rloc: bra Errlocal_forb
.addstrc: bsr.s addstrc
bne.s .asstrc
.rmem: bra Errstrc_ram
addstrc: move.l a0,a2
move.w d0,d2
add.w d0,d1 ;new length
addq.w #1,d1 ;for dot
moveq #0,d0
move.w d1,d0
bsr AllocString
beq.s .rmem
move.l d0,a0 ;new start
move.l a0,a3
move.w (a1)+,d0
subq.w #1,d0
bmi.s .skip1
.l1: move.b (a1)+,(a3)+
dbf d0,.l1
.skip1: move.b #'.',(a3)+
subq.w #1,d2
bmi.s .skip2
.l2: move.b (a2)+,(a3)+
dbf d2,.l2
.skip2: move.w d1,d0 ;new length
.rmem: rts
_rsset: subq.w #1,d3
bne.s .roper
move.l FIELDPTR,a0
FEVAL
bmi.s .rev
tst.b d1
bne.s .rrel
swap d1
tst.b d1
beq.s .end