Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6446 GerdtR 1
#define _TOKR_
2
 
3
 
4
 
5
char useasm=FALSE;
6
 
7
 
8
 
9
void asmtwo1(int basecode); // used for ADD ADC SUB SBB CMP AND OR XOR.
10
 
11
void Scanbit(int basecode);
12
 
13
void asmone1(int basecode); 			// used for INC and DEC.
14
 
15
 
16
 
17
unsigned char tabldeckr(int code);
18
 
19
void doasmmov();		 // do MOV
20
 
21
void movd();
22
 
23
void packMMX(int code,int code1,int code2);
24
 
25
void Shxd(int code);
26
 
27
void FpuType2(unsigned int addrm,unsigned int addrm2);
28
 
29
void FpuType4(unsigned int opcode,unsigned int addrm);
30
 
31
void FpuType6(unsigned int opcode,unsigned int addrm);
32
 
33
void FpuType8(unsigned int opcode,unsigned int addrm);
34
 
35
unsigned long SaveNumber(int type,int tok4,char *name);
36
 
37
void mmxiii(int type);
38
 
39
void pextrw();
40
 
41
void pshufw();
42
 
43
void xmm3instr(int type,int sec);
44
 
45
void movxmm(int code,int code2,int addc=1);
46
 
47
void movxmm3(int code,int code2=0,int type=tk_xmmreg);
48
 
49
void shiftxmm(int rm);	//rxmm,i8
50
 
51
void AADM(int code);
52
 
53
extern void shortjumperror();
54
 
55
extern void invalidfarcallitem();
56
 
57
extern void axalexpected();
58
 
59
extern void reg32regexpected(int type);
60
 
61
extern void regexpected(int type);
62
 
63
extern void mmxregexpected(int type=0);
64
 
65
extern void mmxormem(int type);
66
 
67
extern void xmmregorvarexpected(int type);
68
 
69
extern void fpustakexpected(int type);
70
 
71
72
 
73
{
74
 
75
int htok;
76
 
77
char *hbuf;
78
 
79
unsigned int i=0;
80
 
81
unsigned long hnumber;
82
 
83
	if(nexta==FALSE){
84
 
85
		nexttok();
86
 
87
	}
88
 
89
		htok=itok.rm;
90
 
91
	}
92
 
93
		if(tok2==tk_colon){	//метка
94
 
95
			else doid((char)(tok==tk_ID?1:0),tk_void);
96
 
97
		}
98
 
99
		htok=FastSearch((unsigned char *)asmMnem,ofsmnem,0,(char *)string);
100
 
101
		asmparam=TRUE;
102
 
103
 
104
 
105
			case a_adc: //ADC
106
 
107
			case a_and:	//AND
108
 
109
			case a_xor:	//XOR
110
 
111
				asmtwo1(htok*8);
112
 
113
				break;
114
 
115
			case a_neg:	//NEG
116
 
117
			case a_div:	//DIV
118
 
119
				asmone2((htok-a_not)*8+16);
120
 
121
			case a_rol:	//ROL
122
 
123
			case a_rcl:	//RCL
124
 
125
			case a_shl:	//SHL
126
 
127
			case a_sar:	//SAR
128
 
129
				next=0;
130
 
131
			case a_btc:	//BTC
132
 
133
			case a_bts: //BTS
134
 
135
				CheckBit((htok-a_bt)*8);
136
 
137
				break;
138
 
139
			case a_inc:	//INC
140
 
141
 
142
 
143
			case a_shld:	//SHLD
144
 
145
				next=0;
146
 
147
			case a_aaa:
148
 
149
				op(0x37);	//AAA
150
 
151
			case a_aad:
152
 
153
				AADM(0xD5);	//AAD
154
 
155
			case a_aam:
156
 
157
				AADM(0xD4);	//AAM
158
 
159
			case a_aas:
160
 
161
				op(0x3F);	//AAS
162
 
163
			case a_adrsiz:
164
 
165
				possiblecpu=3;
166
 
167
			case a_arpl:	//ARPL
168
 
169
				htok=tok;
170
 
171
				hbuf=bufrm;
172
 
173
				hstr=strinf;
174
 
175
				nextexpecting2(tk_camma);
176
 
177
				switch(htok){
178
 
179
					case tk_wordvar:
180
 
181
					ClearVarByNum(&hstok);
182
 
183
						CheckAllMassiv(hbuf,2,&hstr,&hstok);
184
 
185
						outseg(&hstok,2);
186
 
187
						op(hstok.rm+(unsigned int)itok.number*8);
188
 
189
						break;
190
 
191
						ClearReg(hstok.number);
192
 
193
						op(192+(unsigned int)itok.number*8+hstok.number);
194
 
195
					default: wordvalexpected();
196
 
197
				possiblecpu=2;
198
 
199
			case a_bound:	//BOUND
200
 
201
				possiblecpu=2;
202
 
203
			case a_lea:
204
 
205
				break;
206
 
207
			case a_les:	//LES
208
 
209
				break;
210
 
211
				asmregmem(0xF,0xB2);
212
 
213
				break;
214
 
215
			case a_lfs:	//LFS
216
 
217
				possiblecpu=3;
218
 
219
			case a_bswap:	//BSWAP
220
 
221
				ClearReg(itok.number);
222
 
223
					op66(tok==tk_reg?r16:r32);
224
 
225
					op(0xC8+(unsigned int)itok.number);
226
 
227
				else preerror("Expecting 32 bit Register for BSWAP");
228
 
229
				break;
230
 
231
			case a_bsr:	//BSR
232
 
233
				break;
234
 
235
				nexttok();
236
 
237
				if(tok==tk_ID||tok==tk_id){
238
 
239
						nexttok();
240
 
241
						htok=1;
242
 
243
					else if(stricmp("NEAR",(char *)string)==0){
244
 
245
						htok=1;
246
 
247
				}
248
 
249
					nexttok();
250
 
251
					htok=1;
252
 
253
//				printf("call %d\n",tok);
254
 
255
					case tk_proc:
256
 
257
							if(itok.segm==DYNAMIC){
258
 
259
								updatetree();
260
 
261
							int flag=itok.flag;
262
 
263
								addacall(itok.number,(unsigned char)(am32!=FALSE?CALL_32:CALL_NEAR));
264
 
265
							}
266
 
267
						}
268
 
269
						break;
270
 
271
						asmparam=FALSE;
272
 
273
						if(faradd==0)callloc(hnumber);
274
 
275
							op(0x9A);
276
 
277
							unsigned long tempi=doconstdwordmath();
278
 
279
							else outdword(tempi);
280
 
281
						}
282
 
283
						break;	 /* CALL num */
284
 
285
						if(faradd==0){
286
 
287
							op(0xE8);
288
 
289
							if(am32==FALSE)outword(itok.number);
290
 
291
/*							op(0xE8);
292
 
293
							if(am32==FALSE)outword((unsigned int)itok.number);
294
 
295
						}
296
 
297
						break;
298
 
299
						op66(r32);
300
 
301
					case tk_reg:
302
 
303
callreg:
304
 
305
							op(0xFF);
306
 
307
						} 	 /* CALL reg */
308
 
309
						break;
310
 
311
					case tk_id:
312
 
313
							tobedefined(am32==FALSE?CALL_NEAR:CALL_32,tk_void);
314
 
315
						} 		 /* CALL NEAR */
316
 
317
						break;
318
 
319
						tok=tk_undefproc;
320
 
321
					case tk_locallabel:
322
 
323
						if(faradd==0){
324
 
325
(unsigned char)((itok.flag&f_extern)!=0?CALL_EXT:(am32==FALSE?CALL_NEAR:CALL_32)));
326
 
327
						} 			/* CALL NEAR */
328
 
329
						break;
330
 
331
					case tk_longvar:
332
 
333
						if(am32==FALSE&&htok==0)faradd=8;
334
 
335
					case tk_wordvar:
336
 
337
						CheckAllMassiv(bufrm,i,&strinf);
338
 
339
						op(0xFF); op(0x10+itok.rm+faradd);
340
 
341
						break;
342
 
343
						preerror("Invalid item for CALL");
344
 
345
				}
346
 
347
				FreeGlobalConst();
348
 
349
				clearregstat();
350
 
351
			case a_cbw:
352
 
353
				if(am32)op(0x66);
354
 
355
				break;
356
 
357
				ClearReg(DX);
358
 
359
				op(0x99);
360
 
361
				break;
362
 
363
				op(0xF8);	//CLC
364
 
365
			case a_cld:
366
 
367
				break;
368
 
369
				op(0xFA);	//CLI
370
 
371
			case a_clts:	//CLTS
372
 
373
				possiblecpu=2;
374
 
375
			case a_cmc:
376
 
377
				break;
378
 
379
				ClearReg(SI);
380
 
381
				op(0xA6);
382
 
383
			case a_cmpsw:
384
 
385
				ClearReg(DI);
386
 
387
				op(0xA7);
388
 
389
			case a_cmpsd:
390
 
391
					xmm3instr(0xC2,0xF2);
392
 
393
					next=0;
394
 
395
				else{
396
 
397
					ClearReg(DI);
398
 
399
					op(0xA7);
400
 
401
				}
402
 
403
			case a_cmpxchg:	//CMPXCHG
404
 
405
				htok=tok;
406
 
407
				hbuf=bufrm;
408
 
409
				hstr=strinf;
410
 
411
				nextexpecting2(tk_camma);
412
 
413
				ClearReg(AX);
414
 
415
					case tk_reg32:
416
 
417
					case tk_reg:
418
 
419
						switch(tok){
420
 
421
								if(i==r16)goto erreg;
422
 
423
	 							op66(i);
424
 
425
								op(128+64+(unsigned int)itok.number*8+hstok.number);
426
 
427
							case tk_longvar:
428
 
429
								if(i==r16)goto erreg;
430
 
431
							case tk_wordvar:
432
 
433
								ClearVarByNum(&itok);
434
 
435
								CheckAllMassiv(bufrm,i,&strinf);
436
 
437
								outseg(&itok,3);
438
 
439
								op(itok.rm+hstok.number*8);
440
 
441
								break;
442
 
443
erreg:
444
 
445
								else dwordvalexpected();
446
 
447
						}
448
 
449
					case tk_beg:
450
 
451
						switch(tok){
452
 
453
								outword(0xB00F);
454
 
455
								break;
456
 
457
							case tk_bytevar:
458
 
459
								outseg(&itok,3);
460
 
461
								op(itok.rm+hstok.number*8);
462
 
463
								break;
464
 
465
								break;
466
 
467
						break;
468
 
469
					case tk_bytevar:
470
 
471
						ClearVarByNum(&hstok);
472
 
473
						if(tok!=tk_beg)begexpected(2);
474
 
475
						KillVar(hstok.name);
476
 
477
						outword(0xB00F);
478
 
479
						outaddress(&hstok);
480
 
481
					case tk_longvar:
482
 
483
						if(tok!=tk_reg32)reg32expected(2);
484
 
485
						goto noint;
486
 
487
					case tk_wordvar:
488
 
489
noint:
490
 
491
						ClearVarByNum(&hstok);
492
 
493
						CheckAllMassiv(hbuf,i,&hstr,&hstok);
494
 
495
						op66(i);
496
 
497
						outword(0xB10F);
498
 
499
						outaddress(&hstok);
500
 
501
					default:
502
 
503
						break;
504
 
505
				possiblecpu=4;
506
 
507
			case a_cmpxchg8b:	//CMPXCHG8B
508
 
509
				if(tok!=tk_qwordvar)qwordvalexpected();
510
 
511
				ClearVarByNum(&itok);
512
 
513
				CheckAllMassiv(bufrm,8,&strinf);
514
 
515
				outseg(&itok,3);
516
 
517
				op(itok.rm+8);
518
 
519
				possiblecpu=5;
520
 
521
			case a_cwd:
522
 
523
				op66(r16);
524
 
525
				break;
526
 
527
				ClearReg(AX);
528
 
529
				op(0x98);
530
 
531
				break;
532
 
533
				ClearReg(AX);
534
 
535
				ClearReg(CX);
536
 
537
				outword(0xa20f);	//CPUID
538
 
539
				break;
540
 
541
				ClearReg(AX);
542
 
543
				break;
544
 
545
				ClearReg(AX);
546
 
547
				break;
548
 
549
				dbgact++;
550
 
551
				do{
552
 
553
					nexttok();
554
 
555
					if(tok==tk_number){
556
 
557
						if(tok==tk_id&&strcmp((char *)string,"dup")==0){
558
 
559
							nexttok();
560
 
561
							if(tok==tk_number)hnumber=doconstdwordmath();
562
 
563
						}
564
 
565
					}
566
 
567
						for(i=0;i<(unsigned int)itok.number;i++)opd(string[i]);
568
 
569
							case zero_term:
570
 
571
								opd(0);
572
 
573
							case dos_term:
574
 
575
								opd('$');
576
 
577
						}
578
 
579
					}
580
 
581
						numexpected();
582
 
583
					}
584
 
585
				dbgact--;
586
 
587
				break;
588
 
589
				faradd++;
590
 
591
				DDDW(faradd);
592
 
593
				break;
594
 
595
				ClearReg(BP);
596
 
597
				nexttok();
598
 
599
				else{
600
 
601
					nexttok();
602
 
603
				expecting2(tk_camma);
604
 
605
				else{
606
 
607
					nexttok();
608
 
609
				next=0;
610
 
611
				break;
612
 
613
				outword(0x770f);
614
 
615
				break;
616
 
617
				nexttok();
618
 
619
				ClearReg(AX);
620
 
621
						case tk_reg32:
622
 
623
							razr=r32;
624
 
625
							ClearReg(DX);
626
 
627
						  op(246+1);
628
 
629
							break;
630
 
631
							op(246);
632
 
633
							break;
634
 
635
						case tk_bytevar:
636
 
637
							outseg(&itok,2);
638
 
639
							op(itok.rm+40);
640
 
641
							break;
642
 
643
						case tk_dwordvar:
644
 
645
							possiblecpu=3;
646
 
647
						case tk_intvar:
648
 
649
							CheckAllMassiv(bufrm,2,&strinf);
650
 
651
							op66(razr);
652
 
653
							op(247);
654
 
655
							outaddress(&itok);
656
 
657
						default: varexpected(1);	break;
658
 
659
				}
660
 
661
					htok=tok;
662
 
663
					ClearReg(hnumber);
664
 
665
					possiblecpu=2;
666
 
667
						switch(tok){
668
 
669
								switch(htok){
670
 
671
										possiblecpu=3;
672
 
673
									case tk_reg:
674
 
675
										if(short_ok(itok.number,TRUE))i=2;	//короткая форма
676
 
677
										op(0xc0+(unsigned int)hnumber+(unsigned int)hnumber*8);
678
 
679
										else{
680
 
681
											else outdword(itok.number);
682
 
683
										break;
684
 
685
								}
686
 
687
							case tk_reg32:
688
 
689
							case tk_reg:
690
 
691
								possiblecpu=3;
692
 
693
								outword(0xaf0f);
694
 
695
								break;
696
 
697
								tok++;
698
 
699
								if(htok!=tk_reg32)reg32expected(1);
700
 
701
								razr=r32;
702
 
703
							case tk_intvar:
704
 
705
							case tk_wordvar:
706
 
707
								possiblecpu=3;
708
 
709
								CheckAllMassiv(bufrm,2,&strinf);
710
 
711
								outseg(&itok,3);
712
 
713
								op(itok.rm+hnumber*8);
714
 
715
								break;
716
 
717
						}
718
 
719
					else{
720
 
721
						hstok=itok;
722
 
723
						hstr=strinf;
724
 
725
						bufrm=NULL;
726
 
727
						if(tok!=tk_number)numexpected(3);
728
 
729
							case tk_reg32:
730
 
731
								razr=r32;
732
 
733
								op66(razr);
734
 
735
								if(short_ok(itok.number,TRUE))i=2;	//короткая форма
736
 
737
								op(0xc0+(unsigned int)hstok.number+(unsigned int)hnumber*8);
738
 
739
								else{
740
 
741
									else outdword(itok.number);
742
 
743
								break;
744
 
745
								tok++;
746
 
747
								possiblecpu=3;
748
 
749
								CheckAllMassiv(hbuf,4,&hstr,&hstok);
750
 
751
								goto imul2;
752
 
753
								tok++;
754
 
755
imul2:
756
 
757
								CheckAllMassiv(hbuf,2,&hstr,&hstok);
758
 
759
								if(short_ok(itok.number,TRUE))i=2;	//короткая форма
760
 
761
								op(0x69+i);
762
 
763
								outaddress(&hstok);
764
 
765
								else{
766
 
767
									else outdword(itok.number);
768
 
769
								break;
770
 
771
						}
772
 
773
				}
774
 
775
			case a_in:	//IN
776
 
777
				nexttok();
778
 
779
					op66(tok==tk_reg?r16:r32);
780
 
781
					nexttok();
782
 
783
					if(tok==tk_number){
784
 
785
						asmparam=FALSE;
786
 
787
						op(hnumber);
788
 
789
					}
790
 
791
					else bytedxexpected();
792
 
793
				else if(tok==tk_beg&&(unsigned int)itok.number==AL){
794
 
795
					expecting(tk_camma);
796
 
797
						op(0xE4);
798
 
799
						if((hnumber=doconstdwordmath())>255)bytedxexpected();
800
 
801
						next=0;
802
 
803
					else if(tok==tk_reg&&(unsigned int)itok.number==DX)op(0xEC);
804
 
805
				}
806
 
807
				break;
808
 
809
				ClearReg(AX);
810
 
811
				op(0x6C);
812
 
813
				break;
814
 
815
				op66(r16);
816
 
817
				goto insd;
818
 
819
			case a_insd:	//INSD
820
 
821
				possiblecpu=3;
822
 
823
				op(0x6D);
824
 
825
				ClearReg(DI);
826
 
827
			case a_int:	//INT
828
 
829
				nexttok();
830
 
831
					asmparam=FALSE;
832
 
833
					if(htok==3)op(0xCC);
834
 
835
						op(0xCD);
836
 
837
					}
838
 
839
				}
840
 
841
				break;
842
 
843
				op(0xCE);	//INTO
844
 
845
			case a_invd:	//INVD
846
 
847
				possiblecpu=4;
848
 
849
			case a_invlpg:	//INVLPG
850
 
851
				switch(tok){
852
 
853
					case tk_dwordvar:
854
 
855
						goto invlgp;
856
 
857
					case tk_wordvar:
858
 
859
invlgp:
860
 
861
						outword(0x010F);
862
 
863
						outaddress(&itok);
864
 
865
866
 
867
						strcpy(hstok.name,itok.name);
868
 
869
					case tk_number:
870
 
871
						outword(0x010f);
872
 
873
		 				if(postnumflag&f_reloc)AddReloc();
874
 
875
						if(am32)outdword(hnumber);
876
 
877
						next=0;
878
 
879
					case tk_postnumber:
880
 
881
						op((am32==FALSE?rm_d16:rm_d32)+0x38);
882
 
883
						if(am32==FALSE)outword(itok.number);	//было 0
884
 
885
						break;
886
 
887
					default:
888
 
889
				}
890
 
891
				break;
892
 
893
#ifdef OPTVARCONST
894
 
895
#endif
896
 
897
				clearregstat();
898
 
899
				op(0xCF);	//IRET
900
 
901
			case a_iretd:
902
 
903
				ClearLVIC();
904
 
905
				RestoreStack();
906
 
907
				op66(r32);
908
 
909
				break;
910
 
911
			case a_jno:
912
 
913
			case a_jnc:
914
 
915
			case a_jnz:
916
 
917
			case a_ja:
918
 
919
			case a_jns:
920
 
921
			case a_jnp:
922
 
923
			case a_jnl:
924
 
925
			case a_jg:
926
 
927
				asmshortjump((htok-a_jo)+0x70,(htok-a_jo)+0x80);
928
 
929
				break;
930
 
931
				RestoreStack();
932
 
933
				asmshortjump(0xE3,0);
934
 
935
				break;
936
 
937
				RestoreStack();
938
 
939
				asmshortjump(0xE3,0);
940
 
941
				break;
942
 
943
				RestoreStack();
944
 
945
				faradd=0;
946
 
947
				if(stricmp("FAR",itok.name)==0){
948
 
949
					faradd=8;
950
 
951
				else if(stricmp("NEAR",itok.name)==0)nexttok();
952
 
953
					nexttok();
954
 
955
					break;
956
 
957
				next=gotol(faradd);
958
 
959
			case a_lahf:
960
 
961
				op(0x9F);	//LAHF
962
 
963
			case a_lar:	//LAR
964
 
965
				lar_lsl(htok-a_lar+2);
966
 
967
			case a_leave:	//LEAVE
968
 
969
				op(0xC9);
970
 
971
				possiblecpu = 2;
972
 
973
			case a_lmsw:
974
 
975
				break;
976
 
977
				outword(0x050F);
978
 
979
				break;
980
 
981
				ClearReg(SI);
982
 
983
				op(0xAC);	//LODSB
984
 
985
			case a_lodsw:
986
 
987
				ClearReg(SI);
988
 
989
				op(0xAD);	//LODSW
990
 
991
			case a_lodsd:
992
 
993
				ClearReg(SI);
994
 
995
				op(0xAD);
996
 
997
				break;
998
 
999
				op(0xF0);	//LOCK
1000
 
1001
			case a_loop:
1002
 
1003
				op67(r16);
1004
 
1005
				next=0;
1006
 
1007
			case a_loopd:
1008
 
1009
				possiblecpu=3;
1010
 
1011
				asmshortjump(0xE2,0);
1012
 
1013
				break;
1014
 
1015
				ClearReg(CX);
1016
 
1017
				next=0;
1018
 
1019
			case a_loopnz:	//LOOPNZ LOOPNE
1020
 
1021
				asmshortjump(0xE0,0);
1022
 
1023
				break;
1024
 
1025
				protectinstr(0,0x18);	//LTR
1026
 
1027
			case a_str:
1028
 
1029
				break;
1030
 
1031
				next=tabldeckr(0x10);
1032
 
1033
			case a_lidt:	//LIDT
1034
 
1035
				break;
1036
 
1037
				protectinstr(0,0x10);	//LLDT
1038
 
1039
			case a_mov:
1040
 
1041
				next=0;
1042
 
1043
			case a_movsb:
1044
 
1045
				break;
1046
 
1047
				if(ScanTok3()==tk_camma&&(tok2==tk_xmmreg||(tok2>=tk_charvar&&tok2
1048
 
1049
					possiblecpu=9;
1050
 
1051
				else movsd();	//MOVSD
1052
 
1053
			case a_movsw:
1054
 
1055
				break;
1056
 
1057
			case a_movsx:
1058
 
1059
				break;
1060
 
1061
				movd();	//MOVD
1062
 
1063
			case a_movq:
1064
 
1065
				break;
1066
 
1067
				op(0x90);	//NOP
1068
 
1069
			case a_opsiz:	//OPSIZ OPSIZE
1070
 
1071
				possiblecpu=3;
1072
 
1073
			case a_out:	//OUT
1074
 
1075
				if(tok==tk_number){
1076
 
1077
					expecting2(tk_camma);
1078
 
1079
						op66(tok==tk_reg?r16:r32);
1080
 
1081
						op(0xE7);	op(hnumber);
1082
 
1083
					else if(tok==tk_beg&&(unsigned int)itok.number==AL){
1084
 
1085
					}
1086
 
1087
				}
1088
 
1089
					nextexpecting2(tk_camma);
1090
 
1091
						op66(tok==tk_reg?r16:r32);
1092
 
1093
						op(0xEF);
1094
 
1095
					else if(tok==tk_beg&&(unsigned int)itok.number==AL)op(0xEE);
1096
 
1097
				}
1098
 
1099
				break;
1100
 
1101
				ClearReg(SI);
1102
 
1103
				possiblecpu=2;
1104
 
1105
			case a_outsw:	//OUTSW
1106
 
1107
				op66(r16);
1108
 
1109
				possiblecpu=2;
1110
 
1111
			case a_outsd:	//OUTSD
1112
 
1113
				op66(r32);
1114
 
1115
				possiblecpu=3;
1116
 
1117
			case a_pop:	//POP
1118
 
1119
				do{
1120
 
1121
					asmparam=TRUE;
1122
 
1123
					razr=r16;
1124
 
1125
						case tk_reg32:
1126
 
1127
							razr=r32;
1128
 
1129
							ClearReg(itok.number);
1130
 
1131
						  op(0x58+(unsigned int)itok.number); break;
1132
 
1133
							tok--;
1134
 
1135
							CheckAllMassiv(bufrm,4,&strinf);
1136
 
1137
							razr=r32;
1138
 
1139
						case tk_wordvar:
1140
 
1141
						case tk_intvar:
1142
 
1143
pop:
1144
 
1145
							ClearVarByNum(&itok);
1146
 
1147
							KillVar(itok.name);
1148
 
1149
							outseg(&itok,2);
1150
 
1151
							outaddress(&itok);
1152
 
1153
						case tk_seg:
1154
 
1155
								PopSeg((unsigned int)itok.number);
1156
 
1157
							}
1158
 
1159
							preerror("Invalid operand for POP");
1160
 
1161
					}
1162
 
1163
					asmparam=FALSE;
1164
 
1165
					nexttok();
1166
 
1167
				next=0;
1168
 
1169
			case a_popa:	//POPA
1170
 
1171
				possiblecpu=2;
1172
 
1173
			case a_popad:	//POPAD
1174
 
1175
				possiblecpu=3;
1176
 
1177
				op66(razr);
1178
 
1179
				RestoreStack();
1180
 
1181
				op(0x61);
1182
 
1183
			case a_popf:
1184
 
1185
				goto POPFD;
1186
 
1187
				razr=r32;
1188
 
1189
POPFD:
1190
 
1191
				addESP-=razr==r16?2:4;
1192
 
1193
				op(0x9D);
1194
 
1195
			case a_push:	//PUSH
1196
 
1197
				do{
1198
 
1199
					nexttok();
1200
 
1201
					asmparam=FALSE;
1202
 
1203
				}while(tok==tk_camma);
1204
 
1205
				break;
1206
 
1207
				razr=r16;
1208
 
1209
				goto PUSHAD;
1210
 
1211
				razr=r32;
1212
 
1213
PUSHAD:
1214
 
1215
				addESP+=razr==r16?16:32;
1216
 
1217
				op(0x60);
1218
 
1219
			case a_pushf:
1220
 
1221
				goto PUSHFD;
1222
 
1223
				razr=r32;
1224
 
1225
PUSHFD:
1226
 
1227
				RestoreStack();
1228
 
1229
				addESP+=razr==r16?2:4;
1230
 
1231
			case a_pcmpeqd:
1232
 
1233
			case a_pcmpeqb:
1234
 
1235
			case a_punpckhdq:
1236
 
1237
			case a_punpckhbw:
1238
 
1239
			case a_pcmpgtd:
1240
 
1241
			case a_pcmpgtb:
1242
 
1243
			case a_punpckldq:
1244
 
1245
			case a_punpcklbw:
1246
 
1247
				break;
1248
 
1249
				mmxiii(0xD5);	//PMULLW
1250
 
1251
			case a_pmuludq:
1252
 
1253
				break;
1254
 
1255
				mmxiii(0xD8);	//PSUBUSB
1256
 
1257
			case a_psubusw:
1258
 
1259
				break;
1260
 
1261
				mmxiii(0xDB);	//PAND
1262
 
1263
			case a_paddusb:	//+xmm
1264
 
1265
				break;
1266
 
1267
				mmxiii(0xDD);//PADDUSW
1268
 
1269
			case a_pandn:   //+xmm
1270
 
1271
				break;
1272
 
1273
				outword(0x90F3);
1274
 
1275
				break;
1276
 
1277
				mmxiii(0xE5);	//PMULHW
1278
 
1279
			case a_psubsb:
1280
 
1281
				break;
1282
 
1283
				mmxiii(0xE9);//PSUBSW
1284
 
1285
			case a_por:
1286
 
1287
				break;
1288
 
1289
				mmxiii(0xEC);	//PADDSB
1290
 
1291
			case a_paddsw:  //+xmm
1292
 
1293
				break;
1294
 
1295
				mmxiii(0xEF);	//PXOR
1296
 
1297
			case a_pmaddwd:
1298
 
1299
				break;
1300
 
1301
				mmxiii(0xF8);	//PSUBB
1302
 
1303
			case a_psubw:
1304
 
1305
				break;
1306
 
1307
				mmxiii(0xFA);//PSUBD
1308
 
1309
			case a_psubq:
1310
 
1311
				possiblecpu=9;
1312
 
1313
			case a_paddb:   //+xmm
1314
 
1315
				break;
1316
 
1317
				mmxiii(0xFD);//PADDW
1318
 
1319
			case a_paddd:   //+xmm
1320
 
1321
				break;
1322
 
1323
				mmxiii(0xD4);//PADDQ
1324
 
1325
				break;
1326
 
1327
			case a_psrlw:
1328
 
1329
				next=0;
1330
 
1331
			case a_psrld:
1332
 
1333
				next=0;
1334
 
1335
			case a_psrlq:
1336
 
1337
				next=0;
1338
 
1339
			case a_psraw:
1340
 
1341
				next=0;
1342
 
1343
			case a_psrad:
1344
 
1345
				next=0;
1346
 
1347
			case a_psllw:
1348
 
1349
				next=0;
1350
 
1351
			case a_pslld:
1352
 
1353
				next=0;
1354
 
1355
			case a_psllq:
1356
 
1357
				next=0;
1358
 
1359
			case a_pslldq:
1360
 
1361
				next=0;
1362
 
1363
				break;
1364
 
1365
				shiftxmm(3);
1366
 
1367
				possiblecpu=9;
1368
 
1369
			case a_rdmsr:
1370
 
1371
				ClearReg(DX);
1372
 
1373
				possiblecpu=5;
1374
 
1375
			case a_rdtsc:
1376
 
1377
				possiblecpu=5;
1378
 
1379
			case a_rep:
1380
 
1381
				ClearReg(CX);
1382
 
1383
			case a_repnz:
1384
 
1385
				ClearReg(CX);
1386
 
1387
			case a_ret:	//RET
1388
 
1389
				ClearLVIC();
1390
 
1391
				RestoreStack();
1392
 
1393
				next=0;
1394
 
1395
//					usedirectiv=TRUE;
1396
 
1397
					op(0xC2);
1398
 
1399
					outword((unsigned int)doconstlongmath());
1400
 
1401
				}
1402
 
1403
					op(0xC3);
1404
 
1405
				}
1406
 
1407
			case a_retf:
1408
 
1409
				ClearLVIC();
1410
 
1411
				RestoreStack();
1412
 
1413
				next=0;
1414
 
1415
					nexttok();
1416
 
1417
				 	asmparam=FALSE;
1418
 
1419
				}
1420
 
1421
					op(0xCB);
1422
 
1423
				}//RETF
1424
 
1425
			case a_rsm:	//RSM
1426
 
1427
				possiblecpu=5;
1428
 
1429
			case a_sahf:
1430
 
1431
				break;
1432
 
1433
				op(0xAE);	//SCASB
1434
 
1435
				break;
1436
 
1437
				op66(r16);
1438
 
1439
				ClearReg(DI);
1440
 
1441
			case a_scasd:	//SCASD
1442
 
1443
				op(0xAF);
1444
 
1445
				ClearReg(DI);
1446
 
1447
			case a_smsw:
1448
 
1449
				break;
1450
 
1451
				op(0xF9);	//STC
1452
 
1453
			case a_std:
1454
 
1455
				break;
1456
 
1457
				op(0xFB);	//STI
1458
 
1459
			case a_stosb:
1460
 
1461
				break;
1462
 
1463
				stosw();	//STOSW
1464
 
1465
			case a_stosd:
1466
 
1467
				break;
1468
 
1469
			case a_setno:
1470
 
1471
			case a_setnc:
1472
 
1473
			case a_setnz:
1474
 
1475
			case a_seta:
1476
 
1477
			case a_setns:
1478
 
1479
			case a_setnp:
1480
 
1481
			case a_setnl:
1482
 
1483
			case a_setg:
1484
 
1485
				nexttok();
1486
 
1487
					case tk_beg:
1488
 
1489
						op(0xf);
1490
 
1491
						op(0xc0+(unsigned int)itok.number);
1492
 
1493
					case tk_charvar:
1494
 
1495
						CheckAllMassiv(bufrm,1,&strinf);
1496
 
1497
						outseg(&itok,3);
1498
 
1499
						op(0x90+i);
1500
 
1501
						outaddress(&itok);
1502
 
1503
					default: bytevalexpected(0);
1504
 
1505
				possiblecpu=3;
1506
 
1507
			case a_sgdt:
1508
 
1509
				break;
1510
 
1511
				next=tabldeckr(0x8);
1512
 
1513
			case a_sldt:
1514
 
1515
				break;
1516
 
1517
			case a_wait:
1518
 
1519
				break;
1520
 
1521
				outword(0x090F);
1522
 
1523
				break;
1524
 
1525
				outword(0x300F);
1526
 
1527
				break;
1528
 
1529
				nexttok();
1530
 
1531
				htok=tok;
1532
 
1533
				bufrm=NULL;
1534
 
1535
				strinf.bufstr=NULL;
1536
 
1537
				switch(htok){
1538
 
1539
						razr=r32;
1540
 
1541
						switch(tok){
1542
 
1543
								if(razr==r16)goto erxreg;
1544
 
1545
								RegToReg(itok.number,hstok.number,razr);
1546
 
1547
								op66(razr);
1548
 
1549
								op(128+64+(unsigned int)itok.number*8+hstok.number);
1550
 
1551
							case tk_longvar:
1552
 
1553
								if(razr==r16)goto erxreg;
1554
 
1555
							case tk_wordvar:
1556
 
1557
								/*if(bufrm==0&&strinf.bufstr==NULL)*/AddRegVar(hstok.number,razr,&itok);
1558
 
1559
								op66(razr);
1560
 
1561
								outword(0xC10F);
1562
 
1563
								outaddress(&itok);
1564
 
1565
							default:
1566
 
1567
								wordvalexpected(); break;
1568
 
1569
						break;
1570
 
1571
						switch(tok){
1572
 
1573
								RegToReg(itok.number,hstok.number,r8);
1574
 
1575
								outword(0xC00F);
1576
 
1577
								break;
1578
 
1579
							case tk_bytevar:
1580
 
1581
								/*if(bufrm==0&&strinf.bufstr==NULL)*/AddRegVar(hstok.number,r8,&itok);
1582
 
1583
								outseg(&itok,3);
1584
 
1585
								op(itok.rm+hstok.number*8);
1586
 
1587
								break;
1588
 
1589
						}
1590
 
1591
					case tk_charvar:
1592
 
1593
						if(tok!=tk_beg)begexpected(2);
1594
 
1595
						ClearReg(itok.number);
1596
 
1597
						outseg(&hstok,3);
1598
 
1599
						op(hstok.rm+(unsigned int)itok.number*8);
1600
 
1601
						break;
1602
 
1603
					case tk_dwordvar:
1604
 
1605
						razr=r32;
1606
 
1607
					case tk_intvar:
1608
 
1609
						if(tok!=tk_reg)regexpected(1);
1610
 
1611
						CheckAllMassiv(hbuf,razr,&hstr,&hstok);
1612
 
1613
						KillVar(hstok.name);
1614
 
1615
						outseg(&hstok,3);
1616
 
1617
						op(hstok.rm+(unsigned int)itok.number*8);
1618
 
1619
						break;
1620
 
1621
				}
1622
 
1623
				break;
1624
 
1625
				nexttok();
1626
 
1627
				hstok=itok;
1628
 
1629
				bufrm=NULL;
1630
 
1631
				strinf.bufstr=NULL;
1632
 
1633
				switch(htok){
1634
 
1635
						razr=r32;
1636
 
1637
					case tk_reg:
1638
 
1639
							case tk_reg32:
1640
 
1641
							case tk_reg:
1642
 
1643
								RegSwapReg(hstok.number,itok.number,razr);
1644
 
1645
								else if((unsigned int)itok.number==AX)op(0x90+hstok.number);
1646
 
1647
									op(0x87);
1648
 
1649
								}
1650
 
1651
							case tk_longvar:
1652
 
1653
								if(razr==r16)goto erregx;
1654
 
1655
							case tk_wordvar:
1656
 
1657
								KillVar(itok.name);
1658
 
1659
								op66(razr);
1660
 
1661
								op(0x87);
1662
 
1663
								outaddress(&itok);
1664
 
1665
							default:
1666
 
1667
								wordvalexpected(); break;
1668
 
1669
						break;
1670
 
1671
						switch(tok){
1672
 
1673
								RegSwapReg(hstok.number,itok.number,r8);
1674
 
1675
								op(128+64+(unsigned int)itok.number*8+hstok.number);
1676
 
1677
							case tk_charvar:
1678
 
1679
								CheckAllMassiv(bufrm,1,&strinf);
1680
 
1681
								IDZToReg(itok.name,hstok.number,r8);
1682
 
1683
								op(0x86);
1684
 
1685
								outaddress(&itok);
1686
 
1687
							default: bytevalexpected(2); break;
1688
 
1689
						break;
1690
 
1691
					case tk_bytevar:
1692
 
1693
						CheckAllMassiv(hbuf,1,&hstr,&hstok);
1694
 
1695
						IDZToReg(hstok.name,itok.number,r8);
1696
 
1697
						op(0x86);
1698
 
1699
						outaddress(&hstok);
1700
 
1701
					case tk_longvar:
1702
 
1703
						razr=r32;
1704
 
1705
						if(tok!=tk_reg32)reg32expected(2);
1706
 
1707
					case tk_intvar:
1708
 
1709
						if(tok!=tk_reg)regexpected(2);
1710
 
1711
		 				CheckAllMassiv(hbuf,razr,&hstr,&hstok);
1712
 
1713
						IDZToReg(hstok.name,itok.number,razr);
1714
 
1715
						outseg(&hstok,2);
1716
 
1717
						op(hstok.rm+(unsigned int)itok.number*8);
1718
 
1719
						break;
1720
 
1721
				}
1722
 
1723
			case a_xlat:
1724
 
1725
				op(0xD7);	//XLAT
1726
 
1727
			case a_hlt:
1728
 
1729
 
1730
 
1731
				protectinstr(0,0x20);	//VERR
1732
 
1733
			case a_verw:
1734
 
1735
				break;
1736
 
1737
				if(iTest()==FALSE)invalidoperand(0);
1738
 
1739
				break;
1740
 
1741
				FpuType1(0x10);
1742
 
1743
			case a_fcomp:	//FCOMP
1744
 
1745
				break;
1746
 
1747
				FpuType2(0,0);
1748
 
1749
			case a_fdiv:	//FDIV
1750
 
1751
				break;
1752
 
1753
				FpuType2(0x30,0x38);
1754
 
1755
			case a_fmul:	//FMUL
1756
 
1757
				break;
1758
 
1759
				FpuType2(0x28,0x20);
1760
 
1761
			case a_fsubr:	//FSUBR
1762
 
1763
				break;
1764
 
1765
				FpuType3(0xDE,0);
1766
 
1767
			case a_fdivp:	//FDIVP
1768
 
1769
				break;
1770
 
1771
 
1772
 
1773
			case a_ffree:	//FFREE
1774
 
1775
				break;
1776
 
1777
				FpuType3(0xDE,8);
1778
 
1779
			case a_fsubp:	//FSUBP
1780
 
1781
				break;
1782
 
1783
				FpuType3(0xDE,0x20);
1784
 
1785
			case a_fucom:	//FUCOM
1786
 
1787
				break;
1788
 
1789
				FpuType3(0xDD,0x28);
1790
 
1791
			case a_fxch:	//FXCH
1792
 
1793
				break;
1794
 
1795
			case a_fiadd:	//FIADD
1796
 
1797
				break;
1798
 
1799
				FpuType4(0,0x10);
1800
 
1801
			case a_ficomp:	//FICOMP
1802
 
1803
				break;
1804
 
1805
				FpuType4(0,0x30);
1806
 
1807
			case a_fidivr:	//FIDIVR
1808
 
1809
				break;
1810
 
1811
				FpuType4(1,0);
1812
 
1813
			case a_fimul:	//FIMUL
1814
 
1815
				break;
1816
 
1817
				FpuType4(1,0x10);
1818
 
1819
			case a_fistp:	//FISTP
1820
 
1821
				break;
1822
 
1823
				FpuType4(0,0x20);
1824
 
1825
			case a_fisubr:	//FISUBR
1826
 
1827
				break;
1828
 
1829
			case a_fld:	//FLD
1830
 
1831
				break;
1832
 
1833
				FpuType5(0xDD,0x10);
1834
 
1835
			case a_fstp:	//FSTP
1836
 
1837
				break;
1838
 
1839
			case a_fbld:	//FBLD
1840
 
1841
				break;
1842
 
1843
				FpuType6(0xDF,0X30);
1844
 
1845
			case a_fildq:	//FILDQ
1846
 
1847
				break;
1848
 
1849
				FpuType6(0xD9,0x20);
1850
 
1851
			case a_frstor:	//FRSTOR БЕЗ РАЗМЕРНОСТИ
1852
 
1853
				break;
1854
 
1855
				fwait();
1856
 
1857
				FpuType6(0xDD,0x30);
1858
 
1859
			case a_fstenv:	//FSTENV БЕЗ РАЗМЕРНОСТИ
1860
 
1861
			case a_fnstenv:	//FNSTENV БЕЗ РАЗМЕРНОСТИ
1862
 
1863
				break;
1864
 
1865
			case a_fldcw:	//FLDCW
1866
 
1867
				break;
1868
 
1869
				fwait();
1870
 
1871
				FpuType7(0x38);
1872
 
1873
1874
 
1875
				outword(0xf0d9);	//F2XM1
1876
 
1877
				break;
1878
 
1879
				outword(0xE1D9);	//FABS
1880
 
1881
			case a_fchs:
1882
 
1883
				break;
1884
 
1885
				fwait();
1886
 
1887
//				break;
1888
 
1889
				outword(0xE2DB);	//FNCLEX
1890
 
1891
			case a_fcompp:
1892
 
1893
				break;
1894
 
1895
				outword(0xFFD9);
1896
 
1897
				break;
1898
 
1899
				outword(0xF6D9);	//FDECSTP
1900
 
1901
			case a_fdisi:
1902
 
1903
			case a_fndisi:
1904
 
1905
				break;
1906
 
1907
				fwait();
1908
 
1909
				outword(0xE0DB);	//FENI
1910
 
1911
			case a_fincstr:
1912
 
1913
				break;
1914
 
1915
				fwait();
1916
 
1917
				outword(0xE3DB);	//FNINIT
1918
 
1919
			case a_fldlg2:
1920
 
1921
				break;
1922
 
1923
				outword(0xEDD9);	//FLDLN2
1924
 
1925
			case a_fldl2e:
1926
 
1927
				break;
1928
 
1929
				outword(0xE9D9);	//FLDL2T
1930
 
1931
			case a_fldpi:
1932
 
1933
				break;
1934
 
1935
				outword(0xEED9);	//FLDZ
1936
 
1937
			case a_fld1:
1938
 
1939
				break;
1940
 
1941
				outword(0xD0D9);	//FNOP
1942
 
1943
			case a_fpatan:
1944
 
1945
				break;
1946
 
1947
				outword(0xF8D9);	//FPREM
1948
 
1949
			case a_fprem1:
1950
 
1951
				possiblecpu=3;
1952
 
1953
			case a_fptan:
1954
 
1955
				break;
1956
 
1957
				outword(0xFCD9);	//FRNDINT
1958
 
1959
			case a_fsetpm:
1960
 
1961
			case a_fnsetpm:
1962
 
1963
				possiblecpu=2;
1964
 
1965
			case a_fscale:
1966
 
1967
				break;
1968
 
1969
				outword(0xFED9);
1970
 
1971
				break;
1972
 
1973
				outword(0xFBD9);
1974
 
1975
				break;
1976
 
1977
				outword(0xFAD9);	//FSQRT
1978
 
1979
			case a_fstsw:	//FSTSW
1980
 
1981
			case a_fnstsw:	//FNSTSW
1982
 
1983
				switch(tok){
1984
 
1985
					case tk_intvar:
1986
 
1987
						KillVar(itok.name);
1988
 
1989
						op(0xDD);
1990
 
1991
						outaddress(&itok);
1992
 
1993
					case tk_reg:
1994
 
1995
						else preerror("Use only AX");
1996
 
1997
						break;
1998
 
1999
				}
2000
 
2001
			case a_ftst:
2002
 
2003
				break;
2004
 
2005
				outword(0xE9DA);
2006
 
2007
				break;
2008
 
2009
				outword(0xE5D9);	//FXAM
2010
 
2011
			case a_fxtract:
2012
 
2013
				break;
2014
 
2015
				outword(0xF1D9);	//FYL2X
2016
 
2017
			case a_fyl2xp1:
2018
 
2019
				break;
2020
 
2021
				outword(0x0B0F);	//UD2
2022
 
2023
				break;
2024
 
2025
				outword(0x340F);	//SYSENTER
2026
 
2027
				break;
2028
 
2029
				outword(0x350F);	//SYSEXIT
2030
 
2031
				break;
2032
 
2033
				outword(0x330F);	//RDPMC
2034
 
2035
				break;
2036
 
2037
				i+=8;
2038
 
2039
				i+=8;
2040
 
2041
				i+=8;
2042
 
2043
				FpuType8(0xDB,i);
2044
 
2045
			case a_fcmovu:
2046
 
2047
			case a_fcmovbe:
2048
 
2049
			case a_fcmove:
2050
 
2051
			case a_fcmovb:
2052
 
2053
				break;
2054
 
2055
				i+=8;
2056
 
2057
				FpuType8(0xDB,i+0x28);
2058
 
2059
			case a_fcomip:
2060
 
2061
			case a_fucomip:
2062
 
2063
				break;
2064
 
2065
			case a_cmovno:
2066
 
2067
			case a_cmovnc:
2068
 
2069
			case a_cmovnz:
2070
 
2071
			case a_cmova:
2072
 
2073
			case a_cmovns:
2074
 
2075
			case a_cmovnp:
2076
 
2077
			case a_cmovnl:
2078
 
2079
			case a_cmovg:
2080
 
2081
				possiblecpu=7;
2082
 
2083
			case a_lfence:	//LFENCE
2084
 
2085
				op(0xE8);
2086
 
2087
				break;
2088
 
2089
				outword(0xAE0F);
2090
 
2091
				possiblecpu=9;
2092
 
2093
			case a_sfence:	//SFENCE
2094
 
2095
				op(0xF8);
2096
 
2097
				break;
2098
 
2099
				nexttok();
2100
 
2101
				if(tok!=tk_mmxreg)mmxregexpected(1);
2102
 
2103
				if(tok!=tk_mmxreg)mmxregexpected(2);
2104
 
2105
				op(0xC0+hnumber+itok.number*8);
2106
 
2107
				break;
2108
 
2109
				movxmm3(0xE7,0,tk_mmxreg);
2110
 
2111
				break;
2112
 
2113
				mmxiii(0xE0);
2114
 
2115
			case a_pavgw:
2116
 
2117
				break;
2118
 
2119
				mmxiii(0xDE);
2120
 
2121
			case a_pmaxsw:
2122
 
2123
				break;
2124
 
2125
				mmxiii(0xDA);
2126
 
2127
			case a_pminsw:
2128
 
2129
				break;
2130
 
2131
				mmxiii(0xE4);
2132
 
2133
			case a_psadbw:
2134
 
2135
				break;
2136
 
2137
				prefetch(0x18,1);
2138
 
2139
				break;
2140
 
2141
				prefetch(0x18,2);
2142
 
2143
				break;
2144
 
2145
				prefetch(0x18,3);
2146
 
2147
				break;
2148
 
2149
				prefetch(0x18,0);
2150
 
2151
				break;
2152
 
2153
				pextrw();
2154
 
2155
				break;
2156
 
2157
				pinsrw();
2158
 
2159
				break;
2160
 
2161
				nexttok();
2162
 
2163
				htok=itok.number;
2164
 
2165
				nextexpecting2(tk_camma);
2166
 
2167
					op(0x66);
2168
 
2169
				}
2170
 
2171
					possiblecpu=8;
2172
 
2173
				}
2174
 
2175
				op(rm_mod11+htok*8+itok.number);
2176
 
2177
			case a_pshufw:
2178
 
2179
				next=0;
2180
 
2181
				break;
2182
 
2183
				xmm3instr(0x70,0x66);
2184
 
2185
				next=0;
2186
 
2187
			case a_pshufhw:
2188
 
2189
				possiblecpu=9;
2190
 
2191
				break;
2192
 
2193
				xmm3instr(0x70,0xf2);
2194
 
2195
				next=0;
2196
 
2197
			case a_addpd:
2198
 
2199
				possiblecpu=9;
2200
 
2201
			case a_addps:
2202
 
2203
				possiblecpu=8;
2204
 
2205
			case a_addsd:
2206
 
2207
				possiblecpu=9;
2208
 
2209
			case a_addss:
2210
 
2211
				possiblecpu=8;
2212
 
2213
			case a_addsubpd:
2214
 
2215
				possiblecpu=9;
2216
 
2217
			case a_addsubps:
2218
 
2219
				possiblecpu=9;
2220
 
2221
			case a_andnpd:
2222
 
2223
				possiblecpu=9;
2224
 
2225
			case a_andnps:
2226
 
2227
				possiblecpu=8;
2228
 
2229
			case a_andpd:
2230
 
2231
				possiblecpu=9;
2232
 
2233
			case a_andps:
2234
 
2235
				possiblecpu=8;
2236
 
2237
			case a_comisd:
2238
 
2239
				possiblecpu=9;
2240
 
2241
			case a_comiss:
2242
 
2243
				possiblecpu=8;
2244
 
2245
			case a_divps:
2246
 
2247
				possiblecpu=8;
2248
 
2249
			case a_divsd:
2250
 
2251
				possiblecpu=9;
2252
 
2253
			case a_divss:
2254
 
2255
				possiblecpu=8;
2256
 
2257
			case a_haddpd:
2258
 
2259
				possiblecpu=9;
2260
 
2261
			case a_haddps:
2262
 
2263
				possiblecpu=9;
2264
 
2265
			case a_hsubpd:
2266
 
2267
				possiblecpu=9;
2268
 
2269
			case a_hsubps:
2270
 
2271
				possiblecpu=9;
2272
 
2273
			case a_maskmovdqu:
2274
 
2275
				possiblecpu=9;
2276
 
2277
			case a_maxpd:
2278
 
2279
				possiblecpu=9;
2280
 
2281
			case a_maxps:
2282
 
2283
				possiblecpu=8;
2284
 
2285
			case a_maxsd:
2286
 
2287
				possiblecpu=9;
2288
 
2289
			case a_maxss:
2290
 
2291
				possiblecpu=8;
2292
 
2293
			case a_minpd:
2294
 
2295
				possiblecpu=9;
2296
 
2297
			case a_minps:
2298
 
2299
				possiblecpu=8;
2300
 
2301
			case a_minsd:
2302
 
2303
				possiblecpu=9;
2304
 
2305
			case a_minss:
2306
 
2307
				possiblecpu=8;
2308
 
2309
			case a_mulpd:
2310
 
2311
				possiblecpu=9;
2312
 
2313
			case a_mulps:
2314
 
2315
				possiblecpu=8;
2316
 
2317
			case a_mulsd:
2318
 
2319
				possiblecpu=9;
2320
 
2321
			case a_mulss:
2322
 
2323
				possiblecpu=8;
2324
 
2325
			case a_orpd:
2326
 
2327
				possiblecpu=9;
2328
 
2329
			case a_orps:
2330
 
2331
				possiblecpu=8;
2332
 
2333
			case a_rcpps:
2334
 
2335
				possiblecpu=8;
2336
 
2337
			case a_rcpss:
2338
 
2339
				possiblecpu=8;
2340
 
2341
			case a_rsqrtps:
2342
 
2343
				possiblecpu=8;
2344
 
2345
			case a_rsqrtss:
2346
 
2347
				possiblecpu=8;
2348
 
2349
			case a_sqrtpd:
2350
 
2351
				possiblecpu=9;
2352
 
2353
			case a_sqrtps:
2354
 
2355
				possiblecpu=8;
2356
 
2357
			case a_sqrtsd:
2358
 
2359
				possiblecpu=9;
2360
 
2361
			case a_sqrtss:
2362
 
2363
				possiblecpu=8;
2364
 
2365
			case a_subpd:
2366
 
2367
				possiblecpu=9;
2368
 
2369
			case a_subps:
2370
 
2371
				possiblecpu=8;
2372
 
2373
			case a_subsd:
2374
 
2375
				possiblecpu=9;
2376
 
2377
			case a_subss:
2378
 
2379
				possiblecpu=8;
2380
 
2381
			case a_ucomisd:
2382
 
2383
				possiblecpu=9;
2384
 
2385
			case a_ucomiss:
2386
 
2387
				possiblecpu=8;
2388
 
2389
			case a_unpckhpd:
2390
 
2391
				possiblecpu=9;
2392
 
2393
			case a_unpckhps:
2394
 
2395
				possiblecpu=8;
2396
 
2397
			case a_unpcklpd:
2398
 
2399
				possiblecpu=9;
2400
 
2401
			case a_unpcklps:
2402
 
2403
				possiblecpu=8;
2404
 
2405
			case a_xorpd:
2406
 
2407
				possiblecpu=9;
2408
 
2409
			case a_xorps:
2410
 
2411
				possiblecpu=8;
2412
 
2413
			case a_cmppd:
2414
 
2415
				possiblecpu=9;
2416
 
2417
				break;
2418
 
2419
			case a_cmpltpd:
2420
 
2421
			case a_cmpunordpd:
2422
 
2423
			case a_cmpnltpd:
2424
 
2425
			case a_cmpordpd:
2426
 
2427
				possiblecpu=9;
2428
 
2429
				break;
2430
 
2431
				xmm3instr(0xC2,0);
2432
 
2433
				next=0;
2434
 
2435
			case a_cmpeqps:
2436
 
2437
			case a_cmpleps:
2438
 
2439
			case a_cmpneqps:
2440
 
2441
			case a_cmpnleps:
2442
 
2443
				xmminstr(0xC2,0);
2444
 
2445
				op(htok-a_cmpeqps);
2446
 
2447
			case a_cmpss:
2448
 
2449
				possiblecpu=8;
2450
 
2451
				break;
2452
 
2453
			case a_cmpltss:
2454
 
2455
			case a_cmpunordss:
2456
 
2457
			case a_cmpnltss:
2458
 
2459
			case a_cmpordss:
2460
 
2461
				possiblecpu=9;
2462
 
2463
				break;
2464
 
2465
			case a_cmpltsd:
2466
 
2467
			case a_cmpunordsd:
2468
 
2469
			case a_cmpnltsd:
2470
 
2471
			case a_cmpordsd:
2472
 
2473
				op(htok-a_cmpeqsd);
2474
 
2475
				break;
2476
 
2477
				xmm3instr(0xC6,0x66);
2478
 
2479
				next=0;
2480
 
2481
			case a_shufps:
2482
 
2483
				possiblecpu=8;
2484
 
2485
				break;
2486
 
2487
				xmminstr(0xE6,0xF3);
2488
 
2489
				break;
2490
 
2491
				xmminstr(0x5B,0);
2492
 
2493
				break;
2494
 
2495
				xmminstr(0xE6,0xF2);
2496
 
2497
				break;
2498
 
2499
				xmminstr(0x2d,0x66,tk_mmxreg,tk_xmmreg);
2500
 
2501
				break;
2502
 
2503
				xmminstr(0x5a,0x66);
2504
 
2505
				break;
2506
 
2507
				xmminstr(0x2a,0x66,tk_xmmreg,tk_mmxreg);
2508
 
2509
				break;
2510
 
2511
				xmminstr(0x2a,0,tk_xmmreg,tk_mmxreg);
2512
 
2513
				break;
2514
 
2515
				xmminstr(0x5b,0x66);
2516
 
2517
				break;
2518
 
2519
				xmminstr(0x5a,0);
2520
 
2521
				break;
2522
 
2523
				xmminstr(0x2a,0xf3,tk_xmmreg,tk_reg32);
2524
 
2525
				break;
2526
 
2527
				xmminstr(0x2d,0,tk_mmxreg,tk_xmmreg);
2528
 
2529
				break;
2530
 
2531
				xmminstr(0x2d,0xf2,tk_reg32,tk_xmmreg);
2532
 
2533
				break;
2534
 
2535
				xmminstr(0x5a,0xf2);
2536
 
2537
				break;
2538
 
2539
				xmminstr(0x2a,0xf2,tk_xmmreg,tk_reg32);
2540
 
2541
				break;
2542
 
2543
				xmminstr(0x5a,0xf3);
2544
 
2545
				break;
2546
 
2547
				xmminstr(0x2d,0xf3,tk_reg32,tk_xmmreg);
2548
 
2549
				break;
2550
 
2551
				xmminstr(0x2c,0x66,tk_mmxreg,tk_xmmreg);
2552
 
2553
				break;
2554
 
2555
				xmminstr(0xE6,0x66);
2556
 
2557
				break;
2558
 
2559
				xmminstr(0x5B,0xF3);
2560
 
2561
				break;
2562
 
2563
				xmminstr(0x2c,0,tk_mmxreg,tk_xmmreg);
2564
 
2565
				break;
2566
 
2567
				xmminstr(0x2C,0xF2,tk_reg32,tk_xmmreg);
2568
 
2569
				break;
2570
 
2571
				xmminstr(0x2C,0xF3,tk_reg32,tk_xmmreg);
2572
 
2573
				break;
2574
 
2575
				xmminstr(0x5E,0x66);
2576
 
2577
				break;
2578
 
2579
				xmminstr(0x6D,0x66);
2580
 
2581
				break;
2582
 
2583
				xmminstr(0x6C,0x66);
2584
 
2585
				break;
2586
 
2587
				prefetch(0xAE,1);
2588
 
2589
				break;
2590
 
2591
				prefetch(0xAE,0);
2592
 
2593
				break;
2594
 
2595
				prefetch(0xAE,2);
2596
 
2597
				break;
2598
 
2599
				prefetch(0xAE,3);
2600
 
2601
				break;
2602
 
2603
				prefetch(0xAE,7);
2604
 
2605
				break;
2606
 
2607
				outword(0x010F);
2608
 
2609
				possiblecpu=9;
2610
 
2611
			case a_mwait:
2612
 
2613
				op(0xc9);
2614
 
2615
				break;
2616
 
2617
				movxmm4(0xF0,0xF2);
2618
 
2619
				break;
2620
 
2621
				xmm2xmm(0x12);
2622
 
2623
				break;
2624
 
2625
				xmm2xmm(0x16);
2626
 
2627
				break;
2628
 
2629
				xmm2xmm(0x50,0,tk_reg32);
2630
 
2631
				break;
2632
 
2633
				movxmm3(0xE7,0x66);
2634
 
2635
				break;
2636
 
2637
				movxmm3(0x2B,0x66);
2638
 
2639
				break;
2640
 
2641
				movxmm3(0x2b,0);
2642
 
2643
				break;
2644
 
2645
				movxmm(0x28,0x66);
2646
 
2647
				break;
2648
 
2649
				movxmm(0x28,0);
2650
 
2651
 
2652
 
2653
				movxmm(0x6f,0x66,0x10);
2654
 
2655
				break;
2656
 
2657
				xmminstr(0x12,0xF2);
2658
 
2659
				break;
2660
 
2661
				xmminstr(0x16,0xF3);
2662
 
2663
				break;
2664
 
2665
				xmminstr(0x12,0xF3);
2666
 
2667
				break;
2668
 
2669
				movxmm(0x6f,0xf3,0x10);
2670
 
2671
				break;
2672
 
2673
				xmm2xmm(0xd6,0xf2,tk_mmxreg);
2674
 
2675
				break;
2676
 
2677
				movxmm2(0x16,0x66);
2678
 
2679
				break;
2680
 
2681
				movxmm2(0x12,0x66);
2682
 
2683
				break;
2684
 
2685
				xmm2xmm(0x50,0x66,tk_reg32);
2686
 
2687
				break;
2688
 
2689
				movxmm3(0xC3,0,tk_reg32);
2690
 
2691
				break;
2692
 
2693
				nexttok();
2694
 
2695
				if(tok!=tk_xmmreg)xmmregexpected(1);
2696
 
2697
				if(tok!=tk_mmxreg)mmxregexpected(2);
2698
 
2699
				outword(0xD60F);
2700
 
2701
				possiblecpu=9;
2702
 
2703
			case a_movupd:
2704
 
2705
				possiblecpu=9;
2706
 
2707
			case a_movups:
2708
 
2709
				possiblecpu=8;
2710
 
2711
			case a_movss:
2712
 
2713
				possiblecpu=8;
2714
 
2715
			case a_movhps:
2716
 
2717
				possiblecpu=8;
2718
 
2719
			case a_movlps:
2720
 
2721
				possiblecpu=8;
2722
 
2723
2724
 
2725
			default:
2726
 
2727
				break;
2728
 
2729
		asmparam=FALSE;
2730
 
2731
		if(next)nexttok();
2732
 
2733
	else if(tok==tk_seg){
2734
 
2735
			case ES: op(0x26); break;
2736
 
2737
			case CS: op(0x2E); break;
2738
 
2739
			case FS: op(0x64);
2740
 
2741
				break;
2742
 
2743
				if(cpu<3)cpu=3;
2744
 
2745
			default: beep(); break;
2746
 
2747
		nextexpecting2(tk_colon);
2748
 
2749
	else if(tok==tk_locallabel)define_locallabel();
2750
 
2751
		nexttok();
2752
 
2753
	}
2754
 
2755
	if(tok==tk_semicolon)nexttok();
2756
 
2757
2758
 
2759
{
2760
 
2761
int reg;
2762
 
2763
	if(tok==tk_reg)type=r16;
2764
 
2765
	reg=itok.number;
2766
 
2767
	nextexpecting2(tk_camma);
2768
 
2769
	switch(tok){
2770
 
2771
			if(type==r32)reg32expected(2);
2772
 
2773
		case tk_reg32:
2774
 
2775
regs:
2776
 
2777
			op(0x40+num);
2778
 
2779
			break;
2780
 
2781
		case tk_intvar:
2782
 
2783
			CheckAllMassiv(bufrm,2,&strinf);
2784
 
2785
		case tk_dwordvar:
2786
 
2787
			if(type==r16)wordvalexpected();
2788
 
2789
dwords:
2790
 
2791
			op(0x0F);
2792
 
2793
			op(itok.rm+reg*8);
2794
 
2795
			break;
2796
 
2797
			varexpected(2);
2798
 
2799
	}
2800
 
2801
2802
 
2803
int GetOperand(int code)
2804
 
2805
	switch(code){
2806
 
2807
		case a_add: return tk_plus;
2808
 
2809
		case a_and:	return tk_and;
2810
 
2811
		case a_sub:	return tk_minus;
2812
 
2813
		case a_not:	return tk_not;
2814
 
2815
		case a_shl:	return tk_ll;
2816
 
2817
	}
2818
 
2819
}
2820
 
2821
2822
 
2823
{
2824
 
2825
int htok,typet=r16;
2826
 
2827
char *hbuf;
2828
 
2829
unsigned char next=1;
2830
 
2831
#ifdef OPTVARCONST
2832
 
2833
int operand=GetOperand(basecode/8);
2834
 
2835
	nexttok();
2836
 
2837
	htok=tok;
2838
 
2839
	bufrm=NULL;
2840
 
2841
	strinf.bufstr=NULL;
2842
 
2843
int i=tok;
2844
 
2845
		case tk_reg:
2846
 
2847
		  switch(tok){
2848
 
2849
					strcpy(hstok.name,itok.name);
2850
 
2851
					goto wnum;
2852
 
2853
					if(tok2!=tk_number){
2854
 
2855
						break;
2856
 
2857
				case tk_number:
2858
 
2859
					asmparam=FALSE;
2860
 
2861
					next=0;
2862
 
2863
					if(hstok.number==AX){
2864
 
2865
						if((postnumflag&f_reloc)!=0)AddReloc();
2866
 
2867
						outword(holdnumber2);
2868
 
2869
					else{
2870
 
2871
							op(128+2+1);
2872
 
2873
							op(holdnumber2);
2874
 
2875
						else{
2876
 
2877
							op(128+64+hstok.number+basecode);
2878
 
2879
							if(i==tk_undefofs)AddUndefOff(2,hstok.name);
2880
 
2881
						}
2882
 
2883
					break;
2884
 
2885
					op66(r16);
2886
 
2887
					else{
2888
 
2889
						op(128+64+hstok.number+basecode);
2890
 
2891
					(itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number);
2892
 
2893
					break;
2894
 
2895
					op66(r16);
2896
 
2897
					op(128+64+(unsigned int)itok.number+hstok.number*8);
2898
 
2899
				case tk_wordvar:
2900
 
2901
					CheckAllMassiv(bufrm,2,&strinf);
2902
 
2903
					outseg(&itok,2);
2904
 
2905
					op(itok.rm+hstok.number*8);
2906
 
2907
					break;
2908
 
2909
			}
2910
 
2911
		case tk_reg32:
2912
 
2913
			switch(tok){
2914
 
2915
					strcpy(hstok.name,itok.name);
2916
 
2917
					goto dnum;
2918
 
2919
					i=tk_number;
2920
 
2921
						dwordvalexpected();
2922
 
2923
					}
2924
 
2925
dnum:
2926
 
2927
					asmparam=FALSE;
2928
 
2929
					next=0;
2930
 
2931
						op(128+2+1);
2932
 
2933
						op((int)longholdnumber);
2934
 
2935
					else{
2936
 
2937
						else{
2938
 
2939
							op(128+64+hstok.number+basecode);
2940
 
2941
						if((postnumflag&f_reloc)!=0)AddReloc();
2942
 
2943
						outdword(longholdnumber);
2944
 
2945
					break;
2946
 
2947
					op66(r32);
2948
 
2949
					else{
2950
 
2951
						op(128+64+hstok.number+basecode);
2952
 
2953
					(itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number);
2954
 
2955
					break;
2956
 
2957
					op66(r32);
2958
 
2959
					op(128+64+(unsigned int)itok.number+hstok.number*8);
2960
 
2961
				case tk_dwordvar:
2962
 
2963
					CheckAllMassiv(bufrm,4,&strinf);
2964
 
2965
					outseg(&itok,2);
2966
 
2967
					op(itok.rm+hstok.number*8);
2968
 
2969
					break;
2970
 
2971
			}
2972
 
2973
			break;
2974
 
2975
			if((basecode/8)!=a_cmp)ClearReg(hstok.number>3?hstok.number-4:hstok.number);
2976
 
2977
				case tk_minus:
2978
 
2979
						bytevalexpected(2);
2980
 
2981
					}
2982
 
2983
					asmparam=FALSE;
2984
 
2985
					next=0;
2986
 
2987
					else{
2988
 
2989
						op(128+64+hstok.number+basecode);
2990
 
2991
					op(holdnumber2);
2992
 
2993
				case tk_beg:
2994
 
2995
					op(128+64+(unsigned int)itok.number+hstok.number*8);
2996
 
2997
				case tk_bytevar:
2998
 
2999
					CheckAllMassiv(bufrm,1,&strinf);
3000
 
3001
					op(2+basecode);
3002
 
3003
					outaddress(&itok);
3004
 
3005
				default: bytevalexpected(2); break;
3006
 
3007
			break;
3008
 
3009
		case tk_longvar:
3010
 
3011
			if(cpu<3)cpu=3;
3012
 
3013
		case tk_wordvar:
3014
 
3015
			CheckAllMassiv(hbuf,typet,&hstr,&hstok);
3016
 
3017
			outseg(&hstok,2);
3018
 
3019
				case tk_undefofs:
3020
 
3021
					tok=tk_number;
3022
 
3023
				case tk_minus:
3024
 
3025
				case tk_number:
3026
 
3027
					asmparam=FALSE;
3028
 
3029
#ifdef OPTVARCONST
3030
 
3031
						initconst=UpdVarConst(&hstok,holdnumber2,tk_dword,operand);
3032
 
3033
#endif
3034
 
3035
					if(i!=tk_undefofs&&(postnumflag&f_reloc)==0&&short_ok(holdnumber2,typet/2-1)){
3036
 
3037
						op(hstok.rm+basecode);
3038
 
3039
						op(holdnumber2);
3040
 
3041
					else{
3042
 
3043
						op(hstok.rm+basecode);
3044
 
3045
						if((postnumflag&f_reloc)!=0)AddReloc();
3046
 
3047
						if(typet==r16)outword(holdnumber2);
3048
 
3049
					}
3050
 
3051
				case tk_postnumber:
3052
 
3053
					op(128+1);
3054
 
3055
					outaddress(&hstok);
3056
 
3057
					if(typet==r16)outword(itok.number);
3058
 
3059
					break;
3060
 
3061
					if(typet==r16)goto erval;
3062
 
3063
					op(1+basecode);
3064
 
3065
					outaddress(&hstok);
3066
 
3067
				default:
3068
 
3069
					if(typet==r16)wordvalexpected();
3070
 
3071
					break;
3072
 
3073
#ifdef OPTVARCONST
3074
 
3075
#endif
3076
 
3077
			break;
3078
 
3079
		case tk_charvar:
3080
 
3081
			CheckAllMassiv(hbuf,1,&hstr,&hstok);
3082
 
3083
				case tk_minus:
3084
 
3085
						bytevalexpected(2);
3086
 
3087
					}
3088
 
3089
					asmparam=FALSE;
3090
 
3091
#ifdef OPTVARCONST
3092
 
3093
						initconst=UpdVarConst(&hstok,holdnumber2,tk_byte,operand);
3094
 
3095
#endif
3096
 
3097
					outseg(&hstok,2);
3098
 
3099
					op(hstok.rm+basecode);
3100
 
3101
					op(holdnumber2);
3102
 
3103
				case tk_beg:
3104
 
3105
					op(basecode);
3106
 
3107
					outaddress(&hstok);
3108
 
3109
				default: bytevalexpected(2); break;
3110
 
3111
#ifdef OPTVARCONST
3112
 
3113
#endif
3114
 
3115
		default: varexpected(1);	break;
3116
 
3117
	if(next)nexttok();
3118
 
3119
3120
 
3121
{
3122
 
3123
	CheckIP();
3124
 
3125
	ClearLVIC();
3126
 
3127
	clearregstat();
3128
 
3129
		case tk_proc:
3130
 
3131
			if(itok.segm!=NOT_DYNAMIC){
3132
 
3133
				itok.segm=ptr->recsegm=DYNAMIC_USED;
3134
 
3135
				goto undefproc;
3136
 
3137
			jumploc(itok.number);	//на процедуры опр ранеее
3138
 
3139
		case tk_number:
3140
 
3141
			jumploc(doconstlongmath());//на конкретный адрес
3142
 
3143
			break;
3144
 
3145
			addlocaljump(CALL_SHORT); //возможную локальную метку
3146
 
3147
			break;
3148
 
3149
			tobedefined(CALL_SHORT,tk_void);//возможно обьявленую метку
3150
 
3151
			break;
3152
 
3153
			tok=tk_undefproc;
3154
 
3155
		case tk_locallabel:
3156
 
3157
undefproc:
3158
 
3159
			outword(0x00EB);	// JMP SHORT
3160
 
3161
		default: shortjumperror(); break;
3162
 
3163
	return next;
3164
 
3165
3166
 
3167
{
3168
 
3169
unsigned long hnumber;
3170
 
3171
	CheckIP();
3172
 
3173
	ClearLVIC();
3174
 
3175
	clearregstat();
3176
 
3177
		case tk_declare:
3178
 
3179
				tok=tk_undefproc;
3180
 
3181
			}
3182
 
3183
		case tk_undefproc:
3184
 
3185
				asmparam=FALSE;
3186
 
3187
				break;
3188
 
3189
			if(faradd==0){
3190
 
3191
				jumploc0();
3192
 
3193
			else invalidfarjumpitem();
3194
 
3195
		case tk_proc:
3196
 
3197
				doanyproc(TRUE);
3198
 
3199
			}
3200
 
3201
				idrec *ptr=itok.rec;
3202
 
3203
				itok.rm=tok=tk_undefofs;	//смещение еще не известной метки
3204
 
3205
					addacall((unsigned int)itok.number,(unsigned char)((itok.flag&f_extern)!=0?CALL_EXT:(am32==FALSE?JMP_NEAR:JMP_32)));
3206
 
3207
					break;
3208
 
3209
			}
3210
 
3211
			if(faradd==0)jumploc(itok.number);
3212
 
3213
			break;
3214
 
3215
			asmparam=FALSE;
3216
 
3217
				if(doanyundefproc(TRUE)==tokens)next=0;
3218
 
3219
			else{
3220
 
3221
					outword(0x25ff);
3222
 
3223
				}
3224
 
3225
					addacall(itok.number,(unsigned char)CALL_32);
3226
 
3227
				}
3228
 
3229
			break;
3230
 
3231
			if(tok2!=tk_number)goto err;
3232
 
3233
			asmparam=FALSE;
3234
 
3235
			if(faradd==0)jumploc(hnumber);
3236
 
3237
				op(0xEA);
3238
 
3239
				int htok=tok;
3240
 
3241
				if(tok==tk_undefofs){
3242
 
3243
					strcpy(name,itok.name);
3244
 
3245
				unsigned long tempi=doconstdwordmath();
3246
 
3247
				if(htok==tk_undefofs)AddUndefOff(2,name);
3248
 
3249
				else outdword(tempi);
3250
 
3251
			}
3252
 
3253
			break;	 /* JMP num */
3254
 
3255
			if(faradd==0){
3256
 
3257
				(itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number);
3258
 
3259
				else outdword(itok.number);
3260
 
3261
			else invalidfarjumpitem();
3262
 
3263
		case tk_reg32:
3264
 
3265
			goto jmpreg;
3266
 
3267
			op66(r16);
3268
 
3269
			if(faradd==0){
3270
 
3271
				op(0xE0+(unsigned int)itok.number);
3272
 
3273
			else invalidfarjumpitem();
3274
 
3275
		case tk_ID:
3276
 
3277
				addlocaljump(am32==FALSE?JMP_NEAR:JMP_32);
3278
 
3279
			} 		 /* JMP num */
3280
 
3281
			break;
3282
 
3283
			if(faradd==0){
3284
 
3285
				jumploc0();
3286
 
3287
			else invalidfarjumpitem();
3288
 
3289
		case tk_dwordvar:
3290
 
3291
			i=2;
3292
 
3293
		case tk_wordvar:
3294
 
3295
			CheckAllMassiv(bufrm,i,&strinf);
3296
 
3297
			op(0xFF);  op(0x20+itok.rm+(faradd==0?(i==4&&am32==0?8:0):8));
3298
 
3299
			break;
3300
 
3301
err:
3302
 
3303
			break;
3304
 
3305
	return next;
3306
 
3307
3308
 
3309
{
3310
 
3311
	nexttok();
3312
 
3313
	if(tok!=tk_reg32&&tok!=tk_reg)reg32regexpected(1);
3314
 
3315
	ClearReg(itok.number);
3316
 
3317
	switch(tok){
3318
 
3319
		case tk_wordvar:
3320
 
3321
		case tk_bytevar:
3322
 
3323
		case tk_dwordvar:
3324
 
3325
		default: varexpected(2);
3326
 
3327
	CheckAllMassiv(bufrm,2,&strinf);
3328
 
3329
	else outseg(&itok,3);
3330
 
3331
	if(out2!=0)op(out2);
3332
 
3333
	outaddress(&itok);
3334
 
3335
3336
 
3337
{
3338
 
3339
int htok,typet=r16;
3340
 
3341
	hnumber=itok.number;
3342
 
3343
	htok=tok;
3344
 
3345
	switch(htok){
3346
 
3347
			typet=r32;
3348
 
3349
		case tk_reg:
3350
 
3351
				case tk_reg32:
3352
 
3353
				case tk_reg:
3354
 
3355
					op(0xf);
3356
 
3357
					op(0xc0+(unsigned int)itok.number+hnumber*8);
3358
 
3359
				case tk_dwordvar:
3360
 
3361
					if(typet==r16)goto erval;
3362
 
3363
				case tk_intvar:
3364
 
3365
					op66(typet);
3366
 
3367
					op(0xf);
3368
 
3369
					op(itok.rm+hnumber*8);
3370
 
3371
					break;
3372
 
3373
erval:
3374
 
3375
					else dwordvalexpected();
3376
 
3377
			}
3378
 
3379
		default: reg32regexpected(1);
3380
 
3381
	if(cpu<3)cpu=3;
3382
 
3383
3384
 
3385
{
3386
 
3387
int htok;
3388
 
3389
unsigned char next=1;
3390
 
3391
SINFO hstr;
3392
 
3393
	hstok=itok;
3394
 
3395
	hbuf=bufrm;
3396
 
3397
	hstr=strinf;
3398
 
3399
	nextexpecting2(tk_camma);
3400
 
3401
		case tk_reg32:
3402
 
3403
			op66(htok==tk_reg?r16:r32);
3404
 
3405
		  switch(tok){
3406
 
3407
					asmparam=FALSE;
3408
 
3409
					next=0;
3410
 
3411
					op(0xe0+code+hstok.number);
3412
 
3413
					break;
3414
 
3415
					if(tok!=htok){
3416
 
3417
						break;
3418
 
3419
				case tk_reg:
3420
 
3421
					op(0xf);
3422
 
3423
					op(0xc0+hstok.number+(unsigned int)itok.number*8);
3424
 
3425
				default: wordvalexpected(); break;
3426
 
3427
			break;
3428
 
3429
		case tk_wordvar:
3430
 
3431
			if(code)KillVar(hstok.name);
3432
 
3433
			switch(tok){
3434
 
3435
varc:
3436
 
3437
					holdnumber2=doconstlongmath();
3438
 
3439
					outseg(&hstok,3);
3440
 
3441
					op(hstok.rm+code+0x20);
3442
 
3443
					op(holdnumber2);
3444
 
3445
				case tk_reg:
3446
 
3447
					outseg(&hstok,3);
3448
 
3449
					op(0xa3+code);
3450
 
3451
					outaddress(&hstok);
3452
 
3453
				default: wordvalexpected(); break;
3454
 
3455
#ifdef OPTVARCONST
3456
 
3457
#endif
3458
 
3459
		case tk_dwordvar:
3460
 
3461
			CheckAllMassiv(hbuf,4,&hstr,&hstok);
3462
 
3463
			op66(r32);
3464
 
3465
			if(tok==tk_reg32)goto varreg;
3466
 
3467
			break;
3468
 
3469
	}
3470
 
3471
	if(next)nexttok();
3472
 
3473
3474
 
3475
{
3476
 
3477
#ifdef OPTVARCONST
3478
 
3479
#endif
3480
 
3481
	switch(tok){
3482
 
3483
			if(cpu<3)cpu=3;
3484
 
3485
		case tk_reg:
3486
 
3487
			op66(razr);
3488
 
3489
			break;
3490
 
3491
			ClearReg(itok.number);
3492
 
3493
			break;
3494
 
3495
		case tk_bytevar:
3496
 
3497
			UpdVarConst(&itok,1,tk_byte,operand);
3498
 
3499
			CheckAllMassiv(bufrm,1,&strinf);
3500
 
3501
			outseg(&itok,2);
3502
 
3503
			op(itok.rm+basecode);
3504
 
3505
			break;
3506
 
3507
		case tk_dwordvar:
3508
 
3509
			if(cpu<3)cpu=3;
3510
 
3511
			goto dec;
3512
 
3513
		case tk_wordvar:
3514
 
3515
dec:
3516
 
3517
			UpdVarConst(&itok,1,tk_dword,operand);
3518
 
3519
			KillVar(itok.name);
3520
 
3521
			outseg(&itok,2);
3522
 
3523
			op(itok.rm+basecode);
3524
 
3525
			break;
3526
 
3527
	}
3528
 
3529
3530
 
3531
{
3532
 
3533
#ifdef OPTVARCONST
3534
 
3535
#endif
3536
 
3537
	switch(tok){
3538
 
3539
			if(cpu<3)cpu=3;
3540
 
3541
		case tk_reg:
3542
 
3543
			op66(razr);
3544
 
3545
		case tk_beg:
3546
 
3547
			op(246); op(128+64+basecode+(unsigned int)itok.number); break;
3548
 
3549
		case tk_charvar:
3550
 
3551
#ifdef OPTVARCONST
3552
 
3553
#endif
3554
 
3555
			KillVar(itok.name);
3556
 
3557
			op(246);
3558
 
3559
			outaddress(&itok);
3560
 
3561
			break;
3562
 
3563
		case tk_dwordvar:
3564
 
3565
			if(cpu<3)cpu=3;
3566
 
3567
			goto neg;
3568
 
3569
		case tk_wordvar:
3570
 
3571
neg:
3572
 
3573
			UpdVarConst(&itok,0,tk_dword,operand);
3574
 
3575
			KillVar(itok.name);
3576
 
3577
			outseg(&itok,2);
3578
 
3579
			op(itok.rm+basecode);
3580
 
3581
			break;
3582
 
3583
	}
3584
 
3585
		ClearReg(AX);
3586
 
3587
 
3588
 
3589
3590
 
3591
{
3592
 
3593
unsigned int address;
3594
 
3595
	ClearLVIC();
3596
 
3597
	nexttok();
3598
 
3599
		preerror("FAR jump not available for this instruction");
3600
 
3601
	}
3602
 
3603
		shortjump=0;
3604
 
3605
	}
3606
 
3607
	if(shortjump){
3608
 
3609
		switch(tok){
3610
 
3611
				*(unsigned int *)&itok.number-=outptr+2;
3612
 
3613
					op(shortcode);
3614
 
3615
				}
3616
 
3617
				break;
3618
 
3619
				asmparam=FALSE;
3620
 
3621
				if(short_ok(address)){
3622
 
3623
					op(address);
3624
 
3625
				else shortjumptoolarge();
3626
 
3627
				break;
3628
 
3629
				addlocaljump(CALL_SHORT);
3630
 
3631
				break;
3632
 
3633
				tobedefined(CALL_SHORT,tk_void);
3634
 
3635
				break;
3636
 
3637
				tok=tk_undefproc;
3638
 
3639
			case tk_locallabel:
3640
 
3641
				addacall((unsigned int)itok.number,(unsigned char)((itok.flag&f_extern)!=0?CALL_EXT:CALL_SHORT));
3642
 
3643
				break;
3644
 
3645
		}
3646
 
3647
	else if(nearcode!=0){
3648
 
3649
		asmparam=FALSE;
3650
 
3651
			case tk_proc:
3652
 
3653
				numlong=itok.number-outptr-2;
3654
 
3655
 
3656
 
3657
			case tk_number:
3658
 
3659
				numlong=doconstdwordmath()-outptr-2;
3660
 
3661
				else outdword(numlong-2);
3662
 
3663
				break;
3664
 
3665
				op(0xF); op(nearcode);
3666
 
3667
				outword(-(int)(outptr-2));
3668
 
3669
				break;
3670
 
3671
				op(0xF); op(nearcode);
3672
 
3673
				numlong=itok.number-outptr-2;
3674
 
3675
 
3676
 
3677
			case tk_ID:
3678
 
3679
				addlocaljump(am32==FALSE?CALL_NEAR:CALL_32);
3680
 
3681
				if(am32!=FALSE)outword(0x0000);
3682
 
3683
			case tk_id:
3684
 
3685
				tobedefined(am32==FALSE?CALL_NEAR:CALL_32,tk_void);
3686
 
3687
				if(am32!=FALSE)outword(0x0000);
3688
 
3689
			case tk_declare:
3690
 
3691
				updatetree();
3692
 
3693
			case tk_undefproc:
3694
 
3695
				addacall((unsigned int)itok.number,(unsigned char)((itok.flag&f_extern)!=0?CALL_EXT:(am32==FALSE?CALL_NEAR:CALL_32)));
3696
 
3697
				if(am32!=FALSE)outword(0x0000);
3698
 
3699
			default: preerror("Invalid operand for NEAR jump"); break;
3700
 
3701
		if(cpu<3)cpu=3;
3702
 
3703
	else preerror("NEAR jump not available for this instruction");
3704
 
3705
}
3706
 
3707
void lar_lsl(int code)
3708
 
3709
unsigned char possiblecpu=0;
3710
 
3711
	nexttok();
3712
 
3713
	int htok=tok;
3714
 
3715
	ClearReg(itok.number);
3716
 
3717
	switch(tok){
3718
 
3719
			if(htok==tk_reg)reg32expected(1);
3720
 
3721
			razr=r32;
3722
 
3723
		case tk_reg:
3724
 
3725
			possiblecpu=2;
3726
 
3727
 
3728
 
3729
			op(code);
3730
 
3731
			break;
3732
 
3733
		case tk_dwordvar:
3734
 
3735
			CheckAllMassiv(bufrm,4,&strinf);
3736
 
3737
			razr=r32;
3738
 
3739
		case tk_intvar:
3740
 
3741
			if(htok==tk_reg32)regexpected(1);
3742
 
3743
			CheckAllMassiv(bufrm,2,&strinf);
3744
 
3745
 
3746
 
3747
			op(0x0f);
3748
 
3749
			op(itok.rm+hnumber*8);
3750
 
3751
			break;
3752
 
3753
	}
3754
 
3755
}
3756
 
3757
unsigned char tabldeckr(int code)
3758
 
3759
unsigned int i=0;
3760
 
3761
unsigned char next=1;
3762
 
3763
	nexttok();
3764
 
3765
	KillVar(itok.name);
3766
 
3767
		case tk_longvar:
3768
 
3769
			i=2;
3770
 
3771
		case tk_wordvar:
3772
 
3773
		case tk_charvar:
3774
 
3775
			i++;
3776
 
3777
			outseg(&itok,3);
3778
 
3779
			op(itok.rm+code);
3780
 
3781
			break;
3782
 
3783
			strcpy(name,itok.name);
3784
 
3785
		case tk_number:
3786
 
3787
			outword(0x010f);
3788
 
3789
		 	if(postnumflag&f_reloc)AddReloc();
3790
 
3791
			if(am32)outdword(i);
3792
 
3793
			next=0;
3794
 
3795
		default: varexpected(0);
3796
 
3797
	if(cpu<2)cpu=2;
3798
 
3799
}
3800
 
3801
void  protectinstr(int code,int code2)
3802
 
3803
int i=0;
3804
 
3805
	switch(tok){
3806
 
3807
		case tk_dwordvar:
3808
 
3809
		case tk_intvar:
3810
 
3811
			i++;
3812
 
3813
		case tk_bytevar:
3814
 
3815
#ifdef OPTVARCONST
3816
 
3817
#endif
3818
 
3819
			KillVar(itok.name);
3820
 
3821
			op(0x0f);
3822
 
3823
			op(itok.rm+code2);
3824
 
3825
			break;
3826
 
3827
		case tk_reg:
3828
 
3829
			op(0x0f);
3830
 
3831
			op(0xc0+code2+(unsigned int)itok.number);
3832
 
3833
		default: wordvalexpected();
3834
 
3835
	if(cpu<2)cpu=2;
3836
 
3837
3838
 
3839
{
3840
 
3841
int htok,typet;
3842
 
3843
char *hbuf;
3844
 
3845
#ifdef OPTVARCONST
3846
 
3847
#endif
3848
 
3849
	hstok=itok;
3850
 
3851
	hbuf=bufrm;
3852
 
3853
	hstr=strinf;
3854
 
3855
	nextexpecting2(tk_camma);
3856
 
3857
int i=tok;
3858
 
3859
		case tk_reg32:
3860
 
3861
			typet=r32;
3862
 
3863
			switch(tok){
3864
 
3865
					ClearReg(hstok.number);
3866
 
3867
					outword(0x210F);
3868
 
3869
					possiblecpu=4;
3870
 
3871
					   ||(unsigned int)itok.number==DR7)possiblecpu=3;
3872
 
3873
				case tk_controlreg:
3874
 
3875
					if(typet==r16)goto erreg;
3876
 
3877
					op(128+64+(unsigned int)itok.number*8+hstok.number);
3878
 
3879
					if((unsigned int)itok.number<=CR3)possiblecpu=3;
3880
 
3881
				case tk_testreg:
3882
 
3883
					if(typet==r16)goto erreg;
3884
 
3885
					op(128+64+(unsigned int)itok.number*8+hstok.number);
3886
 
3887
					if((unsigned int)itok.number==TR6||(unsigned int)itok.number==TR7)possiblecpu=3;
3888
 
3889
				case tk_reg32:
3890
 
3891
				case tk_reg:
3892
 
3893
					op66(typet);
3894
 
3895
					op(128+64+(unsigned int)itok.number*8+hstok.number);
3896
 
3897
				case tk_undefofs:
3898
 
3899
					tok=tk_number;
3900
 
3901
				case tk_minus:
3902
 
3903
						wordvalexpected();
3904
 
3905
					}
3906
 
3907
wnum:
3908
 
3909
					op(0xB8+hstok.number);
3910
 
3911
					asmparam=FALSE;
3912
 
3913
					next=0;
3914
 
3915
				case tk_postnumber:
3916
 
3917
					op66(typet);
3918
 
3919
					(itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number);
3920
 
3921
					else outword((unsigned int)itok.number);
3922
 
3923
				case tk_dwordvar:
3924
 
3925
					if(typet==r16)goto erreg;
3926
 
3927
				case tk_intvar:
3928
 
3929
					IDZToReg(itok.name,hstok.number,typet);
3930
 
3931
					if(hstok.number==0&&((itok.rm==rm_d16&&itok.sib==CODE16)||(itok.rm==rm_d32&&(itok.sib==CODE32||itok.sib==0)))){
3932
 
3933
						op(0xA1);
3934
 
3935
					else{
3936
 
3937
						op(0x8B);
3938
 
3939
					}
3940
 
3941
					break;
3942
 
3943
					if(typet==r32)goto erreg;
3944
 
3945
					op66(r16);
3946
 
3947
					op(128+64+(unsigned int)itok.number*8+hstok.number);
3948
 
3949
					break;
3950
 
3951
erreg:
3952
 
3953
			}
3954
 
3955
		case tk_beg:
3956
 
3957
			switch(tok){
3958
 
3959
						op(0x88);
3960
 
3961
					break;
3962
 
3963
					op(0xB0+hstok.number);
3964
 
3965
					op((int)doconstlongmath());
3966
 
3967
					break;
3968
 
3969
				case tk_charvar:
3970
 
3971
					if(hstok.number==0&&((itok.rm==rm_d16&&itok.sib==CODE16)||(itok.rm==rm_d32&&(itok.sib==CODE32||itok.sib==0)))){
3972
 
3973
						op(0xA0);
3974
 
3975
					else{
3976
 
3977
						op(0x8A);
3978
 
3979
					}
3980
 
3981
					break;
3982
 
3983
			}
3984
 
3985
		case tk_seg:
3986
 
3987
				invalidoperand(1); break;
3988
 
3989
			switch(tok){
3990
 
3991
					op66(r16);
3992
 
3993
					op(128+64+hstok.number*8+(unsigned int)itok.number);
3994
 
3995
					break;
3996
 
3997
				case tk_intvar:
3998
 
3999
					op66(r16);
4000
 
4001
					op(0x8E);
4002
 
4003
					outaddress(&itok);
4004
 
4005
					break;
4006
 
4007
			}
4008
 
4009
		case tk_dwordvar:
4010
 
4011
			possiblecpu=3;
4012
 
4013
		case tk_wordvar:
4014
 
4015
			KillVar(itok.name);
4016
 
4017
			op66(typet);
4018
 
4019
				case tk_reg32:
4020
 
4021
				case tk_reg:
4022
 
4023
					AddRegVar(itok.number,typet,&hstok);
4024
 
4025
						outseg(&hstok,1);
4026
 
4027
						outaddress(&hstok);
4028
 
4029
					else{
4030
 
4031
						op(0x89);
4032
 
4033
						outaddress(&hstok);
4034
 
4035
					break;
4036
 
4037
					strcpy(hstok.name,itok.name);
4038
 
4039
					goto vnum;
4040
 
4041
					if(tok2!=tk_number){
4042
 
4043
						break;
4044
 
4045
				case tk_number:
4046
 
4047
					outseg(&hstok,2);
4048
 
4049
					op(hstok.rm);
4050
 
4051
					asmparam=FALSE;
4052
 
4053
					unsigned long t;
4054
 
4055
					if(typet==r16)t&=0xffff;
4056
 
4057
					if((i==tk_number||i==tk_minus)&&(postnumflag&f_reloc)){
4058
 
4059
						initconst=TRUE;
4060
 
4061
#else
4062
 
4063
#endif
4064
 
4065
					break;
4066
 
4067
					outseg(&hstok,2);
4068
 
4069
					op(hstok.rm);
4070
 
4071
					(itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number);
4072
 
4073
					else outdword(itok.number);
4074
 
4075
				case tk_seg:
4076
 
4077
					if(typet==r32)goto ervar;
4078
 
4079
					op(hstok.rm+(unsigned int)itok.number*8);
4080
 
4081
					if(hstok.number==FS||hstok.number==GS)possiblecpu=3;
4082
 
4083
				default:
4084
 
4085
					invalidoperand(2); break;
4086
 
4087
#ifdef OPTVARCONST
4088
 
4089
#endif
4090
 
4091
		case tk_charvar:
4092
 
4093
			KillVar(itok.name);
4094
 
4095
			switch(tok){
4096
 
4097
			/*if(tok==tk_beg&&hbuf==NULL&&hstr.bufstr==NULL)*/
4098
 
4099
					if(itok.number==0&&((hstok.rm==rm_d16&&hstok.sib==CODE16)||(hstok.rm==rm_d32&&(hstok.sib==CODE32||hstok.sib==0)))){
4100
 
4101
						op(0xA2);
4102
 
4103
					}
4104
 
4105
						outseg(&hstok,2);
4106
 
4107
						op(hstok.rm+(unsigned int)itok.number*8);
4108
 
4109
					}
4110
 
4111
				case tk_number:
4112
 
4113
					op(0xC6);
4114
 
4115
					outaddress(&hstok);
4116
 
4117
#ifdef OPTVARCONST
4118
 
4119
					t=doconstlongmath()&0xff;
4120
 
4121
					if((postnumflag&f_reloc)){
4122
 
4123
						Const2Var(&hstok,t,tk_byte);
4124
 
4125
#else
4126
 
4127
#endif
4128
 
4129
					break;
4130
 
4131
			}
4132
 
4133
			if(initconst==FALSE)ClearVarByNum(&hstok);
4134
 
4135
			break;
4136
 
4137
			if(tok==tk_reg32){
4138
 
4139
				op(128+64+hstok.number*8+(unsigned int)itok.number);
4140
 
4141
				if(hstok.number<=DR3||hstok.number==DR6||hstok.number==DR7)possiblecpu=3;
4142
 
4143
			else invalidoperand(2);
4144
 
4145
		case tk_controlreg:
4146
 
4147
				outword(0x220F);
4148
 
4149
				possiblecpu=4;
4150
 
4151
			}
4152
 
4153
			break;
4154
 
4155
			if(tok==tk_reg32){
4156
 
4157
				op(128+64+hstok.number*8+(unsigned int)itok.number);
4158
 
4159
				if(hstok.number==TR6||hstok.number==TR7)possiblecpu=3;
4160
 
4161
			else invalidoperand(2);
4162
 
4163
		default: invalidoperand(1); break;
4164
 
4165
	asmparam=FALSE;
4166
 
4167
	if(next)nexttok();
4168
 
4169
4170
 
4171
{
4172
 
4173
int razr=r16;
4174
 
4175
	if(tok==tk_reg32)razr=r32;
4176
 
4177
	regnum=(unsigned int)itok.number*8;
4178
 
4179
	nextexpecting2(tk_camma);
4180
 
4181
		case tk_reg:
4182
 
4183
			op(0xF); op(basecode|1);
4184
 
4185
			break;
4186
 
4187
			op66(razr);
4188
 
4189
			op(128+64+regnum+(unsigned int)itok.number);
4190
 
4191
		case tk_wordvar:
4192
 
4193
			CheckAllMassiv(bufrm,2,&strinf);
4194
 
4195
			outseg(&itok,3);
4196
 
4197
			op(itok.rm+regnum);
4198
 
4199
			break;
4200
 
4201
		case tk_charvar:
4202
 
4203
			op66(razr);
4204
 
4205
			op(0xF); op(basecode);
4206
 
4207
			outaddress(&itok);
4208
 
4209
		default: varexpected(2); break;
4210
 
4211
	if(cpu<3)cpu=3;
4212
 
4213
4214
 
4215
{
4216
 
4217
int htok;
4218
 
4219
SINFO hstr;
4220
 
4221
	nexttok();
4222
 
4223
	htok=tok;
4224
 
4225
	bufrm=NULL;
4226
 
4227
	strinf.bufstr=NULL;
4228
 
4229
	if(tok==tk_xmmreg)i++;
4230
 
4231
		case tk_reg32:
4232
 
4233
			if(tok==tk_mmxreg||i){	//MOVD EAX,MM0
4234
 
4235
				outword(0x7E0F);
4236
 
4237
			}
4238
 
4239
			break;
4240
 
4241
		case tk_longvar:
4242
 
4243
#ifdef OPTVARCONST
4244
 
4245
#endif
4246
 
4247
				KillVar(hstok.name);
4248
 
4249
				if(i)op(0x66);
4250
 
4251
				op(hstok.rm+(unsigned int)itok.number*8);
4252
 
4253
			}
4254
 
4255
			break;
4256
 
4257
			i++;
4258
 
4259
			switch(tok){
4260
 
4261
					if(i)op(0x66);
4262
 
4263
					op(0xc0+hstok.number*8+(unsigned int)itok.number);
4264
 
4265
				case tk_dwordvar:	//MOVD MMO,mem
4266
 
4267
					CheckAllMassiv(bufrm,4,&strinf);
4268
 
4269
					if(i)op(0x66);
4270
 
4271
					op(itok.rm+hstok.number*8);
4272
 
4273
					break;
4274
 
4275
			}
4276
 
4277
		default: mmxregordwordexpected(1);
4278
 
4279
	if(cpu<6)cpu=6;
4280
 
4281
}
4282
 
4283
void movq()
4284
 
4285
int htok;
4286
 
4287
char *hbuf;
4288
 
4289
int i=1,xmm=0;
4290
 
4291
	hstok=itok;
4292
 
4293
	hbuf=bufrm;
4294
 
4295
	hstr=strinf;
4296
 
4297
	nextexpecting2(tk_camma);
4298
 
4299
	switch(htok){
4300
 
4301
		case tk_doublevar:
4302
 
4303
		case tk_longvar:
4304
 
4305
		case tk_floatvar:
4306
 
4307
		case tk_wordvar:
4308
 
4309
			i++;
4310
 
4311
		case tk_bytevar:
4312
 
4313
#ifdef OPTVARCONST
4314
 
4315
#endif
4316
 
4317
				CheckAllMassiv(hbuf,i,&hstr,&hstok);
4318
 
4319
				if(xmm){
4320
 
4321
					outword(0xD60f);
4322
 
4323
				else outword(0x7F0F);
4324
 
4325
				outaddress(&hstok);
4326
 
4327
			else mmxregexpected(2);
4328
 
4329
		case tk_mmxreg:
4330
 
4331
				case tk_mmxreg:	//MOVQ MM0,MM1
4332
 
4333
					op(0xc0+hstok.number*8+(unsigned int)itok.number);
4334
 
4335
				case tk_qwordvar:
4336
 
4337
					i+=4;
4338
 
4339
				case tk_dwordvar:
4340
 
4341
					i+=2;
4342
 
4343
				case tk_intvar:
4344
 
4345
				case tk_charvar:
4346
 
4347
					CheckAllMassiv(bufrm,i,&strinf);
4348
 
4349
					outword(0x6F0F);
4350
 
4351
					outaddress(&itok);
4352
 
4353
				default: mmxregordwordexpected(2);
4354
 
4355
			break;
4356
 
4357
			switch(tok){
4358
 
4359
					op(0xF3);
4360
 
4361
					op(0xc0+hstok.number*8+(unsigned int)itok.number);
4362
 
4363
				case tk_qwordvar:
4364
 
4365
					i+=4;
4366
 
4367
				case tk_dwordvar:
4368
 
4369
					i+=2;
4370
 
4371
				case tk_intvar:
4372
 
4373
				case tk_charvar:
4374
 
4375
					CheckAllMassiv(bufrm,i,&strinf);
4376
 
4377
					op(0xF3);
4378
 
4379
					op(itok.rm+hstok.number*8);
4380
 
4381
					xmm++;
4382
 
4383
				default: xmmregorvarexpected(2);
4384
 
4385
			break;
4386
 
4387
	}
4388
 
4389
	if(xmm&&cpu<9)cpu=9;
4390
 
4391
4392
 
4393
{
4394
 
4395
int htok,next=TRUE;
4396
 
4397
int xmm=FALSE;
4398
 
4399
	hnumber=(unsigned int)itok.number;
4400
 
4401
	nextexpecting2(tk_camma);
4402
 
4403
	else if(htok!=tk_mmxreg)mmxregexpected(1);
4404
 
4405
		case tk_mmxreg:
4406
 
4407
			op(0x0f);
4408
 
4409
			op(0xc0+hnumber*8+(unsigned int)itok.number);
4410
 
4411
		case tk_xmmreg:
4412
 
4413
			else op(0x66);
4414
 
4415
			op(code);
4416
 
4417
			break;
4418
 
4419
			if(xmm)op(0x66);
4420
 
4421
			op(code1);
4422
 
4423
		 	asmparam=FALSE;
4424
 
4425
			next=FALSE;
4426
 
4427
		case tk_qwordvar:
4428
 
4429
		case tk_longvar:
4430
 
4431
		case tk_floatvar:
4432
 
4433
		case tk_wordvar:
4434
 
4435
			i++;
4436
 
4437
		case tk_bytevar:
4438
 
4439
			outseg(&itok,xmm==FALSE?3:4);
4440
 
4441
			op(0x0f);
4442
 
4443
			op(itok.rm+hnumber*8);
4444
 
4445
			break;
4446
 
4447
			mmxregordwordexpected(2);
4448
 
4449
	}
4450
 
4451
	if(xmm&&cpu<9)cpu=9;
4452
 
4453
}
4454
 
4455
void asmshift(int basecode) 		 // used for ROL ROR RCL RCR SHL SAL SHR SAR.
4456
 
4457
int htok,precode;
4458
 
4459
int usenumsh=TRUE;
4460
 
4461
char *hbuf;
4462
 
4463
SINFO hstr;
4464
 
4465
#ifdef OPTVARCONST
4466
 
4467
#endif
4468
 
4469
	htok=tok;
4470
 
4471
	hbuf=bufrm;
4472
 
4473
	hstr=strinf;
4474
 
4475
	nextexpecting2(tk_camma);
4476
 
4477
		precode=0xD2;
4478
 
4479
	}
4480
 
4481
		asmparam=FALSE;
4482
 
4483
		if(holdbyte==1){
4484
 
4485
			usenumsh=FALSE;
4486
 
4487
		else /*if(holdbyte!=0)*/{
4488
 
4489
			if(cpu<2)cpu=2;
4490
 
4491
		next=0;
4492
 
4493
	else clornumberexpected();
4494
 
4495
		switch(htok){
4496
 
4497
				if(cpu<3)cpu=3;
4498
 
4499
			case tk_reg:
4500
 
4501
				op66(razr);
4502
 
4503
				break;
4504
 
4505
				ClearReg(hstok.number);
4506
 
4507
				break;
4508
 
4509
			case tk_bytevar:
4510
 
4511
				if(precode==0xD0||precode==0xc0)UpdVarConst(&hstok,holdbyte,tk_byte,operand);
4512
 
4513
#endif
4514
 
4515
				KillVar(hstok.name);
4516
 
4517
				op(precode);
4518
 
4519
				outaddress(&hstok);
4520
 
4521
			case tk_dwordvar:
4522
 
4523
				CheckAllMassiv(hbuf,4,&hstr,&hstok);
4524
 
4525
				razr=r32;
4526
 
4527
			case tk_wordvar:
4528
 
4529
				CheckAllMassiv(hbuf,2,&hstr,&hstok);
4530
 
4531
#ifdef OPTVARCONST
4532
 
4533
				else ClearVarByNum(&hstok);
4534
 
4535
				KillVar(hstok.name);
4536
 
4537
				outseg(&hstok,2);
4538
 
4539
				op(hstok.rm+basecode);
4540
 
4541
				break;
4542
 
4543
		}
4544
 
4545
	if(next)nexttok();
4546
 
4547
4548
 
4549
{
4550
 
4551
	if(tok==tk_beg){
4552
 
4553
		else clornumberexpected();
4554
 
4555
	else if(tok!=tk_number)clornumberexpected();
4556
 
4557
}
4558
 
4559
void Shxd(int code)
4560
 
4561
unsigned int h2number;
4562
 
4563
ITOK hstok;
4564
 
4565
unsigned char next=1;
4566
 
4567
	nexttok();
4568
 
4569
	htok=tok;
4570
 
4571
	bufrm=NULL;
4572
 
4573
	strinf.bufstr=NULL;
4574
 
4575
	h2number=(unsigned int)itok.number;
4576
 
4577
	h2tok=tok;
4578
 
4579
	switch(htok){
4580
 
4581
			if(h2tok==tk_reg){
4582
 
4583
regreg:
4584
 
4585
				CheckCl(code);
4586
 
4587
				if(tok==tk_number){
4588
 
4589
					op(doconstlongmath());
4590
 
4591
				}
4592
 
4593
			else regexpected(2);
4594
 
4595
		case tk_reg32:
4596
 
4597
				op66(r32);
4598
 
4599
			}
4600
 
4601
			break;
4602
 
4603
		case tk_wordvar:
4604
 
4605
				CheckAllMassiv(hbuf,2,&hstr,&hstok);
4606
 
4607
varreg:
4608
 
4609
			ClearVarByNum(&hstok);
4610
 
4611
4612
 
4613
				outseg(&hstok,3);
4614
 
4615
				op(hstok.rm+h2number*8);
4616
 
4617
				if(tok==tk_number){
4618
 
4619
					op(doconstlongmath());
4620
 
4621
				}
4622
 
4623
			else regexpected(2);
4624
 
4625
		case tk_dwordvar:
4626
 
4627
			if(h2tok==tk_reg32){
4628
 
4629
				op66(r32);
4630
 
4631
			}
4632
 
4633
			break;
4634
 
4635
	}
4636
 
4637
	if(next)nexttok();
4638
 
4639
4640
 
4641
{
4642
 
4643
int oscan=scanlexmode;
4644
 
4645
	nexttok();
4646
 
4647
	if(tok==tk_endline||tok==tk_semicolon){
4648
 
4649
		op(0xC1+addrm);
4650
 
4651
	}
4652
 
4653
		opcode=0xdc;
4654
 
4655
	}
4656
 
4657
		case tk_fpust:
4658
 
4659
			op(0xC0+(unsigned int)itok.number+addrm);
4660
 
4661
		case tk_longvar:
4662
 
4663
		case tk_floatvar:
4664
 
4665
			outseg(&itok,2);
4666
 
4667
			op(itok.rm+addrm);
4668
 
4669
			break;
4670
 
4671
			CheckAllMassiv(bufrm,8,&strinf);
4672
 
4673
			op(0xDC);
4674
 
4675
			outaddress(&itok);
4676
 
4677
		default: fpuvarexpected(0);
4678
 
4679
}
4680
 
4681
void FpuType2(unsigned int addrm,unsigned int addrm2)
4682
 
4683
long hnum;
4684
 
4685
int oscan=scanlexmode;
4686
 
4687
	nexttok();
4688
 
4689
	if(tok==tk_endline||tok==tk_semicolon){
4690
 
4691
		op(0xC1+addrm);
4692
 
4693
	}
4694
 
4695
		opcode=0xdc;
4696
 
4697
	}
4698
 
4699
		case tk_fpust:
4700
 
4701
			nextexpecting2(tk_camma);
4702
 
4703
				if(tok==tk_fpust){
4704
 
4705
					op(0xC0+addrm2+(unsigned int)itok.number);
4706
 
4707
				else fpustakexpected(2);
4708
 
4709
			else{
4710
 
4711
					if(itok.number!=0)fpu0expected();
4712
 
4713
					op(0xC0+(unsigned int)hnum+addrm);
4714
 
4715
				else fpustakexpected(2);
4716
 
4717
			break;
4718
 
4719
		case tk_dwordvar:
4720
 
4721
			CheckAllMassiv(bufrm,4,&strinf);
4722
 
4723
			op(opcode);
4724
 
4725
			outaddress(&itok);
4726
 
4727
		case tk_doublevar:
4728
 
4729
			outseg(&itok,2);
4730
 
4731
			op(addrm2+itok.rm);
4732
 
4733
			break;
4734
 
4735
	}
4736
 
4737
4738
 
4739
{
4740
 
4741
4742
 
4743
	nexttok();
4744
 
4745
	retoldscanmode(oscan);
4746
 
4747
		op(opcode);
4748
 
4749
	}
4750
 
4751
		op(opcode);
4752
 
4753
	}
4754
 
4755
	if(opcode==0xDE&&tok2==tk_camma){
4756
 
4757
		nexttok();
4758
 
4759
4760
 
4761
}
4762
 
4763
void FpuType4(unsigned int opcode,unsigned int addrm)
4764
 
4765
	nexttok();
4766
 
4767
		if(addrm==0)addrm=0x28;
4768
 
4769
		CheckAllMassiv(bufrm,8,&strinf);
4770
 
4771
		outseg(&itok,2);
4772
 
4773
		op(itok.rm+addrm);
4774
 
4775
		return;
4776
 
4777
	switch(tok){
4778
 
4779
		case tk_intvar:
4780
 
4781
			KillVar(itok.name);
4782
 
4783
			op(0xDE + opcode);
4784
 
4785
			outaddress(&itok);
4786
 
4787
		case tk_longvar:
4788
 
4789
		case tk_floatvar:
4790
 
4791
			KillVar(itok.name);
4792
 
4793
			op(0xDA+opcode);
4794
 
4795
			outaddress(&itok);
4796
 
4797
		default: fpuvarexpected(0);
4798
 
4799
}
4800
 
4801
void  FpuType5(unsigned int opcode,unsigned int addrm)
4802
 
4803
int opc=0xd9;
4804
 
4805
	nexttok();
4806
 
4807
		nexttok();
4808
 
4809
	}
4810
 
4811
		opc=0xdb;
4812
 
4813
		if(addrm==0)addrm=40;
4814
 
4815
		nexttok();
4816
 
4817
	}
4818
 
4819
		case tk_fpust:
4820
 
4821
			op(0xC0+(unsigned int)itok.number+addrm);
4822
 
4823
		case tk_qwordvar:
4824
 
4825
			opc=0xdd;
4826
 
4827
		case tk_longvar:
4828
 
4829
		case tk_floatvar:
4830
 
4831
			if(opcode!=0xD9)KillVar(itok.name);
4832
 
4833
			op(opc);
4834
 
4835
			outaddress(&itok);
4836
 
4837
		default: fpuvarexpected(0);
4838
 
4839
}
4840
 
4841
void FpuType6(unsigned int opcode,unsigned int addrm)
4842
 
4843
int i=0;
4844
 
4845
	if(opcode==0xDF){
4846
 
4847
			nexttok();
4848
 
4849
		}
4850
 
4851
			i=2;
4852
 
4853
			tok=tk_qwordvar;
4854
 
4855
	}
4856
 
4857
		case tk_qwordvar:
4858
 
4859
			i=+4;
4860
 
4861
		case tk_dwordvar:
4862
 
4863
			i+=2;
4864
 
4865
		case tk_intvar:
4866
 
4867
			CheckAllMassiv(bufrm,i,&strinf);
4868
 
4869
			outseg(&itok,2);
4870
 
4871
			op(itok.rm+addrm);
4872
 
4873
			break;
4874
 
4875
	}
4876
 
4877
4878
 
4879
{
4880
 
4881
	switch(tok){
4882
 
4883
		case tk_intvar:
4884
 
4885
			if(addrm!=0x28)KillVar(itok.name);
4886
 
4887
			op(0xD9);
4888
 
4889
			outaddress(&itok);
4890
 
4891
		default: wordvalexpected();
4892
 
4893
}
4894
 
4895
void FpuType8(unsigned int opcode,unsigned int addrm)
4896
 
4897
	nexttok();
4898
 
4899
		nexttok();
4900
 
4901
	}
4902
 
4903
		op(opcode);
4904
 
4905
		if(cpu<7)cpu=7;
4906
 
4907
	else fpustakexpected(1);
4908
 
4909
4910
 
4911
4912
 
4913
{
4914
 
4915
		if(thenumber<=SHORTMAX&&thenumber>=SHORTMIN)return(1);
4916
 
4917
	else{
4918
 
4919
	}
4920
 
4921
}
4922
 
4923
void cbw()
4924
 
4925
	if(optimizespeed&&(chip==5||chip==6)){
4926
 
4927
		op(7);
4928
 
4929
	else{
4930
 
4931
		op(0x98);
4932
 
4933
	ClearReg(AX);
4934
 
4935
4936
 
4937
{
4938
 
4939
	ClearReg(DI);
4940
 
4941
4942
 
4943
{
4944
 
4945
	op(0xAB);
4946
 
4947
}
4948
 
4949
void stosd()
4950
 
4951
	op66(r32);
4952
 
4953
	if(cpu<3)cpu=3;
4954
 
4955
}
4956
 
4957
void movsb()
4958
 
4959
	op(0xA4);
4960
 
4961
	ClearReg(SI);
4962
 
4963
4964
 
4965
{
4966
 
4967
	op(0xA5);
4968
 
4969
	ClearReg(SI);
4970
 
4971
4972
 
4973
{
4974
 
4975
	op(0xA5);
4976
 
4977
	ClearReg(DI);
4978
 
4979
}
4980
 
4981
void pushds()  /* produce PUSH DS */
4982
 
4983
	RestoreStack();
4984
 
4985
}
4986
 
4987
void pushss()
4988
 
4989
	RestoreStack();
4990
 
4991
}
4992
 
4993
void popes()	 /* produce POP ES */
4994
 
4995
	RestoreStack();
4996
 
4997
}
4998
 
4999
void ret()		/* produce RET */
5000
 
5001
	RestoreStack();
5002
 
5003
}
5004
 
5005
void retf() 	/* produce RETF */
5006
 
5007
	RestoreStack();
5008
 
5009
}
5010
 
5011
void jumploc(long loc)		 /* produce JUMP # */
5012
 
5013
5014
 
5015
	if(loc>-130&&loc<127){
5016
 
5017
		op(0xEB);
5018
 
5019
		if(loc==0)notunreach=TRUE;
5020
 
5021
	else{
5022
 
5023
			op(0xE9);
5024
 
5025
		}
5026
 
5027
			if(!optimizespeed&&(loc>126&&loc<65533)){
5028
 
5029
				outword(loc-1);
5030
 
5031
			else{
5032
 
5033
				outdword(loc-2);
5034
 
5035
		}
5036
 
5037
}
5038
 
5039
void callloc(long loc)	 /* produce CALL # */
5040
 
5041
	loc=loc-outptr-3;
5042
 
5043
	if(am32==FALSE)	outword(loc);
5044
 
5045
}
5046
 
5047
void xorAHAH()	 /* produce XOR AH,AH */
5048
 
5049
	outword(0xE430);
5050
 
5051
}
5052
 
5053
void xorAXAX()	 /* produce XOR AX,AX */
5054
 
5055
	op66(r16);
5056
 
5057
	ConstToReg(0,AX,r16);
5058
 
5059
5060
 
5061
{
5062
 
5063
	outword(0xC031);
5064
 
5065
	ConstToReg(0,AX,r32);
5066
 
5067
5068
 
5069
{
5070
 
5071
	op(0x31);
5072
 
5073
	ConstToReg(0,reg,razr);
5074
 
5075
5076
 
5077
{
5078
 
5079
}
5080
 
5081
void cwdq(int razr)
5082
 
5083
	op66(razr);
5084
 
5085
		outword(0xC289);	//mov dx,ax
5086
 
5087
		outword(0xFAC1);	//sar dx,15
5088
 
5089
	}
5090
 
5091
	ClearReg(DX);
5092
 
5093
5094
 
5095
{
5096
 
5097
	expecting2(want);
5098
 
5099
5100
 
5101
{
5102
 
5103
	nexttok();
5104
 
5105
5106
 
5107
{
5108
 
5109
		tok=tk_number;
5110
 
5111
	}
5112
 
5113
5114
 
5115
{
5116
 
5117
	outword(0); 	/* the large jump */
5118
 
5119
}
5120
 
5121
void callloc0()
5122
 
5123
	op(0xE8);
5124
 
5125
	if(am32!=FALSE)outword(0);
5126
 
5127
5128
 
5129
{
5130
 
5131
		outword(0xEC89);	// MOV SP,BP
5132
 
5133
	}
5134
 
5135
}
5136
 
5137
void  tobedefined(int callkind,int expectedreturn)
5138
 
5139
//	strcpy(itok.name,(char *)string);
5140
 
5141
	itok.flag=(unsigned char)(tok==tk_ID?tp_fastcall:(comfile==file_w32?tp_stdcall:tp_pascal));
5142
 
5143
	itok.number=secondcallnum;
5144
 
5145
	itok.rm=expectedreturn;
5146
 
5147
	addtotree(itok.name);
5148
 
5149
}
5150
 
5151
void  addlocaljump(int callkind)
5152
 
5153
	addlocalvar((char *)string,tk_locallabel,secondcallnum,TRUE);
5154
 
5155
}
5156
 
5157
unsigned long SaveNumber(int type,int tok4,char *name)
5158
 
5159
	unsigned long t=doconstdwordmath();
5160
 
5161
	else if((postnumflag&f_reloc)!=0)AddReloc();
5162
 
5163
	else outdword(t);
5164
 
5165
}
5166
 
5167
void Swap2tok(int *tok4, ITOK *itok4, char **buf4, SINFO *strinf4, int *tok6,
5168
 
5169
{
5170
 
5171
ITOK hstok;
5172
 
5173
SINFO hstr;
5174
 
5175
	*tok4=*tok6;
5176
 
5177
	hstok=*itok4;
5178
 
5179
	*itok6=hstok;
5180
 
5181
	*buf4=*buf6;
5182
 
5183
	hstr=*strinf4;
5184
 
5185
	*strinf6=hstr;
5186
 
5187
5188
 
5189
{
5190
 
5191
ITOK hstok;
5192
 
5193
SINFO hstr;
5194
 
5195
unsigned long num;
5196
 
5197
	nexttok();
5198
 
5199
	hstok=itok;
5200
 
5201
	bufrm=NULL;
5202
 
5203
	strinf.bufstr=NULL;
5204
 
5205
	else nexttok();
5206
 
5207
	i=r16;
5208
 
5209
//	 tok,itok.number,bufrm,htok,hstok.number,hbuf);
5210
 
5211
			&htok,&hstok,&hbuf,&hstr);
5212
 
5213
//	 tok,itok.number,bufrm,htok,hstok.number,hbuf);
5214
 
5215
		case tk_reg32:
5216
 
5217
			possiblecpu=3;
5218
 
5219
			switch(tok){
5220
 
5221
					if(i==r16){
5222
 
5223
						return FALSE;
5224
 
5225
					op66(i);
5226
 
5227
					op(128+64+(unsigned int)itok.number*8+hstok.number);
5228
 
5229
				case tk_reg:
5230
 
5231
						reg32expected(2);
5232
 
5233
					}
5234
 
5235
					op(0x85);
5236
 
5237
					break;
5238
 
5239
				 	asmparam=FALSE;
5240
 
5241
					if(mode){
5242
 
5243
						if(num<65536)i=r16;
5244
 
5245
					op66(i);
5246
 
5247
					else{
5248
 
5249
						op(128+64+hstok.number);
5250
 
5251
					if(i==r16)outword((unsigned int)num);
5252
 
5253
					next=0;
5254
 
5255
				case tk_postnumber:
5256
 
5257
					op66(r16);
5258
 
5259
					else{
5260
 
5261
						op(128+64+hstok.number);
5262
 
5263
					(itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number);
5264
 
5265
					break;
5266
 
5267
				case tk_longvar:
5268
 
5269
						reg32expected(1);
5270
 
5271
					}
5272
 
5273
					op66(i);
5274
 
5275
					op(0x85);
5276
 
5277
					outaddress(&itok);
5278
 
5279
				case tk_wordvar:
5280
 
5281
					if(i==r32){
5282
 
5283
						return FALSE;
5284
 
5285
					CheckAllMassiv(bufrm,i,&strinf);
5286
 
5287
					outseg(&itok,2);
5288
 
5289
					op(hstok.number*8+itok.rm);
5290
 
5291
					break;
5292
 
5293
			}
5294
 
5295
		case tk_beg:
5296
 
5297
				case tk_beg:
5298
 
5299
					op(128+64+(unsigned int)itok.number*8+hstok.number);
5300
 
5301
				case tk_number:
5302
 
5303
					num=doconstdwordmath();
5304
 
5305
					if(hstok.number==AL)op(0xA8);
5306
 
5307
						op(0xF6);
5308
 
5309
					}
5310
 
5311
					next=0;
5312
 
5313
				case tk_charvar:
5314
 
5315
					CheckAllMassiv(bufrm,1,&strinf);
5316
 
5317
					op(0x84);
5318
 
5319
					outaddress(&itok);
5320
 
5321
				default: return FALSE;
5322
 
5323
			break;
5324
 
5325
		case tk_longvar:
5326
 
5327
			possiblecpu=3;
5328
 
5329
		case tk_intvar:
5330
 
5331
			switch(tok){
5332
 
5333
					if(i==r16){
5334
 
5335
						return FALSE;
5336
 
5337
					op66(i);
5338
 
5339
					op(0x85);
5340
 
5341
					outaddress(&hstok);
5342
 
5343
				case tk_reg:
5344
 
5345
						reg32expected(2);
5346
 
5347
					}
5348
 
5349
					outseg(&hstok,2);
5350
 
5351
					op((unsigned int)itok.number*8+hstok.rm);
5352
 
5353
					break;
5354
 
5355
				 	asmparam=FALSE;
5356
 
5357
					if(mode){
5358
 
5359
						if(num<65536)i=r16;
5360
 
5361
					op66(i);
5362
 
5363
					op(0xF7);
5364
 
5365
					outaddress(&hstok);
5366
 
5367
					else outword((unsigned int)num);
5368
 
5369
					break;
5370
 
5371
					op66(i);
5372
 
5373
					if(i==r32)return FALSE;
5374
 
5375
					op(hstok.rm);
5376
 
5377
					(itok.flag&f_extern)==0?setwordpost(&itok):setwordext(&itok.number);
5378
 
5379
					break;
5380
 
5381
			}
5382
 
5383
		case tk_charvar:
5384
 
5385
			CheckAllMassiv(hbuf,1,&hstr,&hstok);
5386
 
5387
				case tk_beg:
5388
 
5389
					op(0x84);
5390
 
5391
					outaddress(&hstok);
5392
 
5393
				case tk_number:
5394
 
5395
					num=doconstdwordmath();
5396
 
5397
					outseg(&hstok,2);
5398
 
5399
					op(hstok.rm);
5400
 
5401
					op(num);
5402
 
5403
					break;
5404
 
5405
			}
5406
 
5407
		default: return FALSE;
5408
 
5409
	if(cpu
5410
 
5411
	return TRUE;
5412
 
5413
5414
 
5415
{
5416
 
5417
int xmm=FALSE;
5418
 
5419
	if(tok==tk_xmmreg)xmm=TRUE;
5420
 
5421
	num1=itok.number;
5422
 
5423
	switch(tok){
5424
 
5425
			if(xmm)xmmregorvarexpected(2);
5426
 
5427
			op(type);
5428
 
5429
			break;
5430
 
5431
			if(xmm==FALSE)mmxormem(2);
5432
 
5433
			op(type);
5434
 
5435
			break;
5436
 
5437
			i+=4;
5438
 
5439
		case tk_dwordvar:
5440
 
5441
			i+=2;
5442
 
5443
		case tk_intvar:
5444
 
5445
 
5446
 
5447
			CheckAllMassiv(bufrm,i,&strinf);
5448
 
5449
			if(xmm)op(0x66);
5450
 
5451
			op(type);
5452
 
5453
			outaddress(&itok);
5454
 
5455
		default:
5456
 
5457
			break;
5458
 
5459
	if(cpu<8)cpu=8;
5460
 
5461
}
5462
 
5463
void prefetch(int code,int type)
5464
 
5465
int i=1;
5466
 
5467
	switch(tok){
5468
 
5469
			i+=4;
5470
 
5471
		case tk_dwordvar:
5472
 
5473
			i+=2;
5474
 
5475
		case tk_intvar:
5476
 
5477
		case tk_charvar:
5478
 
5479
			CheckAllMassiv(bufrm,i,&strinf);
5480
 
5481
			outseg(&itok,3);
5482
 
5483
			op(code);
5484
 
5485
			outaddress(&itok);
5486
 
5487
		default:
5488
 
5489
			break;
5490
 
5491
}
5492
 
5493
void pextrw()
5494
 
5495
int num1,num2;
5496
 
5497
	nexttok();
5498
 
5499
	num1=itok.number;
5500
 
5501
	nextexpecting2(tk_camma);
5502
 
5503
	else if(tok!=tk_mmxreg)mmxregexpected(2);
5504
 
5505
	nextexpecting2(tk_camma);
5506
 
5507
	if(xmm)op(0x66);
5508
 
5509
	op(rm_mod11+num1+num2*8);
5510
 
5511
	if(cpu<8)cpu=8;
5512
 
5513
 
5514
 
5515
void pinsrw()
5516
 
5517
int num1,htok;
5518
 
5519
char *hbuf;
5520
 
5521
int xmm=FALSE;
5522
 
5523
	if(tok==tk_xmmreg)xmm=TRUE;
5524
 
5525
	num1=itok.number;
5526
 
5527
	htok=tok;
5528
 
5529
	hbuf=bufrm;
5530
 
5531
	hstr=strinf;
5532
 
5533
	nextexpecting2(tk_camma);
5534
 
5535
	switch(htok){
5536
 
5537
			if(xmm)op(0x66);
5538
 
5539
			op(rm_mod11+num1+hstok.number*8);
5540
 
5541
		case tk_wordvar:
5542
 
5543
			CheckAllMassiv(hbuf,2,&hstr);
5544
 
5545
			if(xmm)op(0x66);
5546
 
5547
			op(hstok.rm+num1*8);
5548
 
5549
			break;
5550
 
5551
			reg32orword(2);
5552
 
5553
	}
5554
 
5555
	if(cpu<8)cpu=8;
5556
 
5557
}
5558
 
5559
void pshufw()
5560
 
5561
int num1,htok;
5562
 
5563
char *hbuf;
5564
 
5565
int i=1;
5566
 
5567
	if(tok!=tk_mmxreg)mmxregexpected(1);
5568
 
5569
	nextexpecting2(tk_camma);
5570
 
5571
	hstok=itok;
5572
 
5573
	bufrm=NULL;
5574
 
5575
	strinf.bufstr=NULL;
5576
 
5577
	if(tok!=tk_number)numexpected(3);
5578
 
5579
		case tk_mmxreg:
5580
 
5581
			op(rm_mod11+num1+hstok.number*8);
5582
 
5583
		case tk_longvar:
5584
 
5585
		case tk_floatvar:
5586
 
5587
		case tk_wordvar:
5588
 
5589
			i++;
5590
 
5591
		case tk_bytevar:
5592
 
5593
			KillVar(hstok.name);
5594
 
5595
			outword(0x700F);
5596
 
5597
			outaddress(&hstok);
5598
 
5599
		default:
5600
 
5601
 
5602
 
5603
	op(doconstdwordmath());
5604
 
5605
5606
 
5607
{
5608
 
5609
	nexttok();
5610
 
5611
		if(op1==tk_mmxreg)mmxregexpected(1);
5612
 
5613
		else xmmregexpected(1);
5614
 
5615
	if(tok==tk_reg32)ClearReg(itok.number);
5616
 
5617
	nextexpecting2(tk_camma);
5618
 
5619
		case tk_reg32:
5620
 
5621
		case tk_xmmreg:
5622
 
5623
				if(op2==tk_mmxreg)mmxregexpected(2);
5624
 
5625
				else xmmregexpected(2);
5626
 
5627
			if(sec)op(sec);
5628
 
5629
			op(type);
5630
 
5631
			break;
5632
 
5633
			i+=4;
5634
 
5635
		case tk_dwordvar:
5636
 
5637
			i+=2;
5638
 
5639
		case tk_intvar:
5640
 
5641
 
5642
 
5643
			CheckAllMassiv(bufrm,i,&strinf);
5644
 
5645
			if(sec)op(sec);
5646
 
5647
			op(type);
5648
 
5649
			outaddress(&itok);
5650
 
5651
		default:
5652
 
5653
			else if(op2==tk_reg32)reg32orword(2);
5654
 
5655
			break;
5656
 
5657
}
5658
 
5659
void xmm3instr(int type,int sec)	//xmm,xmm/mem,i8
5660
 
5661
int num1,i=1,htok;
5662
 
5663
char *hbuf;
5664
 
5665
	nexttok();
5666
 
5667
	num1=itok.number;
5668
 
5669
	htok=tok;
5670
 
5671
	hbuf=bufrm;
5672
 
5673
	hstr=strinf;
5674
 
5675
	nextexpecting2(tk_camma);
5676
 
5677
	switch(htok){
5678
 
5679
			if(sec)op(sec);
5680
 
5681
			op(type);
5682
 
5683
			break;
5684
 
5685
			i+=4;
5686
 
5687
		case tk_dwordvar:
5688
 
5689
			i+=2;
5690
 
5691
		case tk_intvar:
5692
 
5693
		case tk_charvar:
5694
 
5695
			CheckAllMassiv(hbuf,i,&hstr);
5696
 
5697
			if(sec)op(sec);
5698
 
5699
			op(type);
5700
 
5701
			outaddress(&hstok);
5702
 
5703
		default:
5704
 
5705
			break;
5706
 
5707
	op(doconstdwordmath());
5708
 
5709
5710
 
5711
{
5712
 
5713
	nexttok();
5714
 
5715
		if(type==tk_mmxreg)mmxregexpected(1);
5716
 
5717
		else xmmregexpected(1);
5718
 
5719
	if(tok==tk_reg32)ClearReg(itok.number);
5720
 
5721
	nextexpecting2(tk_camma);
5722
 
5723
	if(code2)op(code2);
5724
 
5725
	op(code);
5726
 
5727
}
5728
 
5729
void movxmm3(int code,int code2,int type)
5730
 
5731
int i=1,htok;
5732
 
5733
char *hbuf;
5734
 
5735
	nexttok();
5736
 
5737
	hstok=itok;
5738
 
5739
	bufrm=NULL;
5740
 
5741
	strinf.bufstr=NULL;
5742
 
5743
	if(tok!=type){
5744
 
5745
		else if(type==tk_xmmreg)xmmregexpected(2);
5746
 
5747
	}
5748
 
5749
		case tk_qwordvar:
5750
 
5751
		case tk_longvar:
5752
 
5753
		case tk_floatvar:
5754
 
5755
		case tk_wordvar:
5756
 
5757
			i+=1;
5758
 
5759
		case tk_bytevar:
5760
 
5761
			KillVar(hstok.name);
5762
 
5763
			if(code2)op(code2);
5764
 
5765
			op(code);
5766
 
5767
			outaddress(&hstok);
5768
 
5769
		default: varexpected(1);
5770
 
5771
}
5772
 
5773
void movxmm4(int code,int code2)
5774
 
5775
int i=1;
5776
 
5777
	nexttok();
5778
 
5779
	if(tok!=tk_xmmreg)xmmregexpected(1);
5780
 
5781
	switch(tok){
5782
 
5783
			i+=4;
5784
 
5785
		case tk_dwordvar:
5786
 
5787
			i+=2;
5788
 
5789
		case tk_intvar:
5790
 
5791
		case tk_charvar:
5792
 
5793
			CheckAllMassiv(bufrm,i,&strinf);
5794
 
5795
			if(code2)op(code2);
5796
 
5797
			op(code);
5798
 
5799
			outaddress(&itok);
5800
 
5801
		default: varexpected(2);
5802
 
5803
}
5804
 
5805
void movxmm(int code,int code2,int addc)
5806
 
5807
int i=1,htok;
5808
 
5809
char *hbuf;
5810
 
5811
	nexttok();
5812
 
5813
	hstok=itok;
5814
 
5815
	bufrm=NULL;
5816
 
5817
	strinf.bufstr=NULL;
5818
 
5819
	switch(htok){
5820
 
5821
			switch(tok){
5822
 
5823
					if(code2)op(code2);
5824
 
5825
					op(code);
5826
 
5827
					break;
5828
 
5829
					i+=4;
5830
 
5831
				case tk_dwordvar:
5832
 
5833
					i+=2;
5834
 
5835
				case tk_intvar:
5836
 
5837
				case tk_charvar:
5838
 
5839
					CheckAllMassiv(bufrm,i,&strinf);
5840
 
5841
					if(code2)op(code2);
5842
 
5843
					op(code);
5844
 
5845
					outaddress(&itok);
5846
 
5847
				default:
5848
 
5849
					break;
5850
 
5851
			break;
5852
 
5853
			i+=4;
5854
 
5855
		case tk_dwordvar:
5856
 
5857
			i+=2;
5858
 
5859
		case tk_intvar:
5860
 
5861
		case tk_charvar:
5862
 
5863
			if(tok!=tk_xmmreg)xmmregexpected(2);
5864
 
5865
			KillVar(hstok.name);
5866
 
5867
			if(code2)op(code2);
5868
 
5869
			op(code+addc);
5870
 
5871
			outaddress(&hstok);
5872
 
5873
		default:
5874
 
5875
			break;
5876
 
5877
}
5878
 
5879
void movxmm2(int code,int code2)
5880
 
5881
int i=1,htok;
5882
 
5883
char *hbuf;
5884
 
5885
	nexttok();
5886
 
5887
	hstok=itok;
5888
 
5889
	bufrm=NULL;
5890
 
5891
	strinf.bufstr=NULL;
5892
 
5893
	switch(htok){
5894
 
5895
			switch(tok){
5896
 
5897
					i+=4;
5898
 
5899
				case tk_dwordvar:
5900
 
5901
					i+=2;
5902
 
5903
				case tk_intvar:
5904
 
5905
				case tk_charvar:
5906
 
5907
					CheckAllMassiv(bufrm,i,&strinf);
5908
 
5909
					if(code2)op(code2);
5910
 
5911
					op(code);
5912
 
5913
					outaddress(&itok);
5914
 
5915
				default:
5916
 
5917
					break;
5918
 
5919
			break;
5920
 
5921
			i+=4;
5922
 
5923
		case tk_dwordvar:
5924
 
5925
			i+=2;
5926
 
5927
		case tk_intvar:
5928
 
5929
		case tk_charvar:
5930
 
5931
			if(tok!=tk_xmmreg)xmmregexpected(2);
5932
 
5933
			KillVar(hstok.name);
5934
 
5935
			if(code2)op(code2);
5936
 
5937
			op(code+1);
5938
 
5939
			outaddress(&hstok);
5940
 
5941
		default:
5942
 
5943
			break;
5944
 
5945
}
5946
 
5947
void shiftxmm(int rm)	//rxmm,i8
5948
 
5949
int num;
5950
 
5951
	if(tok!=tk_xmmreg)xmmregexpected(1);
5952
 
5953
	nextexpecting2(tk_camma);
5954
 
5955
	op(0x66);
5956
 
5957
	op(0x73);
5958
 
5959
	op(doconstdwordmath());
5960
 
5961
5962
 
5963
{
5964
 
5965
char name[IDLENGTH];
5966
 
5967
	if(dbg&2)AddDataNullLine(faradd==0?2:4);
5968
 
5969
	asmparam=FALSE;
5970
 
5971
		i=1;
5972
 
5973
		CheckIP();
5974
 
5975
		switch(tok){
5976
 
5977
				tok=tk_number;
5978
 
5979
			case tk_number:
5980
 
5981
				if(tok==tk_id&&strcmp((char *)string,"dup")==0){
5982
 
5983
					nexttok();
5984
 
5985
					htok=tok;
5986
 
5987
						tok=tk_number;
5988
 
5989
					}
5990
 
5991
					else numexpected();
5992
 
5993
				for(;i!=0;i--){
5994
 
5995
				 	if(htok==tk_undefofs)AddUndefOff(2,name);
5996
 
5997
					else outword(hnumber);
5998
 
5999
				break;
6000
 
6001
				setwordpost(&itok);
6002
 
6003
				else outword(itok.number);
6004
 
6005
				break;
6006
 
6007
				numexpected();
6008
 
6009
				break;
6010
 
6011
	}while(tok==tk_camma);
6012
 
6013
}
6014
 
6015
void AADM(int code)
6016
 
6017
	op(code);
6018
 
6019
	if(tok2==tk_number)nexttok();
6020
 
6021
	ClearReg(AX);
6022
 
6023
6024
 
6025
{
6026
 
6027
int razr;
6028
 
6029
unsigned long hnumber;
6030
 
6031
int next=1;
6032
 
6033
	razr=r16;
6034
 
6035
		case tk_id:
6036
 
6037
			if((stricmp("dword",(char *)string)==0)||(stricmp("long",(char *)string)==0))i=r32;
6038
 
6039
			else return FALSE;
6040
 
6041
		case tk_dword:
6042
 
6043
			i=r32;
6044
 
6045
		case tk_int:
6046
 
6047
			i=r16;
6048
 
6049
			nexttok();
6050
 
6051
			if(tok==tk_number)goto pushnum;
6052
 
6053
			return FALSE;
6054
 
6055
			possiblecpu=3;
6056
 
6057
			op66(tok==tk_reg?r16:r32);
6058
 
6059
			break;
6060
 
6061
			PushSeg((unsigned int)itok.number);
6062
 
6063
		case tk_undefofs:
6064
 
6065
			hstok=itok;
6066
 
6067
			hnumber=doconstlongmath();
6068
 
6069
			op(0x68);
6070
 
6071
		 	AddUndefOff(2,hstok.name);
6072
 
6073
			else outdword(hnumber);
6074
 
6075
			next=0;
6076
 
6077
		case tk_minus:
6078
 
6079
		case tk_number:
6080
 
6081
			hnumber=doconstlongmath();
6082
 
6083
			else hnumber&=0xffffffff;
6084
 
6085
			op66(i);
6086
 
6087
				op(0x6A);
6088
 
6089
			}
6090
 
6091
				op(0x68);
6092
 
6093
				if(i==r16)outword(hnumber);
6094
 
6095
			}
6096
 
6097
			next=0;
6098
 
6099
		case tk_dwordvar:
6100
 
6101
			CheckAllMassiv(bufrm,4,&strinf);
6102
 
6103
			razr=r32;
6104
 
6105
		case tk_wordvar:
6106
 
6107
			CheckAllMassiv(bufrm,2,&strinf);
6108
 
6109
			op66(razr);
6110
 
6111
			op(0xFF);	op(0x30+itok.rm);
6112
 
6113
			break;
6114
 
6115
			op(0x68);
6116
 
6117
			if(am32==FALSE)outword((unsigned int)itok.number);
6118
 
6119
			break;
6120
 
6121
			op66(i);
6122
 
6123
			if(am32==FALSE)outword(addpoststring());
6124
 
6125
			break;
6126
 
6127
			return FALSE;
6128
 
6129
	if(cpu
6130
 
6131
	if(next)nexttok();
6132
 
6133
}
6134
 
6135
>
6136
 
6137
6138
 
6139
>
6140
 
6141
6142
 
6143
>
6144
 
6145
6146
 
6147
>
6148
 
6149
>
6150
 
6151
 
6152
 
6153
>
6154
 
6155
>
6156
 
6157
>
6158
 
6159
>
6160
 
6161
>
6162
 
6163
>
6164
 
6165
}
6166
 
6167
void>
6168
 
6169
}
6170
 
6171
void>
6172
 
6173
}
6174
 
6175
void>
6176
 
6177
>
6178
 
6179
}
6180
 
6181
void>
6182
 
6183
>
6184
 
6185
>
6186
 
6187
>
6188
 
6189
}
6190
 
6191
void>
6192
 
6193
>
6194
 
6195
>
6196
 
6197
>
6198
 
6199