-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopcheck.inc
1542 lines (1501 loc) · 22.1 KB
/
opcheck.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;Checks for valid operation code and performs certain actions depending on the code.
mov byt3,al
and al,11100111b
cmp al,00000111b
je pop1
mov al,byt3
and al,11111000b
cmp al,01011000b
je pop2
mov al,byt3
and al,11111111b
cmp al,10001111b
je pop3
mov al,byt3
and al,11111100b
cmp al,00100000b
je and1
mov al,byt3
and al,11111110b
cmp al,00100100b
je and2
jmp blocknext1
pop1:
lea dx, commands
mov cx,4
call output
call popsr
jmp checkend
pop2:
lea dx, commands
mov cx,4
call output
call wreg
jmp checkend
pop3:
lea dx, commands
mov cx,4
call output
call readnextbyte
call modrm
jmp checkend
and1:
lea dx,[commands+420]
mov cx,4
call output
call regrm
jmp checkend
and2:
lea dx,[commands+420]
mov cx,4
call output
call andab
jmp checkend
blocknext1:
mov al,byt3
and al,11111100b
cmp al,10000000b
je block1
jmp blocknext2
block1:
mov al,byt3
call checkd
mov al,byt3
call checkw
call readnextbyte
and al,00111000b
cmp al, 00000000b
je add3
mov al, byt3
and al,00111000b
cmp al, 00001000b
je or3
mov al,byt3
and al,00111000b
cmp al, 00010000b
je adc3
mov al,byt3
and al,00111000b
cmp al,00011000b
je sbb3
mov al,byt3
and al,00111000b
cmp al,00100000b
je and3
mov al,byt3
and al,00111000b
cmp al,00101000b
je sub3
add3:
lea dx, [commands+231]
mov cx,4
jmp block1end
or3:
lea dx, [commands+240]
mov cx,4
jmp block1end
adc3:
lea dx, [commands+243]
mov cx,4
jmp block1end
sbb3:
lea dx, [commands+247]
mov cx,4
jmp block1end
and3:
mov [command],41h
mov [command+1],4eh
mov [command+2],44h
mov [command+3],20h
lea dx,command
mov cx,4
jmp block1end
sub3:
lea dx, [commands+251]
mov cx,4
jmp block1end
xor3:
lea dx,[commands+255]
mov cx,4
jmp block1end
cmp3:
lea dx,[commands+259]
mov cx,4
block1end:
call output
call andrmb
jmp checkend
blocknext2:
mov al,byt3
and al,11111100b
cmp al,11010000b
je block2
jmp blocknext3
block2:
mov al,byt3
call checkd
mov al,byt3
call checkw
call readnextbyte
and al,00111000b
cmp al, 00000000b
je rol1
mov al, byt3
and al,00111000b
cmp al, 00001000b
je ror1
mov al,byt3
and al,00111000b
cmp al, 00010000b
je rcl1
mov al,byt3
and al,00111000b
cmp al,00011000b
je rcr1
mov al,byt3
and al,00111000b
cmp al,00100000b
je shl1
mov al,byt3
and al,00111000b
cmp al,00101000b
je shr1
mov al,byt3
and al,00111000b
cmp al,00111000b
je sar1
rol1:
lea dx, [commands+354]
mov cx,4
jmp block2end
ror1:
lea dx, [commands+358]
mov cx,4
jmp block2end
rcl1:
lea dx, [commands+362]
mov cx,4
jmp block2end
rcr1:
lea dx, [commands+366]
mov cx,4
jmp block2end
shl1:
lea dx, [commands+370]
mov cx,4
jmp block2end
shr1:
lea dx, [commands+374]
mov cx,4
jmp block2end
sar1:
lea dx,[commands+378]
mov cx,4
jmp block2end
block2end:
call output
call modrm
call comma
cmp direction,1
je nextcl
lea dx,one
mov cx,1
call output
jmp checkend
nextcl:
lea dx,[registers+4]
mov cx,2
call output
jmp checkend
blocknext3:
mov al,byt3
and al,11111110b
cmp al,11110110b
je block3
jmp blocknext4
block3:
mov al,byt3
call checkw
call readnextbyte
and al,00111000b
cmp al, 00000000b
je test3
mov al, byt3
and al,00111000b
cmp al, 00010000b
je not1
mov al, byt3
and al,00111000b
cmp al, 00011000b
je neg1
mov al,byt3
and al,00111000b
cmp al, 00100000b
je mul1
mov al,byt3
and al,00111000b
cmp al,00101000b
je imul1
mov al,byt3
and al,00111000b
cmp al,00110000b
je div1
mov al,byt3
and al,00111000b
cmp al,00111000b
je idiv1
test3:
lea dx, [commands+267]
mov cx,5
call output
call andrmb
jmp checkend
not1:
lea dx, [commands+382]
mov cx,4
jmp block3end
neg1:
lea dx, [commands+386]
mov cx,4
jmp block3end
mul1:
lea dx, [commands+390]
mov cx,4
jmp block3end
imul1:
lea dx, [commands+394]
mov cx,5
jmp block3end
div1:
lea dx, [commands+399]
mov cx,4
jmp block3end
idiv1:
lea dx, [commands+403]
mov cx,5
block3end:
call output
call modrm
jmp checkend
blocknext4:
mov al,byt3
and al,11111110b
cmp al,11111110b
je block4
jmp next1
block4:
mov al,byt3
call checkw
call readnextbyte
and al,00111000b
cmp al, 00000000b
je inc2
mov al, byt3
and al,00111000b
cmp al, 00001000b
je dec2
mov al,byt3
and al,00111000b
cmp al,00110000b
je push3
jmp block4_1
inc2:
lea dx, [commands+263]
mov cx,4
jmp block4end
dec2:
lea dx, [commands+12]
mov cx,4
jmp block4end
push3:
lea dx, [commands+235]
mov cx,5
block4end:
call output
call modrm
jmp checkend
block4_1:
mov al,byt3
and al,00111000b
cmp al, 00010000b
je call2
mov al,byt3
and al,00111000b
cmp al,00011000b
je call3
mov al,byt3
and al,00111000b
cmp al,00100000b
je jmp1
mov al,byt3
and al,00111000b
cmp al,00101000b
je jmp2
call2:
lea dx, [commands+408]
mov cx,5
jmp block4_1end
call3:
lea dx, [commands+408]
mov cx,5
jmp block4_2end
jmp1:
lea dx, [commands+413]
mov cx,4
jmp block4_1end
jmp2:
lea dx, [commands+413]
mov cx,4
jmp block4_2end
block4_1end:
call output
call modrm
jmp checkend
block4_2end:
call output
mov indirect,2
call modrm
jmp checkend
next1:
mov al,byt3
and al,11111111b
cmp al,10001101b
je lea1
mov al,byt3
and al,11111111b
cmp al,11000101b
je lds1
mov al,byt3
and al,11111000b
cmp al,01001000b
je dec1
jmp next2
lea1:
lea dx,[commands+4]
mov cx,4
call output
call readnextbyte
call mreg
jmp checkend
lds1:
lea dx,[commands+8]
mov cx,4
call output
call readnextbyte
call mreg
jmp checkend
dec1:
lea dx,[commands+12]
mov cx,4
call output
call wreg
jmp checkend
next2:
mov al,byt3
and al,11111111b
cmp al,11100010b
je loop1
mov al,byt3
and al,11111111b
cmp al,11100001b
je loope1
mov al,byt3
and al,11111111b
cmp al,11100000b
je loopne1
jmp next3
loop1:
lea dx, [commands+16]
mov cx,5
call output
call shiftforloop
jmp checkend
loope1:
lea dx, [commands+21]
mov cx,6
call output
call shiftforloop
jmp checkend
loopne1:
lea dx, [commands+27]
mov cx,7
call output
call shiftforloop
jmp checkend
next3:
mov al,byt3
and al,11111111b
cmp al,00100111b
je daa1
mov al,byt3
and al,11111111b
cmp al,00101111b
je das1
mov al,byt3
and al,11111111b
cmp al,00110111b
je aaa1
mov al,byt3
and al,11111111b
cmp al,00111111b
je aas1
mov al,byt3
and al,11111111b
cmp al,10010000b
je nop1
mov al,byt3
and al,11111111b
cmp al,10011000b
je cbw1
mov al,byt3
and al,11111111b
cmp al,10011001b
je cwd1
mov al,byt3
and al,11111111b
cmp al,10011011b
je wait1
mov al,byt3
and al,11111111b
cmp al,10011100b
je pushf1
mov al,byt3
and al,11111111b
cmp al,10011101b
je popf1
jmp next4
daa1:
lea dx, [commands+34]
mov cx,3
call output
jmp checkend
das1:
lea dx, [commands+38]
mov cx,3
call output
jmp checkend
aaa1:
lea dx, [commands+42]
mov cx,3
call output
jmp checkend
aas1:
lea dx, [commands+46]
mov cx,3
call output
jmp checkend
nop1:
lea dx, [commands+50]
mov cx,3
call output
jmp checkend
cbw1:
lea dx, [commands+54]
mov cx,3
call output
jmp checkend
cwd1:
lea dx, [commands+58]
mov cx,3
call output
jmp checkend
wait1:
lea dx, [commands+62]
mov cx,4
call output
jmp checkend
pushf1:
lea dx, [commands+67]
mov cx,5
call output
jmp checkend
popf1:
lea dx, [commands+73]
mov cx,4
call output
jmp checkend
next4:
mov al,byt3
and al,11111111b
cmp al,10011110b
je sahf1
mov al,byt3
and al,11111111b
cmp al,10011111b
je lahf1
mov al,byt3
and al,11111111b
cmp al,11000011b
je ret1
mov al,byt3
and al,11111111b
cmp al,11001011b
je retf1
mov al,byt3
and al,11111111b
cmp al,11001100b
je int31
mov al,byt3
and al,11111111b
cmp al,11001110b
je into1
mov al,byt3
and al,11111111b
cmp al,11001111b
je iret1
mov al,byt3
and al,11111111b
cmp al,11010100b
je aam1
mov al,byt3
and al,11111111b
cmp al,11010101b
je aad1
mov al,byt3
and al,11111111b
cmp al,11010111b
je xlat1
jmp next5
sahf1:
lea dx, [commands+78]
mov cx,4
call output
jmp checkend
lahf1:
lea dx, [commands+83]
mov cx,4
call output
jmp checkend
ret1:
lea dx, [commands+88]
mov cx,3
call output
jmp checkend
retf1:
lea dx, [commands+92]
mov cx,4
call output
jmp checkend
int31:
lea dx, [commands+97]
mov cx,5
call output
jmp checkend
into1:
lea dx, [commands+103]
mov cx,4
call output
jmp checkend
iret1:
lea dx, [commands+108]
mov cx,4
call output
jmp checkend
aam1:
call readnextbyte
lea dx, [commands+113]
mov cx,3
call output
jmp checkend
aad1:
call readnextbyte
lea dx, [commands+117]
mov cx,3
call output
jmp checkend
xlat1:
lea dx, [commands+121]
mov cx,4
call output
jmp checkend
next5:
mov al,byt3
and al,11111111b
cmp al,11110000b
je lock1
mov al,byt3
and al,11111111b
cmp al,11110010b
je repnz1
mov al,byt3
and al,11111111b
cmp al,11110011b
je rep1
mov al,byt3
and al,11111111b
cmp al,11110100b
je hlt1
mov al,byt3
and al,11111111b
cmp al,11110101b
je cmc1
mov al,byt3
and al,11111111b
cmp al,11111000b
je clc1
mov al,byt3
and al,11111111b
cmp al,11111001b
je stc1
mov al,byt3
and al,11111111b
cmp al,11111010b
je cli1
mov al,byt3
and al,11111111b
cmp al,11111011b
je sti1
jmp next6
lock1:
lea dx, [commands+126]
mov cx,4
call output
jmp checkend
repnz1:
lea dx, [commands+131]
mov cx,5
call output
jmp checkend
rep1:
lea dx, [commands+137]
mov cx,3
call output
jmp checkend
hlt1:
lea dx, [commands+141]
mov cx,3
call output
jmp checkend
cmc1:
lea dx, [commands+145]
mov cx,3
call output
jmp checkend
clc1:
lea dx, [commands+149]
mov cx,3
call output
jmp checkend
stc1:
lea dx, [commands+153]
mov cx,3
call output
jmp checkend
cli1:
lea dx, [commands+157]
mov cx,3
call output
jmp checkend
sti1:
lea dx, [commands+161]
mov cx,3
call output
jmp checkend
next6:
mov al,byt3
and al,11111111b
cmp al,11111100b
je cld1
mov al,byt3
and al,11111111b
cmp al,11111101b
je std1
mov al,byt3
and al,11111111b
cmp al,01110000b
je jo1
mov al,byt3
and al,11111111b
cmp al,01110001b
je jno1
mov al,byt3
and al,11111111b
cmp al,01110010b
je jnae1
mov al,byt3
and al,11111111b
cmp al,01110011b
je jae1
mov al,byt3
and al,11111111b
cmp al,01110100b
je je1
mov al,byt3
and al,11111111b
cmp al,01110101b
je jne1
mov al,byt3
and al,11111111b
cmp al,01110110b
je jbe1
jmp next7
cld1:
lea dx, [commands+165]
mov cx,3
call output
jmp checkend
std1:
lea dx, [commands+169]
mov cx,3
call output
jmp checkend
jo1:
lea dx, [commands+173]
mov cx,3
call output
call shiftforloop
jmp checkend
jno1:
lea dx, [commands+176]
mov cx,4
call output
call shiftforloop
jmp checkend
jnae1:
lea dx, [commands+180]
mov cx,5
call output
call shiftforloop
jmp checkend
jae1:
lea dx, [commands+185]
mov cx,4
call output
call shiftforloop
jmp checkend
je1:
lea dx, [commands+189]
mov cx,3
call output
call shiftforloop
jmp checkend
jne1:
lea dx, [commands+192]
mov cx,4
call output
call shiftforloop
jmp checkend
jbe1:
lea dx, [commands+196]
mov cx,4
call output
call shiftforloop
jmp checkend
next7:
mov al,byt3
and al,11111111b
cmp al,01110111b
je ja1
mov al,byt3
and al,11111111b
cmp al,01111000b
je js1
mov al,byt3
and al,11111111b
cmp al,01111001b
je jns1
mov al,byt3
and al,11111111b
cmp al,01111010b
je jp1
mov al,byt3
and al,11111111b
cmp al,01111011b
je jnp1
mov al,byt3
and al,11111111b
cmp al,01111100b
je jl1
mov al,byt3
and al,11111111b
cmp al,01111101b
je jge1
mov al,byt3
and al,11111111b
cmp al,01111110b
je jle1
mov al,byt3
and al,11111111b
cmp al,01111111b
je jg1
jmp next8
ja1:
lea dx, [commands+200]
mov cx,3
call output
call shiftforloop
jmp checkend
js1:
lea dx, [commands+203]
mov cx,3
call output
call shiftforloop
jmp checkend
jns1:
lea dx, [commands+206]
mov cx,4
call output
call shiftforloop
jmp checkend
jp1:
lea dx, [commands+210]
mov cx,3
call output
call shiftforloop
jmp checkend
jnp1:
lea dx, [commands+213]
mov cx,4
call output
call shiftforloop
jmp checkend
jl1:
lea dx, [commands+217]
mov cx,3
call output
call shiftforloop
jmp checkend
jge1:
lea dx, [commands+220]
mov cx,4
call output
call shiftforloop
jmp checkend
jle1:
lea dx, [commands+224]
mov cx,4
call output
call shiftforloop
jmp checkend
jg1:
lea dx, [commands+228]
mov cx,3
call output
call shiftforloop
jmp checkend
next8:
mov al,byt3
and al,11111100b
cmp al,00000000b
je add1
mov al,byt3
and al,11111110b
cmp al,00000100b
je add2
mov al,byt3
and al,11100111b
cmp al,00000110b
je push1
mov al,byt3
and al,11111100b
cmp al,00001000b
je or1
mov al,byt3
and al,11111110b
cmp al,00001100b
je or2
mov al,byt3
and al,11111100b
cmp al,00010000b
je adc1
mov al,byt3
and al,11111110b
cmp al,00010100b
je adc2
mov al,byt3
and al,11111100b
cmp al,00011000b
je sbb1
mov al,byt3
and al,11111110b
cmp al,00011100b
je sbb2
jmp next9
add1:
lea dx,[commands+231]
mov cx,4
call output
call regrm
jmp checkend
add2:
lea dx,[commands+231]
mov cx,4
call output
call andab
jmp checkend
push1:
lea dx, [commands+235]
mov cx,5
call output
call popsr
jmp checkend
or1:
lea dx,[commands+240]
mov cx,3
call output
call regrm
jmp checkend
or2:
lea dx,[commands+240]
mov cx,3
call output
call andab
jmp checkend
adc1:
lea dx,[commands+243]
mov cx,4
call output
call regrm
jmp checkend
adc2:
lea dx,[commands+243]
mov cx,4
call output
call andab
jmp checkend
sbb1:
lea dx,[commands+247]
mov cx,4
call output
call regrm
jmp checkend
sbb2:
lea dx,[commands+247]
mov cx,4
call output
call andab
jmp checkend
next9:
mov al,byt3
and al,11111100b
cmp al,00101000b
je sub1
mov al,byt3
and al,11111110b