forked from qwordAtGitHub/SmplMath
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSmplMath.inc
1989 lines (1837 loc) · 46.8 KB
/
SmplMath.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 *
; * *
; * Modified by HSE, 2020-2021 *
; * *
; * SmplMath.Masm{at}gmx{dot}net *
; * http://sourceforge.net/projects/smplmath/ *
; * *
; * https://github.com/ASMHSE/SmplMath *
; * *
; * Further Copyright and Legal statements are located *
; * in the documentation (Documentation.pdf). *
; * *
; ********************************************************
IFNDEF BOOLEAN_BYTE
BOOLEAN_BYTE typedef BYTE
ENDIF
fslv_glb_error = 0
fslv_glb_error_msg TEXTEQU <>
fslv_glbl_int_type = 4 ; 2=SWORD,4=SDWORD,8=SQWORD
fslv_glbl_real_type = 8 ; 4=REAL4,8=REAL8,10=REAL10
fslv_lcl_real_type = fslv_glbl_real_type ;-fSlv,fSolve
fslv_lcl_int_type = fslv_glbl_int_type ;/
fslv4_def_int_type = 4 ;-fSlv4
fslv4_def_real_type = 4 ;/
fslv8_def_int_type = 4 ;-fSlv8
fslv8_def_real_type = 8 ;/
fslv10_def_int_type = 4 ;-fSlv10
fslv10_def_real_type = 10 ;/
@fslv4_def_int_type = 4 ;-@fSlv4()
@fslv4_def_real_type = 4 ;/
@fslv8_def_int_type = 4 ;-@fSlv8()
@fslv8_def_real_type = 8 ;/
@fslvI_def_int_type = 4 ;-@fSlvI()
@fslvI_def_real_type = 8 ;/
@fslvI64_def_int_type = 4 ;-@fSlvI64()
@fslvI64_def_real_type = 8 ;/
fsTSA_glbl_int_type = 4
fsTSA_glbl_real_type = 4
fcmp_def_int_type = fslv_glbl_int_type
fcmp_def_real_type = fslv_glbl_real_type
fSolve macro expr:VARARG
IFB FSBE_ENTITY
EXITM
ELSEIF fslv_glb_error
EXITM
ENDIF
fslv_nc=fslv_nc+1
fslvm_pos INSTR 1,<&expr>,<=>
fslvm_size SIZESTR <&expr>
IFE fslvm_pos
.err <missing '='>
EXITM
ELSEIF fslvm_size LE 1
.err <invalid argument>
EXITM
ELSEIF fslvm_pos EQ 1
fslvm_dest TEXTEQU <>
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,2
ELSE
fslvm_dest SUBSTR <&expr>,1,fslvm_pos-1
fslvm_dest TEXTEQU @TrimStr(%fslvm_dest)
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,fslvm_pos+1
ENDIF
IFNB fslvm_dest
IFIDNI @TrimStr(<%fslvm_expr>),<st0>
fst fslvm_dest
EXITM
ENDIF
ELSE
IF FSBE_FNC(%FSBE_ENTITY,%FSEN_REQ_RETVAL)
.err <destination operand required>
ENDIF
ENDIF
fslv_extract_attributes %fslvm_expr
IF fsea_found NE 0
fslvm_expr TEXTEQU fsea_expr
fslv_current_attributes TEXTEQU fsea_attributes
fslv_attributes? = 1
fslv_local_type_from_attributes fslv_glbl_real_type,fslv_glbl_int_type,%fsea_attributes
ELSE
fslv_attributes? = 0
fslv_lcl_real_type = fslv_glbl_real_type
fslv_lcl_int_type = fslv_glbl_int_type
ENDIF
ll_MathTokenize SlvPath,SubExpr,%fslvm_expr
;ll_DebugOut SlvPath,2,8,1,width=15,<<ralign=1,tmt=1,width=30>>
IF tmt_error
fslv_glb_error = 1
fslv_glb_error_msg CATSTR <PARSER: >,tmt_err_txt
.err fslv_glb_error_msg
EXITM
ENDIF
ll_fSlv SlvPath,SubExpr
IF fslv_glb_error
.err fslv_glb_error_msg
EXITM
ENDIF
endm
fSlv EQU fSolve
fSlv4 macro expr:VARARG
IFB FSBE_ENTITY
EXITM
ELSEIF fslv_glb_error
EXITM
ENDIF
fslv4_nc=fslv4_nc+1
fslvm_pos INSTR 1,<&expr>,<=>
fslvm_size SIZESTR <&expr>
IFE fslvm_pos
.err <missing '='>
EXITM
ELSEIF fslvm_size LE 1
.err <invalid argument>
EXITM
ELSEIF fslvm_pos EQ 1
fslvm_dest TEXTEQU <>
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,2
ELSE
fslvm_dest SUBSTR <&expr>,1,fslvm_pos-1
fslvm_dest TEXTEQU @TrimStr(%fslvm_dest)
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,fslvm_pos+1
ENDIF
IFNB fslvm_dest
IFIDNI @TrimStr(%fslvm_expr),<st0>
fst fslvm_dest
EXITM
ENDIF
ELSE
IF FSBE_FNC(%FSBE_ENTITY,%FSEN_REQ_RETVAL)
.err <destination operand required>
ENDIF
ENDIF
fslv_extract_attributes %fslvm_expr
IF fsea_found NE 0
fslvm_expr TEXTEQU fsea_expr
fslv_current_attributes TEXTEQU fsea_attributes
fslv_attributes? = 1
fslv_local_type_from_attributes fslv4_def_real_type,fslv4_def_int_type,%fsea_attributes
ELSE
fslv_attributes? = 0
fslv_lcl_real_type = fslv4_def_real_type
fslv_lcl_int_type = fslv4_def_int_type
ENDIF
ll_MathTokenize SlvPath,SubExpr,%fslvm_expr
IF tmt_error
fslv_glb_error = 1
fslv_glb_error_msg CATSTR <PARSER: >,tmt_err_txt
.err fslv_glb_error_msg
EXITM
ENDIF
ll_fSlv SlvPath,SubExpr
IF fslv_glb_error
.err fslv_glb_error_msg
EXITM
ENDIF
endm
fSlv8 macro expr:VARARG
IFB FSBE_ENTITY
EXITM
ELSEIF fslv_glb_error
EXITM
ENDIF
fslv8_nc=fslv8_nc+1
fslvm_pos INSTR 1,<&expr>,<=>
fslvm_size SIZESTR <&expr>
IFE fslvm_pos
.err <missing '='>
EXITM
ELSEIF fslvm_size LE 1
.err <invalid argument>
EXITM
ELSEIF fslvm_pos EQ 1
fslvm_dest TEXTEQU <>
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,2
ELSE
fslvm_dest SUBSTR <&expr>,1,fslvm_pos-1
fslvm_dest TEXTEQU @TrimStr(%fslvm_dest)
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,fslvm_pos+1
ENDIF
IFNB fslvm_dest
IFIDNI @TrimStr(%fslvm_expr),<st0>
fst fslvm_dest
EXITM
ENDIF
ELSE
IF FSBE_FNC(%FSBE_ENTITY,%FSEN_REQ_RETVAL)
.err <destination operand required>
ENDIF
ENDIF
fslv_extract_attributes %fslvm_expr
IF fsea_found NE 0
fslvm_expr TEXTEQU fsea_expr
fslv_current_attributes TEXTEQU fsea_attributes
fslv_attributes? = 1
fslv_local_type_from_attributes fslv8_def_real_type,fslv8_def_int_type,%fsea_attributes
ELSE
fslv_attributes? = 0
fslv_lcl_real_type = fslv8_def_real_type
fslv_lcl_int_type = fslv8_def_int_type
ENDIF
ll_MathTokenize SlvPath,SubExpr,%fslvm_expr
IF tmt_error
fslv_glb_error = 1
fslv_glb_error_msg CATSTR <PARSER: >,tmt_err_txt
.err fslv_glb_error_msg
EXITM
ENDIF
ll_fSlv SlvPath,SubExpr
IF fslv_glb_error
.err fslv_glb_error_msg
EXITM
ENDIF
endm
fSlv10 macro expr:VARARG
IFB FSBE_ENTITY
EXITM
ELSEIF fslv_glb_error
EXITM
ENDIF
fslv10_nc=fslv10_nc+1
fslvm_pos INSTR 1,<&expr>,<=>
fslvm_size SIZESTR <&expr>
IFE fslvm_pos
.err <missing '='>
EXITM
ELSEIF fslvm_size LE 1
.err <invalid argument>
EXITM
ELSEIF fslvm_pos EQ 1
fslvm_dest TEXTEQU <>
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,2
ELSE
fslvm_dest SUBSTR <&expr>,1,fslvm_pos-1
fslvm_dest TEXTEQU @TrimStr(%fslvm_dest)
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,fslvm_pos+1
ENDIF
IFNB fslvm_dest
IFIDNI @TrimStr(%fslvm_expr),<st0>
fst fslvm_dest
EXITM
ENDIF
ELSE
IF FSBE_FNC(%FSBE_ENTITY,%FSEN_REQ_RETVAL)
.err <destination operand required>
ENDIF
ENDIF
fslv_extract_attributes %fslvm_expr
IF fsea_found NE 0
fslvm_expr TEXTEQU fsea_expr
fslv_current_attributes TEXTEQU fsea_attributes
fslv_attributes? = 1
fslv_local_type_from_attributes fslv10_def_real_type,fslv10_def_int_type,%fsea_attributes
ELSE
fslv_attributes? = 0
fslv_lcl_real_type = fslv10_def_real_type
fslv_lcl_int_type = fslv10_def_int_type
ENDIF
ll_MathTokenize SlvPath,SubExpr,%fslvm_expr
IF tmt_error
fslv_glb_error = 1
fslv_glb_error_msg CATSTR <PARSER: >,tmt_err_txt
.err fslv_glb_error_msg
EXITM
ENDIF
ll_fSlv SlvPath,SubExpr
IF fslv_glb_error
.err fslv_glb_error_msg
EXITM
ENDIF
endm
@fSlv4 macro expr:VARARG
LOCAL r4lbl
IFB FSBE_ENTITY
EXITM fslv_retval@error(REAL4)
ELSEIF fslv_glb_error
EXITM fslv_retval@error(REAL4)
ENDIF
@fslv4_nc=@fslv4_nc+1
fslvm_pos INSTR 1,<&expr>,<=>
fslvm_size SIZESTR <&expr>
IF fslvm_pos EQ 0
fslvm_dest TEXTEQU <>
fslvm_expr TEXTEQU <&expr>
ELSE
fslvm_dest SUBSTR <&expr>,1,fslvm_pos-1
fslvm_dest TEXTEQU @TrimStr(%fslvm_dest)
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,fslvm_pos+1
IFB fslvm_dest
.err <missing lvalue: '='>
EXITM <0>
ENDIF
ENDIF
fslv_extract_attributes %fslvm_expr
IF fsea_found NE 0
fslvm_expr TEXTEQU fsea_expr
fslv_current_attributes TEXTEQU fsea_attributes
fslv_attributes? = 1
fslv_local_type_from_attributes @fslv4_def_real_type,@fslv4_def_int_type,%fsea_attributes
ELSE
fslv_attributes? = 0
fslv_lcl_real_type = @fslv4_def_real_type
fslv_lcl_int_type = @fslv4_def_int_type
ENDIF
ll_MathTokenize SlvPath,SubExpr,%fslvm_expr
IF tmt_error
fslv_glb_error = 1
fslv_glb_error_msg CATSTR <PARSER: >,tmt_err_txt
.err fslv_glb_error_msg
EXITM fslv_retval@error(REAL4)
ENDIF
FSBE_PREPARE_ALLOC r4lbl,REAL4,4
ll_fSlv SlvPath,SubExpr,1,0,4
IF fslv_glb_error
.err fslv_glb_error_msg
EXITM fslv_retval@error(REAL4)
ENDIF
EXITM lfs_retval
endm
@fSlv8 macro expr:VARARG
LOCAL r8lbl
IFB FSBE_ENTITY
EXITM fslv_retval@error(REAL8)
ELSEIF fslv_glb_error
EXITM fslv_retval@error(REAL8)
ENDIF
@fslv8_nc=@fslv8_nc+1
fslvm_pos INSTR 1,<&expr>,<=>
fslvm_size SIZESTR <&expr>
IF fslvm_pos EQ 0
fslvm_dest TEXTEQU <>
fslvm_expr TEXTEQU <&expr>
ELSE
fslvm_dest SUBSTR <&expr>,1,fslvm_pos-1
fslvm_dest TEXTEQU @TrimStr(%fslvm_dest)
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,fslvm_pos+1
IFB fslvm_dest
.err <missing lvalue: '='>
EXITM <0>
ENDIF
ENDIF
fslv_extract_attributes %fslvm_expr
IF fsea_found NE 0
fslvm_expr TEXTEQU fsea_expr
fslv_current_attributes TEXTEQU fsea_attributes
fslv_attributes? = 1
fslv_local_type_from_attributes @fslv8_def_real_type,@fslv8_def_int_type,%fsea_attributes
ELSE
fslv_attributes? = 0
fslv_lcl_real_type = @fslv8_def_real_type
fslv_lcl_int_type = @fslv8_def_int_type
ENDIF
ll_MathTokenize SlvPath,SubExpr,%fslvm_expr
IF tmt_error
fslv_glb_error = 1
fslv_glb_error_msg CATSTR <PARSER: >,tmt_err_txt
.err fslv_glb_error_msg
EXITM fslv_retval@error(REAL8)
ENDIF
FSBE_PREPARE_ALLOC r8lbl,REAL8,8
ll_fSlv SlvPath,SubExpr,1,0,8
IF fslv_glb_error
.err fslv_glb_error_msg
EXITM fslv_retval@error(REAL8)
ENDIF
EXITM lfs_retval
endm
@fSlvI macro expr:VARARG
LOCAL dwlbl
IFB FSBE_ENTITY
EXITM fslv_retval@error(SDWORD)
ELSEIF fslv_glb_error
EXITM fslv_retval@error(SDWORD)
ENDIF
@fslvI_nc=@fslvI_nc+1
fslvm_pos INSTR 1,<&expr>,<=>
fslvm_size SIZESTR <&expr>
IF fslvm_pos EQ 0
fslvm_dest TEXTEQU <>
fslvm_expr TEXTEQU <&expr>
ELSE
fslvm_dest SUBSTR <&expr>,1,fslvm_pos-1
fslvm_dest TEXTEQU @TrimStr(%fslvm_dest)
fslvm_expr TEXTEQU <&expr>
;fslvm_expr SUBSTR <&expr>,fslvm_pos+1
IFB fslvm_dest
.err <missing lvalue: '='>
EXITM <0>
ENDIF
ENDIF
fslv_extract_attributes %fslvm_expr
IF fsea_found NE 0
fslvm_expr TEXTEQU fsea_expr
fslv_current_attributes TEXTEQU fsea_attributes
fslv_attributes? = 1
fslv_local_type_from_attributes @fslvI_def_real_type,@fslvI_def_int_type,%fsea_attributes
ELSE
fslv_attributes? = 0
fslv_lcl_real_type = @fslvI_def_real_type
fslv_lcl_int_type = @fslvI_def_int_type
ENDIF
ll_MathTokenize SlvPath,SubExpr,%fslvm_expr
IF tmt_error
fslv_glb_error = 1
fslv_glb_error_msg CATSTR <PARSER: >,tmt_err_txt
.err fslv_glb_error_msg
EXITM fslv_retval@error(SDWORD)
ENDIF
FSBE_PREPARE_ALLOC dwlbl,SDWORD,4
ll_fSlv SlvPath,SubExpr,1,4,0
IF fslv_glb_error
.err fslv_glb_error_msg
EXITM fslv_retval@error(SDWORD)
ENDIF
EXITM lfs_retval
endm
IF @WordSize EQ 8
@fSlvI64 macro expr:VARARG
LOCAL dqlbl
IFB FSBE_ENTITY
EXITM fslv_retval@error(SQWORD)
ELSEIF fslv_glb_error
EXITM fslv_retval@error(SQWORD)
ENDIF
@fslvI64_nc=@fslvI64_nc+1
fslvm_pos INSTR 1,<&expr>,<=>
fslvm_size SIZESTR <&expr>
IF fslvm_pos EQ 0
fslvm_dest TEXTEQU <>
fslvm_expr TEXTEQU <&expr>
ELSE
fslvm_dest SUBSTR <&expr>,1,fslvm_pos-1
fslvm_dest TEXTEQU @TrimStr(%fslvm_dest)
fslvm_expr TEXTEQU <&expr>
IFB fslvm_dest
.err <missing lvalue: '='>
EXITM <0>
ENDIF
ENDIF
fslv_extract_attributes %fslvm_expr
IF fsea_found NE 0
fslvm_expr TEXTEQU fsea_expr
fslv_current_attributes TEXTEQU fsea_attributes
fslv_attributes? = 1
fslv_local_type_from_attributes @fslvI64_def_real_type,@fslvI64_def_int_type,%fsea_attributes
ELSE
fslv_attributes? = 0
fslv_lcl_real_type = @fslvI64_def_real_type
fslv_lcl_int_type = @fslvI64_def_int_type
ENDIF
ll_MathTokenize SlvPath,SubExpr,%fslvm_expr
IF tmt_error
fslv_glb_error = 1
fslv_glb_error_msg CATSTR <PARSER: >,tmt_err_txt
.err fslv_glb_error_msg
EXITM fslv_retval@error(SQWORD)
ENDIF
FSBE_PREPARE_ALLOC dqlbl,SQWORD,8
ll_fSlv SlvPath,SubExpr,1,8,0
IF fslv_glb_error
.err fslv_glb_error_msg
EXITM fslv_retval@error(SQWORD)
ENDIF
EXITM lfs_retval
endm
ENDIF
@fSlvI_T macro expr:VARARG
IF @WordSize EQ 8
EXITM @fSlvI64(expr)
ELSE
EXITM @fSlvI(expr)
ENDIF
endm
@fSlvI_t EQU @fSlvI_T
fSlvTLS macro name:=<fslv_tls>,cb:=<4*@WordSize>
IFB FSBE_ENTITY
EXITM <&name&[1]:BYTE>
ELSEIF fslv_glb_error
EXITM <&name&[1]:BYTE>
ENDIF
% IFDEF fslv_tls_name
.err <TLS duplication>
ELSE
fslv_tls_curr_used = 0 ; 04/10/2020 HSE
fslv_tls_alloc_line = @Line
fslv_tls_cb = FSBE_FNC(%FSBE_ENTITY,%FSEN_TLS_SIZE)
IF fslv_tls_cb NE 0 AND fslv_tls_cb GT cb
fslv_tls_cb = (fslv_tls_cb+15) AND (-16)
ELSE
fslv_tls_cb = (cb+15) AND (-16)
ENDIF
fslv_tls_name TEXTEQU @TrimStr(<&name>)
EXITM @CatStr(<&name&[fslv_tls_cb]:BYTE>)
ENDIF
endm
; instruction sets
FSIS_FPU EQU 1 ; function descriptor: requires FNCD_ISTCK
FSIS_SSE2 EQU 2 ; function descriptor: requires FNCD_IREG
FSIS_SSE3 EQU 4 ; " " " "
FSIS_SSSE3 EQU 8 ; ...
FSIS_SSE4 EQU 16
FSIS_SSE41 EQU (32 OR FSIS_SSE4)
FSIS_SSE42 EQU (64 OR FSIS_SSE4)
FSIS_SSE4A EQU (128 OR FSIS_SSE4)
FSIS_AVX EQU 256
FSIS_CVT16 EQU 512
FSIS_XOP EQU 1024
FSIS_FMA3 EQU 2048
FSIS_FMA4 EQU 4096
fslv_nc = 0
fslv4_nc = 0
fslv8_nc = 0
fslv10_nc = 0
@fslv4_nc = 0
@fslv8_nc = 0
@fslvI_nc = 0
@fslvI64_nc = 0
@fEQ_nc = 0
@fNE_nc = 0
@faEQ_nc = 0
@fLT_nc = 0
@fLE_nc = 0
@fGT_nc = 0
@fGE_nc = 0
@fTest_nc = 0
FSLV_SUPPRESS_ALL_WARNINGS = 0
FSLV_SUPPRESS_TS_WARNIGNS = 0
FSLV_NO_FORMULA_OPTIMIZATION = 0
fslv_glb_flags = 0
fslv_glb_instrset = 0
fslv_current_attributes TEXTEQU <>
fslv_attributes? = 0
IF @WordSize EQ 4
fslv_volatile_xmm_regs TEXTEQU <xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7>
ELSE
fslv_volatile_xmm_regs TEXTEQU <xmm0,xmm1,xmm2,xmm3,xmm4,xmm5>
ENDIF
fslv_volatile_xmmregs_nesting = 0
fslv_regc_txt TEXTEQU <>
fslv_regc_val TEXTEQU <>
fslvTLS_curr_line = -1
fslv_tls_curr_used = 0
fslv_tls_name TEXTEQU <>
fslv_tls_cb = 0
fslv_tls_last TEXTEQU <>
fslv_tls_last_size = 0
fslv_tls_byte = 0
fslv_tls_alloc_line = 0
fSlvVolatileXmmRegs macro operation:=<add>,regs:VARARG
IF @WordSize EQ 4
fsvxr_regs TEXTEQU <xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7>
ELSE
fsvxr_regs TEXTEQU <xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7,xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15>
ENDIF
IFIDNI <&operation>,<add>
IF @GetArgCount(regs) LE @WordSize*2
FOR arg1,<regs>
IF @MatchStrI(<&arg1>,0,%fsvxr_regs)
IFE @MatchStrI(<&arg1>,0,%fslv_volatile_xmm_regs)
IFB fslv_volatile_xmm_regs
fslv_volatile_xmm_regs TEXTEQU <&arg1>
ELSE
fslv_volatile_xmm_regs TEXTEQU fslv_volatile_xmm_regs,<,>,<&arg1>
ENDIF
ENDIF
ELSE
.err <invalid register: arg1>
EXITM
ENDIF
ENDM
ELSE
.err <to many registers>
ENDIF
ELSEIFIDNI <&operation>,<remove>
IF @GetArgCount(regs) LE @WordSize*2
FOR arg1,<regs>
IF @MatchStrI(<&arg1>,0,%fsvxr_regs)
ml71_wa_txt TEXTEQU <&arg1>
fslv_volatile_xmm_regs TEXTEQU @RemoveArgI(%ml71_wa_txt,%fslv_volatile_xmm_regs) ; ML7.1: %arg1 -> XMMn -> XMM(n)
ELSE
.err <invalid register: arg1>
EXITM
ENDIF
ENDM
ELSE
.err <to many registers to remove>
ENDIF
IFE @GetArgCount(%fslv_volatile_xmm_regs)
.err <no volatile XMM registers left>
fslv_volatile_xmm_regs TEXTEQU fsvxr_regs
ENDIF
ELSEIFIDNI <&operation>,<set>
IFB <regs>
.err <missing arguments>
ELSE
IF @GetArgCount(regs) LE @WordSize*2
fslv_volatile_xmm_regs TEXTEQU <>
FOR arg1,<regs>
IF @MatchStrI(<&arg1>,0,%fsvxr_regs)
IFE @MatchStrI(<&arg1>,0,%fslv_volatile_xmm_regs)
IFB fslv_volatile_xmm_regs
fslv_volatile_xmm_regs TEXTEQU <&arg1>
ELSE
fslv_volatile_xmm_regs TEXTEQU fslv_volatile_xmm_regs,<,>,<&arg1>
ENDIF
ELSE
.err <register duplicated: arg1>
EXITM
ENDIF
ELSE
.err <invalid register: arg1>
EXITM
ENDIF
ENDM
EXITM
ELSE
.err <to many registers>
ENDIF
IF @WordSize EQ 4
fslv_volatile_xmm_regs TEXTEQU <xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7>
ELSE
fslv_volatile_xmm_regs TEXTEQU <xmm0,xmm1,xmm2,xmm3,xmm4,xmm5>
ENDIF
ENDIF
ELSEIFIDNI <&operation>,<default>
IFNB <regs>
.err <invalid usage: no additinal arguments are allowed>
ENDIF
IF @WordSize EQ 4
fslv_volatile_xmm_regs TEXTEQU <xmm0,xmm1,xmm2,xmm3,xmm4,xmm5,xmm6,xmm7>
ELSE
fslv_volatile_xmm_regs TEXTEQU <xmm0,xmm1,xmm2,xmm3,xmm4,xmm5>
ENDIF
ELSEIFIDNI <&operation>,<push>
fslv_volatile_xmmregs_nesting = fslv_volatile_xmmregs_nesting + 1
@CatStr(<fslv_volatile_xmmregs_stck_>,%fslv_volatile_xmmregs_nesting) TEXTEQU fslv_volatile_xmm_regs
ELSEIFIDNI <&operation>,<pop>
fslv_volatile_xmm_regs TEXTEQU @CatStr(<fslv_volatile_xmmregs_stck_>,%fslv_volatile_xmmregs_nesting)
fslv_volatile_xmmregs_nesting = fslv_volatile_xmmregs_nesting - 1
ELSE
.err <invalid macro usage: &operation>
ENDIF
endm
@IsVolatileXmmReg macro regName:req
qivxmr_match = 0
% FOR arg0,<fslv_volatile_xmm_regs>
IFIDNI <&arg0>,<®Name>
qivxmr_match = -1
EXITM
ENDIF
ENDM
EXITM %qivxmr_match
endm
fslv_volatile_gp_regs TEXTEQU <>
fslv_volatile_gprs = 0
fslv_volatile_regs_nesting = 0
FSVGPR_EAX EQU 1
FSVGPR_EBX EQU 2
FSVGPR_ECX EQU 4
FSVGPR_EDX EQU 8
FSVGPR_EDI EQU 16
FSVGPR_ESI EQU 32
FSVGPR_EBP EQU 64
FSVGPR_ESP EQU 128
FSVGPR_R8D EQU 256
FSVGPR_R9D EQU 512
FSVGPR_R10D EQU 1024
FSVGPR_R11D EQU 800h
FSVGPR_R12D EQU 1000h
FSVGPR_R13D EQU 2000h
FSVGPR_R14D EQU 4000h
FSVGPR_R15D EQU 8000h
fSlvVolatileGPReg macro operation:=<add>,regs:VARARG
IFIDNI <&operation>,<add>
IF @GetArgCount(regs) LE @WordSize*2
FOR arg1,<regs>
IF @IsGPReg(<&arg1>)
fsvgpr_basereg TEXTEQU @GetBaseGPR()
IFE @MatchStrI(%fsvgpr_basereg,0,%fslv_volatile_gp_regs)
IFB fslv_volatile_gp_regs
fslv_volatile_gp_regs TEXTEQU fsvgpr_basereg
ELSE
fslv_volatile_gp_regs TEXTEQU fslv_volatile_gp_regs,<,>,fsvgpr_basereg
ENDIF
ENDIF
ELSE
.err <invalid register: arg1>
EXITM
ENDIF
ENDM
ELSE
.err <to many registers>
EXITM
ENDIF
ELSEIFIDNI <&operation>,<remove>
IF @GetArgCount(regs) LE @WordSize*2
FOR arg1,<regs>
IF @IsGPReg(<&arg1>)
fslv_volatile_gp_regs TEXTEQU @RemoveArgI(@GetBaseGPR(),%fslv_volatile_gp_regs)
ELSE
.err <invalid register: arg1>
EXITM
ENDIF
ENDM
ELSE
.err <to many registers to remove>
EXITM
ENDIF
ELSEIFIDNI <&operation>,<set>
IFB <regs>
.err <missing arguments>
ELSE
IF @GetArgCount(regs) LE @WordSize*2
fslv_volatile_gp_regs TEXTEQU <>
FOR arg1,<regs>
IF @IsGPReg(<&arg1>)
fsvgpr_basereg TEXTEQU @GetBaseGPR()
IFE @MatchStrI(<&arg1>,0,%fslv_volatile_gp_regs)
IFB fslv_volatile_gp_regs
fslv_volatile_gp_regs TEXTEQU fsvgpr_basereg
ELSE
fslv_volatile_gp_regs TEXTEQU fslv_volatile_gp_regs,<,>,fsvgpr_basereg
ENDIF
ELSE
.err <register duplicated: arg1>
EXITM
ENDIF
ELSE
.err <invalid register: arg1>
EXITM
ENDIF
ENDM
ELSE
.err <to many registers>
ENDIF
fslv_volatile_gp_regs TEXTEQU <>
ENDIF
ELSEIFIDNI <&operation>,<default>
IFNB <regs>
.err <invalid usage: no additinal arguments are allowed>
ENDIF
fslv_volatile_gp_regs TEXTEQU <>
ELSEIFIDNI <&operation>,<push>
fslv_volatile_regs_nesting = fslv_volatile_regs_nesting + 1
@CatStr(<fslv_volatile_regs_stck_>,%fslv_volatile_regs_nesting) TEXTEQU fslv_volatile_gp_regs
ELSEIFIDNI <&operation>,<pop>
fslv_volatile_gp_regs TEXTEQU @CatStr(<fslv_volatile_regs_stck_>,%fslv_volatile_regs_nesting)
fslv_volatile_regs_nesting = fslv_volatile_regs_nesting - 1
ELSE
.err <invalid macro usage: &operation>
EXITM
ENDIF
fslv_volatile_gprs = 0
% FOR arg0,<fslv_volatile_gp_regs>
fslv_volatile_gprs = fslv_volatile_gprs OR @CatStr(<FSVGPR_>,@ToUpperCase(<&arg0>))
ENDM
endm
@IsVolatileGPR macro regName:req
qivgpr_match = 0
% FOR arg0,<fslv_volatile_gp_regs>
IFIDNI <&arg0>,<®Name>
qivgpr_match = -1
EXITM
ENDIF
ENDM
EXITM %qivgpr_match
endm
; macroName: name of fSlv-macros, enclosed by brackets
; e.g.: fSlvSetDefaultPrecision <@fSlv4>,REAL10,SQWORD
fSlvSetPrecision macro macroName:req,realPrec,intPrec
fssdp_int = 0
fssdp_real = 0
IFIDNI <&realPrec>,<REAL4>
fssdp_real = 4
ELSEIFIDNI <&realPrec>,<REAL8>
fssdp_real = 8
ELSEIFIDNI <&realPrec>,<REAL10>
fssdp_real = 10
ELSEIFNB <&realPrec>
.err <invalid precision specifier: &realPrec>
EXITM
ENDIF
IFIDNI <&intPrec>,<SWORD>
fssdp_int = 2
ELSEIFIDNI <&intPrec>,<SDWORD>
fssdp_int = 4
ELSEIFIDNI <&intPrec>,<QWORD>
fssdp_int = 8
ELSEIFIDNI <&intPrec>,<SQWORD>
fssdp_int = 8
ELSEIFNB <&intPrec>
.err <invalid precision specifier: &intPrec>
EXITM
ENDIF
fssdp_cmp=0
IFIDN <¯oName>,<fSlv>
IFNB <&realPrec>
fslv_glbl_real_type = fssdp_real
ENDIF
IFNB <&intPrec>
fslv_glbl_int_type = fssdp_int
ENDIF
ELSEIFIDN <¯oName>,<fSlv4>
IFNB <&realPrec>
fslv4_def_real_type = fssdp_real
ENDIF
IFNB <&intPrec>
fslv4_def_int_type = fssdp_int
ENDIF
ELSEIFIDN <¯oName>,<fSlv8>
IFNB <&realPrec>
fslv8_def_real_type = fssdp_real
ENDIF
IFNB <&intPrec>
fslv8_def_int_type = fssdp_int
ENDIF
ELSEIFIDN <¯oName>,<fSlv10>
IFNB <&realPrec>
fslv10_def_real_type = fssdp_real
ENDIF
IFNB <&intPrec>
fslv10_def_int_type = fssdp_int
ENDIF
ELSEIFIDN <¯oName>,<@fSlv4>
IFNB <&realPrec>
@fslv4_def_real_type = fssdp_real
ENDIF
IFNB <&intPrec>
@fslv4_def_int_type = fssdp_int
ENDIF
ELSEIFIDN <¯oName>,<@fSlv8>
IFNB <&realPrec>
@fslv8_def_real_type = fssdp_real
ENDIF
IFNB <&intPrec>
@fslv8_def_int_type = fssdp_int
ENDIF
ELSEIFIDN <¯oName>,<@fSlvI>
IFNB <&realPrec>
@fslvI_def_real_type = fssdp_real
ENDIF
IFNB <&intPrec>
@fslvI_def_int_type = fssdp_int
ENDIF
ELSEIFIDN <¯oName>,<fEQ>
fssdp_cmp=1
ELSEIFIDN <¯oName>,<fNE>
fssdp_cmp=1
ELSEIFIDN <¯oName>,<fGT>
fssdp_cmp=1
ELSEIFIDN <¯oName>,<fGE>
fssdp_cmp=1
ELSEIFIDN <¯oName>,<fLT>
fssdp_cmp=1
ELSEIFIDN <¯oName>,<fLE>
fssdp_cmp=1
ELSEIFIDN <¯oName>,<faEQ>
fssdp_cmp=1
ELSE
.err <unknown macro name: macroName>
EXITM
ENDIF
IF fssdp_cmp
IFNB <&realPrec>
fcmp_def_real_type = fssdp_real
ENDIF
IFNB <&intPrec>
fcmp_def_int_type = fssdp_int
ENDIF
ENDIF
endm
fSlvLoadBackEnd macro name:req
abb_cntr = 0
abb_txt TEXTEQU <>
abb_flg = 0
WHILE abb_cntr LT FSBE_N_BACKENDS
abb_backend_entity CATSTR <FSO_BACKEND_ENTITY_>,%abb_cntr
IF FSBE_FNC(%abb_backend_entity,%FSEN_NAME) NE 0
IFDEF fsbe_txt
IFIDNI fsbe_txt,<&name>
%_discard_ FSBE_FNC(%abb_backend_entity,%FSEN_MAPPING)
fslv_glb_flags = fslv_glb_flags AND (NOT FSF_INSTRSET_MSK)
IF fslv_glb_instrset AND FSIS_FPU
fslv_glb_flags = fslv_glb_flags or FSF_USE_FPU
ENDIF
IF fslv_glb_instrset AND FSIS_SSE2
fslv_glb_flags = fslv_glb_flags or FSF_USE_SSE2
ENDIF
abb_flg = 1
EXITM
ENDIF
ELSE
% .err <faulty back end detected (Entity: abb_backend_entity)>
ENDIF
ENDIF
abb_cntr = abb_cntr + 1
ENDM
IF abb_flg EQ 0
.err <no matching back end found for: name>
ENDIF
endm
FSF_USE_FPU EQU 1 ; use the FPU. This flag has a lower priority than FSF_USE_SSE2
FSF_USE_SSE2 EQU 2 ; use SSE2 if possible. The FPU is also used, if necessary. (this is the default for x64)
FSF_REUSE_BY_TYPE EQU 4 ; reuse contants only, if the types are equal - this flag applies only to integer contants
FSF_CHECK_SQWORD EQU 8 ; check QWORD-constants for range (only decimal)
FSF_NO_INT_CONSTS EQU 16 ; do not create integer constants -> convert them to REAL4/8/10 constants
FSF_INSTRSET_MSK EQU (FSF_USE_FPU or FSF_USE_SSE2)
;;FSF_USE_VCRT EQU