From: "Eduardo Felipe" <edusaper@gmail.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: Detecting an assembly instruction in QEMU
Date: Sun, 8 Apr 2007 16:13:31 +0200 [thread overview]
Message-ID: <83a4d4ca0704080713t596e4d83lbd1c495d92eda581@mail.gmail.com> (raw)
In-Reply-To: <d5f3bd2b0704071406pf13d34arfc6b46d44d7a0ccd@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1258 bytes --]
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):
XXYYYZZZ
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:
http://pdos.csail.mit.edu/6.828/2005/readings/i386/s17_02.htm
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,
OT_WORD,
OT_LONG,
OT_QUAD,
};
being 8, 16, 32 and 64 bits respectively.
Regards,
Eduardo
[-- Attachment #2: Type: text/html, Size: 1943 bytes --]
next prev parent reply other threads:[~2007-04-08 14:17 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-04 4:57 [Qemu-devel] Detecting an assembly instruction in QEMU Atif Hashmi
2007-04-05 17:37 ` [Qemu-devel] " Atif Hashmi
2007-04-06 12:15 ` Eduardo Felipe
2007-04-07 21:06 ` Atif Hashmi
2007-04-08 14:13 ` Eduardo Felipe [this message]
2007-04-08 21:38 ` Atif Hashmi
2007-04-08 22:14 ` Eduardo Felipe
2007-04-17 0:17 ` Atif Hashmi
2007-04-17 0:22 ` Atif Hashmi
2007-04-17 9:49 ` Eduardo Felipe
2007-04-17 20:33 ` Atif Hashmi
2007-04-22 13:09 ` Eduardo Felipe
2007-04-24 7:30 ` Atif Hashmi
2007-04-24 9:34 ` Eduardo Felipe
2007-04-25 16:21 ` Atif Hashmi
2007-04-25 16:50 ` Atif Hashmi
2007-04-26 14:03 ` Eduardo Felipe
2007-04-26 21:26 ` Atif Hashmi
2007-04-27 10:16 ` Eduardo Felipe
2007-05-01 20:28 ` Atif Hashmi
2007-04-11 16:05 ` Thiemo Seufer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83a4d4ca0704080713t596e4d83lbd1c495d92eda581@mail.gmail.com \
--to=edusaper@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).