[LIP] Intel Opcode Query

Trideepraj Roychoudhury <fsalabs-/[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Message-ID <[email protected]>
Hi,
I am trying to write a disassembler for x86
processors. I have basic query on the format of the
instruction bytes.

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

Otherwise how do I decide which addressing mode to use
i.e. 16-bit or 32-bit?
For e.g.: here are opcodes and operands for ADD
instruction:

opcode      Instruction     Operand1        Operand2
0x00            ADD         r/m8            r8
0x01            ADD         r/m16           r16
0x01            ADD         r/m32           r32

r/m = bits-7,6,2,1,0 of MOD R/M byte
r/m8 = memory address for 8-bit data
r8 = 8-bit general purpose register ( eg: AL )

When opcode=0x00 how do I know which addressing mode
to use i.e. 16-bit/32-bit?

When opcode=0x01 how do I know which addressing mode
to use i.e. 16-bit/32-bit?
Also how do I know whether the registers are
16-bit/32-bit( eg: AX or EAX )?
So i need additional two pieces of information,
addressing mode and register size. Where do I get them
from?

I read the Intel Instruction Set Manual but didnt
understand how to go about. Any clue?

=====
FSA Labs 
http://www.fsalabs.com
Linux Kernel Consulting
Phone: +91-22-2754-4226


	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
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.