Re: [LIP] Intel Opcode Query

Arun Sharma <[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Message-ID <[email protected]>
On Thu, Jun 10, 2004 at 03:43:09AM -0700, Trideepraj Roychoudhury wrote:
> Hi,
> I am trying to write a disassembler for x86
> processors.

Why not use the existing GNU or BSD disassemblers ?

> Does every opcode that has "one memory operand" needs
> to be "prefixed" with the "Operand-Size/Address-Size
> Prefix" code?

Not every one requires a prefix.

$ cat foo.s
.text

add %eax, %ebx
add %ax, %bx

mov %eax, %ebx
mov %al, %bl

$ objdump -d foo.o

foo.o:     file format elf32-i386

Disassembly of section .text:

00000000 <.text>:
   0:   01 c3                   add    %eax,%ebx
   2:   66 01 c3                add    %ax,%bx
   5:   89 c3                   mov    %eax,%ebx
   7:   88 c3                   mov    %al,%bl

> 
> Otherwise how do I decide which addressing mode to use
> i.e. 16-bit or 32-bit?

You need to look at both the opcode and prefix.

	-Arun


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.