-
Notifications
You must be signed in to change notification settings - Fork 3
/
tokr.cpp
6610 lines (6513 loc) · 144 KB
/
tokr.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 _TOKR_
#include "misc.h"
#include "tok.h"
char useasm = FALSE;
char asmparam = FALSE;
#include "asmnemon.h"
void asmtwo1(int basecode); // used for ADD ADC SUB SBB CMP AND OR XOR.
void asmregmem(int out1, int out2); // used for LEA LDS LES LFS LGS LSS.
void Scanbit(int basecode);
void CheckBit(int code);
void asmone1(int basecode); // used for INC and DEC.
void asmone2(int basecode); // used for NEG NOT MUL IMUL DIV IDIV.
void asmshortjump(int shortcode, int nearcode);
void lar_lsl(int code);
unsigned char tabldeckr(int code);
void protectinstr(int code, int code2);
void doasmmov(); // do MOV
void asmextend(int basecode); // procedure MOVSX and MOVZX
void movd();
void movq();
void packMMX(int code, int code1, int code2);
void asmshift(int basecode); // used for ROL ROR RCL RCR SHL SAL SHR SAR.
void Shxd(int code);
void FpuType1(unsigned int addrm);
void FpuType2(unsigned int addrm, unsigned int addrm2);
void FpuType3(unsigned int opcode, unsigned int addrm);
void FpuType4(unsigned int opcode, unsigned int addrm);
void FpuType5(unsigned int opcode, unsigned int addrm);
void FpuType6(unsigned int opcode, unsigned int addrm);
void FpuType7(unsigned int addrm);
void FpuType8(unsigned int opcode, unsigned int addrm);
void addlocaljump(int callkind);
unsigned long SaveNumber(int type, int tok4, char *name);
void cmov(int num);
void mmxiii(int type);
void prefetch(int code, int type);
void pextrw();
void pinsrw();
void pshufw();
void xmminstr(int type, int sec, int op1 = tk_xmmreg, int op2 = tk_xmmreg);
void xmm3instr(int type, int sec);
void xmm2xmm(int code, int code2 = 0, int type = tk_xmmreg);
void movxmm(int code, int code2, int addc = 1);
void movxmm2(int code, int code2 = 0);
void movxmm3(int code, int code2 = 0, int type = tk_xmmreg);
void movxmm4(int code, int code2);
void shiftxmm(int rm); // rxmm,i8
void DDDW(int faradd);
void AADM(int code);
extern void shortjumperror();
extern void invalidfarjumpitem();
extern void invalidfarcallitem();
extern void bytedxexpected();
extern void axalexpected();
extern void clornumberexpected();
extern void reg32regexpected(int type);
extern void begexpected(int type);
extern void regexpected(int type);
extern void invalidoperand(int type);
extern void mmxregexpected(int type = 0);
extern void mmxregordwordexpected(int type);
extern void mmxormem(int type);
extern void reg32orword(int type);
extern void xmmregorvarexpected(int type);
extern void xmmregexpected(int type);
extern void fpustakexpected(int type);
extern void fpuvarexpected(int type);
void doasm(int nexta) {
unsigned char possiblecpu = 0, next = 1;
int htok;
ITOK hstok;
char *hbuf;
SINFO hstr;
unsigned int i = 0;
int razr = r16;
unsigned long hnumber;
int faradd = 0;
if (nexta == FALSE) {
useasm = TRUE;
nexttok();
useasm = FALSE;
}
if (tok == tk_idasm) {
htok = itok.rm;
goto sw_asm;
}
if (tok == tk_ID || tok == tk_id || tok == tk_undefproc) {
if (tok2 == tk_colon) { //метка
if (tok == tk_undefproc)
doanyundefproc();
else
doid((char)(tok == tk_ID ? 1 : 0), tk_void);
return;
}
cmm_strupr((char *)string);
htok = FastSearch((unsigned char *)asmMnem, ofsmnem, 0, (char *)string);
sw_asm:
asmparam = TRUE;
switch (htok) {
case a_add: // ADD
case a_or: // OR
case a_adc: // ADC
case a_sbb: // SBB
case a_and: // AND
case a_sub: // SUB
case a_xor: // XOR
case a_cmp: // CMP
asmtwo1(htok * 8);
next = 0;
break;
case a_not: // NOT
case a_neg: // NEG
case a_mul: // MUL
case a_div: // DIV
case a_idiv: // IDIV
asmone2((htok - a_not) * 8 + 16);
break;
case a_rol: // ROL
case a_ror: // ROR
case a_rcl: // RCL
case a_rcr: // RCR
case a_shl: // SHL
case a_shr: // SHR
case a_sar: // SAR
asmshift((htok - a_rol) * 8);
next = 0;
break;
case a_btc: // BTC
case a_btr: // BTR
case a_bts: // BTS
case a_bt: // BT
CheckBit((htok - a_bt) * 8);
next = 0;
break;
case a_dec: // DEC
case a_inc: // INC
asmone1((htok - a_inc) * 8);
break;
case a_shrd: // SHRD
case a_shld: // SHLD
Shxd((htok - a_shld) * 8 + 0xa4);
next = 0;
break;
case a_aaa:
ClearReg(AX);
op(0x37); // AAA
break;
case a_aad:
ClearReg(AX);
AADM(0xD5); // AAD
break;
case a_aam:
ClearReg(AX);
AADM(0xD4); // AAM
break;
case a_aas:
ClearReg(AX);
op(0x3F); // AAS
break;
case a_adrsiz:
op(0x67);
possiblecpu = 3;
break;
case a_arpl: // ARPL
nexttok();
htok = tok;
hstok = itok;
hbuf = bufrm;
bufrm = NULL;
hstr = strinf;
strinf.bufstr = NULL;
nextexpecting2(tk_camma);
if (tok != tk_reg)
regexpected(2);
switch (htok) {
case tk_intvar:
case tk_wordvar:
#ifdef OPTVARCONST
ClearVarByNum(&hstok);
#endif
CheckAllMassiv(hbuf, 2, &hstr, &hstok);
KillVar(hstok.name);
outseg(&hstok, 2);
op(0x63);
op(hstok.rm + (unsigned int)itok.number * 8);
outaddress(&hstok);
break;
case tk_reg:
ClearReg(hstok.number);
op(0x63);
op(192 + (unsigned int)itok.number * 8 + hstok.number);
break;
default:
wordvalexpected();
}
possiblecpu = 2;
break;
case a_bound: // BOUND
asmregmem(0x62, 0);
possiblecpu = 2;
break;
case a_lea:
asmregmem(0x8D, 0); // LEA
break;
case a_lds: // LDS
case a_les: // LES
asmregmem(htok - a_les + 0xC4, 0);
break;
case a_lss: // LSS
asmregmem(0xF, 0xB2);
possiblecpu = 3;
break;
case a_lgs: // LGS
case a_lfs: // LFS
asmregmem(0xF, htok - a_lfs + 0xB4);
possiblecpu = 3;
break;
case a_bswap: // BSWAP
nexttok();
ClearReg(itok.number);
if (tok == tk_reg32 || tok == tk_reg) {
op66(tok == tk_reg ? r16 : r32);
op(0x0F);
op(0xC8 + (unsigned int)itok.number);
} else
preerror("Expecting 32 bit Register for BSWAP");
possiblecpu = 4;
break;
case a_bsf: // BSF
case a_bsr: // BSR
Scanbit(htok - a_bsf + 0xbc);
break;
case a_call: // CALL
nexttok();
htok = 0;
if (tok == tk_ID || tok == tk_id) {
if (strcasecmp("FAR", (char *)string) == 0) {
nexttok();
faradd = 8;
htok = 1;
} else if (strcasecmp("NEAR", (char *)string) == 0) {
nexttok();
htok = 1;
}
} else if (tok == tk_far) {
nexttok();
faradd = 8;
htok = 1;
}
// printf("call %d\n",tok);
switch (tok) {
case tk_proc:
if (faradd == 0) {
if (itok.segm == DYNAMIC) {
itok.segm = DYNAMIC_USED;
updatetree();
}
if (itok.segm < NOT_DYNAMIC) { //динамическая процедура
addacall(itok.number,
(unsigned char)(am32 != FALSE ? CALL_32 : CALL_NEAR));
callloc0();
} else
callloc(itok.number);
} else
invalidfarcallitem();
break;
case tk_number:
asmparam = FALSE;
hnumber = doconstdwordmath();
if (faradd == 0)
callloc(hnumber);
else {
op(0x9A);
expecting2(tk_colon);
unsigned long tempi = doconstdwordmath();
if (am32 == FALSE)
outword((unsigned int)tempi);
else
outdword(tempi);
outword(hnumber);
}
next = 0;
break; /* CALL num */
case tk_postnumber:
if (faradd == 0) {
itok.number = itok.number - outptr - 3;
op(0xE8);
(itok.flag & f_extern) == 0 ? setwordpost(&itok)
: setwordext(&itok.number);
if (am32 == FALSE)
outword(itok.number);
else
outdword(itok.number - 2);
/* op(0xE8);
(itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number);
if(am32==FALSE)outword((unsigned
int)itok.number); else outdword(itok.number);*/
} else
invalidfarcallitem();
break;
case tk_reg32:
op66(r32);
goto callreg;
case tk_reg:
op66(r16);
callreg:
if (faradd == 0) {
op(0xFF);
op(0xD0 + (unsigned int)itok.number);
} /* CALL reg */
else
invalidfarcallitem();
break;
case tk_ID:
case tk_id:
if (faradd == 0) {
tobedefined(am32 == FALSE ? CALL_NEAR : CALL_32, tk_void);
callloc0();
} /* CALL NEAR */
else
invalidfarcallitem();
break;
case tk_declare:
tok = tk_undefproc;
updatetree();
case tk_locallabel:
case tk_undefproc:
if (faradd == 0) {
addacall(
(unsigned int)itok.number,
(unsigned char)((itok.flag & f_extern) != 0
? CALL_EXT
: (am32 == FALSE ? CALL_NEAR : CALL_32)));
callloc0();
} /* CALL NEAR */
else
invalidfarcallitem();
break;
case tk_dwordvar:
case tk_longvar:
i = 2;
if (am32 == FALSE && htok == 0)
faradd = 8;
case tk_intvar:
case tk_wordvar:
i += 2;
CheckAllMassiv(bufrm, i, &strinf);
outseg(&itok, 2);
op(0xFF);
op(0x10 + itok.rm + faradd);
outaddress(&itok);
break;
default:
preerror("Invalid item for CALL");
break;
}
#ifdef OPTVARCONST
FreeGlobalConst();
#endif
clearregstat();
break;
case a_cbw:
ClearReg(AX);
if (am32)
op(0x66);
op(0x98); // CBW
break;
case a_cdq:
ClearReg(DX);
op66(r32);
op(0x99);
possiblecpu = 3; // CDQ
break;
case a_clc:
op(0xF8); // CLC
break;
case a_cld:
op(0xFC); // CLD
break;
case a_cli:
op(0xFA); // CLI
break;
case a_clts: // CLTS
outword(0x060F);
possiblecpu = 2;
break;
case a_cmc:
op(0xF5); // CMC
break;
case a_cmpsb:
ClearReg(SI);
ClearReg(DI);
op(0xA6);
break;
case a_cmpsw:
ClearReg(SI);
ClearReg(DI);
op66(r16);
op(0xA7);
break;
case a_cmpsd:
if (ScanTok3() == tk_camma && tok2 == tk_xmmreg) {
xmm3instr(0xC2, 0xF2);
possiblecpu = 9;
next = 0;
} else {
ClearReg(SI);
ClearReg(DI);
op66(r32);
op(0xA7);
possiblecpu = 3;
}
break;
case a_cmpxchg: // CMPXCHG
nexttok();
htok = tok;
hstok = itok;
hbuf = bufrm;
bufrm = NULL;
hstr = strinf;
strinf.bufstr = NULL;
nextexpecting2(tk_camma);
i = r16;
ClearReg(AX);
switch (htok) {
case tk_reg32:
i = r32;
case tk_reg:
ClearReg(hstok.number);
switch (tok) {
case tk_reg32:
if (i == r16)
goto erreg;
case tk_reg:
op66(i);
outword(0xB10F);
op(128 + 64 + (unsigned int)itok.number * 8 + hstok.number);
break;
case tk_longvar:
case tk_dwordvar:
if (i == r16)
goto erreg;
case tk_intvar:
case tk_wordvar:
#ifdef OPTVARCONST
ClearVarByNum(&itok);
#endif
CheckAllMassiv(bufrm, i, &strinf);
op66(i);
outseg(&itok, 3);
outword(0xB10F);
op(itok.rm + hstok.number * 8);
outaddress(&itok);
break;
default:
erreg:
if (i == r16)
wordvalexpected();
else
dwordvalexpected();
break;
}
break;
case tk_beg:
ClearReg(hstok.number);
switch (tok) {
case tk_beg:
outword(0xB00F);
op(128 + 64 + (unsigned int)itok.number * 8 + hstok.number);
break;
case tk_charvar:
case tk_bytevar:
CheckAllMassiv(bufrm, 1, &strinf);
outseg(&itok, 3);
outword(0xB00F);
op(itok.rm + hstok.number * 8);
outaddress(&itok);
break;
default:
bytevalexpected(2);
break;
}
break;
case tk_charvar:
case tk_bytevar:
#ifdef OPTVARCONST
ClearVarByNum(&hstok);
#endif
if (tok != tk_beg)
begexpected(2);
CheckAllMassiv(hbuf, 1, &hstr, &hstok);
KillVar(hstok.name);
outseg(&hstok, 3);
outword(0xB00F);
op(hstok.rm + (unsigned int)itok.number * 8);
outaddress(&hstok);
break;
case tk_longvar:
case tk_dwordvar:
if (tok != tk_reg32)
reg32expected(2);
i = r32;
goto noint;
case tk_intvar:
case tk_wordvar:
if (tok != tk_reg)
regexpected(2);
noint:
#ifdef OPTVARCONST
ClearVarByNum(&hstok);
#endif
CheckAllMassiv(hbuf, i, &hstr, &hstok);
KillVar(hstok.name);
op66(i);
outseg(&hstok, 3);
outword(0xB10F);
op(hstok.rm + (unsigned int)itok.number * 8);
outaddress(&hstok);
break;
default:
varexpected(1);
break;
}
possiblecpu = 4;
break;
case a_cmpxchg8b: // CMPXCHG8B
nexttok();
if (tok != tk_qwordvar)
qwordvalexpected();
#ifdef OPTVARCONST
ClearVarByNum(&itok);
#endif
CheckAllMassiv(bufrm, 8, &strinf);
KillVar(itok.name);
outseg(&itok, 3);
outword(0xc70f);
op(itok.rm + 8);
outaddress(&itok);
possiblecpu = 5;
break;
case a_cwd:
ClearReg(DX);
op66(r16);
op(0x99); // CWD
break;
case a_cwde:
ClearReg(AX);
if (!am32)
op(0x66);
op(0x98);
possiblecpu = 3;
break;
case a_cpuid:
ClearReg(AX);
ClearReg(BX);
ClearReg(CX);
ClearReg(DX);
outword(0xa20f); // CPUID
possiblecpu = 5;
break;
case a_daa:
ClearReg(AX);
op(0x27); // DAA
break;
case a_das:
ClearReg(AX);
op(0x2F); // DAS
break;
case a_db: // DB
dbgact++;
asmparam = FALSE;
do {
i = 1;
nexttok();
CheckIP();
if (tok == tk_number) {
hnumber = doconstdwordmath();
if (tok == tk_id && strcmp((char *)string, "dup") == 0) {
i = hnumber;
nexttok();
CheckMinusNum();
if (tok == tk_number)
hnumber = doconstdwordmath();
else
numexpected();
}
for (; i != 0; i--)
op(hnumber);
} else if (tok == tk_string) {
for (i = 0; i < (unsigned int)itok.number; i++)
opd(string[i]);
switch (itok.flag & 3) {
case zero_term:
if (itok.flag & s_unicod)
opd(0);
opd(0);
break;
case dos_term:
if (itok.flag & s_unicod)
opd(0);
opd('$');
break;
}
nexttok();
} else {
numexpected();
nexttok();
}
} while (tok == tk_camma);
dbgact--;
next = 0;
break;
case a_dd: // DD
faradd++;
case a_dw: // DW
DDDW(faradd);
next = 0;
break;
case a_enter: // ENTER
ClearReg(BP);
op(0xC8);
nexttok();
if (tok == tk_number)
outword((unsigned int)doconstlongmath());
else {
numexpected(1);
nexttok();
}
expecting2(tk_camma);
if (tok == tk_number)
op((int)doconstlongmath());
else {
numexpected(2);
nexttok();
}
next = 0;
possiblecpu = 2;
break;
case a_emms: // EMMS
outword(0x770f);
possiblecpu = 6;
break;
case a_imul: // IMUL
nexttok();
if (tok2 != tk_camma) {
ClearReg(AX);
switch (tok) {
case tk_reg32:
possiblecpu = 3;
razr = r32;
case tk_reg:
ClearReg(DX);
op66(razr);
op(246 + 1);
op(128 + 64 + 40 + (unsigned int)itok.number);
break;
case tk_beg:
op(246);
op(128 + 64 + 40 + (unsigned int)itok.number);
break;
case tk_charvar:
case tk_bytevar:
CheckAllMassiv(bufrm, 1, &strinf);
outseg(&itok, 2);
op(246);
op(itok.rm + 40);
outaddress(&itok);
break;
case tk_longvar:
case tk_dwordvar:
CheckAllMassiv(bufrm, 4, &strinf);
possiblecpu = 3;
razr = r32;
case tk_intvar:
case tk_wordvar:
CheckAllMassiv(bufrm, 2, &strinf);
ClearReg(DX);
op66(razr);
outseg(&itok, 2);
op(247);
op(itok.rm + 40);
outaddress(&itok);
break;
default:
varexpected(1);
break;
}
} else {
htok = tok;
hnumber = itok.number;
ClearReg(hnumber);
nextexpecting2(tk_camma);
possiblecpu = 2;
if (tok2 != tk_camma) {
switch (tok) {
case tk_number:
switch (htok) {
case tk_reg32:
possiblecpu = 3;
razr = r32;
case tk_reg:
op66(razr);
if (short_ok(itok.number, TRUE))
i = 2; //короткая форма
op(0x69 + i);
op(0xc0 + (unsigned int)hnumber + (unsigned int)hnumber * 8);
if (i == 2)
op(itok.number);
else {
if (htok == tk_reg)
outword(itok.number);
else
outdword(itok.number);
}
break;
default:
reg32regexpected(1);
}
break;
case tk_reg32:
razr = r32;
case tk_reg:
op66(razr);
possiblecpu = 3;
if (htok != tok)
reg32regexpected(1);
outword(0xaf0f);
op(0xc0 + (unsigned int)itok.number + (unsigned int)hnumber * 8);
break;
case tk_longvar:
tok++;
case tk_dwordvar:
if (htok != tk_reg32)
reg32expected(1);
CheckAllMassiv(bufrm, 4, &strinf);
razr = r32;
goto imul1;
case tk_intvar:
tok++;
case tk_wordvar:
imul1:
possiblecpu = 3;
if (htok != tk_reg && (tok == tk_intvar || tok == tk_wordvar))
regexpected(1);
CheckAllMassiv(bufrm, 2, &strinf);
op66(razr);
outseg(&itok, 3);
outword(0xaf0f);
op(itok.rm + hnumber * 8);
outaddress(&itok);
break;
default:
varexpected(2);
}
} else {
int htok2 = tok;
hstok = itok;
hbuf = bufrm;
hstr = strinf;
strinf.bufstr = NULL;
bufrm = NULL;
nextexpecting2(tk_camma);
if (tok != tk_number)
numexpected(3);
switch (htok2) {
case tk_reg32:
possiblecpu = 3;
razr = r32;
case tk_reg:
op66(razr);
if (htok != htok2)
reg32regexpected(2);
if (short_ok(itok.number, TRUE))
i = 2; //короткая форма
op(0x69 + i);
op(0xc0 + (unsigned int)hstok.number + (unsigned int)hnumber * 8);
if (i == 2)
op(itok.number);
else {
if (htok == tk_reg)
outword(itok.number);
else
outdword(itok.number);
}
break;
case tk_longvar:
tok++;
case tk_dwordvar:
possiblecpu = 3;
if (htok != tk_reg32)
reg32expected(2);
CheckAllMassiv(hbuf, 4, &hstr, &hstok);
razr = r32;
goto imul2;
case tk_intvar:
tok++;
case tk_wordvar:
imul2:
if (htok != tk_reg && (htok2 == tk_intvar || htok2 == tk_wordvar))
regexpected(1);
CheckAllMassiv(hbuf, 2, &hstr, &hstok);
op66(razr);
if (short_ok(itok.number, TRUE))
i = 2; //короткая форма
outseg(&hstok, 2);
op(0x69 + i);
op(hstok.rm + hnumber * 8);
outaddress(&hstok);
if (i == 2)
op(itok.number);
else {
if (htok == tk_reg)
outword(itok.number);
else
outdword(itok.number);
}
break;
default:
varexpected(2);
}
}
}
break;
case a_in: // IN
ClearReg(AX);
nexttok();
if ((tok == tk_reg || tok == tk_reg32) &&
(unsigned int)itok.number == AX) {
op66(tok == tk_reg ? r16 : r32);
if (tok == tk_reg32)
possiblecpu = 3;
nexttok();
expecting(tk_camma);
if (tok == tk_number) {
op(0xE5);
asmparam = FALSE;
if ((hnumber = doconstdwordmath()) > 255)
bytedxexpected();
op(hnumber);
next = 0;
} else if (tok == tk_reg && (unsigned int)itok.number == DX)
op(0xED);
else
bytedxexpected();
} else if (tok == tk_beg && (unsigned int)itok.number == AL) {
nexttok();
expecting(tk_camma);
if (tok == tk_number) {
op(0xE4);
asmparam = FALSE;
if ((hnumber = doconstdwordmath()) > 255)
bytedxexpected();
op(hnumber);
next = 0;
} else if (tok == tk_reg && (unsigned int)itok.number == DX)
op(0xEC);
else
bytedxexpected();
} else
axalexpected();
break;
case a_insb: // INSB
ClearReg(AX);
ClearReg(DI);
op(0x6C);
possiblecpu = 2;
break;
case a_insw: // INSW
op66(r16);
possiblecpu = 2;
goto insd;
break;
case a_insd: // INSD
op66(r32);
possiblecpu = 3;
insd:
op(0x6D);
ClearReg(AX);
ClearReg(DI);
break;
case a_int: // INT
clearregstat();
nexttok();
if (tok == tk_number) {
asmparam = FALSE;
htok = doconstlongmath();
if (htok == 3)
op(0xCC);
else {
op(0xCD);
op(htok);
}
next = 0;
} else
numexpected();
break;
case a_into:
op(0xCE); // INTO
break;
case a_invd: // INVD
outword(0x080F);
possiblecpu = 4;
break;
case a_invlpg: // INVLPG
nexttok();
switch (tok) {
case tk_longvar:
case tk_dwordvar:
CheckAllMassiv(bufrm, 4, &strinf);
goto invlgp;
case tk_intvar:
case tk_wordvar:
CheckAllMassiv(bufrm, 2, &strinf);
invlgp:
outseg(&itok, 3);
outword(0x010F);
op(itok.rm + 0x38);
outaddress(&itok);
break;
case tk_undefofs:
strcpy(hstok.name, itok.name);
tok = tk_number;
case tk_number:
hnumber = doconstdwordmath();
outword(0x010f);
op((am32 == FALSE ? rm_d16 : rm_d32) + 0x38);
if (postnumflag & f_reloc)
AddReloc();
if (htok == tk_undefofs)
AddUndefOff(2, hstok.name);
if (am32)
outdword(hnumber);
else
outword(hnumber);
next = 0;
break;
case tk_postnumber:
outword(0x010F);
op((am32 == FALSE ? rm_d16 : rm_d32) + 0x38);
(itok.flag & f_extern) == 0 ? setwordpost(&itok)
: setwordext(&itok.number);
if (am32 == FALSE)
outword(itok.number); //было 0
outdword(itok.number);
break;
default:
varexpected(0);
break;
}
possiblecpu = 4;
break;
case a_iret:
#ifdef OPTVARCONST
ClearLVIC();
#endif
RestoreStack();
clearregstat();
op66(r16);
op(0xCF); // IRET
break;
case a_iretd:
#ifdef OPTVARCONST
ClearLVIC();
#endif
RestoreStack();
clearregstat();
op66(r32);
op(0xCF); // IRETD
break;
case a_jo:
case a_jno:
case a_jc:
case a_jnc:
case a_jz:
case a_jnz:
case a_jna:
case a_ja:
case a_js:
case a_jns:
case a_jp:
case a_jnp:
case a_jl:
case a_jnl:
case a_jng:
case a_jg:
RestoreStack();
asmshortjump((htok - a_jo) + 0x70, (htok - a_jo) + 0x80);
next = 0;
break;
case a_jecxz: // JECXZ
RestoreStack();
op67(r32);
asmshortjump(0xE3, 0);