-
Notifications
You must be signed in to change notification settings - Fork 1
/
eval68k.s
3382 lines (3326 loc) · 61.4 KB
/
eval68k.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
;REGARDER VAR_STACK/a2
XDEF Evaluate,GloEval,LocEval,ForEval,OptEval
XDEF EvalErrP,EvalErrN,LValAlloc,FreeEval
XDEF GetEvFonc
XREF Eval1,GloEval1,LocEval1,ForEval1,OptEval1
XREF GetGloVar,GetLocVar,ForceGloVar,ForceLocVar
XREF icmpsort,FindEqu
XREF MyMalloc,MyMfree,GetXref
XREF CurSection,SecSize,TextSize
XREF GlobPatchFlag,LocPatchFlag
include "comequ.s"
LOCSTACK_SIZEOF EQU 8
VALMEMSPACE EQU 1000 ;1k/bloc de valeurs
EVALONE EQU 1
VAL_SIZE EQU 10
; #[ A faire:
;voir les cas de non EQU_EQU ni EQU_SET ni EQU_EQUR
; #] A faire:
; #[ Equrs:
VALUE equr d3
SIGN equr d4
PRIO equr d6
VAR_TYPE equr d7
EVAL_STR equr a0
VAR_STACK equr a2
OPERAND_JT equr a3
OPERATOR_JT equr a4
START_STACK equr a6
EVAL_REGS REG d3-d7/a0-a4/a6
GLOB_REGS REG d3-d7/a0-a4/a6
; #] Equrs:
; #[ Priority equs:
;unaires
PLUS_PRI equ 6
MINUS_PRI equ 6
NOT_PRI equ 6
;binaires
ADD_PRI equ 2
SUB_PRI equ 2
MUL_PRI equ 3
DIV_PRI equ 3
OR_PRI equ 4
AND_PRI equ 4
XOR_PRI equ 4
CMP_PRI equ 1
EQUAL_PRI equ 1
SHIFT_PRI equ 5
; #] Priority equs:
; #[ Macros:
JSOPERAND MACRO
IFNE _68000
add.w d1,d1
move.w 0(OPERAND_JT,d1.w),d1
ELSEIF
move.w 0(OPERAND_JT,d1.w*2),d1
ENDC ;_68000
jsr 0(OPERAND_JT,d1.w)
ENDM
JSOPERATOR MACRO
IFNE _68000
add.w d1,d1
move.w 0(OPERATOR_JT,d1.w),d1
ELSEIF
move.w 0(OPERATOR_JT,d1.w*2),d1
ENDC ;_68000
jsr 0(OPERATOR_JT,d1.w)
ENDM
JMOPERAND MACRO
IFNE _68000
add.w d1,d1
move.w 0(OPERAND_JT,d1.w),d1
ELSEIF
move.w 0(OPERAND_JT,d1.w*2),d1
ENDC
jmp 0(OPERAND_JT,d1.w)
ENDM
JMOPERATOR MACRO
IFNE _68000
add.w d1,d1
move.w 0(OPERATOR_JT,d1.w),d1
ELSEIF
move.w 0(OPERATOR_JT,d1.w*2),d1
ENDC
jmp 0(OPERATOR_JT,d1.w)
ENDM
COMPL2 MACRO ;value,sign
tst.b \2
beq.s .\@
sf \2
neg.l \1
.\@:
ENDM
PUSHEVAL MACRO
; movem.l EVAL_REGS,-(sp)
movem.l EVAL_REGS,_regsbuf
ENDM
POPEVAL MACRO
; movem.l (sp)+,EVAL_REGS
movem.l _regsbuf,EVAL_REGS
ENDM
PUSHGLOB MACRO
; movem.l GLOB_REGS,-(sp)
movem.l GLOB_REGS,_regsbuf
ENDM
POPGLOB MACRO
; movem.l (sp)+,GLOB_REGS
movem.l _regsbuf,GLOB_REGS
ENDM
; #] Macros:
; #[ Eval Entries:
; #[ First eval:
;Internal: PRIO=pri,ParNestCnt=parent_cnt,START_STACK=start sp
;Out: d1 = -errno ou 0 ou (0:expr_size:ff si evalone:type backpatch)
;d2 = SIGN
Evaluate:
IFNE EVALONE
tst.w d0
beq Eval1
ENDC
PUSHEVAL
suba.l VAR_STACK,VAR_STACK
lea pass1_operand_jt(pc),OPERAND_JT
lea numonly_operator_jt(pc),OPERATOR_JT
moveq #0,PRIO ;pri
move.l sp,START_STACK
clr.l _global_found ;+local+set
moveq #0,d1
move.b (EVAL_STR)+,d1
ble.s .err
JSOPERAND
move.l VALUE,d0
move.b SIGN,d2
bne.s .neg
moveq #0,d1
POPEVAL
rts
.neg: neg.l d0
bgt.s .overf
.noerr: moveq #0,d1
POPEVAL
rts
.err: bra err_unexp_end
.overf: cmp.l VALUE,d0
beq.s .noerr
bra err_overflow
; #] First eval:
; #[ ForceEval:
;a priori meme operator_jt qu'en global patch
;renvoie dans d1 00:SIGN:00:section+1
ForEval:
IFNE EVALONE
tst.w d0
beq ForEval1
ENDC
PUSHEVAL
lea force_operand_jt(pc),OPERAND_JT
lea type_operator_jt(pc),OPERATOR_JT
moveq #0,PRIO ;pri
move.l sp,START_STACK
moveq #0,VAR_TYPE
moveq #0,d1
move.b (EVAL_STR)+,d1
ble.s .err
JSOPERAND
move.l VALUE,d0
tst.b SIGN
bne.s .neg
swap SIGN
or.l SIGN,VAR_TYPE
move.l VAR_TYPE,d1
POPEVAL
rts
.neg: tst.l d0
bmi.s .overf
.noerr: swap SIGN
or.l SIGN,VAR_TYPE
move.l VAR_TYPE,d1
POPEVAL
rts
.err: bra err_unexp_end
.overf: cmp.l #$80000000,d0
beq.s .noerr
bra err_overflow
; #] ForceEval:
; #[ LocEval:
LocEval:
IFNE EVALONE
tst.b d0
beq LocEval1
ENDC
PUSHEVAL
lea local_operand_jt(pc),OPERAND_JT
lea type_operator_jt(pc),OPERATOR_JT
lea _val_table,VAR_STACK
sf _global_found
moveq #0,PRIO ;pri
move.l sp,START_STACK
moveq #0,VAR_TYPE
moveq #0,d1
move.b (EVAL_STR)+,d1
ble.s .err
JSOPERAND
move.l VALUE,d0
tst.b SIGN
bne.s .neg
move.l VAR_TYPE,d1
beq.s .end
moveq #EVAL_RELOC,d1
.end: POPEVAL
rts
.neg: neg.l d0
bgt.s .overf
.noerr: moveq #1,d1
swap d1
or.w VAR_TYPE,d1
beq.s .end
addq.w #EVAL_RELOC,d1
POPEVAL
rts
.err: bra err_unexp_end
.overf: cmp.l VALUE,d0
beq.s .noerr
bra err_overflow
; #] LocEval:
; #[ GloEval:
GloEval:
IFNE EVALONE
tst.b d0
beq GloEval1
ENDC
PUSHGLOB
move.l EXP_backval(a3),VAR_STACK
lea glob_operand_jt(pc),OPERAND_JT
lea type_operator_jt(pc),OPERATOR_JT
moveq #0,PRIO ;pri
move.l sp,START_STACK
moveq #0,d1
move.b (EVAL_STR)+,d1
ble.s .err
JSOPERAND
move.l VALUE,d0
move.b SIGN,d2
bne.s .neg
.end: move.l VAR_TYPE,d1
POPGLOB
rts
.neg: neg.l d0
bgt.s .overf
.noerr: move.l VAR_TYPE,d1
POPGLOB
rts
.err: bra err_unexp_end
.overf: cmp.l VALUE,d0
beq.s .noerr
bra err_overflow
; #] GloEval:
; #[ OptiEval:
;Internal: PRIO=pri,ParNestCnt=parent_cnt,START_STACK=start sp
;Out: d1 = -errno ou 0 ou (0:expr_size:ff si evalone:type backpatch)
OptEval:
IFNE EVALONE
tst.w d0
beq OptEval1
ENDC
PUSHEVAL
suba.l VAR_STACK,VAR_STACK
lea opti_operand_jt(pc),OPERAND_JT
lea opti_operator_jt(pc),OPERATOR_JT
moveq #0,PRIO ;pri
move.l sp,START_STACK
clr.l _global_found ;+local+set
moveq #0,d1
move.b (EVAL_STR)+,d1
ble.s .err
JSOPERAND
move.l VALUE,d0
tst.b SIGN
beq.s .plus
neg.l d0
bgt.s .overf
.plus: move.l VAR_TYPE,d1
beq.s ._end
swap d1
move.w #EVAL_OPTI,d1
._end: POPEVAL
rts
.err: bra err_unexp_end
.overf: cmp.l VALUE,d0
beq.s .plus
bra err_overflow
; #] OptiEval:
; #] Eval Entries:
; #[ Eval Exits:
; #[ First Eval:
;(global ou local) + set
set_found_exit:
move.w d0,d3
addq.w #1,d0
add.w d0,d0
move.w d0,d1
add.w d1,d1
add.w d1,d0
ext.l d0
move.l d0,d2
bsr LValAlloc
beq.s .no_mem
lea _val_table,a2
move.l d0,a1
move.w d3,(a1)+
subq.w #1,d3
.cp: move.l (a2)+,(a1)+
move.w (a2)+,(a1)+
dbf d3,.cp
clr.l (a1)
st _global_found
bra.s fskip_x
.no_mem: bra err_nomem
;global ou local found
first_skip_exit:
move.w _setcnt,d0
bne.s set_found_exit
moveq #0,d0
fskip_x: clr.l ParNestCnt ;+FoncNestCnt
move.l EVAL_STR,d1
sub.l _a0_buf,d1
subq.w #1,d1
swap d1
lea _global_found,a1
tst.b (a1)+
bne.s .gf
;_local_found mis obligatoirement
addq.w #EVAL_LOC,d1
POPEVAL
rts
.gf: tst.b (a1) ;_local_found
bne.s .lgf ;cas marginal
addq.w #EVAL_GLO,d1
POPEVAL
rts
.lgf: addq.w #EVAL_LOCGLO,d1
POPEVAL
rts
; #] First Eval:
; #[ LocEval:
;y'a forcement un local dans l'expr
glob_found_exit: ;LocalPatch uniquement
clr.l ParNestCnt ;+FoncNestCnt
move.l VAR_STACK,d0
lea _val_table,a2
sub.l a2,d0
IFNE BLINDOS
beq.s .illeg ;impossible
ENDC
move.l d0,d2
addq.l #6,d0
bsr LValAlloc
beq.s .no_mem
move.l d0,a1
clr.w (a1)+
lea 4(a1),a3
move.l a3,(a1)+
lsr.w #2,d2 ;/4
subq.w #1,d2
.cp: move.l (a2)+,(a1)+
dbf d2,.cp
moveq #EVAL_LOCGLO+EVAL_RELOC,d1
POPEVAL
.end: rts
.no_mem: bra err_nomem
IFNE BLINDOS
.illeg: _Debugger
ENDC
; #] LocEval:
; #] Eval Exits:
; #[ Eval:
;In: PRIO.w=niveau de priorite,EVAL_STR=@chaine courante
;Out: VALUE.l=valeur
;Internal: VALUE=value,SIGN.b=sign
Eval: moveq #0,d1
move.b (EVAL_STR)+,d1
ble.s .err
JMOPERAND
.err: bra err_unexp_end
; #] Eval:
; #[ Get2ndOp:
get_2nd_op:
moveq #0,d1
move.b (EVAL_STR)+,d1
ble.s _end
JMOPERATOR
; #[ END OF EXPR '\0',-1:
_end: subq.w #1,EVAL_STR
tst.w ParNestCnt
bne.s .errp
rts
.errp: bra err_matching
; #] END OF EXPR '\0',-1:
; #] Get2ndOp:
; #[ Operand:
; #[ Commun:
; #[ Fonctions:
EvalFonc: move.l EVAL_STR,a1
move.l a0,-(sp)
lea intg_foncs_table(pc),a0
moveq #FONCS_NB,d1
bsr GetEvFonc
move.l (sp)+,a0
tst.l d0
beq err_fonc_nf
add.w d5,EVAL_STR
move.l d0,a1
moveq #0,d0
move.b FS_nargs(a1),d0
move.w d0,d1
mulu #VAL_SIZE,d1 ;pour les args
add.w #12,d1 ;pour le controle
sub.w d1,sp
move.w d1,(sp)
move.w d0,2(sp) ;nbre d'args
move.l a1,4(sp)
; move.l RVALUE,8(sp)
addq.w #1,FoncNestCnt
addq.w #1,ParNestCnt
.evarg: move.w 2(sp),d0
subq.w #1,d0
mulu #VAL_SIZE,d0
lea 12(sp,d0.w),a2
addq.w #1,EVAL_STR
move.l FS_ev_fonc(a1),a5
move.l a2,-(sp)
move.w PRIO,-(sp)
moveq #0,PRIO
jsr (a5) ;eval de l'arg.
move.w (sp)+,PRIO
move.l (sp)+,a2
move.l VALUE,(a2)+
move.l VAR_TYPE,(a2)+
move.w SIGN,(a2)+
move.l 4(sp),a1
subq.w #1,2(sp)
beq.s .args_ok
cmp.b #',',(EVAL_STR)
beq.s .evarg ;arg. suivant
bra.s .errarg
.args_ok: cmp.b #')',-1(EVAL_STR)
bne.s .errarg
move.l FS_fonc(a1),a5
; move.l 8(sp),RVALUE
; move.l RVALUE,a1
lea 12(sp),a2
jsr (a5)
bmi.s .out
subq.w #1,FoncNestCnt
add.w (sp),sp
bra get_2nd_op
.errev: clr.w FoncNestCnt
.out: add.w (sp),sp
tst.l d1
rts
.errarg: add.w (sp),sp
bra err_fonc_args
;In: a0=@table fonctions,a1=@fonc name, d0.w=len
; d1.w=nbre de foncs de la table
;Out: d0.L=@fonction struct
;aussi appelee par FpuEval
GetEvFonc:
movem.l d1/d2/d7/a0-a4,-(sp)
move.l a0,a2
move.l a1,a3
move.w d0,d2
move.l a2,a4
subq.w #1,d1
bmi.s .endnf
.l1: cmp.b (a2),d2
bne.s .next
move.w 2(a2),a0
add.l a4,a0
move.l a3,a1
move.w d2,d7
subq.w #1,d7
jsr icmpsort
bne.s .next
move.l a2,d0
bra.s .end
.next: lea FS_SIZEOF(a2),a2
dbf d1,.l1
.endnf: moveq #0,d0
.end: movem.l (sp)+,d1/d2/d7/a0-a4
rts
; #] Fonctions:
; #[ Octal:
_octal_string:
moveq #0,VAR_TYPE
sf SIGN
moveq #'0',d1
moveq #7,d2
moveq #0,VALUE
.l1:
REPT 4
move.b (EVAL_STR)+,d0
sub.b d1,d0
bmi.s .end
cmp.b d2,d0
bhi.s .end
add.l VALUE,VALUE
bcs.s .errbig
add.l VALUE,VALUE
bcs.s .errbig
add.l VALUE,VALUE
bcs.s .errbig
or.b d0,VALUE
ENDR
bra.s .l1
.end: subq.w #1,EVAL_STR
bra get_2nd_op
.errbig: bra err_num2big
; #] Octal:
; #[ Binary:
_binary_string:
moveq #0,VAR_TYPE
sf SIGN
moveq #'0',d1
moveq #1,d2
moveq #0,VALUE
.l1:
REPT 8
move.b (EVAL_STR)+,d0
sub.b d1,d0
bmi.s .end
cmp.b d2,d0
bhi.s .end
add.l VALUE,VALUE
bcs.s .errbig
or.b d0,VALUE
ENDR
bra .l1
.end: subq.w #1,EVAL_STR
bra get_2nd_op
.errbig: bra err_num2big
; #] Binary:
; #[ Strings: voir TOKENQUOTE
_quote_string:
moveq #0,VALUE
sf SIGN
; move.b -1(EVAL_STR),d0
moveq #TOKENQUOTE,d0
REPT 4
move.b (EVAL_STR)+,d1
; ble.s .err
cmp.b d0,d1
beq.s .end
cmp.b #"'",d1
beq.s .end
cmp.b #'"',d1
beq.s .end
lsl.l #8,VALUE
or.b d1,VALUE
ENDR
cmp.b (EVAL_STR)+,d0
bne.s .long
.end: moveq #0,VAR_TYPE
bra get_2nd_op
.err: bra err_unexp_end
.long: bra err_str2long
; #] Strings:
; #[ Space: inutile ?
space_operand:
moveq #' ',d0
cmp.b (EVAL_STR)+,d0
beq.s space_operand
subq.w #1,EVAL_STR
bra Eval
; #] Space:
; #[ Decimal number:
;Out:a1=@start dec string
_dec_string:
moveq #0,VAR_TYPE
moveq #'0',d1
moveq #0,VALUE
lea -1(EVAL_STR),a1
move.b (a1),VALUE
sub.b d1,VALUE
moveq #10,d2
sf SIGN
moveq #0,d0
REPT 7 ;8 digits sans erreur
move.b (EVAL_STR)+,d0
sub.b d1,d0
bmi.s *+6 ;.end
cmp.b d2,d0
bcs.s *+8 ;.add
;.end:
subq.w #1,EVAL_STR
bra get_2nd_op
;.add:
add.l VALUE,VALUE
move.l VALUE,d5 ;a*2
add.l VALUE,VALUE
add.l VALUE,VALUE ;a*8
add.l d5,VALUE ;a*10
add.l d0,VALUE
ENDR
.get: move.b (EVAL_STR)+,d0
sub.b d1,d0
bmi.s .end
add.l VALUE,VALUE
bcs.s .error
move.l VALUE,d5 ;a*2
add.l VALUE,VALUE
bcs.s .error
add.l VALUE,VALUE ;a*8
bcs.s .error
add.l d5,VALUE
bcs.s .error
add.l d0,VALUE
bcc.s .get
bra.s .error
.end: subq.w #1,EVAL_STR
bra get_2nd_op
.error: bra err_num2big
; #] Decimal number:
; #[ Hex number:
_hex_string:
moveq #0,VAR_TYPE
sf SIGN
moveq #4,d2
moveq #0,d1
move.b (EVAL_STR)+,d1
move.b hextab(pc,d1.w),d1
bne.s .chk
.fst: move.b (EVAL_STR)+,d1 ;0 debute le nbre
move.b hextab(pc,d1.w),d1
beq.s .fst
bgt.s .notz
moveq #0,VALUE
.endh: subq.w #1,EVAL_STR
.end: bra get_2nd_op ;sortie 1
.chk: bmi.s .err
.notz: move.l d1,VALUE
.l1:
REPT 7
move.b (EVAL_STR)+,d1
move.b hextab(pc,d1.w),d1
bmi.s .endh
lsl.l d2,VALUE
or.b d1,VALUE
ENDR
move.b (EVAL_STR),d1
move.b hextab(pc,d1.w),d1
bmi.s .end ;sortie 2
.lnum: bra err_num2big
.err: bra err_bad_hexa
; #[ Hex tab:
hextab: dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b +0,+1,+2,+3,+4,+5,+6,+7,+8,+9,-1,-1,-1,-1,-1,-1
dc.b -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
dc.b -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
; #] Hex tab:
; #] Hex number:
; #[ '(':
open_parent:
addq.w #1,ParNestCnt
move.w PRIO,-(sp) ;niveau
moveq #0,PRIO
bsr Eval
move.w (sp)+,PRIO
bra get_2nd_op
; #] '(':
; #[ Unary plus: tous types d'eval
u_plus: move.w PRIO,-(sp)
moveq #PLUS_PRI,PRIO
bsr Eval
move.w (sp)+,PRIO
bra get_2nd_op
; #] Unary plus:
; #] Commun:
; #[ 1st Eval:
; #[ Unary minus:
u_minus: move.w PRIO,-(sp)
moveq #MINUS_PRI,PRIO
bsr Eval
not.b SIGN
move.w (sp)+,PRIO
bra get_2nd_op
; #] Unary minus:
; #[ Not:
_not: move.w PRIO,-(sp)
moveq #NOT_PRI,PRIO
bsr Eval
COMPL2 VALUE,SIGN
not.l VALUE
bpl.s .plus
neg.l VALUE
st SIGN
.plus: move.w (sp)+,PRIO
bra get_2nd_op
.err: bra err_operr
; #] Not:
; #[ *:PC
u_star: moveq #0,VAR_TYPE
move.w CurSection,VAR_TYPE
addq.w #1,VAR_TYPE
move.l VAR_STACK,d0
bne.s .notfst
clr.w _setcnt
lea _val_table,VAR_STACK
.notfst: move.l SecSize,(VAR_STACK)+
clr.b (VAR_STACK)+ ;sign
move.b VAR_TYPE,(VAR_STACK)+
addq.w #1,_setcnt
bra FirstEvalSkip
; #] *:
; #[ Var/Equate:
var_pass1:
moveq #0,VAR_TYPE
subq.w #1,EVAL_STR
bsr getvarlen
move.w d0,d5
cmp.b #'(',0(EVAL_STR,d5.w)
beq.s .fonc
jsr FindEqu
add.w d5,EVAL_STR
beq.s .equnf
move.l d0,a1
move.l VAR_value(a1),VALUE
move.b VAR_sec(a1),VAR_TYPE
addq.b #1,VAR_TYPE
bgt.s .reloc ;equ/set en reloc pour GlobPatch
move.b VAR_type(a1),d1
lsl.b #1,d1
scs SIGN
beq get_2nd_op ;VAR_EQU
subq.b #EQU_SET*2,d1
bne.s .equr
bsr.s .stset ;VAR_SET -> stocker valeur
bra get_2nd_op
.reloc: cmp.b #EQU_SET,VAR_type(a1)
bne.s .equnf
bsr.s .stset
.equnf: st _global_found
bra FirstEvalSkip
.equr: tst.b (EVAL_STR)
bpl.s .errequr
move.l VALUE,d0
move.l START_STACK,sp
POPEVAL
moveq #EVAL_EQUR,d1
rts
.errequr: bra err_equr
.fonc: bra EvalFonc
;SET variable
.stset: move.l VAR_STACK,d0
bne.s .notfst
clr.w _setcnt
lea _val_table,VAR_STACK
.notfst: move.l VALUE,(VAR_STACK)+
move.b SIGN,(VAR_STACK)+
move.b VAR_TYPE,(VAR_STACK)+
addq.w #1,_setcnt
rts
; #] Var/Equate:
; #[ Local:
local_pass1:
bsr getvarlen
ble.s .errsyn
add.w d0,EVAL_STR
st _local_found
bra FirstEvalSkip
.errsyn: bra err_varchar
; #] Local:
; #] 1st Eval:
; #[ Global patch:
; #[ Unary minus: global+force+local+opti
local_u_minus:
force_u_minus:
glob_u_minus:
opti_u_minus:
move.w PRIO,-(sp)
moveq #MINUS_PRI,PRIO
bsr Eval
tst.w VAR_TYPE
bne.s .errt
not.b SIGN
move.w (sp)+,PRIO
bra get_2nd_op
.errt: bra err_operr
; #] Unary minus:
; #[ Not: global+force+local+opti
local_not:
force_not:
opti_not:
glob_not: move.w PRIO,-(sp)
moveq #NOT_PRI,PRIO
bsr Eval
tst.w VAR_TYPE
bne.s .err
COMPL2 VALUE,SIGN
not.l VALUE
bpl.s .plus
neg.l VALUE
st SIGN
.plus: move.w (sp)+,PRIO
bra get_2nd_op
.err: bra err_operr
; #] Not:
; #[ *:PC
;aussi appele par var_globpatch
global_set:
move.l VAR_STACK,d0
beq.s .fwset
move.b (VAR_STACK),d0
cmp.b 1(VAR_STACK),d0
bge.s .fwset
addq.b #1,(VAR_STACK)
ext.w d0
add.w d0,d0
move.w d0,d1
add.w d1,d1
add.w d1,d0 ;(compteur set)*6
move.l 2(VAR_STACK,d0.w),VALUE
move.b 6(VAR_STACK,d0.w),SIGN
move.b 7(VAR_STACK,d0.w),VAR_TYPE
IFNE ATARI
cmp.b #SEC_data+1,VAR_TYPE
bne.s .no_data
add.l TextSize,VALUE
.no_data: ENDC
bra get_2nd_op
.fwset: bra err_set_forward
; #] *:
; #[ Var/Equate:
var_globpatch:
moveq #0,VAR_TYPE
subq.w #1,EVAL_STR
bsr getvarlen
move.w d0,d5
cmp.b #'(',0(EVAL_STR,d0.w)
beq.s .fonc
jsr GetGloVar
beq.s .xref
add.w d5,EVAL_STR
move.l d0,VALUE
addq.b #1,d1 ;sec++
bne.s .rel
moveq #0,d1
.rel: move.l d1,VAR_TYPE ;#+0+sec
move.b VAR_type(a1),d1
lsl.b #1,d1
scs SIGN
beq get_2nd_op ;EQU_EQU
subq.b #EQU_SET*2,d1
beq.s global_set ;SET variable
subq.b #(EQU_GLOB-EQU_SET)*2,d1
beq get_2nd_op
bra err_type ;ni EQU_SET ni EQU_EQU
.errvar: bra err_var_nf
.fonc: bra EvalFonc
.xref: move.w d5,d0
jsr GetXref
beq.s .errvar
add.w d5,a0
moveq #0,VALUE
sf SIGN
swap d0 ;#<<16
move.l d0,d1
st d1 ;undef
move.l d1,VAR_TYPE
bra get_2nd_op
; #] Var/Equate:
; #[ Local:
local_globpatch:
move.w (VAR_STACK),d0
ext.w d0
add.w d0,d0
move.w d0,d1
add.w d1,d1
add.w d0,d1
move.l 2(VAR_STACK,d1.w),d0
bmi.s .notfst
move.l d0,_loc_list
neg.l d0
move.l d0,2(VAR_STACK,d1.w)
.notfst: bsr getvarlen
ble.s .errsyn ;impossible?
add.w d0,EVAL_STR
move.l _loc_list,a1
IFNE AMIGA
move.l (a1)+,VAR_TYPE
move.l (a1)+,VALUE
ENDC
IFNE ATARI
move.l (a1)+,d1
move.l (a1)+,VALUE
; subq.b #SEC_data+1,d1
cmp.b #SEC_data+1,d1
bne.s .nodata
add.l TextSize,VALUE
; addq.b #SEC_data+1,d1
.nodata: move.l d1,VAR_TYPE
ENDC ;ATARI
.end: sf SIGN
bset #8,d1
move.l a1,_loc_list
bra get_2nd_op
.errsyn: bra err_varchar
; #] Local:
; #] Global patch:
; #[ Force:
; #[ *:PC
force_u_star:
moveq #0,VAR_TYPE
move.w CurSection,VAR_TYPE
addq.w #1,VAR_TYPE
move.l SecSize,VALUE
moveq #0,SIGN
bra get_2nd_op
; #] *:
; #[ Var/Equate:
var_force:
moveq #0,VAR_TYPE
subq.w #1,EVAL_STR
bsr getvarlen
move.w d0,d2
cmp.b #'(',0(EVAL_STR,d0.w)
beq.s .fonc
jsr FindEqu
beq.s .equnf
move.l d0,a1
move.l VAR_value(a1),VALUE
move.b VAR_type(a1),d1
lsl.b #1,d1
scs SIGN
subq.b #EQU_EQUR*2,d1
beq.s .errequr
move.b VAR_sec(a1),VAR_TYPE
addq.b #1,VAR_TYPE
add.w d2,EVAL_STR
bra get_2nd_op
.equnf: move.w d2,d0
jsr ForceGloVar
beq.s .errnf
add.w d2,EVAL_STR
sf SIGN
move.b VAR_sec(a1),VAR_TYPE
addq.b #1,VAR_TYPE
move.l d0,VALUE
bra get_2nd_op
.errnf: bra err_must_eval
.errequr: bra err_equr
.fonc: bra EvalFonc
; #] Var/Equate:
; #[ Local:
local_force:
moveq #0,VAR_TYPE
bsr getvarlen
ble.s .errsyn
move.w d0,d2
jsr ForceLocVar
beq.s .errnf
add.w d2,EVAL_STR
move.b VAR_sec(a1),VAR_TYPE
addq.b #1,VAR_TYPE
sf SIGN
move.l d0,VALUE