[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Re: Detecting an assembly instruction in QEMU

From: Atif Hashmi
Subject: Re: [Qemu-devel] Re: Detecting an assembly instruction in QEMU
Date: Sun, 8 Apr 2007 16:38:31 -0500

Hi Eduardo,

Thanks a lot for your help. I really appreciate it. I have added the functionality that I wanted.

By the way, Is there any documentation that can help me better understand the QEMU source code?


On 4/8/07, Eduardo Felipe <address@hidden> wrote:
Hi Atif,

In 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:

0x89 0xC0
0x8B 0xC0

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 is the byte following the 0x89 or 0x8B opcode. After

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):
enum {
    OT_BYTE = 0,

being 8, 16, 32 and 64 bits respectively.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]