Mercurial > repos > blastem
comparison gen_x86.c @ 1216:0649cd8ca097
Cycle accurate MULU/MULS emulation
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 04 Feb 2017 00:41:15 -0800 |
parents | 2ec5e6eaf81d |
children | d5a47597b61f |
comparison
equal
deleted
inserted
replaced
1215:cf69a179aeaf | 1216:0649cd8ca097 |
---|---|
29 #define PRE_REX 0x40 | 29 #define PRE_REX 0x40 |
30 #define OP_PUSH 0x50 | 30 #define OP_PUSH 0x50 |
31 #define OP_POP 0x58 | 31 #define OP_POP 0x58 |
32 #define OP_MOVSXD 0x63 | 32 #define OP_MOVSXD 0x63 |
33 #define PRE_SIZE 0x66 | 33 #define PRE_SIZE 0x66 |
34 #define OP_IMUL 0x69 | |
34 #define OP_JCC 0x70 | 35 #define OP_JCC 0x70 |
35 #define OP_IMMED_ARITH 0x80 | 36 #define OP_IMMED_ARITH 0x80 |
36 #define OP_TEST 0x84 | 37 #define OP_TEST 0x84 |
37 #define OP_XCHG 0x86 | 38 #define OP_XCHG 0x86 |
38 #define OP_MOV 0x88 | 39 #define OP_MOV 0x88 |
528 opcode |= BIT_DIR; | 529 opcode |= BIT_DIR; |
529 } | 530 } |
530 if (size == SZ_W) { | 531 if (size == SZ_W) { |
531 *(out++) = PRE_SIZE; | 532 *(out++) = PRE_SIZE; |
532 } | 533 } |
533 if (dst == RAX && !sign_extend) { | 534 if (dst == RAX && !sign_extend && al_opcode) { |
534 if (size != SZ_B) { | 535 if (size != SZ_B) { |
535 al_opcode |= BIT_SIZE; | 536 al_opcode |= BIT_SIZE; |
536 if (size == SZ_Q) { | 537 if (size == SZ_Q) { |
537 #ifdef X86_64 | 538 #ifdef X86_64 |
538 *out = PRE_REX | REX_QUAD; | 539 *out = PRE_REX | REX_QUAD; |
1142 } | 1143 } |
1143 | 1144 |
1144 void imul_rdispr(code_info *code, uint8_t src_base, int32_t disp, uint8_t dst, uint8_t size) | 1145 void imul_rdispr(code_info *code, uint8_t src_base, int32_t disp, uint8_t dst, uint8_t size) |
1145 { | 1146 { |
1146 x86_rrdisp_sizedir(code, OP2_IMUL | (PRE_2BYTE << 8), dst, src_base, disp, size, 0); | 1147 x86_rrdisp_sizedir(code, OP2_IMUL | (PRE_2BYTE << 8), dst, src_base, disp, size, 0); |
1148 } | |
1149 | |
1150 void imul_irr(code_info *code, int32_t val, uint8_t src, uint8_t dst, uint8_t size) | |
1151 { | |
1152 if (size == SZ_B) { | |
1153 fatal_error("imul immediate only supports 16-bit sizes and up"); | |
1154 } | |
1155 | |
1156 x86_ir(code, OP_IMUL, dst, 0, val, src, size); | |
1147 } | 1157 } |
1148 | 1158 |
1149 void not_r(code_info *code, uint8_t dst, uint8_t size) | 1159 void not_r(code_info *code, uint8_t dst, uint8_t size) |
1150 { | 1160 { |
1151 x86_r_size(code, OP_NOT_NEG, OP_EX_NOT, dst, size); | 1161 x86_r_size(code, OP_NOT_NEG, OP_EX_NOT, dst, size); |