Revision dab2ed99 op-i386.c
b/op-i386.c | ||
---|---|---|
464 | 464 |
EDX = r; |
465 | 465 |
} |
466 | 466 |
|
467 |
/* constant load */ |
|
467 |
/* constant load & misc op */
|
|
468 | 468 |
|
469 | 469 |
void OPPROTO op_movl_T0_im(void) |
470 | 470 |
{ |
471 | 471 |
T0 = PARAM1; |
472 | 472 |
} |
473 | 473 |
|
474 |
void OPPROTO op_addl_T0_im(void) |
|
475 |
{ |
|
476 |
T0 += PARAM1; |
|
477 |
} |
|
478 |
|
|
479 |
void OPPROTO op_andl_T0_ffff(void) |
|
480 |
{ |
|
481 |
T0 = T0 & 0xffff; |
|
482 |
} |
|
483 |
|
|
484 |
void OPPROTO op_movl_T0_T1(void) |
|
485 |
{ |
|
486 |
T0 = T1; |
|
487 |
} |
|
488 |
|
|
474 | 489 |
void OPPROTO op_movl_T1_im(void) |
475 | 490 |
{ |
476 | 491 |
T1 = PARAM1; |
477 | 492 |
} |
478 | 493 |
|
494 |
void OPPROTO op_addl_T1_im(void) |
|
495 |
{ |
|
496 |
T1 += PARAM1; |
|
497 |
} |
|
498 |
|
|
499 |
void OPPROTO op_movl_T1_A0(void) |
|
500 |
{ |
|
501 |
T1 = A0; |
|
502 |
} |
|
503 |
|
|
479 | 504 |
void OPPROTO op_movl_A0_im(void) |
480 | 505 |
{ |
481 | 506 |
A0 = PARAM1; |
... | ... | |
574 | 599 |
|
575 | 600 |
void OPPROTO op_jmp_T0(void) |
576 | 601 |
{ |
577 |
PC = T0;
|
|
602 |
EIP = T0;
|
|
578 | 603 |
} |
579 | 604 |
|
580 | 605 |
void OPPROTO op_jmp_im(void) |
581 | 606 |
{ |
582 |
PC = PARAM1;
|
|
607 |
EIP = PARAM1;
|
|
583 | 608 |
} |
584 | 609 |
|
585 | 610 |
void OPPROTO op_int_im(void) |
586 | 611 |
{ |
587 |
PC = PARAM1;
|
|
612 |
EIP = PARAM1;
|
|
588 | 613 |
raise_exception(EXCP0D_GPF); |
589 | 614 |
} |
590 | 615 |
|
591 | 616 |
void OPPROTO op_int3(void) |
592 | 617 |
{ |
593 |
PC = PARAM1;
|
|
618 |
EIP = PARAM1;
|
|
594 | 619 |
raise_exception(EXCP03_INT3); |
595 | 620 |
} |
596 | 621 |
|
... | ... | |
599 | 624 |
int eflags; |
600 | 625 |
eflags = cc_table[CC_OP].compute_all(); |
601 | 626 |
if (eflags & CC_O) { |
602 |
PC = PARAM1;
|
|
627 |
EIP = PARAM1;
|
|
603 | 628 |
raise_exception(EXCP04_INTO); |
604 | 629 |
} else { |
605 |
PC = PARAM2;
|
|
630 |
EIP = PARAM2;
|
|
606 | 631 |
} |
607 | 632 |
} |
608 | 633 |
|
... | ... | |
665 | 690 |
} |
666 | 691 |
|
667 | 692 |
/* push/pop */ |
668 |
/* XXX: add 16 bit operand/16 bit seg variants */ |
|
669 | 693 |
|
670 | 694 |
void op_pushl_T0(void) |
671 | 695 |
{ |
... | ... | |
676 | 700 |
ESP = offset; |
677 | 701 |
} |
678 | 702 |
|
679 |
void op_pushl_T1(void) |
|
703 |
void op_pushw_T0(void) |
|
704 |
{ |
|
705 |
uint32_t offset; |
|
706 |
offset = ESP - 2; |
|
707 |
stw((void *)offset, T0); |
|
708 |
/* modify ESP after to handle exceptions correctly */ |
|
709 |
ESP = offset; |
|
710 |
} |
|
711 |
|
|
712 |
void op_pushl_ss32_T0(void) |
|
680 | 713 |
{ |
681 | 714 |
uint32_t offset; |
682 | 715 |
offset = ESP - 4; |
683 |
stl((void *)offset, T1);
|
|
716 |
stl(env->seg_cache[R_SS].base + offset, T0);
|
|
684 | 717 |
/* modify ESP after to handle exceptions correctly */ |
685 | 718 |
ESP = offset; |
686 | 719 |
} |
687 | 720 |
|
721 |
void op_pushw_ss32_T0(void) |
|
722 |
{ |
|
723 |
uint32_t offset; |
|
724 |
offset = ESP - 2; |
|
725 |
stw(env->seg_cache[R_SS].base + offset, T0); |
|
726 |
/* modify ESP after to handle exceptions correctly */ |
|
727 |
ESP = offset; |
|
728 |
} |
|
729 |
|
|
730 |
void op_pushl_ss16_T0(void) |
|
731 |
{ |
|
732 |
uint32_t offset; |
|
733 |
offset = (ESP - 4) & 0xffff; |
|
734 |
stl(env->seg_cache[R_SS].base + offset, T0); |
|
735 |
/* modify ESP after to handle exceptions correctly */ |
|
736 |
ESP = (ESP & ~0xffff) | offset; |
|
737 |
} |
|
738 |
|
|
739 |
void op_pushw_ss16_T0(void) |
|
740 |
{ |
|
741 |
uint32_t offset; |
|
742 |
offset = (ESP - 2) & 0xffff; |
|
743 |
stw(env->seg_cache[R_SS].base + offset, T0); |
|
744 |
/* modify ESP after to handle exceptions correctly */ |
|
745 |
ESP = (ESP & ~0xffff) | offset; |
|
746 |
} |
|
747 |
|
|
748 |
/* NOTE: ESP update is done after */ |
|
688 | 749 |
void op_popl_T0(void) |
689 | 750 |
{ |
690 | 751 |
T0 = ldl((void *)ESP); |
752 |
} |
|
753 |
|
|
754 |
void op_popw_T0(void) |
|
755 |
{ |
|
756 |
T0 = lduw((void *)ESP); |
|
757 |
} |
|
758 |
|
|
759 |
void op_popl_ss32_T0(void) |
|
760 |
{ |
|
761 |
T0 = ldl(env->seg_cache[R_SS].base + ESP); |
|
762 |
} |
|
763 |
|
|
764 |
void op_popw_ss32_T0(void) |
|
765 |
{ |
|
766 |
T0 = lduw(env->seg_cache[R_SS].base + ESP); |
|
767 |
} |
|
768 |
|
|
769 |
void op_popl_ss16_T0(void) |
|
770 |
{ |
|
771 |
T0 = ldl(env->seg_cache[R_SS].base + (ESP & 0xffff)); |
|
772 |
} |
|
773 |
|
|
774 |
void op_popw_ss16_T0(void) |
|
775 |
{ |
|
776 |
T0 = lduw(env->seg_cache[R_SS].base + (ESP & 0xffff)); |
|
777 |
} |
|
778 |
|
|
779 |
void op_addl_ESP_4(void) |
|
780 |
{ |
|
691 | 781 |
ESP += 4; |
692 | 782 |
} |
693 | 783 |
|
784 |
void op_addl_ESP_2(void) |
|
785 |
{ |
|
786 |
ESP += 2; |
|
787 |
} |
|
788 |
|
|
789 |
void op_addw_ESP_4(void) |
|
790 |
{ |
|
791 |
ESP = (ESP & ~0xffff) | ((ESP + 4) & 0xffff); |
|
792 |
} |
|
793 |
|
|
794 |
void op_addw_ESP_2(void) |
|
795 |
{ |
|
796 |
ESP = (ESP & ~0xffff) | ((ESP + 2) & 0xffff); |
|
797 |
} |
|
798 |
|
|
694 | 799 |
void op_addl_ESP_im(void) |
695 | 800 |
{ |
696 | 801 |
ESP += PARAM1; |
697 | 802 |
} |
698 | 803 |
|
699 |
void op_pushal(void) |
|
700 |
{ |
|
701 |
uint8_t *sp; |
|
702 |
sp = (void *)(ESP - 32); |
|
703 |
stl(sp, EDI); |
|
704 |
stl(sp + 4, ESI); |
|
705 |
stl(sp + 8, EBP); |
|
706 |
stl(sp + 12, ESP); |
|
707 |
stl(sp + 16, EBX); |
|
708 |
stl(sp + 20, EDX); |
|
709 |
stl(sp + 24, ECX); |
|
710 |
stl(sp + 28, EAX); |
|
711 |
ESP = (unsigned long)sp; |
|
712 |
} |
|
713 |
|
|
714 |
void op_pushaw(void) |
|
715 |
{ |
|
716 |
uint8_t *sp; |
|
717 |
sp = (void *)(ESP - 16); |
|
718 |
stw(sp, EDI); |
|
719 |
stw(sp + 2, ESI); |
|
720 |
stw(sp + 4, EBP); |
|
721 |
stw(sp + 6, ESP); |
|
722 |
stw(sp + 8, EBX); |
|
723 |
stw(sp + 10, EDX); |
|
724 |
stw(sp + 12, ECX); |
|
725 |
stw(sp + 14, EAX); |
|
726 |
ESP = (unsigned long)sp; |
|
727 |
} |
|
728 |
|
|
729 |
void op_popal(void) |
|
730 |
{ |
|
731 |
uint8_t *sp; |
|
732 |
sp = (void *)ESP; |
|
733 |
EDI = ldl(sp); |
|
734 |
ESI = ldl(sp + 4); |
|
735 |
EBP = ldl(sp + 8); |
|
736 |
EBX = ldl(sp + 16); |
|
737 |
EDX = ldl(sp + 20); |
|
738 |
ECX = ldl(sp + 24); |
|
739 |
EAX = ldl(sp + 28); |
|
740 |
ESP = (unsigned long)sp + 32; |
|
741 |
} |
|
742 |
|
|
743 |
void op_popaw(void) |
|
744 |
{ |
|
745 |
uint8_t *sp; |
|
746 |
sp = (void *)ESP; |
|
747 |
EDI = ldl(sp); |
|
748 |
ESI = ldl(sp + 2); |
|
749 |
EBP = ldl(sp + 4); |
|
750 |
EBX = ldl(sp + 8); |
|
751 |
EDX = ldl(sp + 10); |
|
752 |
ECX = ldl(sp + 12); |
|
753 |
EAX = ldl(sp + 14); |
|
754 |
ESP = (unsigned long)sp + 16; |
|
755 |
} |
|
756 |
|
|
757 |
void op_enterl(void) |
|
758 |
{ |
|
759 |
unsigned int bp, frame_temp, level; |
|
760 |
uint8_t *sp; |
|
761 |
|
|
762 |
sp = (void *)ESP; |
|
763 |
bp = EBP; |
|
764 |
sp -= 4; |
|
765 |
stl(sp, bp); |
|
766 |
frame_temp = (unsigned int)sp; |
|
767 |
level = PARAM2; |
|
768 |
if (level) { |
|
769 |
while (level--) { |
|
770 |
bp -= 4; |
|
771 |
sp -= 4; |
|
772 |
stl(sp, bp); |
|
773 |
} |
|
774 |
sp -= 4; |
|
775 |
stl(sp, frame_temp); |
|
776 |
} |
|
777 |
EBP = frame_temp; |
|
778 |
sp -= PARAM1; |
|
779 |
ESP = (int)sp; |
|
804 |
void op_addw_ESP_im(void) |
|
805 |
{ |
|
806 |
ESP = (ESP & ~0xffff) | ((ESP + PARAM1) & 0xffff); |
|
780 | 807 |
} |
781 | 808 |
|
782 | 809 |
/* rdtsc */ |
... | ... | |
988 | 1015 |
int eflags; |
989 | 1016 |
eflags = cc_table[CC_OP].compute_all(); |
990 | 1017 |
if (eflags & CC_O) |
991 |
PC = PARAM1;
|
|
1018 |
EIP = PARAM1;
|
|
992 | 1019 |
else |
993 |
PC = PARAM2;
|
|
1020 |
EIP = PARAM2;
|
|
994 | 1021 |
FORCE_RET(); |
995 | 1022 |
} |
996 | 1023 |
|
997 | 1024 |
void OPPROTO op_jb_cc(void) |
998 | 1025 |
{ |
999 | 1026 |
if (cc_table[CC_OP].compute_c()) |
1000 |
PC = PARAM1;
|
|
1027 |
EIP = PARAM1;
|
|
1001 | 1028 |
else |
1002 |
PC = PARAM2;
|
|
1029 |
EIP = PARAM2;
|
|
1003 | 1030 |
FORCE_RET(); |
1004 | 1031 |
} |
1005 | 1032 |
|
... | ... | |
1008 | 1035 |
int eflags; |
1009 | 1036 |
eflags = cc_table[CC_OP].compute_all(); |
1010 | 1037 |
if (eflags & CC_Z) |
1011 |
PC = PARAM1;
|
|
1038 |
EIP = PARAM1;
|
|
1012 | 1039 |
else |
1013 |
PC = PARAM2;
|
|
1040 |
EIP = PARAM2;
|
|
1014 | 1041 |
FORCE_RET(); |
1015 | 1042 |
} |
1016 | 1043 |
|
... | ... | |
1019 | 1046 |
int eflags; |
1020 | 1047 |
eflags = cc_table[CC_OP].compute_all(); |
1021 | 1048 |
if (eflags & (CC_Z | CC_C)) |
1022 |
PC = PARAM1;
|
|
1049 |
EIP = PARAM1;
|
|
1023 | 1050 |
else |
1024 |
PC = PARAM2;
|
|
1051 |
EIP = PARAM2;
|
|
1025 | 1052 |
FORCE_RET(); |
1026 | 1053 |
} |
1027 | 1054 |
|
... | ... | |
1030 | 1057 |
int eflags; |
1031 | 1058 |
eflags = cc_table[CC_OP].compute_all(); |
1032 | 1059 |
if (eflags & CC_S) |
1033 |
PC = PARAM1;
|
|
1060 |
EIP = PARAM1;
|
|
1034 | 1061 |
else |
1035 |
PC = PARAM2;
|
|
1062 |
EIP = PARAM2;
|
|
1036 | 1063 |
FORCE_RET(); |
1037 | 1064 |
} |
1038 | 1065 |
|
... | ... | |
1041 | 1068 |
int eflags; |
1042 | 1069 |
eflags = cc_table[CC_OP].compute_all(); |
1043 | 1070 |
if (eflags & CC_P) |
1044 |
PC = PARAM1;
|
|
1071 |
EIP = PARAM1;
|
|
1045 | 1072 |
else |
1046 |
PC = PARAM2;
|
|
1073 |
EIP = PARAM2;
|
|
1047 | 1074 |
FORCE_RET(); |
1048 | 1075 |
} |
1049 | 1076 |
|
... | ... | |
1052 | 1079 |
int eflags; |
1053 | 1080 |
eflags = cc_table[CC_OP].compute_all(); |
1054 | 1081 |
if ((eflags ^ (eflags >> 4)) & 0x80) |
1055 |
PC = PARAM1;
|
|
1082 |
EIP = PARAM1;
|
|
1056 | 1083 |
else |
1057 |
PC = PARAM2;
|
|
1084 |
EIP = PARAM2;
|
|
1058 | 1085 |
FORCE_RET(); |
1059 | 1086 |
} |
1060 | 1087 |
|
... | ... | |
1063 | 1090 |
int eflags; |
1064 | 1091 |
eflags = cc_table[CC_OP].compute_all(); |
1065 | 1092 |
if (((eflags ^ (eflags >> 4)) & 0x80) || (eflags & CC_Z)) |
1066 |
PC = PARAM1;
|
|
1093 |
EIP = PARAM1;
|
|
1067 | 1094 |
else |
1068 |
PC = PARAM2;
|
|
1095 |
EIP = PARAM2;
|
|
1069 | 1096 |
FORCE_RET(); |
1070 | 1097 |
} |
1071 | 1098 |
|
Also available in: Unified diff