forked from qwordAtGitHub/SmplMath
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcode_generator.inc
1449 lines (1384 loc) · 44.7 KB
/
code_generator.inc
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
;/********************************************************
; * This file is part of the SmplMath macros-system. *
; * *
; * Copyright by qWord, 2011-2014 *
; * *
; * SmplMath.Masm{at}gmx{dot}net *
; * http://sourceforge.net/projects/smplmath/ *
; * *
; * Further Copyright and Legal statements are located *
; * in the documentation (Documentation.pdf). *
; * *
; ********************************************************/
FSO_N_STACK = 0
;
; this macro creates code using the current selected back end
;
ll_fSlv macro SlvPath,SubExpr,bFunction:=<0>,retval_int_type:=<0>,retval_real_type:=<0>
IFNDEF lfs_lbl
lfs_lbl = 0
ENDIF
lfs_stack_cntr = 0
lfs_flg = 0
lfs_copy_only = 0
lfs_copy_src TEXTEQU <>
lfs_retval TEXTEQU <>
iml_create StkSlot
lfs_nss = 0
IFE FSBE_FNC(%FSBE_ENTITY,%FSEN_INIT,%__SMPLMATH__,0)
lfs_error = 1
EXITM
ENDIF
lfs_no_int_consts = FSBE_FNC(%FSBE_ENTITY,%FSEN_NO_INT_CONST)
lfs_no_real_consts = FSBE_FNC(%FSBE_ENTITY,%FSEN_NO_REAL_CONST)
lfs_imm_free_regs = FSBE_FNC(%FSBE_ENTITY,%FSEN_IMM_FREE)
IF lfs_no_int_consts NE 0 AND lfs_no_real_consts NE 0
fslv_glb_error_msg TEXTEQU <[#CG22] invalid back end (nonsense response to: FSEN_NO_INT/REAL_CONST)>
fslv_glb_error = 1
EXITM
ELSEIFE ((fslv_glb_flags AND FSF_NO_INT_CONSTS) NE 0) AND (lfs_no_real_consts NE 0)
lfs_no_int_consts = lfs_no_int_consts OR ((fslv_glb_flags AND FSF_NO_INT_CONSTS) NE 0)
ENDIF
;----------------------------
; go through list and:
; - search for registers (e.g. FPU: st0,st1,...)
; - delete empty nodes
; - trim tokens
;----------------------------
IFNB FSBE_ENUM_TKN
FSBE_PROC %FSBE_ENUM_TKN,%FSB_ENUM_START,<>,0
ENDIF
lfs_st_max = -1
lfs_iNode = ll_get_first(SlvPath)
WHILE lfs_iNode
lfs_txt TEXTEQU ll_get_data(SlvPath,%lfs_iNode,1)
IFB lfs_txt
lfs_iNode = ll_delete(SlvPath,%lfs_iNode)
ELSE
lfs_txt TEXTEQU @TrimStr(%lfs_txt)
IFNB FSBE_ENUM_TKN
FSBE_PROC %FSBE_ENUM_TKN,%FSB_ENUM_TKN,<<%lfs_txt>>,ll_get_data(SlvPath,%lfs_iNode,2)
ENDIF
IF FSBE_FNC(%FSBE_IS_TKN_REG,<<%lfs_txt>>)
ll_or_value SlvPath,%lfs_iNode,2,%TMT_ST
ll_set_data SlvPath,%lfs_iNode,1,%fsbeitr_index
IF fsbeitr_index GT lfs_st_max
lfs_st_max = fsbeitr_index
ENDIF
ELSE
ll_set_data SlvPath,%lfs_iNode,1,%lfs_txt
ENDIF
IF fslv_glb_error
EXITM
ENDIF
lfs_iNode = ll_get_next(SlvPath,%lfs_iNode)
ENDIF
ENDM
IF fslv_glb_error
EXITM
ENDIF
IF lfs_st_max NE -1
lfs_stack_cntr = lfs_st_max + 1
ENDIF
IFNB FSBE_ENUM_TKN
FSBE_PROC %FSBE_ENUM_TKN,%FSB_ENUM_END,<>,0
ENDIF
IF fslv_glb_error
EXITM
ENDIF
FSO_N_STACK = FSBE_FNC(%FSBE_ENTITY,%FSEN_MAX_STACK)
IF FSO_N_STACK LE 0
fslv_glb_error_msg TEXTEQU <[#CG23] invalid back end (nonsense response to: FSEN_MAX_STACK)>
fslv_glb_error = 1
EXITM
ENDIF
lfs_stack_cntr = lfs_stack_cntr + FSBE_FNC(%FSBE_ENTITY,%FSEN_STCK_USAGE,%lfs_stack_cntr)
IF FSBE_FNC(%FSBE_ENTITY,%FSEN_TEST_ATTR,<stck>)
IF @fslv_test_attribute(<stck>,<:>,0)
IF lfs_st_max EQ -1 AND fsta_value GT 0
lfs_stack_cntr = fsta_value
ELSE
IF lfs_st_max+1 GT fsta_value
lfs_stack_cntr = lfs_st_max + 1
fslv_glb_error_msg TEXTEQU <[#CG24] Attribute <stck:N>: the number of used registers in expression is greater than N>
fslv_glb_error = 1
EXITM
ELSE
lfs_stack_cntr = fsta_value
lfs_st_max = fsta_value - 1
ENDIF
ENDIF
ENDIF
ENDIF
lfs_copy_supported = FSBE_FNC(%FSBE_ENTITY,%FSEN_COPY_SUPPORTED)
lfs_dest_cntr = 0
;-----------------------------------------
; - create 'streaming' buffer serving
; tokens from linked list.
; - each token has a textmacro: lfs_txtX
; and a constant lfs_flgX
; - 4 tokens are stocked
; - lfs_txt2/flg2 is the current token
;-----------------------------------------
lfs_iNode = ll_stream_tm(SlvPath,,1,,lfs_txt2,lfs_txt3,lfs_txt4,lfs_txt5)
lfs_iNode = ll_stream_const(SlvPath,,2,,lfs_flg2,lfs_flg3,lfs_flg4,lfs_flg5)
lfs_iNode = ll_stream_links(SlvPath,,lfs_iNode2,lfs_iNode3,lfs_iNode4,lfs_iNode5)
;-----------------------------------------------
; - process token list
; - lfs_skip is used to discard tokens
; prior lfs_txt/flg2
; - lfs_stack_cntr holds the number of currently
; used register
;-----------------------------------------------
lfs_skip = 0
WHILE lfs_flg2
IF lfs_skip
lfs_skip = lfs_skip - 1
ELSE
IF lfs_flg2 AND TMT_ASSIGN
IFE lfs_flg2 AND TMT_ST
IF lfs_dest_cntr EQ 0
lfs_retval TEXTEQU FSBE_FNC(%FSBE_ASSIGN_DEST,%lfs_txt2,%@IsIntegerType(%lfs_txt2),%@IsRealType(%lfs_txt2),bFunction,retval_int_type,retval_real_type,0,<>)
ELSE
%_discard_ FSBE_FNC(%FSBE_ASSIGN_DEST,%lfs_txt2,%@IsIntegerType(%lfs_txt2),%@IsRealType(%lfs_txt2),0,0,0,0,<>)
ENDIF
ELSE
FSBE_PROC %FSBE_SET_REG,%(lfs_stack_cntr-(lfs_st_max-lfs_txt2)-1),1
ENDIF
lfs_stack_cntr = lfs_stack_cntr - 1
lfs_dest_cntr = lfs_dest_cntr + 1
ELSEIF lfs_flg2 AND TMT_TXT
IF lfs_copy_supported NE 0 AND (lfs_flg2 AND TMT_NEG) EQ 0 AND (lfs_flg3 AND TMT_ASSIGN) NE 0
IF lfs_flg2 AND TMT_ST
lfs__txt2 TEXTEQU %(lfs_stack_cntr-(lfs_st_max-lfs_txt2)-1
ELSE
lfs__txt2 TEXTEQU lfs_txt2
ENDIF
IF lfs_flg3 AND TMT_ST
lfs__txt3 TEXTEQU %(lfs_stack_cntr-(lfs_st_max-lfs_txt3)-1)
ELSE
lfs__txt3 TEXTEQU lfs_txt3
ENDIF
lfs_flg = _IF$(lfs_flg2 AND TMT_ST,2,1) OR _IF$(lfs_flg3 AND TMT_ST,4,0)
lfs__iTyp = _IF$(lfs_flg3 AND TMT_ST,0,@IsIntegerType(%lfs__txt3))
lfs__rTyp = _IF$(lfs_flg3 AND TMT_ST,0,@IsRealType(%lfs__txt3))
IF lfs_dest_cntr EQ 0
lfs_retval TEXTEQU FSBE_FNC(%FSBE_ASSIGN_DEST,%lfs__txt3,%lfs__iTyp,%lfs__rTyp,bFunction,retval_int_type,retval_real_type,%lfs_flg,%lfs__txt2)
ELSE
%_discard_ FSBE_FNC(%FSBE_ASSIGN_DEST,%lfs__txt3,%lfs__iTyp,%lfs__rTyp,0,0,0,%lfs_flg,%lfs__txt2)
ENDIF
lfs_dest_cntr = lfs_dest_cntr + 1
lfs_skip = 1
ELSE
IF lfs_flg2 AND TMT_ST
FSBE_PROC %FSBE_LOAD_REG,%(lfs_stack_cntr-(lfs_st_max-lfs_txt2)-1),%(lfs_flg2 AND TMT_NEG)
ELSE
FSBE_PROC %FSBE_LOAD_ARG,%lfs_txt2,%(lfs_flg2 AND TMT_NEG)
ENDIF
lfs_stack_cntr = lfs_stack_cntr + 1
ENDIF
ELSEIF lfs_flg2 AND TMT_CONST
IF lfs_copy_supported NE 0 AND (lfs_flg2 AND TMT_NEG) EQ 0 AND (lfs_flg3 AND TMT_ASSIGN) NE 0
lfs_flg = lfs_flg2
lfs_txt TEXTEQU lfs_txt2
lfs__txt2 TEXTEQU llfs_make_const()
;lfs__txt3 TEXTEQU _IF$(lfs_flg3 AND TMT_ST,%(lfs_stack_cntr-(lfs_st_max-lfs_txt3)-1),%lfs_txt3)
IF lfs_flg3 AND TMT_ST
lfs__txt3 TEXTEQU %(lfs_stack_cntr-(lfs_st_max-lfs_txt3)-1)
ELSE
lfs__txt3 TEXTEQU lfs_txt3
ENDIF
IFB lfs__txt2
lfs_flg = 0
lfs_stack_cntr = lfs_stack_cntr + 1
ELSE
lfs_flg = _IF$(lfs_flg2 AND TMT_ST,2,1) OR _IF$(lfs_flg3 AND TMT_ST,4,0)
ENDIF
lfs__iTyp = _IF$(lfs_flg3 AND TMT_ST,0,@IsIntegerType(%lfs__txt3))
lfs__rTyp = _IF$(lfs_flg3 AND TMT_ST,0,@IsRealType(%lfs__txt3))
IF lfs_dest_cntr EQ 0
lfs_retval TEXTEQU FSBE_FNC(%FSBE_ASSIGN_DEST,%lfs__txt3,%lfs__iTyp,%lfs__rTyp,bFunction,retval_int_type,retval_real_type,%lfs_flg,%lfs__txt2)
ELSE
%_discard_ FSBE_FNC(%FSBE_ASSIGN_DEST,%lfs__txt3,%lfs__iTyp,%lfs__rTyp,0,0,0,%lfs_flg,%lfs__txt2)
ENDIF
IFB lfs__txt2
lfs_stack_cntr = lfs_stack_cntr - 1
ENDIF
lfs_dest_cntr = lfs_dest_cntr + 1
lfs_skip = 1
ELSE
fslv_on_const SlvPath,SubExpr
ENDIF
ELSEIF lfs_flg2 AND TMT_PUSH
IF (lfs_flg3 AND TMT_OPRT) NE 0 AND (lfs_flg4 AND TMT_POP) NE 0
;; st(1) <+-*/^> st(0)
FSBE_PROC %FSBE_REG1_OPRT_REG0_P,%lfs_txt3
lfs_stack_cntr = lfs_stack_cntr - 1
lfs_skip = 2
ELSEIF (lfs_flg3 AND TMT_OPERAND) NE 0 AND (lfs_flg4 AND TMT_OPRT) NE 0 AND (lfs_flg5 AND TMT_POP) NE 0
;; ? <+-*/^> st(0)
fslv_load_larg
IFNB lfs_txt
IF lfs_flg AND TMT_ST NE 0
FSBE_PROC %FSBE_REGX_OPRT_REG0,%lfs_txt4,%lfs_txt
ELSE
FSBE_PROC %FSBE_MEM_OPRT_REG0,%lfs_txt,%lfs_txt4,%@IsIntegerType(%lfs_txt),%@IsRealType(%lfs_txt)
ENDIF
ELSE
fslv_stck_chk 1
lfs_stack_cntr = lfs_stack_cntr + 1
FSBE_PROC %FSBE_REG0_OPRT_REG1_P,%lfs_txt4
lfs_stack_cntr = lfs_stack_cntr - 1
ENDIF
lfs_skip = 3
ELSEIF (lfs_flg3 AND TMT_OPRT) NE 0
%echo debug: push,<+-*/^>,? - unknown situation - report to author
ELSEIF lfs_flg3 AND TMT_POP
;; push,pop
;; hold st(0)
lfs_skip = 1
ELSE
;; push
lfs_stack_cntr = lfs_stack_cntr + 1
ENDIF
ELSEIF lfs_flg2 AND TMT_POP
%echo debug: pop - unknown situation - report to author
ELSEIF lfs_flg2 AND TMT_STO
lfs_idn_23 = llfs_is_idn(<%lfs_txt2>,<%lfs_txt3>)
lfs_idn_24 = llfs_is_idn(<%lfs_txt2>,<%lfs_txt4>)
lfs_idn_25 = llfs_is_idn(<%lfs_txt2>,<%lfs_txt5>)
IF (lfs_flg3 AND TMT_OPRT) NE 0 AND (lfs_flg4 AND TMT_REC) NE 0 AND lfs_idn_24 NE 0
;; st(1) <+-*/^> st(0)
fslv_sto SubExpr,<%lfs_txt2>,1,%lfs_stack_cntr
IF lfs_flg4 AND TMT_NEG
FSBE_PROC %FSBE_NEG
ENDIF
FSBE_PROC %FSBE_REG1_OPRT_REG0_P,%lfs_txt3
lfs_stack_cntr = lfs_stack_cntr - 1
lfs_skip = 2
ELSEIF (lfs_flg3 AND TMT_OPERAND) NE 0 AND (lfs_flg4 AND TMT_OPRT) NE 0 AND (lfs_flg5 AND TMT_REC) NE 0 AND lfs_idn_25 NE 0
;; ? <+-*/^> st(0)
fssror_done = 0
IF (lfs_flg3 AND TMT_REC) NE 0 AND lfs_idn_23 NE 0 AND FSLV_NO_FORMULA_OPTIMIZATION EQ 0
fslv_sto_rec0_oprt_rec0
ENDIF
IF fssror_done EQ 0
fslv_sto SubExpr,<%lfs_txt2>,1,%lfs_stack_cntr
IF lfs_flg5 AND TMT_NEG
FSBE_PROC %FSBE_NEG
ENDIF
fslv_load_larg
IFNB lfs_txt
IF lfs_flg AND TMT_ST NE 0
FSBE_PROC %FSBE_REGX_OPRT_REG0,%lfs_txt4,%lfs_txt
ELSE
FSBE_PROC %FSBE_MEM_OPRT_REG0,%lfs_txt,%lfs_txt4,%@IsIntegerType(%lfs_txt),%@IsRealType(%lfs_txt)
ENDIF
ELSE
fslv_stck_chk 1
lfs_stack_cntr = lfs_stack_cntr + 1
FSBE_PROC %FSBE_REG0_OPRT_REG1_P,%lfs_txt4
lfs_stack_cntr = lfs_stack_cntr - 1
ENDIF
ENDIF
lfs_skip = 3
ELSEIF (lfs_flg3 AND TMT_REC) NE 0 AND lfs_idn_23 NE 0 AND (lfs_flg4 AND TMT_REC) NE 0 AND lfs_idn_24 NE 0
;; sto x , rec x , rec x
fslv_sto SubExpr,<%lfs_txt2>,2,%lfs_stack_cntr
IF (lfs_flg3 AND TMT_NEG) NE 0 AND (lfs_flg4 AND TMT_NEG) NE 0
FSBE_PROC %FSBE_NEG
FSBE_PROC %FSBE_LOAD_REG,0
lfs_stack_cntr = lfs_stack_cntr + 1
ELSEIF lfs_flg3 AND TMT_NEG
FSBE_PROC %FSBE_LOAD_REG,0,1
lfs_stack_cntr = lfs_stack_cntr + 1
FSBE_PROC %FSBE_XCHG
ELSEIF lfs_flg4 AND TMT_NEG
FSBE_PROC %FSBE_LOAD_REG,0,1
lfs_stack_cntr = lfs_stack_cntr + 1
ELSE
FSBE_PROC %FSBE_LOAD_REG,0
lfs_stack_cntr = lfs_stack_cntr + 1
ENDIF
lfs_skip = 2
ELSEIF (lfs_flg3 AND TMT_REC) NE 0 AND lfs_idn_23 NE 0
;; sto x, rec x
;; hold
fslv_sto SubExpr,<%lfs_txt2>,1,%lfs_stack_cntr
IF lfs_flg3 AND TMT_NEG
FSBE_PROC %FSBE_NEG
ENDIF
lfs_skip = 1
ELSE
fslv_sto SubExpr,<%lfs_txt2>,0,%lfs_stack_cntr
;lfs_stack_cntr = lfs_stack_cntr - 1
ENDIF
ELSEIF lfs_flg2 AND TMT_REC
lfs_txt TEXTEQU fslv_rec(SubExpr,<%lfs_txt2>,%lfs_stack_cntr)
FSBE_PROC %FSBE_LOAD_REG,%lfs_txt,%lfs_flg2 AND TMT_NEG
lfs_stack_cntr = lfs_stack_cntr + 1
ELSEIF lfs_flg2 AND TMT_OPRT
;; st(0) <+-*/^> ?
lfs_rcval_used = 0
IF lfs_flg3 AND TMT_OPERAND
fslv_load_rarg
ELSE
fslv_glb_error_msg TEXTEQU <[#CG2] missing operand>
fslv_glb_error = 1
EXITM
ENDIF
IFNB lfs_txt
IF lfs_flg AND TMT_ST
FSBE_PROC %FSBE_REG0_OPRT_REGX,%lfs_txt2,%lfs_txt
ELSE
FSBE_PROC %FSBE_REG0_OPRT_MEM,%lfs_txt,%lfs_txt2,%@IsIntegerType(%lfs_txt),%@IsRealType(%lfs_txt)
ENDIF
ELSE
IF lfs_rcval_used EQ 0
lfs_stack_cntr = lfs_stack_cntr + 1
FSBE_PROC %FSBE_REG1_OPRT_REG0_P,%lfs_txt2
lfs_stack_cntr = lfs_stack_cntr - 1
ENDIF
ENDIF
lfs_skip = 1
ELSEIF lfs_flg2 AND TMT_FNC
lfs_flg = lfs_flg2
lfs_txt TEXTEQU lfs_txt2
fslv_call_fnc
ELSEIF lfs_flg2 AND TMT_NEG
FSBE_PROC %FSBE_NEG
ELSE
fslv_glb_error_msg TEXTEQU <[#CG2] unknown>
fslv_glb_error = 1
ENDIF
ENDIF
;%echo STK: @CatStr(%lfs_stack_cntr)
fslv_stck_chk 0
IF fslv_glb_error
EXITM
ENDIF
;---------------------------------------
; - make one step forward in
; token-buffer
;---------------------------------------
lfs_flg2 = lfs_flg3
lfs_flg3 = lfs_flg4
lfs_flg4 = lfs_flg5
lfs_iNode2 = lfs_iNode3
lfs_iNode3 = lfs_iNode4
lfs_iNode4 = lfs_iNode5
lfs_iNode5 = lfs_iNode
lfs_txt2 TEXTEQU lfs_txt3
lfs_txt3 TEXTEQU lfs_txt4
lfs_txt4 TEXTEQU lfs_txt5
IF lfs_iNode
lfs_txt5 TEXTEQU ll_get_data(SlvPath,%lfs_iNode,1)
lfs_flg5 = ll_get_data(SlvPath,%lfs_iNode,2)
lfs_iNode = ll_get_next(SlvPath,%lfs_iNode)
ELSE
lfs_txt5 TEXTEQU <>
lfs_flg5 = 0
ENDIF
ENDM
IF fslv_glb_error
IF FSBE_FNC(%FSBE_ENTITY,%FSEN_NAME)
fslv_glb_error_msg TEXTEQU <[back end: >,fsbe_txt,<]>,fslv_glb_error_msg
ENDIF
EXITM
ENDIF
IF lfs_dest_cntr EQ 0 AND bFunction NE 0
lfs_retval TEXTEQU FSBE_FNC(%FSBE_ASSIGN_DEST,<>,0,0,bFunction,retval_int_type,retval_real_type,0,<>)
lfs_stack_cntr = lfs_stack_cntr - 1
ENDIF
IF iml_get_max(StkSlot) GE 0 AND lfs_imm_free_regs EQ 0
lfs_cntr=0
REPEAT iml_get_max(StkSlot)+1
FSBE_PROC %FSBE_FREE_REG,%lfs_stack_cntr+lfs_cntr
lfs_cntr = lfs_cntr + 1
ENDM
ENDIF
IF FSBE_FNC(%FSBE_ENTITY,%FSEN_TEST_ATTR,<pop>)
IF @fslv_test_attribute(<pop>,<:>,0)
IF fsta_value GT 0
REPEAT fsta_value
FSBE_PROC %FSBE_SET_REG,0,1
ENDM
ENDIF
ENDIF
ENDIF
IF FSBE_FNC(%FSBE_ENTITY,%FSEN_TEST_ATTR,<free>)
IF @fslv_test_attribute(<free>,<:>,0)
fslv_tmp_i INSTR 1,fsta_value,<->
IF fslv_tmp_i EQ 0
FSBE_PROC %FSBE_FREE_REG,%fsta_value
ELSE
fslv_tmp_i1 SUBSTR fsta_value,1,fslv_tmp_i-1
fslv_tmp_i2 SUBSTR fsta_value,fslv_tmp_i+1
IF fslv_tmp_i2 LT fslv_tmp_i1
fslv_tmp_i = fslv_tmp_i2
fslv_tmp_i2 = fslv_tmp_i1
fslv_tmp_i1 = fslv_tmp_i
ENDIF
fslv_tmp_i = fslv_tmp_i1
REPEAT fslv_tmp_i2 - fslv_tmp_i1 + 1
FSBE_PROC %FSBE_FREE_REG,%fslv_tmp_i
fslv_tmp_i = fslv_tmp_i + 1
ENDM
ENDIF
ENDIF
ENDIF
%_discard_ FSBE_FNC(%FSBE_ENTITY,%FSEN_END)
IF fslv_glb_error
IF FSBE_FNC(%FSBE_ENTITY,%FSEN_NAME)
fslv_glb_error_msg TEXTEQU <[back end: >,fsbe_txt,<]>,fslv_glb_error_msg
ENDIF
ENDIF
endm
fslv__expand_const macro arg
EXITM <&arg>
endm
; integer optimization
; res = [c op2] ((IFNB _neg ? -1:1)*(a op b)) ; []=optinal
; checks overflow by reversing the operation (needed for MASM 6-7)
fslv_const_calc macro a,b,op,op2,_c,_neg
; TODO: check overflow
fscc_done = 0
fscc_result TEXTEQU <>
fscc_result0 TEXTEQU <>
IF @InStr(1,<+-*>,<&op>) NE 0
fscc_result TEXTEQU @CatStr(%((a) op (b)))
IF a EQ (fscc_result @SubStr(<-+/>,@InStr(1,<+-*>,<&op>),1) b)
fscc_done = 1
ENDIF
ELSEIFIDN <&op>,</>
IF b EQ 0
fslv_glb_error_msg TEXTEQU <[#CG29] division by zero in constant integer expression>
fslv_glb_error = 1
ELSEIF (a MOD b) EQ 0
fscc_result TEXTEQU @CatStr(%((a) op (b)))
IF a EQ (fscc_result * b)
fscc_done = 1
ENDIF
ENDIF
ELSEIFIDN <&op>,<^>
IF b EQ 0
fscc_result TEXTEQU <1>
fscc_done = 1
ELSEIF b EQ 1
fscc_result TEXTEQU <&a>
fscc_done = 1
ELSEIF b GE 2 AND b LE 31
fscc_im_res = a
fscc_cntr = 0
WHILE fscc_cntr LT b-1
fscc_im_res = fscc_im_res * (a)
fscc_cntr = fscc_cntr + 1
ENDM
fscc_result TEXTEQU @CatStr(%(fscc_im_res))
fscc_cntr = 0
WHILE fscc_cntr LT b-1
fscc_im_res = fscc_im_res / (a)
fscc_cntr = fscc_cntr + 1
ENDM
IF a EQ @CatStr(%fscc_im_res)
fscc_done = 1
ENDIF
ENDIF
ENDIF
IF fscc_done NE 0
IFNB <&op2>
fscc_result0 TEXTEQU fscc_result
IFB <&_neg>
fslv_const_calc <&_c>,%fscc_result,<&op2>
ELSE
fslv_const_calc <&_c>,%(-(fscc_result)),<&op2>
ENDIF
ENDIF
ENDIF
IF fscc_done
IFE lfs_no_int_consts
IF fscc_result LT -2147483648 OR fscc_result GT 2147483647
fscc_done = 0
ENDIF
ELSE
IF fslv_lcl_real_type EQ 4
IF fscc_result LT -16777216 OR fscc_result GT 16777216 ; REAL4: exact representable integers
fscc_done = 0
ENDIF
ENDIF
ENDIF
ENDIF
; IF fscc_done
; %echo DONE: fscc_result = _c op2 (a op b)
; ELSE
; %echo REJ: _c op2 (a op b)
; ENDIF
endm
fslv_repl_all_recs macro SlvPath,iNode,refVal,constValue
fsrar_iNode = iNode
WHILE fsrar_iNode
fsrar_flg = ll_get_data(SlvPath,%fsrar_iNode,2)
IF fsrar_flg AND TMT_REC
fsrar_txt TEXTEQU ll_get_data(SlvPath,%fsrar_iNode,1)
IFIDN fsrar_txt,<&refVal>
IF fsrar_flg AND TMT_NEG
ll_set_data SlvPath,%fsrar_iNode,1,%(-(constValue))
ELSE
ll_set_data SlvPath,%fsrar_iNode,1,constValue
ENDIF
ll_set_data SlvPath,%fsrar_iNode,2,%(TMT_INT OR TMT_OPTMZTN)
ENDIF
ENDIF
fsrar_iNode = ll_get_next(SlvPath,%fsrar_iNode)
ENDM
endm
fslv_on_const macro SlvPath,SubExpr
lfs_idn_35 = llfs_is_idn(<%lfs_txt3>,<%lfs_txt5>) NE 0
lfs__cond = (lfs_flg3 AND TMT_PUSH) NE 0 AND (lfs_flg4 AND TMT_OPRT) NE 0 AND @InStr(1,<+-*>,%lfs_txt4) NE 0 AND (lfs_flg5 AND TMT_POP) NE 0
lfs__cond = lfs__cond OR ((lfs_flg3 AND TMT_STO) NE 0 AND (lfs_flg4 AND TMT_OPRT) NE 0 AND @InStr(1,<+-*>,%lfs_txt4) NE 0 AND (lfs_flg5 AND TMT_REC) NE 0 AND lfs_idn_35)
IF lfs__cond AND (lfs_flg2 AND TMT_INT) NE 0
; st(0) <+-*> int
lfs__txt2 TEXTEQU lfs_txt2
IF (lfs_flg2 AND TMT_NEG) NE 0 AND (lfs_flg2 AND TMT_INT) NE 0
lfs__txt2 TEXTEQU @CatStr(%-(lfs_txt2))
ENDIF
IFIDNI lfs_txt4,<->
IF (lfs_flg2 AND TMT_INT) NE 0
lfs__txt2 TEXTEQU @CatStr(%-(lfs__txt2))
lfs_txt4 TEXTEQU <+>
ENDIF
ENDIF
IF (lfs_flg5 AND TMT_REC) NE 0 AND (lfs_flg5 AND TMT_NEG) NE 0 AND (lfs_flg2 AND TMT_INT) NE 0
lfs__txt2 TEXTEQU @CatStr(%-(lfs__txt2))
ENDIF
IF (lfs_flg5 AND TMT_REC) NE 0
fslv_sto SubExpr,%lfs_txt5,1,%lfs_stack_cntr
ENDIF
lfs_flg = TMT_INT
lfs_txt TEXTEQU lfs__txt2
lfs_txt TEXTEQU llfs_make_const()
FSBE_PROC %FSBE_REG0_OPRT_MEM,%lfs_txt,%lfs_txt4,%@IsIntegerType(%lfs_txt),%@IsRealType(%lfs_txt)
lfs_skip = 3
EXITM
ENDIF
IF ((fslv_lcl_int_type LE 4) OR (lfs_no_int_consts NE 0)) AND FSLV_NO_FORMULA_OPTIMIZATION EQ 0 AND (lfs_flg2 AND TMT_INT) NE 0
lfs_flg6 = ll_get(SlvPath,%lfs_iNode,0,2,1,<0>)
lfs_txt6 TEXTEQU ll_get(SlvPath,%lfs_iNode,0,1,1,< >)
IF (lfs_flg3 AND TMT_OPRT) NE 0 AND (lfs_flg4 AND TMT_INT) NE 0
; B = A <op> B
lfs__txt2 TEXTEQU lfs_txt2
lfs__txt4 TEXTEQU lfs_txt4
IF lfs_flg2 AND TMT_NEG
lfs__txt2 TEXTEQU @CatStr(%-(lfs_txt2))
ENDIF
IF lfs_flg4 AND TMT_NEG
lfs__txt4 TEXTEQU @CatStr(%-(lfs_txt4))
ENDIF
fslv_const_calc %lfs__txt2,%lfs__txt4,%lfs_txt3
IF fscc_done
ll_set_data SlvPath,%lfs_iNode4,1,%fscc_result
ll_set_data SlvPath,%lfs_iNode4,2,%(TMT_INT OR TMT_OPTMZTN)
lfs_txt4 TEXTEQU fscc_result
lfs_flg4 = TMT_INT OR TMT_OPTMZTN
lfs_skip = 1
EXITM
ENDIF
ELSEIF (lfs_flg3 AND TMT_INT) NE 0 AND (lfs_flg4 AND TMT_PUSH) NE 0 AND (lfs_flg5 AND TMT_OPRT) NE 0 AND (lfs_flg6 AND TMT_POP) NE 0
; A <op> B
lfs__txt2 TEXTEQU lfs_txt2
lfs__txt3 TEXTEQU lfs_txt3
IF lfs_flg2 AND TMT_NEG
lfs__txt2 TEXTEQU @CatStr(%-(lfs_txt2))
ENDIF
IF lfs_flg3 AND TMT_NEG
lfs__txt3 TEXTEQU @CatStr(%-(lfs_txt3))
ENDIF
fslv_const_calc %lfs__txt2,%lfs__txt3,%lfs_txt5
IF fscc_done
ll_set_data SlvPath,%lfs_iNode,1,%fscc_result
ll_set_data SlvPath,%lfs_iNode,2,%(TMT_INT OR TMT_OPTMZTN)
lfs_skip = 3
EXITM
ENDIF
ELSE
lfs_idn_36 = llfs_is_idn(<%lfs_txt3>,<%lfs_txt6>) NE 0
lfs_idn_34 = llfs_is_idn(<%lfs_txt3>,<%lfs_txt4>) NE 0
lfs_idn_46 = llfs_is_idn(<%lfs_txt4>,<%lfs_txt6>) NE 0
IF (lfs_flg3 AND TMT_INT) NE 0 AND (lfs_flg4 AND TMT_STO) NE 0 AND (lfs_flg5 AND TMT_OPRT) NE 0 AND (lfs_flg6 AND TMT_REC) NE 0 AND lfs_idn_46
; A <*/^> B
lfs__txt2 TEXTEQU lfs_txt2
lfs__txt3 TEXTEQU lfs_txt3
IF lfs_flg2 AND TMT_NEG
lfs__txt2 TEXTEQU @CatStr(%-(lfs_txt2))
ENDIF
IF lfs_flg3 AND TMT_NEG
lfs__txt3 TEXTEQU @CatStr(%-(lfs_txt3))
ENDIF
IF lfs_flg6 AND TMT_NEG
lfs__txt3 TEXTEQU @CatStr(%-(lfs__txt3))
ENDIF
fslv_const_calc %lfs__txt2,%lfs__txt3,%lfs_txt5
IF fscc_done
fslv_repl_all_recs SlvPath,%lfs_iNode,%lfs_txt4,%lfs_txt3
ll_set_data SlvPath,%lfs_iNode,1,%fscc_result
ll_set_data SlvPath,%lfs_iNode,2,%(TMT_INT OR TMT_OPTMZTN)
lst_set_data SubExpr,%(lfs_txt4+2),2,0
lfs_skip = 3
EXITM
ENDIF
ELSEIF (lfs_flg3 AND TMT_STO) NE 0 AND (lfs_flg4 AND TMT_REC) NE 0 AND (lfs_flg5 AND TMT_OPRT) NE 0 AND (lfs_flg6 AND TMT_INT) NE 0 AND lfs_idn_34
lfs__txt2 TEXTEQU lfs_txt2
IF lfs_flg2 AND TMT_NEG
lfs__txt2 TEXTEQU @CatStr(%-(lfs_txt2))
ENDIF
IF lfs_flg4 AND TMT_NEG
lfs__txt2 TEXTEQU @CatStr(%-(lfs__txt2))
ENDIF
IF lfs_flg6 AND TMT_NEG
lfs_txt6 TEXTEQU @CatStr(%-(lfs_txt6))
ENDIF
fslv_const_calc %lfs__txt2,%lfs_txt6,%lfs_txt5
IF fscc_done
ll_set_data SlvPath,%lfs_iNode,1,%fscc_result
ll_set_data SlvPath,%lfs_iNode,2,%(TMT_INT OR TMT_OPTMZTN)
lst_set_data SubExpr,%(lfs_txt3+2),2,0
fslv_repl_all_recs SlvPath,%lfs_iNode,%lfs_txt3,%lfs_txt2
lfs_skip = 3
EXITM
ENDIF
ELSEIF (lfs_flg3 AND TMT_STO) NE 0 AND (lfs_flg4 AND TMT_INT) NE 0 AND (lfs_flg5 AND TMT_OPRT) NE 0 AND (lfs_flg6 AND TMT_REC) NE 0 AND lfs_idn_36
lfs__txt2 TEXTEQU lfs_txt2
lfs__txt4 TEXTEQU lfs_txt4
IF lfs_flg2 AND TMT_NEG
lfs__txt2 TEXTEQU @CatStr(%-(lfs_txt2))
ENDIF
IF lfs_flg4 AND TMT_NEG
lfs__txt4 TEXTEQU @CatStr(%-(lfs_txt4))
ENDIF
IF lfs_flg6 AND TMT_NEG
lfs__txt2 TEXTEQU @CatStr(%-(lfs__txt2))
ENDIF
fslv_const_calc %lfs__txt4,%lfs_txt2,%lfs_txt5
IF fscc_done
ll_set_data SlvPath,%lfs_iNode,1,%fscc_result
ll_set_data SlvPath,%lfs_iNode,2,%(TMT_INT OR TMT_OPTMZTN)
lst_set_data SubExpr,%(lfs_txt3+2),2,0
fslv_repl_all_recs SlvPath,%lfs_iNode,%lfs_txt3,%lfs_txt2
lfs_skip = 3
EXITM
ENDIF
ELSEIF (lfs_flg3 AND TMT_INT) NE 0 AND (lfs_flg4 AND TMT_OPRT) NE 0 AND (lfs_flg5 AND TMT_INT) NE 0
lfs_flg7 = ll_get(SlvPath,%lfs_iNode,1,2,1,<0>)
lfs_flg8 = ll_get(SlvPath,%lfs_iNode,2,2,1,<0>)
lfs_txt7 TEXTEQU ll_get(SlvPath,%lfs_iNode,1,1,1,< >)
lfs_txt8 TEXTEQU ll_get(SlvPath,%lfs_iNode,2,1,1,< >)
IF (lfs_flg6 AND TMT_PUSH) NE 0 AND (lfs_flg7 AND TMT_OPRT) NE 0 AND (lfs_flg8 AND TMT_POP) NE 0
; D = C <op> A <op> B ; constant integers
lfs__txt2 TEXTEQU lfs_txt2
lfs__txt3 TEXTEQU lfs_txt3
lfs__txt5 TEXTEQU lfs_txt5
IF lfs_flg2 AND TMT_NEG
lfs__txt2 TEXTEQU @CatStr(%-(lfs_txt2))
ENDIF
IF lfs_flg3 AND TMT_NEG
lfs__txt3 TEXTEQU @CatStr(%-(lfs_txt3))
ENDIF
IF lfs_flg5 AND TMT_NEG
lfs__txt5 TEXTEQU @CatStr(%-(lfs_txt5))
ENDIF
fslv_const_calc %lfs__txt3,%lfs__txt5,%lfs_txt4,%lfs_txt7,%lfs__txt2
IF fscc_done
ll_set_data SlvPath,%ll_get(SlvPath,%lfs_iNode,2,0,0,0),1,%fscc_result
ll_set_data SlvPath,%ll_get(SlvPath,%lfs_iNode,2,0,0,0),2,%(TMT_INT OR TMT_OPTMZTN)
lfs_skip = 5
EXITM
ENDIF
ELSE
IF (lfs_flg6 AND TMT_STO) NE 0 AND (lfs_flg7 AND TMT_OPRT) NE 0 AND (lfs_flg8 AND TMT_REC) NE 0 AND llfs_is_idn(<%lfs_txt6>,<%lfs_txt8>) NE 0 ;AND @InStr(1,<*/^>,%lfs_txt7) NE 0
; D = A{+-*}A{+-*}B ; constant integers
lfs__txt2 TEXTEQU lfs_txt2
lfs__txt3 TEXTEQU lfs_txt3
lfs__txt5 TEXTEQU lfs_txt5
IF lfs_flg2 AND TMT_NEG
lfs__txt2 TEXTEQU @CatStr(%-(lfs_txt2))
ENDIF
IF lfs_flg3 AND TMT_NEG
lfs__txt3 TEXTEQU @CatStr(%-(lfs_txt3))
ENDIF
IF lfs_flg5 AND TMT_NEG
lfs__txt5 TEXTEQU @CatStr(%-(lfs_txt5))
ENDIF
IF lfs_flg8 AND TMT_NEG
fslv_const_calc %lfs__txt3,%lfs__txt5,%lfs_txt4,%lfs_txt7,%lfs__txt2,<neg>
ELSE
fslv_const_calc %lfs__txt3,%lfs__txt5,%lfs_txt4,%lfs_txt7,%lfs__txt2,<>
ENDIF
IF fscc_done
lfs__iNode = ll_get(SlvPath,%lfs_iNode,2,0,0,0)
ll_set_data SlvPath,%lfs__iNode,1,%fscc_result
ll_set_data SlvPath,%lfs__iNode,2,%(TMT_INT OR TMT_OPTMZTN)
lst_set_data SubExpr,%(lfs_txt6+2),2,0
fslv_repl_all_recs SlvPath,%lfs_iNode,%lfs_txt6,%fscc_result0
lfs_skip = 5
EXITM
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
lfs_txt TEXTEQU lfs_txt2
lfs_flg = lfs_flg2
llfs_load_const
lfs_stack_cntr = lfs_stack_cntr + 1
endm
fslv_sto_rec0_oprt_rec0 macro
fssror_done = 1
fssror_op = @MatchStrI(%lfs_txt4,0,<+>,<->,<*>,</>,<^>)
IF fssror_op EQ 4 AND ((lfs_flg3 AND TMT_NEG) EQ (lfs_flg5 AND TMT_NEG))
fslv_glb_error_msg TEXTEQU <[#CG26] unnecessary division of bracket enclosed expression: will always evaluate to +1 : +-()/+-()>
fslv_glb_error = 1
ELSEIF fssror_op EQ 4 AND ((lfs_flg3 AND TMT_NEG) NE (lfs_flg5 AND TMT_NEG))
fslv_glb_error_msg TEXTEQU <[#CG27] unnecessary division of bracket enclosed expression: will always evaluate to -1 : +-()/-+()>
fslv_glb_error = 1
ELSEIF fssror_op LE 2 AND ((lfs_flg3 AND TMT_NEG) NE ((lfs_flg5 AND TMT_NEG) XOR ((fssror_op EQ 2) AND TMT_NEG)))
fslv_glb_error_msg TEXTEQU <[#CG28] unnecessary summation of bracket enclosed expression: will always evaluate to zero: +-()-+()>
fslv_glb_error = 1
ELSEIF fssror_op EQ 5 AND ((lfs_flg3 AND TMT_NEG) NE (lfs_flg5 AND TMT_NEG))
fssror_done = 0
EXITM
ELSE
fslv_sto SubExpr,<%lfs_txt2>,2,%lfs_stack_cntr
IF fssror_op LE 2
FSBE_PROC %FSBE_REG0_OPRT_REGX,<+>,0
ELSE
FSBE_PROC %FSBE_REG0_OPRT_REGX,%lfs_txt4,0
ENDIF
IF fssror_op LE 2 AND (lfs_flg3 AND TMT_NEG) NE 0
FSBE_PROC %FSBE_NEG
ENDIF
ENDIF
endm
fslv_stck_chk macro nstck:req
IF lfs_stack_cntr + nstck + lfs_nss GT FSO_N_STACK
fslv_glb_error_msg TEXTEQU <[#CG3] ERROR: register-stack overflow - reformulate expression>
fslv_glb_error = 1
EXITM
ENDIF
endm
fslv_call_fnc macro
IF lfs_flg AND (TMT_SINGLE_FLT OR TMT_SINGLE_INT OR TMT_SINGLE_ARG)
lfs_fncName SUBSTR lfs_txt,@InStr(1,<%lfs_txt>,<,>)+1
ELSE
lfs_fncName TEXTEQU lfs_txt
ENDIF
lfs_fncName TEXTEQU @TrimStr(<%lfs_fncName>)
IF FSBE_FNC(%FSBE_FNC_DSCPTR,%lfs_fncName,0,1)
??lfs_ins_test = FNCD_X32
IF @WordSize EQ 8
??lfs_ins_test = FNCD_X64
ENDIF
IF FSBE_FNC(%FSBE_FNC_DSCPTR,%lfs_fncName,%??lfs_ins_test) NE 0
IF FSBE_FNC(%FSBE_FNC_DSCPTR,%lfs_fncName,%FNCD_TST_LCL_TYPES) NE 0
lfs_fnc_nargs = FSBE_FNC(%FSBE_FNC_DSCPTR,%lfs_fncName,%FNCD_NARGS)
IF (lfs_flg AND (TMT_SINGLE_INT OR TMT_SINGLE_FLT)) NE 0 AND lfs_fnc_nargs NE 1
fslv_glb_error_msg TEXTEQU <[#CG4] function >,lfs_fncName,< require 1 argument>
fslv_glb_error = 1
ELSE
IF lfs_flg AND (TMT_SINGLE_INT OR TMT_SINGLE_FLT)
lfs_txt TEXTEQU @SubStr(<%lfs_txt>,1,%(@InStr(1,<%lfs_txt>,<,>)-1))
lfs_txt TEXTEQU @TrimStr(%lfs_txt)
IF lfs_flg AND TMT_SINGLE_INT
lfs_flg = lfs_flg OR TMT_INT
ELSE
lfs_flg = lfs_flg OR TMT_FLT
ENDIF
llfs_load_const
lfs_stack_cntr = lfs_stack_cntr + 1
fslv_stck_chk FSBE_FNC(%FSBE_FNC_DSCPTR,%lfs_fncName,%FNCD_NREGS)
IFE fslv_glb_error
FSBE_PROC %FSBE_CALL_FNC,%lfs_fncName
ENDIF
ELSEIF lfs_flg AND TMT_SINGLE_ARG
lfs_arg TEXTEQU @SubStr(<%lfs_txt>,1,%(@InStr(1,<%lfs_txt>,<,>)-1))
lfs_arg TEXTEQU @TrimStr(%lfs_arg)
fslv_stck_chk 1
IFE fslv_glb_error
FSBE_PROC %FSBE_LOAD_ARG,%lfs_arg,0
lfs_stack_cntr = lfs_stack_cntr + 1
fslv_stck_chk FSBE_FNC(%FSBE_FNC_DSCPTR,%lfs_fncName,%FNCD_NREGS)
IFE fslv_glb_error
FSBE_PROC %FSBE_CALL_FNC,%lfs_fncName
ENDIF
ENDIF
ELSE
fslv_stck_chk FSBE_FNC(%FSBE_FNC_DSCPTR,%lfs_fncName,%FNCD_NREGS)
IFE fslv_glb_error
FSBE_PROC %FSBE_CALL_FNC,%lfs_fncName
ENDIF
lfs_stack_cntr = lfs_stack_cntr - (lfs_fnc_nargs - 1)
ENDIF
IF (lfs_flg AND TMT_NEG) NE 0 AND fslv_glb_error EQ 0
FSBE_PROC %FSBE_NEG
ENDIF
ENDIF
ELSE
fslv_glb_error_msg TEXTEQU <[#CG21] function does not support current precision settings: >,lfs_fncName
fslv_glb_error = 1
ENDIF
ELSE
IF @WordSize EQ 8
fslv_glb_error_msg TEXTEQU <[#CG5] function has no x86-64 implementation: >,lfs_fncName
ELSE
fslv_glb_error_msg TEXTEQU <[#CG5] function has no x86-32 implementation: >,lfs_fncName
ENDIF
fslv_glb_error = 1
ENDIF
ELSE
fslv_glb_error_msg TEXTEQU <[#CG6] function is undefined or not supported by current back end: >,lfs_fncName
fslv_glb_error = 1
IF @Version LT 800
IFIDNI lfs_fncName,<XMM>
fslv_glb_error_msg TEXTEQU <[#CG22] XMM registers can't be used as arguments with MASM 6 and 7 - use JWASM or ML 8+>
ENDIF
ENDIF
ENDIF
endm
; return: lfs_txt = operator, lfs_flg = flags => vaild if lfs_txt not blank => TMT_ST
fslv_load_rarg macro
IF lfs_flg3 AND TMT_TXT
lfs_flg = 0
IF lfs_flg3 AND TMT_ST
;lfs_txt TEXTEQU FSBE_FNC(%FSBE_PREPARE_REG,%lfs_stack_cntr-(lfs_st_max-lfs_txt3)-1,%lfs_flg3 AND TMT_NEG)
;lfs_flg = TMT_ST
IF lfs_flg3 AND TMT_NEG
FSBE_PROC %FSBE_LOAD_REG,%lfs_stack_cntr-(lfs_st_max-lfs_txt3)-1,1
lfs_txt TEXTEQU <>
ELSE
lfs_txt TEXTEQU %lfs_stack_cntr-(lfs_st_max-lfs_txt3)-1
lfs_flg = TMT_ST
ENDIF
ELSE
lfs_txt TEXTEQU FSBE_FNC(%FSBE_PREPARE_ARG,%lfs_txt3,%lfs_flg3 AND TMT_NEG)
ENDIF
ELSEIF lfs_flg3 AND TMT_CONST
fsberor_new_const_is_int = 0
fsberor_new_params = 0
fsberor_new_op TEXTEQU lfs_txt2
fsberor_new_const TEXTEQU lfs_txt3
IF FSBE_FNC(%FSBE_REG0_OPRT_RCVAL,%lfs_txt2,%lfs_txt3,%(lfs_flg3 AND TMT_NEG))
lfs_rcval_used = 1
lfs_txt TEXTEQU <>
lfs_flg = 0
EXITM
ENDIF
IF fsberor_new_params
lfs_txt2 TEXTEQU fsberor_new_op
lfs_txt3 TEXTEQU fsberor_new_const
lfs_flg3 = lfs_flg3 AND (NOT TMT_CONST)
IF fsberor_new_const_is_int
lfs_flg3 = lfs_flg3 OR TMT_INT
ELSE
lfs_flg3 = lfs_flg3 OR TMT_FLT
ENDIF
ENDIF
lfs_txt TEXTEQU lfs_txt3
lfs_flg = lfs_flg3
lfs_txt TEXTEQU llfs_make_const()
lfs_flg = 0
ELSEIF lfs_flg3 AND TMT_REC
lfs_txt TEXTEQU fslv_rec(SubExpr,<%lfs_txt3>,%lfs_stack_cntr)
lfs_flg = TMT_ST
IF lfs_flg3 AND TMT_NEG
IFNB lfs_txt
FSBE_PROC %FSBE_LOAD_REG,%lfs_txt,1
lfs_txt TEXTEQU <>
ENDIF
ENDIF
ELSEIF lfs_flg3 AND (TMT_SINGLE_FLT OR TMT_SINGLE_INT OR TMT_SINGLE_ARG)
lfs_flg = lfs_flg3
lfs_txt TEXTEQU lfs_txt3
fslv_call_fnc
lfs_txt TEXTEQU <>
lfs_stack_cntr = lfs_stack_cntr - 1 ;; correction only
ENDIF
endm
; return: lfs_txt = operator, lfs_flg = flags = vaild if lfs_txt not blank -> TMT_ST
fslv_load_larg macro
IF lfs_flg3 AND TMT_TXT
lfs_flg = 0
IF lfs_flg3 AND TMT_ST
;lfs_txt TEXTEQU FSBE_FNC(%FSBE_PREPARE_REG,%lfs_stack_cntr-(lfs_st_max-lfs_txt3)-1,%lfs_flg3 AND TMT_NEG)
;lfs_flg = TMT_ST
IF lfs_flg3 AND TMT_NEG
FSBE_PROC %FSBE_LOAD_REG,%lfs_stack_cntr-(lfs_st_max-lfs_txt3)-1,1
lfs_txt TEXTEQU <>
ELSE
lfs_txt TEXTEQU %lfs_stack_cntr-(lfs_st_max-lfs_txt3)-1
lfs_flg = TMT_ST
ENDIF
ELSE
lfs_txt TEXTEQU FSBE_FNC(%FSBE_PREPARE_ARG,%lfs_txt3,%lfs_flg3 AND TMT_NEG)
ENDIF
ELSEIF lfs_flg3 AND TMT_CONST
lfs_txt TEXTEQU lfs_txt3
lfs_flg = lfs_flg3
lfs_txt TEXTEQU llfs_make_const()
lfs_flg = 0
ELSEIF lfs_flg3 AND TMT_REC
lfs_txt TEXTEQU fslv_rec(SubExpr,<%lfs_txt3>,%lfs_stack_cntr)
lfs_flg = TMT_ST
IF lfs_flg3 AND TMT_NEG
IFNB lfs_txt
FSBE_PROC %FSBE_LOAD_REG,%lfs_txt,1
lfs_txt TEXTEQU <>
ENDIF
ENDIF
ELSEIF lfs_flg3 AND (TMT_SINGLE_FLT OR TMT_SINGLE_INT OR TMT_SINGLE_ARG)
lfs_flg = lfs_flg3
lfs_txt TEXTEQU lfs_txt3
fslv_call_fnc
lfs_txt TEXTEQU <>
lfs_stack_cntr = lfs_stack_cntr - 1 ;; correction only
ENDIF
endm
fslv_sto macro SubExpr,refValue:req,RecCnt:req,nStack
fss_nUse = lst_get_data(SubExpr,%(refValue+2),2)
IF fss_nUse GT RecCnt AND RecCnt NE 0
IF lfs_nss+nStack+1 LT FSO_N_STACK
lfs_nss = lfs_nss + 1
fss_index=iml_request_index(StkSlot)
lst_set_data SubExpr,%(refValue+2),2,%(fss_nUse-RecCnt)
lst_set_data SubExpr,%(refValue+2),3,%fss_index
lst_set_data SubExpr,%(refValue+2),4,<1> ; type = stack
FSBE_PROC %FSBE_SET_REG,%(nStack+fss_index),0
ELSE
fslv_glb_error_msg TEXTEQU <[#CG7] register-stack overflow>
fslv_glb_error = 1
ENDIF
ELSEIF RecCnt EQ fss_nUse
; hold
lst_set_data SubExpr,%(refValue+2),2,0
ELSEIF RecCnt EQ 0
IF lfs_nss+nStack+1 LT FSO_N_STACK
lfs_nss = lfs_nss + 1
fss_index=iml_request_index(StkSlot)
lst_set_data SubExpr,%(refValue+2),3,%fss_index
lst_set_data SubExpr,%(refValue+2),4,<1> ; type = stack
;IF nStack+fss_index NE 1
FSBE_PROC %FSBE_SET_REG,%(nStack+fss_index),1