|
From: Abhijit Menon-S. <am...@wi...> - 2003-10-13 23:58:07
|
At 2003-10-13 18:12:25 -0400, pr...@gn... wrote:
>
> Geert Fannes wrote:
> >
> > disInstr: unhandled instruction bytes: 0xE0 0x6E 0x40 0x80
>
> Indeed, its doesn't seem to implement this instruction.
Would the following suffice to implement LOOPZ/LOOPNZ? (It just adds a
uCond() to the JIFZ; the rest is as for 0xE3/LOOP.) I'd appreciate any
comments, since I'm not yet familiar enough with valgrind to feel sure
that my approach is correct, and I couldn't figure out how to test it.
Thanks.
-- ams
--- vg_to_ucode.c~ Tue Oct 14 04:28:46 2003
+++ vg_to_ucode.c Tue Oct 14 05:00:09 2003
@@ -4876,6 +4876,24 @@
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);
+ uCond(cb, (opc == 0xE1 ? CondZ : CondNZ));
+ uInstr1(cb, JMP, 0, Literal, 0);
+ uLiteral(cb, d32);
+ uCond(cb, CondAlways);
+ *isEnd = True;
+ if (dis)
+ VG_(printf)("loopz 0x%x\n", d32);
+ break;
+
/* ------------------------ IMUL ----------------------- */
case 0x69: /* IMUL Iv, Ev, Gv */
|