-
Notifications
You must be signed in to change notification settings - Fork 3
/
toke.cpp
2899 lines (2829 loc) · 71.6 KB
/
toke.cpp
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
#define _TOKE_
#include <fcntl.h> /* O_ constant definitions */
#include <sys/stat.h>
#ifndef _MSC_VER
#include <unistd.h>
#else
#include <io.h>
#endif
#include "misc.h"
#include "tok.h"
unsigned char gotoendif = FALSE;
unsigned char atex = FALSE;
unsigned char usedirectiv = TRUE; //идет обработка директивы
unsigned char parsecommandline = 0; // parse command line flag
unsigned char sdp_mode =
FALSE; //режим принудительной выгрузки динамических процедур
unsigned int startexit;
extern int maxerrors; // number of errors to stop at
unsigned int postnumflag; //флаг последнего идентификатора в вычислении номера
int calcnumber = FALSE;
char mesmain[] = "main";
const char *macroname[] = {
"inp", "inportb", "inport", "inportd", "outp", "outportb", "outport",
"outportd", "sqrt", "cos", "sin", "atan2", "tan", "log",
"log10", "exp", "atan", "fabs", NULL};
enum {
m_ib,
m_ibt,
m_iw,
m_id,
m_ob,
m_obt,
m_ow,
m_od,
m_sqrt,
m_cos,
m_sin,
m_atan2,
m_tan,
m_log,
m_log10,
m_exp,
m_atan,
m_fabs,
m_end
};
int FindProcLib(int);
int RetAtExit();
int ConvRetCode(int i);
int CompConst(int firstval);
int dirmode;
#define NUMIFDEF 32 //максимальная вложеность директив ifdef/ifndef
int endifcount = -1; // depth count of ?if
char ujo[] = "Unknown #jumptomain option";
char toelse[] = "#else use once in #if";
char ido[] = "Unknown #inline option";
unsigned char startuptomain = FALSE;
unsigned char dosstring = FALSE;
unsigned char useelse[NUMIFDEF]; //флаги использования директивы else
unsigned char jumptomain = CALL_NEAR; // jump to the main()
unsigned char resizemem = 1; // set owned memory block to 64K
unsigned char fargc = FALSE;
unsigned int startptrdata = 0x100; // data start address
unsigned int resizesizeaddress; /* location of resize memory size descr. */
unsigned int stackstartaddress; /* location of SP assignment */
/*-----------------18.09.98 23:20-------------------
Реализация SYS
--------------------------------------------------*/
char sysname[8] = "NO_NAME";
int sysatr = 0x2000;
int sysstack = 0;
int sysnumcom = 0;
int syscom;
//переменные для компиляции rom-bios
int unsigned romsize = 0;
int dataromstart, dataromsize;
int dataseg = 0x70;
unsigned int numdomain = 0; //число процедур запускаемых до main
char *domain; //буфер имен процедур запускаемых до main
int ifdefconst();
void CheckNumIF();
void KillVarOfTree(idrec **treestart);
void IncludeFile(char *fileincl, int tfind);
char *pragmalist[] = {"option", "line", "startup", "resource",
"pack", "debug", "indexregs", ""};
enum { p_op, p_li, p_st, p_re, p_pa, p_db, p_idx, p_end };
int strpackdef = 1;
int strpackcur = 1;
struct STACKALIGN {
STACKALIGN *prev;
int size;
char id[IDLENGTH];
};
#ifdef DEBUGMODE
int debug = FALSE;
#endif
STACKALIGN *stackalign = NULL;
/* -------------- constant math procedures start --------------- */
int calcqwordnumber(unsigned long long *retnum, unsigned long long number,
int operand) {
unsigned long long value;
value = *retnum;
switch (operand) {
case tk_minus:
value -= number;
break;
case tk_plus:
value += number;
break;
case tk_xor:
value ^= number;
break;
case tk_and:
value &= number;
break;
case tk_or:
value |= number;
break;
case tk_mod:
value %= number;
break;
case tk_div:
value /= number;
break;
case tk_mult:
value *= number;
break;
case tk_rr:
value >>= number;
break;
case tk_ll:
value <<= number;
break;
case tk_xorminus:
value ^= -number;
break;
case tk_andminus:
value &= -number;
break;
case tk_orminus:
value |= -number;
break;
case tk_modminus:
value %= -number;
break;
case tk_divminus:
value /= -number;
break;
case tk_multminus:
value *= -number;
break;
case tk_rrminus:
value >>= -number;
break;
case tk_llminus:
value <<= -number;
break;
default:
return FALSE;
}
*retnum = value;
return TRUE;
}
unsigned long long doconstqwordmath() {
unsigned long long value;
unsigned int htok;
int fundef; //флаг использования неизв адреса
CheckMinusNum();
if (tok != tk_number) {
numexpected();
return (0);
}
if (itok.rm == tk_float)
value = *(float *)&itok.number;
else if (itok.rm == tk_double)
value = *(double *)&itok.lnumber;
else
value = itok.lnumber;
fundef = itok.rm;
postnumflag = itok.flag;
// usedirectiv=TRUE;
calcnumber = TRUE;
while (itok2.type == tp_opperand) {
if (fundef == tk_undefofs && tok2 != tk_plus && tok2 != tk_minus)
break;
nexttok();
htok = tok;
if (tok2 != tk_number) {
if (tok2 != tk_dollar && tok2 != tk_not) {
calcnumber = FALSE;
return (value);
}
nexttok();
if (tok != tk_number) {
calcnumber = FALSE;
return (value);
}
} else
nexttok();
if (itok.rm == tk_float)
itok.number = *(float *)&itok.number;
else if (itok.rm == tk_double)
itok.lnumber = *(double *)&itok.lnumber;
if (calcqwordnumber(&value, itok.lnumber, htok) == FALSE)
beep();
postnumflag ^= itok.flag;
}
nexttok();
calcnumber = FALSE;
return (value);
}
int calcdwordnumber(unsigned long *retnum, unsigned long number, int operand) {
unsigned long value;
value = *retnum;
switch (operand) {
case tk_minus:
value -= number;
break;
case tk_plus:
value += number;
break;
case tk_xor:
value ^= number;
break;
case tk_and:
value &= number;
break;
case tk_or:
value |= number;
break;
case tk_mod:
value %= number;
break;
case tk_div:
value /= number;
break;
case tk_mult:
value *= number;
break;
case tk_rr:
value >>= number;
break;
case tk_ll:
value <<= number;
break;
case tk_xorminus:
value ^= -number;
break;
case tk_andminus:
value &= -number;
break;
case tk_orminus:
value |= -number;
break;
case tk_modminus:
value %= -number;
break;
case tk_divminus:
value /= -number;
break;
case tk_multminus:
value *= -number;
break;
case tk_rrminus:
value >>= -number;
break;
case tk_llminus:
value <<= -number;
break;
default:
return FALSE;
}
*retnum = value;
return TRUE;
}
unsigned long doconstdwordmath() {
unsigned long value;
unsigned int htok;
int fundef; //флаг использования неизв адреса
CheckMinusNum();
if (tok != tk_number) {
numexpected();
return (0);
}
if (itok.rm == tk_float)
value = *(float *)&itok.number;
else
value = itok.number;
fundef = itok.rm;
postnumflag = itok.flag;
// usedirectiv=TRUE;
calcnumber = TRUE;
while (itok2.type == tp_opperand) {
if (fundef == tk_undefofs && tok2 != tk_plus && tok2 != tk_minus)
break;
nexttok();
htok = tok;
if (tok2 != tk_number) {
if (tok2 != tk_dollar && tok2 != tk_not) {
calcnumber = FALSE;
return (value);
}
nexttok();
if (tok != tk_number) {
calcnumber = FALSE;
return (value);
}
} else
nexttok();
if (itok.rm == tk_float)
itok.number = *(float *)&itok.number;
if (itok.rm == tk_double)
itok.number = *(double *)&itok.lnumber;
if (calcdwordnumber(&value, itok.number, htok) == FALSE)
beep();
postnumflag ^= itok.flag;
}
nexttok();
calcnumber = FALSE;
return (value);
}
int calclongnumber(long *retnum, long number, int operand) {
long value;
value = *retnum;
switch (operand) {
case tk_minus:
value -= number;
break;
case tk_plus:
value += number;
break;
case tk_xor:
value ^= number;
break;
case tk_and:
value &= number;
break;
case tk_or:
value |= number;
break;
case tk_mod:
value %= number;
break;
case tk_div:
value /= number;
break;
case tk_mult:
value *= number;
break;
case tk_rr:
value >>= number;
break;
case tk_ll:
value <<= number;
break;
case tk_xorminus:
value ^= -number;
break;
case tk_andminus:
value &= -number;
break;
case tk_orminus:
value |= -number;
break;
case tk_modminus:
value %= -number;
break;
case tk_divminus:
value /= -number;
break;
case tk_multminus:
value *= -number;
break;
case tk_rrminus:
value >>= -number;
break;
case tk_llminus:
value <<= -number;
break;
default:
return FALSE;
}
*retnum = value;
return TRUE;
}
signed long doconstlongmath()
//вычислить выражение
{
long value;
unsigned int htok;
int fundef; //флаг использования неизв адреса
CheckMinusNum();
if (tok != tk_number) {
numexpected();
return (0);
}
fundef = itok.rm;
if (itok.rm == tk_float)
value = *(float *)&itok.number;
else
value = itok.number;
// value=itok.number;
postnumflag = itok.flag;
// usedirectiv=TRUE;
calcnumber = TRUE;
while (itok2.type == tp_opperand) { //пока операнд
if (fundef == tk_undefofs && tok2 != tk_plus && tok2 != tk_minus)
break;
nexttok();
// printf("tok=%d tok2=%d\n",tok,tok2);
htok = tok;
if (tok2 != tk_number) {
if (tok2 != tk_dollar && tok2 != tk_not) {
calcnumber = FALSE;
return (value);
}
nexttok();
if (tok != tk_number) {
calcnumber = FALSE;
return (value);
}
} else
nexttok();
if (itok.rm == tk_float)
itok.number = *(float *)&itok.number;
if (itok.rm == tk_double)
itok.number = *(double *)&itok.lnumber;
if (calclongnumber(&value, itok.number, htok) == FALSE)
beep();
postnumflag ^= itok.flag;
}
nexttok();
calcnumber = FALSE;
return (value);
}
int calcfloatnumber(float *retnum, float number, int operand) {
float value;
value = *retnum;
switch (operand) {
case tk_minus:
value -= number;
break;
case tk_plus:
value += number;
break;
case tk_div:
value /= number;
break;
case tk_mult:
value *= number;
break;
case tk_divminus:
value /= -number;
break;
case tk_multminus:
value *= -number;
break;
default:
return FALSE;
}
*retnum = value;
return TRUE;
}
long doconstfloatmath()
//вычислить выражение
{
float value;
postnumflag = 0;
CheckMinusNum();
if (tok != tk_number) {
numexpected();
return (0);
}
if (itok.rm == tk_double)
*(float *)&itok.number = itok.dnumber;
else if (itok.rm != tk_float) {
float temp = itok.number;
*(float *)&itok.number = temp;
}
value = itok.fnumber;
// usedirectiv=TRUE;
calcnumber = TRUE;
while (itok2.type == tp_opperand) { //пока операнд
nexttok();
if (tok2 != tk_number) {
calcnumber = FALSE;
return *(long *)&value; //нет никаких действий
}
if (itok2.rm == tk_double)
*(float *)&itok2.number = itok2.dnumber;
else if (itok2.rm != tk_float)
*(float *)&itok2.number = itok2.number;
itok2.rm = tk_float;
if (calcfloatnumber(&value, itok2.fnumber, tok) == FALSE)
beep();
nexttok();
}
nexttok();
calcnumber = FALSE;
return *(long *)&value;
}
int calcdoublenumber(double *retnum, double number, int operand) {
double value;
value = *retnum;
switch (operand) {
case tk_minus:
value -= number;
break;
case tk_plus:
value += number;
break;
case tk_div:
value /= number;
break;
case tk_mult:
value *= number;
break;
case tk_divminus:
value /= -number;
break;
case tk_multminus:
value *= -number;
break;
default:
return FALSE;
}
*retnum = value;
return TRUE;
}
long long doconstdoublemath()
//вычислить выражение
{
double value;
postnumflag = 0;
CheckMinusNum();
if (tok != tk_number) {
numexpected();
return (0);
}
if (itok.rm == tk_float) {
itok.dnumber = *(float *)&itok.number;
itok.rm = tk_double;
} else if (itok.rm != tk_double) {
itok.dnumber = itok.lnumber;
}
value = itok.dnumber;
// usedirectiv=TRUE;
calcnumber = TRUE;
while (itok2.type == tp_opperand) { //пока операнд
nexttok();
if (tok2 != tk_number) {
calcnumber = FALSE;
return *(long long *)&value; //нет никаких действий
}
if (itok2.rm == tk_float)
itok2.dnumber = *(float *)&itok2.number;
else if (itok2.rm != tk_double)
itok2.dnumber = itok2.lnumber;
;
itok2.rm = tk_double;
if (calcdoublenumber(&value, itok2.dnumber, tok) == FALSE)
beep();
nexttok();
}
nexttok();
calcnumber = FALSE;
return *(long long *)&value;
}
/* ================= simple syntax procedures start =================== */
void nextseminext() {
nexttok();
seminext();
}
void seminext() {
if (tok != tk_semicolon)
expected(';');
else
nexttok();
}
void beep() /* beep for any internal errors */
{
printf("\a");
}
int expecting(int want)
/* compares current token with want token. If different, issues error
message and returns 1, else advances to next token and returns 0 */
{
if (want != tok) {
SwTok(want);
return (1);
}
nexttok();
return (0);
}
void expectingoperand(int want)
/* compares current token with want token. If different, issues error
message and returns 1, else advances to next token and returns 0 */
{
if (want != tok)
SwTok(want);
else
getoperand();
}
void SwTok(int want) {
switch (want) {
case tk_closebracket:
expected(')');
break;
case tk_openbracket:
expected('(');
break;
case tk_semicolon:
expected(';');
break;
case tk_colon:
expected(':');
break;
case tk_openblock:
expected('[');
break;
case tk_closeblock:
expected(']');
break;
case tk_openbrace:
expected('{');
break;
case tk_closebrace:
expected('}');
break;
case tk_camma:
expected(',');
break;
default:
preerror("expecting a different token");
break;
}
}
/*-----------------03.07.99 22:48-------------------
Внутренние процедуры
--------------------------------------------------*/
void outprocedure(unsigned char *array, unsigned int length) {
if ((outptr + length) >= outptrsize)
CheckCodeSize();
memcpy(output + outptr, array, length);
outptr += length;
if (splitdata == 0)
outptrdata = outptr;
}
#define MMBANER 11
unsigned char aabaner[] = {0x53, 0x50, 0x48, 0x49, 0x4E, 0x58,
0x43, 0x2d, 0x2d, ver1, ver2}; //надпись SPHINXC--ver
#define MMEXP 18
unsigned char aaEXP[] = {0xD9, 0xE8, // fld1
0xD9, 0xEA, // fldl2e
0xD8, 0xCA, // fmul st, st(2)
0xDD, 0xD2, // fst st(2)
0xD9, 0xF8, // fprem
0xD9, 0xF0, // f2xm1
0xDE, 0xC1, // faddp st(1), st
0xD9, 0xFD, // fscale
0xDD, 0xD9}; // fstp st(1)
void CallExitProcess()
//вызов процедуры ExitProcess
{
tok = tk_id;
searchvar("ExitProcess");
if (FastCallApi == TRUE) {
outword(0x15FF);
AddApiToPost(itok.number);
} else {
addacall((unsigned int)itok.number, (unsigned char)CALL_32);
callloc0(); /* produce CALL [#] */
}
}
int includeit(int type) {
int i = 0;
itok.post = 1;
if (strcmp("ABORT", itok.name) == 0) {
RestoreStack();
clearregstat();
#ifdef OPTVARCONST
ClearLVIC();
#endif
type = 0;
if (type == 1 && dbg & 2)
AddCodeNullLine("ABORT()");
if (comfile == file_w32)
outword(0xC031); // xor eax,eax
if (atex == TRUE)
i = RetAtExit();
if (i == 0) {
if (comfile == file_exe)
outdword(0x21CD4CB4);
else if (comfile == file_w32) {
if (jumptomain != CALL_NONE)
jumploc(startexit);
else {
op(0x50);
CallExitProcess();
}
} else
outword(0x20CD);
}
retproc = TRUE;
} else if (strcmp("ATEXIT", itok.name) == 0) {
if (type && AlignProc)
AlignCD(CS, alignproc);
if (atex == FALSE)
preerror("?atexit must be set for ATEXIT");
if (type == 1 && dbg & 2)
AddCodeNullLine("ATEXIT()");
searchvar("__atexitproc");
itok2 = itok;
searchvar("__numatexit");
if (am32) {
op(0x51); // push ecx
outword(0x0D8B); // mov ecx,numatex
if (itok.post)
setwordpost(&itok);
outdword(itok.number);
outdword(0x7310F983);
outdword(0x8D04890F); // cmp ecx,10 jnb bp mov [numatexit+4+ECX*4]=EAX
if (itok2.post)
setwordpost(&itok2);
outdword(itok2.number);
outword(0x05FF); // inc numatexit
if (itok.post)
setwordpost(&itok);
outdword(itok.number);
outword(0xC031); // xor eax,eax
// bp:
op(0x59); // pop ECX
} else {
outword(0x368B);
if (itok.post)
setwordpost(&itok);
outword(itok.number);
op(0x83);
outdword(0x0C7310FE); // cmp si,10 jnb
outdword(0x8489F601); // si+=si
if (itok2.post)
setwordpost(&itok2);
outword(itok2.number);
outword(0x06FF);
if (itok.post)
setwordpost(&itok);
outword(itok.number);
outword(0xC031);
}
} else if (strcmp("EXIT", itok.name) == 0) {
RestoreStack();
clearregstat();
#ifdef OPTVARCONST
ClearLVIC();
#endif
type = 0;
if (dbg & 2)
AddCodeNullLine("EXIT()");
if (atex == TRUE)
i = RetAtExit();
if (i == 0) {
if (comfile == file_w32) {
if (jumptomain != CALL_NONE)
jumploc(startexit);
else {
op(0x50);
CallExitProcess();
}
} else if (comfile == file_meos) {
outdword(0xCDFFC883);
op(0x40);
} else
outdword(0x21CD4CB4);
}
retproc = TRUE;
} else
return ConvRetCode(FindProcLib(type));
if (type == 1)
ret(); /* if it is a REG Proc not a MACRO */
return (am32 == FALSE ? tk_word : tk_dword);
}
int ConvRetCode(int i) {
switch (i) {
case 0:
return tk_void;
case 1:
return tk_char;
case 2:
return tk_byte;
case 3:
return tk_int;
case 4:
return tk_word;
case 5:
return tk_long;
case 6:
return tk_dword;
case 7:
return tk_float;
default:
return -1;
}
}
int RetAtExit() {
if (comfile == file_exe || fobj != FALSE || comfile == file_w32 ||
comfile == file_meos) {
jumploc(startexit);
return 1;
} else
callloc(startexit);
return 0;
}
int includeproc() { return ConvRetCode(FindProcLib(1)); }
/*-----------------18.01.99 22:42-------------------
Макропроцедуры
--------------------------------------------------*/
int CheckMacros() {
int m, app = 0, s32 = 0;
unsigned int num;
char *ofsstr = NULL;
int razr;
for (m = 0; m < m_end; m++)
if (strcmp(macroname[m], (char *)string) == 0)
break;
if (m == m_end)
return tokens;
nexttok();
ofsstr = GetLecsem(tk_closebracket, tk_camma);
nexttok();
if (m < m_sqrt) {
switch (m) {
case m_id:
s32++;
case m_iw:
app++;
case m_ib:
case m_ibt:
if (tok != tk_closebracket) {
if (tok == tk_number) {
num = doconstlongmath();
if (num < 256) {
if (s32 != 0)
op66(r32);
else if (app == 1)
op66(r16);
op(0xe4 + app);
op(num);
break;
}
if (optimizespeed) {
op(0xB8 + DX); // MOV reg,#
if (am32)
outdword(num);
else
outword(num);
} else {
op66(r16);
op(0xB8 + DX); // MOV reg,#
outword(num);
}
} else
getintoreg(EDX, r16, 0, &ofsstr);
if (ofsstr) {
IDZToReg(ofsstr, DX, r16);
free(ofsstr);
ofsstr = NULL;
}
}
if (s32 != 0)
op66(r32);
else if (app == 1)
op66(r16);
op(0xEC + app);
ClearReg(AL);
break;
case m_od:
s32++;
case m_ow:
app++;
case m_ob:
case m_obt:
if (tok != tk_closebracket) {
if (s32 != 0) {
do_e_axmath(0, r32, &ofsstr);
razr = r32;
} else if (app != 0) {
do_e_axmath(0, r16, &ofsstr);
razr = r16;
} else {
doalmath(0, &ofsstr);
razr = r8;
}
if (ofsstr) {
IDZToReg(ofsstr, AX, razr);
free(ofsstr);
ofsstr = NULL;
}
if (tok == tk_camma) {
ofsstr = GetLecsem(tk_camma, tk_closebracket);
nexttok();
if (tok == tk_number) {
num = doconstlongmath();
if (num < 256) {
if (s32 != 0)
op66(r32);
else if (app == 1)
op66(r16);
op(0xe6 + app);
op(num);
goto enout;
}
if (optimizespeed) {
op(0xB8 + DX); // MOV reg,#
if (am32)
outdword(num);
else
outword(num);
} else {
op66(r16);
op(0xB8 + DX); // MOV reg,#
outword(num);
}
} else
getintoreg(EDX, r16, 0, &ofsstr);
if (ofsstr) {
IDZToReg(ofsstr, DX, r16);
free(ofsstr);
ofsstr = NULL;
}
}
}
if (s32 != 0)
op66(r32);
else if (app == 1)
op66(r16);
op(0xEE + app);
enout:
if (ofsstr)
free(ofsstr);
return tk_void;
}
if (ofsstr)
free(ofsstr);
} else {
if (ofsstr)
free(ofsstr);
if (tok == tk_closebracket) {
missingpar(macroname[m]);
return (tokens);
}
doeaxfloatmath(tk_fpust);
switch (m) {
case m_sqrt:
outword(0xFAD9); // FSQRT
return tk_fpust; //результат в стеке fpu
case m_cos:
outword(0xFFD9);
return tk_fpust; //результат в стеке fpu
case m_sin:
outword(0xFED9);
return tk_fpust; //результат в стеке fpu
case m_atan2:
if (expecting(tk_camma)) {