forked from wfeldt/libx86emu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ops.c
5661 lines (4877 loc) · 137 KB
/
ops.c
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
/****************************************************************************
*
* Realmode X86 Emulator Library
*
* Copyright (c) 1996-1999 SciTech Software, Inc.
* Copyright (c) David Mosberger-Tang
* Copyright (c) 1999 Egbert Eich
* Copyright (c) 2007-2017 SUSE LINUX GmbH; Author: Steffen Winterfeldt
*
* ========================================================================
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of the authors not be used
* in advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The authors makes no
* representations about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* ========================================================================
*
* Description:
* Subroutines to implement the decoding and emulation of all the
* x86 processor instructions.
*
* There are approximately 250 subroutines in here, which correspond
* to the 256 byte-"opcodes" found on the 8086. The table which
* dispatches this is found in the files optab.[ch].
*
* Each opcode proc has a comment preceeding it which gives it's table
* address. Several opcodes are missing (undefined) in the table.
*
* Each proc includes information for decoding (OP_DECODE).
*
* Many of the procedures are *VERY* similar in coding. This has
* allowed for a very large amount of code to be generated in a fairly
* short amount of time (i.e. cut, paste, and modify). The result is
* that much of the code below could have been folded into subroutines
* for a large reduction in size of this file. The downside would be
* that there would be a penalty in execution speed. The file could
* also have been *MUCH* larger by inlining certain functions which
* were called. This could have resulted even faster execution. The
* prime directive I used to decide whether to inline the code or to
* modularize it, was basically: 1) no unnecessary subroutine calls,
* 2) no routines more than about 200 lines in size, and 3) modularize
* any code that I might not get right the first time. The fetch_*
* subroutines fall into the latter category. The The decode_* fall
* into the second category. The coding of the "switch(mod){ .... }"
* in many of the subroutines below falls into the first category.
* Especially, the coding of {add,and,or,sub,...}_{byte,word}
* subroutines are an especially glaring case of the third guideline.
* Since so much of the code is cloned from other modules (compare
* opcode #00 to opcode #01), making the basic operations subroutine
* calls is especially important; otherwise mistakes in coding an
* "add" would represent a nightmare in maintenance.
*
****************************************************************************/
#include "include/x86emu_int.h"
/*----------------------------- Implementation ----------------------------*/
static u8 (*op_A_byte[8])(x86emu_t *emu, u8 d, u8 s) = {
add_byte, or_byte, adc_byte, sbb_byte, and_byte, sub_byte, xor_byte, cmp_byte
};
static u16 (*op_A_word[8])(x86emu_t *emu, u16 d, u16 s) = {
add_word, or_word, adc_word, sbb_word, and_word, sub_word, xor_word, cmp_word
};
static u32 (*op_A_long[8])(x86emu_t *emu, u32 d, u32 s) = {
add_long, or_long, adc_long, sbb_long, and_long, sub_long, xor_long, cmp_long
};
static void decode_op_A(x86emu_t *emu, int type)
{
switch(type) {
case 0:
OP_DECODE("add ");
break;
case 1:
OP_DECODE("or ");
break;
case 2:
OP_DECODE("adc ");
break;
case 3:
OP_DECODE("sbb ");
break;
case 4:
OP_DECODE("and ");
break;
case 5:
OP_DECODE("sub ");
break;
case 6:
OP_DECODE("xor ");
break;
case 7:
OP_DECODE("cmp ");
break;
}
}
static u8 (*op_B_byte[8])(x86emu_t *emu, u8 d, u8 s) = {
rol_byte, ror_byte, rcl_byte, rcr_byte, shl_byte, shr_byte, shl_byte, sar_byte
};
static u16 (*op_B_word[8])(x86emu_t *emu, u16 s, u8 d) = {
rol_word, ror_word, rcl_word, rcr_word, shl_word, shr_word, shl_word, sar_word
};
static u32 (*op_B_long[8])(x86emu_t *emu, u32 s, u8 d) = {
rol_long, ror_long, rcl_long, rcr_long, shl_long, shr_long, shl_long, sar_long
};
static void decode_op_B(x86emu_t *emu, int type)
{
switch(type) {
case 0:
OP_DECODE("rol ");
break;
case 1:
OP_DECODE("ror ");
break;
case 2:
OP_DECODE("rcl ");
break;
case 3:
OP_DECODE("rcr ");
break;
case 4:
OP_DECODE("shl ");
break;
case 5:
OP_DECODE("shr ");
break;
case 6:
OP_DECODE("sal ");
break;
case 7:
OP_DECODE("sar ");
break;
}
}
void decode_cond(x86emu_t *emu, int type)
{
switch(type) {
case 0:
OP_DECODE("o ");
break;
case 1:
OP_DECODE("no ");
break;
case 2:
OP_DECODE("b ");
break;
case 3:
OP_DECODE("nb ");
break;
case 4:
OP_DECODE("z ");
break;
case 5:
OP_DECODE("nz ");
break;
case 6:
OP_DECODE("na ");
break;
case 7:
OP_DECODE("a ");
break;
case 8:
OP_DECODE("s ");
break;
case 9:
OP_DECODE("ns ");
break;
case 10:
OP_DECODE("p ");
break;
case 11:
OP_DECODE("np ");
break;
case 12:
OP_DECODE("l ");
break;
case 13:
OP_DECODE("nl ");
break;
case 14:
OP_DECODE("ng ");
break;
case 15:
OP_DECODE("g ");
break;
}
}
/****************************************************************************
PARAMETERS:
op1 - Instruction op code
REMARKS:
Handles illegal opcodes.
****************************************************************************/
static void x86emuOp_illegal_op(x86emu_t *emu, u8 op1)
{
OP_DECODE("illegal opcode");
INTR_RAISE_UD(emu);
}
/****************************************************************************
REMARKS:
Handles opcode 0x00, 0x08, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38
****************************************************************************/
static void x86emuOp_op_A_byte_RM_R(x86emu_t *emu, u8 op1)
{
int mod, rl, rh, type;
u8 *src, *dst, val;
u32 addr;
type = op1 >> 3;
decode_op_A(emu, type);
fetch_decode_modrm(emu, &mod, &rh, &rl);
if(mod == 3) {
dst = decode_rm_byte_register(emu, rl);
OP_DECODE(",");
src = decode_rm_byte_register(emu, rh);
*dst = (*op_A_byte[type])(emu, *dst, *src);
}
else {
addr = decode_rm_address(emu, mod, rl);
OP_DECODE(",");
val = fetch_data_byte(emu, addr);
src = decode_rm_byte_register(emu, rh);
val = (*op_A_byte[type])(emu, val, *src);
if(type != 7) store_data_byte(emu, addr, val);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x01, 0x09, 0x11, 0x19, 0x21, 0x29, 0x31, 0x39
****************************************************************************/
static void x86emuOp_op_A_word_RM_R(x86emu_t *emu, u8 op1)
{
int mod, rl, rh, type;
u32 *src32, *dst32, val, addr;
u16 *src16, *dst16;
type = op1 >> 3;
decode_op_A(emu, type);
fetch_decode_modrm(emu, &mod, &rh, &rl);
if(mod == 3) {
if(MODE_DATA32) {
dst32 = decode_rm_long_register(emu, rl);
OP_DECODE(",");
src32 = decode_rm_long_register(emu, rh);
*dst32 = (*op_A_long[type])(emu, *dst32, *src32);
}
else {
dst16 = decode_rm_word_register(emu, rl);
OP_DECODE(",");
src16 = decode_rm_word_register(emu, rh);
*dst16 = (*op_A_word[type])(emu, *dst16, *src16);
}
}
else {
addr = decode_rm_address(emu, mod, rl);
OP_DECODE(",");
if(MODE_DATA32) {
val = fetch_data_long(emu, addr);
src32 = decode_rm_long_register(emu, rh);
val = (*op_A_long[type])(emu, val, *src32);
if(type != 7) store_data_long(emu, addr, val);
}
else {
val = fetch_data_word(emu, addr);
src16 = decode_rm_word_register(emu, rh);
val = (*op_A_word[type])(emu, val, *src16);
if(type != 7) store_data_word(emu, addr, val);
}
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x02, 0x0a, 0x12, 0x1a, 0x22, 0x2a, 0x32, 0x3a
****************************************************************************/
static void x86emuOp_op_A_byte_R_RM(x86emu_t *emu, u8 op1)
{
int mod, rl, rh, type;
u8 *src, *dst, val;
u32 addr;
type = op1 >> 3;
decode_op_A(emu, type);
fetch_decode_modrm(emu, &mod, &rh, &rl);
if(mod == 3) {
dst = decode_rm_byte_register(emu, rh);
OP_DECODE(",");
src = decode_rm_byte_register(emu, rl);
*dst = (*op_A_byte[type])(emu, *dst, *src);
}
else {
dst = decode_rm_byte_register(emu, rh);
OP_DECODE(",");
addr = decode_rm_address(emu, mod, rl);
val = fetch_data_byte(emu, addr);
*dst = (*op_A_byte[type])(emu, *dst, val);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x03, 0x0b, 0x13, 0x1b, 0x23, 0x2b, 0x33, 0x3b
****************************************************************************/
static void x86emuOp_op_A_word_R_RM(x86emu_t *emu, u8 op1)
{
int mod, rl, rh, type;
u32 *src32, *dst32, val, addr;
u16 *src16, *dst16;
type = op1 >> 3;
decode_op_A(emu, type);
fetch_decode_modrm(emu, &mod, &rh, &rl);
if(mod == 3) {
if(MODE_DATA32) {
dst32 = decode_rm_long_register(emu, rh);
OP_DECODE(",");
src32 = decode_rm_long_register(emu, rl);
*dst32 = (*op_A_long[type])(emu, *dst32, *src32);
}
else {
dst16 = decode_rm_word_register(emu, rh);
OP_DECODE(",");
src16 = decode_rm_word_register(emu, rl);
*dst16 = (*op_A_word[type])(emu, *dst16, *src16);
}
}
else {
if(MODE_DATA32) {
dst32 = decode_rm_long_register(emu, rh);
OP_DECODE(",");
addr = decode_rm_address(emu, mod, rl);
val = fetch_data_long(emu, addr);
*dst32 = (*op_A_long[type])(emu, *dst32, val);
}
else {
dst16 = decode_rm_word_register(emu, rh);
OP_DECODE(",");
addr = decode_rm_address(emu, mod, rl);
val = fetch_data_word(emu, addr);
*dst16 = (*op_A_word[type])(emu, *dst16, val);
}
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x04, 0x0c, 0x14, 0x1c, 0x24, 0x2c, 0x34, 0x3c
****************************************************************************/
static void x86emuOp_op_A_byte_AL_IMM(x86emu_t *emu, u8 op1)
{
int type;
u8 val;
type = op1 >> 3;
decode_op_A(emu, type);
OP_DECODE("al,");
val = fetch_byte(emu);
DECODE_HEX2(val);
emu->x86.R_AL = (*op_A_byte[type])(emu, emu->x86.R_AL, val);
}
/****************************************************************************
REMARKS:
Handles opcode 0x05, 0x0d, 0x15, 0x1d, 0x25, 0x2d, 0x35, 0x3d
****************************************************************************/
static void x86emuOp_op_A_word_AX_IMM(x86emu_t *emu, u8 op1)
{
int type;
u32 val;
type = op1 >> 3;
decode_op_A(emu, type);
if(MODE_DATA32) {
OP_DECODE("eax,");
val = fetch_long(emu);
DECODE_HEX8(val);
emu->x86.R_EAX = (*op_A_long[type])(emu, emu->x86.R_EAX, val);
}
else {
OP_DECODE("ax,");
val = fetch_word(emu);
DECODE_HEX4(val);
emu->x86.R_AX = (*op_A_word[type])(emu, emu->x86.R_AX, val);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x06
****************************************************************************/
static void x86emuOp_push_ES(x86emu_t *emu, u8 op1)
{
OP_DECODE("push es");
if(MODE_DATA32) {
push_long(emu, emu->x86.R_ES);
}
else {
push_word(emu, emu->x86.R_ES);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x07
****************************************************************************/
static void x86emuOp_pop_ES(x86emu_t *emu, u8 op1)
{
OP_DECODE("pop es");
x86emu_set_seg_register(emu, emu->x86.R_ES_SEL, MODE_DATA32 ? pop_long(emu) : pop_word(emu));
}
/****************************************************************************
REMARKS:
Handles opcode 0x0e
****************************************************************************/
static void x86emuOp_push_CS(x86emu_t *emu, u8 op1)
{
OP_DECODE("push cs");
if(MODE_DATA32) {
push_long(emu, emu->x86.R_CS);
}
else {
push_word(emu, emu->x86.R_CS);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x0f. Escape for two-byte opcode (286 or better)
****************************************************************************/
static void x86emuOp_two_byte(x86emu_t *emu, u8 op1)
{
u8 op2 = fetch_byte(emu);
(*x86emu_optab2[op2])(emu, op2);
}
/****************************************************************************
REMARKS:
Handles opcode 0x16
****************************************************************************/
static void x86emuOp_push_SS(x86emu_t *emu, u8 op1)
{
OP_DECODE("push ss");
if(MODE_DATA32) {
push_long(emu, emu->x86.R_SS);
}
else {
push_word(emu, emu->x86.R_SS);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x17
****************************************************************************/
static void x86emuOp_pop_SS(x86emu_t *emu, u8 op1)
{
OP_DECODE("pop ss");
x86emu_set_seg_register(emu, emu->x86.R_SS_SEL, MODE_DATA32 ? pop_long(emu) : pop_word(emu));
}
/****************************************************************************
REMARKS:
Handles opcode 0x1e
****************************************************************************/
static void x86emuOp_push_DS(x86emu_t *emu, u8 op1)
{
OP_DECODE("push ds");
if(MODE_DATA32) {
push_long(emu, emu->x86.R_DS);
}
else {
push_word(emu, emu->x86.R_DS);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x1f
****************************************************************************/
static void x86emuOp_pop_DS(x86emu_t *emu, u8 op1)
{
OP_DECODE("pop ds");
x86emu_set_seg_register(emu, emu->x86.R_DS_SEL, MODE_DATA32 ? pop_long(emu) : pop_word(emu));
}
/****************************************************************************
REMARKS:
Handles opcode 0x27
****************************************************************************/
static void x86emuOp_daa(x86emu_t *emu, u8 op1)
{
OP_DECODE("daa");
emu->x86.R_AL = daa_byte(emu, emu->x86.R_AL);
}
/****************************************************************************
REMARKS:
Handles opcode 0x2f
****************************************************************************/
static void x86emuOp_das(x86emu_t *emu, u8 op1)
{
OP_DECODE("das");
emu->x86.R_AL = das_byte(emu, emu->x86.R_AL);
}
/****************************************************************************
REMARKS:
Handles opcode 0x37
****************************************************************************/
static void x86emuOp_aaa(x86emu_t *emu, u8 op1)
{
OP_DECODE("aaa");
emu->x86.R_AX = aaa_word(emu, emu->x86.R_AX);
}
/****************************************************************************
REMARKS:
Handles opcode 0x3f
****************************************************************************/
static void x86emuOp_aas(x86emu_t *emu, u8 op1)
{
OP_DECODE("aas");
emu->x86.R_AX = aas_word(emu, emu->x86.R_AX);
}
/****************************************************************************
REMARKS:
Handles opcode 0x40
****************************************************************************/
static void x86emuOp_inc_AX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("inc eax");
emu->x86.R_EAX = inc_long(emu, emu->x86.R_EAX);
}
else {
OP_DECODE("inc ax");
emu->x86.R_AX = inc_word(emu, emu->x86.R_AX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x41
****************************************************************************/
static void x86emuOp_inc_CX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("inc ecx");
emu->x86.R_ECX = inc_long(emu, emu->x86.R_ECX);
}
else {
OP_DECODE("inc cx");
emu->x86.R_CX = inc_word(emu, emu->x86.R_CX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x42
****************************************************************************/
static void x86emuOp_inc_DX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("inc edx");
emu->x86.R_EDX = inc_long(emu, emu->x86.R_EDX);
}
else {
OP_DECODE("inc dx");
emu->x86.R_DX = inc_word(emu, emu->x86.R_DX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x43
****************************************************************************/
static void x86emuOp_inc_BX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("inc ebx");
emu->x86.R_EBX = inc_long(emu, emu->x86.R_EBX);
}
else {
OP_DECODE("inc bx");
emu->x86.R_BX = inc_word(emu, emu->x86.R_BX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x44
****************************************************************************/
static void x86emuOp_inc_SP(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("inc esp");
emu->x86.R_ESP = inc_long(emu, emu->x86.R_ESP);
}
else {
OP_DECODE("inc sp");
emu->x86.R_SP = inc_word(emu, emu->x86.R_SP);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x45
****************************************************************************/
static void x86emuOp_inc_BP(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("inc ebp");
emu->x86.R_EBP = inc_long(emu, emu->x86.R_EBP);
}
else {
OP_DECODE("inc bp");
emu->x86.R_BP = inc_word(emu, emu->x86.R_BP);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x46
****************************************************************************/
static void x86emuOp_inc_SI(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("inc esi");
emu->x86.R_ESI = inc_long(emu, emu->x86.R_ESI);
}
else {
OP_DECODE("inc si");
emu->x86.R_SI = inc_word(emu, emu->x86.R_SI);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x47
****************************************************************************/
static void x86emuOp_inc_DI(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("inc edi");
emu->x86.R_EDI = inc_long(emu, emu->x86.R_EDI);
}
else {
OP_DECODE("inc di");
emu->x86.R_DI = inc_word(emu, emu->x86.R_DI);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x48
****************************************************************************/
static void x86emuOp_dec_AX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("dec eax");
emu->x86.R_EAX = dec_long(emu, emu->x86.R_EAX);
}
else {
OP_DECODE("dec ax");
emu->x86.R_AX = dec_word(emu, emu->x86.R_AX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x49
****************************************************************************/
static void x86emuOp_dec_CX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("dec ecx");
emu->x86.R_ECX = dec_long(emu, emu->x86.R_ECX);
}
else {
OP_DECODE("dec cx");
emu->x86.R_CX = dec_word(emu, emu->x86.R_CX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x4a
****************************************************************************/
static void x86emuOp_dec_DX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("dec edx");
emu->x86.R_EDX = dec_long(emu, emu->x86.R_EDX);
}
else {
OP_DECODE("dec dx");
emu->x86.R_DX = dec_word(emu, emu->x86.R_DX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x4b
****************************************************************************/
static void x86emuOp_dec_BX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("dec ebx");
emu->x86.R_EBX = dec_long(emu, emu->x86.R_EBX);
}
else {
OP_DECODE("dec bx");
emu->x86.R_BX = dec_word(emu, emu->x86.R_BX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x4c
****************************************************************************/
static void x86emuOp_dec_SP(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("dec esp");
emu->x86.R_ESP = dec_long(emu, emu->x86.R_ESP);
}
else {
OP_DECODE("dec sp");
emu->x86.R_SP = dec_word(emu, emu->x86.R_SP);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x4d
****************************************************************************/
static void x86emuOp_dec_BP(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("dec ebp");
emu->x86.R_EBP = dec_long(emu, emu->x86.R_EBP);
}
else {
OP_DECODE("dec bp");
emu->x86.R_BP = dec_word(emu, emu->x86.R_BP);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x4e
****************************************************************************/
static void x86emuOp_dec_SI(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("dec esi");
emu->x86.R_ESI = dec_long(emu, emu->x86.R_ESI);
}
else {
OP_DECODE("dec si");
emu->x86.R_SI = dec_word(emu, emu->x86.R_SI);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x4f
****************************************************************************/
static void x86emuOp_dec_DI(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("dec edi");
emu->x86.R_EDI = dec_long(emu, emu->x86.R_EDI);
}
else {
OP_DECODE("dec di");
emu->x86.R_DI = dec_word(emu, emu->x86.R_DI);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x50
****************************************************************************/
static void x86emuOp_push_AX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("push eax");
push_long(emu, emu->x86.R_EAX);
}
else {
OP_DECODE("push ax");
push_word(emu, emu->x86.R_AX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x51
****************************************************************************/
static void x86emuOp_push_CX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("push ecx");
push_long(emu, emu->x86.R_ECX);
}
else {
OP_DECODE("push cx");
push_word(emu, emu->x86.R_CX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x52
****************************************************************************/
static void x86emuOp_push_DX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("push edx");
push_long(emu, emu->x86.R_EDX);
}
else {
OP_DECODE("push dx");
push_word(emu, emu->x86.R_DX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x53
****************************************************************************/
static void x86emuOp_push_BX(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("push ebx");
push_long(emu, emu->x86.R_EBX);
}
else {
OP_DECODE("push bx");
push_word(emu, emu->x86.R_BX);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x54
****************************************************************************/
static void x86emuOp_push_SP(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("push esp");
push_long(emu, emu->x86.R_ESP);
}
else {
OP_DECODE("push sp");
push_word(emu, emu->x86.R_SP);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x55
****************************************************************************/
static void x86emuOp_push_BP(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("push ebp");
push_long(emu, emu->x86.R_EBP);
}
else {
OP_DECODE("push bp");
push_word(emu, emu->x86.R_BP);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x56
****************************************************************************/
static void x86emuOp_push_SI(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("push esi");
push_long(emu, emu->x86.R_ESI);
}
else {
OP_DECODE("push si");
push_word(emu, emu->x86.R_SI);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x57
****************************************************************************/
static void x86emuOp_push_DI(x86emu_t *emu, u8 op1)
{
if(MODE_DATA32) {
OP_DECODE("push edi");
push_long(emu, emu->x86.R_EDI);
}
else {
OP_DECODE("push di");
push_word(emu, emu->x86.R_DI);
}
}
/****************************************************************************
REMARKS:
Handles opcode 0x58
****************************************************************************/
static void x86emuOp_pop_AX(x86emu_t *emu, u8 op1)
{