title: What is the method for counting how many bytes your program will be, reading from 32 bit x86 assembly code
body: <p>I am working on a simple stack smashing exercise. I need to write into my assembly a short jump of a specific offset. I need to calculate the offset by how many bytes the two instructions are separated by.</p>
  
  <p>I have been searching google but I can't seem to get the right search terms.</p>
  
  <p>I know, for example, that the <code>mov</code> opcode is 2 bytes. But how many bytes the whole instruction will be depends on your <code>src</code> and <code>dest</code> ... whether your are using immediate values or offsets, what the addressing mode is, etc.</p>
  
  <p>I know there has to be a chart or something, somewhere, I can use to calculate this.</p>
  
  <p>page 12 of Aleph One's Smashing the Stack for Fun and Profit shows what I'm trying to do (count bytes from assembly code): <a href="http://www-inst.eecs.berkeley.edu/~cs161/fa08/papers/stack_smashing.pdf" rel="nofollow noreferrer">http://www-inst.eecs.berkeley.edu/~cs161/fa08/papers/stack_smashing.pdf</a></p>