Note that there are some explanatory texts on larger screens.

plurals
  1. POx86 Assembly: How do Disassemblers know how to break up instructions?
    primarykey
    data
    text
    <p>How does a x86 disassembler know where to break up the instructions?</p> <p>I am looking at the <a href="http://datasheets.chipdb.org/Intel/x86/808x/datashts/8088/" rel="nofollow noreferrer">8088</a> instruction set. For example the move instruction has 7 variations that range from 2 to 4 bytes. The instructions themselves seem to follow no particular order. Another reason for <a href="https://stackoverflow.com/questions/2679882/why-is-x86-ugly-aka-why-is-x86-considered-inferior-when-compared-to-others">Why is x86 ugly?</a>.</p> <p>For example:</p> <pre><code> 76543210 76543210 76543210 76543210 reg/mem to/from reg 100010dw ||regr/m imm to reg/mem 1100011w ||000r/m dat dat w=1 imm to reg 1011wreg data dat w=1 imm to accum 1010000w addr-low addrhigh accum to mem 1010001w addr-low addrhigh reg/mem to seg 10001100 ||0ssr/m seg to reg/mem 10001100 ||0ssr/m Legend: ||=mod {NO-DISP=0,DISP-LOW,DISP-HIGH,REG} ss=seg enum{es=0,cs,ss,ds} reg=enum{ax=0,bx,cd,dx,bx,sp,bp,si,di (if w=1)} enum{al,bl...} (if w=0) r/m=reg or mem (mod=3 then REG, else mem) </code></pre> <p>many instruction can overlap in the first byte:</p> <pre><code> 76543210 76543210 76543210 76543210 push 11111111 ||110r/m inc 1111111w ||000r/m </code></pre> <p>The bitmasks appears to have arbitrary assignment. How does a disassembler break apart the instructions?</p> <p>This question is a sub set of <a href="https://stackoverflow.com/questions/924303/how-to-write-a-disassembler">How to write a disassembler.</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload