|
From: Abhijit Menon-S. <am...@wi...> - 2003-10-14 16:17:45
|
At 2003-10-14 18:28:22 +0530, am...@wi... wrote:
>
> The question is, how best to write this in disInstr()?
Like this. (This passes all the tests I've thought up so far, but I'm
still not completely convinced that it preserves flags correctly.)
Geert, could you please try valgrind with this patch applied on your
program and see if it works?
-- ams
--- coregrind/vg_to_ucode.c~ Tue Oct 14 04:28:46 2003
+++ coregrind/vg_to_ucode.c Tue Oct 14 21:42:52 2003
@@ -4876,6 +4876,27 @@
VG_(printf)("loop 0x%x\n", d32);
break;
+ case 0xE1: /* LOOPZ disp8 */
+ case 0xE0: /* LOOPNZ disp8 */
+ d32 = (eip+1) + getSDisp8(eip); eip++;
+ t1 = newTemp(cb);
+ uInstr2(cb, GET, 4, ArchReg, R_ECX, TempReg, t1);
+ uInstr1(cb, DEC, 4, TempReg, t1);
+ uInstr2(cb, PUT, 4, TempReg, t1, ArchReg, R_ECX);
+ uInstr2(cb, JIFZ, 4, TempReg, t1, Literal, 0);
+ uLiteral(cb, eip);
+ uInstr1(cb, JMP, 0, Literal, 0);
+ uLiteral(cb, d32);
+ uCond(cb, (opc == 0xE1 ? CondZ : CondNZ));
+ uFlagsRWU(cb, FlagsOSZACP, FlagsEmpty, FlagsEmpty);
+ uInstr1(cb, JMP, 0, Literal, 0);
+ uLiteral(cb, eip);
+ uCond(cb, CondAlways);
+ *isEnd = True;
+ if (dis)
+ VG_(printf)("loop%s 0x%x\n", (opc == 0xE1 ? "z" : "nz"), d32);
+ break;
+
/* ------------------------ IMUL ----------------------- */
case 0x69: /* IMUL Iv, Ev, Gv */
|