Closed Thread
Results 1 to 4 of 4

Thread: Determine operand size

  1. #1
    Vahagn_iv is offline Newbie
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Determine operand size

    Hi all,

    I've just started to learn assembly and now trying to write a disassembler. My program determines prefixes and opcodes. But when I pass to the operand determination a problem occurs. Let us take as an example opcode 0x09 (OR). Here is the list of all x86 opcodes in 64 bit mode. The opcode 0x09 takes as first operand r/m16/32/64. The question is what are the cases for each operand size?

    I am not sure, but I think that it should depend on the presence of 0x66 prefix. But how the third size appears?? Or, may be I mix something....

    Thanks in advance.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Determine operand size

    It depends on what mode you're running in, which you can't determine just by looking at the program because the operating system decides. You're going to have to let the user provide the mode the program is running in. For example:

    16-bit mode: 0x66 makes the instruction 32-bit.
    32-bit mode: 0x66 makes the instruction 16-bit.
    IA-32e mode: 0x66 makes the instruction 64-bit.
    IA-64 mode: 0x66 makes the instruction 32-bit.

    In pure binary executables (such as Windows' COM format) the default execution mode is typically 16-bit. Other executable forms, such as EXE, PE, ELF, and so on, should indicate the default mode they run in. When the program is loaded into memory, the operating system sets special flags to let the processor know what mode to use when executing.

    Look at Chapter 18 of Intel's System Programming Guide, Part A.
    Last edited by dargueta; 03-08-2010 at 01:23 PM. Reason: Added link.
    sudo rm -rf /

  4. #3
    Vahagn_iv is offline Newbie
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Re: Determine operand size

    dargueta,

    thank you very much.

  5. #4
    Join Date
    Oct 2007
    Location
    /dev/null
    Posts
    4,513
    Blog Entries
    8
    Rep Power
    59

    Re: Determine operand size

    No problem!
    sudo rm -rf /

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Determine power of 2 in C
    By fayyazlodhi in forum C Tutorials
    Replies: 12
    Last Post: 07-14-2011, 11:29 AM
  2. J2EE: Limit File Size or Request Size
    By tarek.mostafa in forum Java Help
    Replies: 0
    Last Post: 05-27-2010, 05:46 AM
  3. [SIZE="2"]net headers[/SIZE]
    By mIXpRo in forum C and C++
    Replies: 4
    Last Post: 01-31-2010, 03:05 PM
  4. Change font size of 'Product', 'Size', ...
    By DavidBoggitt in forum ionFiles
    Replies: 1
    Last Post: 09-03-2009, 06:21 PM
  5. Size/Size on Disk
    By BlaineSch in forum Technology Ramble
    Replies: 14
    Last Post: 07-03-2009, 05:44 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts