regs.ecx = 0x12345678;
regs.eax = (unsigned long)res;
*res = 0x7FFFFFFF;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x92345677) ||
(regs.eflags != 0xa94) ||
regs.eip = (unsigned long)&instr[0];
regs.ecx = 0x12345678;
regs.eax = 0x7FFFFFFF;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(regs.ecx != 0x12345678) ||
(regs.eax != 0x92345677) ||
regs.ecx = 0x12345678UL;
#endif
regs.eax = (unsigned long)res;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x92345677) ||
(regs.ecx != 0x8000000FUL) ||
regs.eip = (unsigned long)&instr[0];
regs.ecx = ~0UL;
regs.eax = (unsigned long)res;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x92345677) ||
(regs.ecx != 0x92345677UL) ||
regs.eax = 0x92345677UL;
regs.ecx = 0xAA;
regs.ebx = (unsigned long)res;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x923456AA) ||
(regs.eflags != 0x244) ||
regs.eax = 0xAABBCC77UL;
regs.ecx = 0xFF;
regs.ebx = (unsigned long)res;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x923456AA) ||
((regs.eflags&0x240) != 0x200) ||
regs.eip = (unsigned long)&instr[0];
regs.ecx = 0x12345678;
regs.eax = (unsigned long)res;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x12345678) ||
(regs.eflags != 0x200) ||
regs.eax = 0x923456AAUL;
regs.ecx = 0xDDEEFF00L;
regs.ebx = (unsigned long)res;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0xDDEEFF00) ||
(regs.eflags != 0x244) ||
regs.eip = (unsigned long)&instr[0];
regs.esi = (unsigned long)res + 0;
regs.edi = (unsigned long)res + 2;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x44554455) ||
(regs.eflags != 0x200) ||
regs.eflags = 0x200;
regs.eip = (unsigned long)&instr[0];
regs.edi = (unsigned long)res;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x2233445D) ||
((regs.eflags&0x201) != 0x201) ||
regs.eip = (unsigned long)&instr[0];
regs.eax = -32;
regs.edi = (unsigned long)(res+1);
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x2233445E) ||
((regs.eflags&0x201) != 0x201) ||
regs.ecx = 0xCCCCFFFF;
regs.eip = (unsigned long)&instr[0];
regs.edi = (unsigned long)res;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(res[0] != 0x9999AAAA) ||
(res[1] != 0xCCCCFFFF) ||
regs.eflags = 0x200;
regs.eip = (unsigned long)&instr[0];
regs.edi = (unsigned long)res;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(res[0] != 0x9999AAAA) ||
(res[1] != 0xCCCCFFFF) ||
regs.ecx = 0x12345678;
regs.eax = (unsigned long)res;
*res = 0x82;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x82) ||
(regs.ecx != 0xFFFFFF82) ||
regs.ecx = 0x12345678;
regs.eax = (unsigned long)res;
*res = 0x1234aa82;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x1234aa82) ||
(regs.ecx != 0xaa82) ||
regs.ecx = (unsigned long)res;
regs.eax = 0x12345678;
*res = 0x11111111;
- rc = x86_emulate_memop(&ctxt, &emulops);
+ rc = x86_emulate(&ctxt, &emulops);
if ( (rc != 0) ||
(*res != 0x11116789) ||
(regs.eax != 0x12341111) ||
goto fail;
printf("okay\n");
+ printf("%-40s", "Testing dec %%ax...");
+ instr[0] = 0x66; instr[1] = 0x48;
+ regs.eflags = 0x200;
+ regs.eip = (unsigned long)&instr[0];
+ regs.eax = 0x00000000;
+ rc = x86_emulate(&ctxt, &emulops);
+ if ( (rc != 0) ||
+ (regs.eax != 0x0000ffff) ||
+ ((regs.eflags&0x240) != 0x200) ||
+ (regs.eip != (unsigned long)&instr[2]) )
+ goto fail;
+ printf("okay\n");
+
+ printf("%-40s", "Testing lea 8(%%ebp),%%eax...");
+ instr[0] = 0x8d; instr[1] = 0x45; instr[2] = 0x08;
+ regs.eflags = 0x200;
+ regs.eip = (unsigned long)&instr[0];
+ regs.eax = 0x12345678;
+ regs.ebp = 0xaaaaaaaa;
+ rc = x86_emulate(&ctxt, &emulops);
+ if ( (rc != 0) ||
+ (regs.eax != 0xaaaaaab2) ||
+ ((regs.eflags&0x240) != 0x200) ||
+ (regs.eip != (unsigned long)&instr[3]) )
+ goto fail;
+ printf("okay\n");
+
return 0;
fail:
/* 0x88 - 0x8F */
ByteOp|DstMem|SrcReg|ModRM|Mov, DstMem|SrcReg|ModRM|Mov,
ByteOp|DstReg|SrcMem|ModRM|Mov, DstReg|SrcMem|ModRM|Mov,
- 0, 0, 0, DstMem|SrcNone|ModRM|Mov,
+ 0, DstReg|SrcNone|ModRM, 0, DstMem|SrcNone|ModRM|Mov,
/* 0x90 - 0x9F */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0xA0 - 0xA7 */
}
int
-x86_emulate_memop(
+x86_emulate(
struct x86_emulate_ctxt *ctxt,
struct x86_emulate_ops *ops)
{
case 0xc6 ... 0xc7: /* mov (sole member of Grp11) */
dst.val = src.val;
break;
+ case 0x8d: /* lea */
+ dst.val = ea.mem.off;
+ break;
case 0x8f: /* pop (sole member of Grp1a) */
/* 64-bit mode: POP defaults to a 64-bit operand. */
if ( (mode == X86EMUL_MODE_PROT64) && (dst.bytes == 4) )