|Subject:||Re: [Qemu-devel] Re: Detecting an assembly instruction in QEMU|
|Date:||Sun, 8 Apr 2007 16:38:31 -0500|
Hi Atif,modrm is the byte following the 0x89 or 0x8B opcode. AfterIn target-i386/translate.c, there are many variants of mov i.e.
case 0x89: /* mov Gv, Ev */
case 0xc7: /* mov Ev, Iv */
case 0x8b: /* mov Ev, Gv */
case 0x8e: /* mov seg, Gv */
That's true. I forgot the fact that mov %eax,%eax can be both:
It's up to the compiler to choose which one to use.which one do you think will be called when "mov %eax, %eax" instruction is translated.
I printed the value of modrm inside the case 0x89 but the value remains the same whether I use %eax or %ebx.
Secondly, How can I extract the source and destination registers from modrm.
modrm = ldub_code(s->pc++);
you can decode it this way (in binary):
XX --> Indexing mode
YYY --> Destination register
ZZZ --> Source register
0xC0 is the value you are looking for 11 000 000 --> (no indexing)(%eax)(%eax).
You can find more information here:
One more thing: you may want to check operand size. It's on "ot" variable, and its meaning (from translate.c):
OT_BYTE = 0,
being 8, 16, 32 and 64 bits respectively.
|[Prev in Thread]||Current Thread||[Next in Thread]|