title: Why is the operation address incremented by two?
body: <p>I am looking at a <a href="http://fir.sh/projects/jsnes/" rel="nofollow">Javascript emulator</a> of a NES to try and understand how it works.</p>
  
  <p>On <a href="https://github.com/bfirsh/jsnes/blob/master/source/cpu.js#L178" rel="nofollow">this line</a>:</p>
  
  <pre><code>    addr = this.load(opaddr+2);
  </code></pre>
  
  <p>The opcode is incremented by two. However, the <a href="http://nesdev.com/NESDoc.pdf" rel="nofollow">documentation</a> (see appendix E) I'm reading says:</p>
  
  <blockquote>
    <p>Zero page addressing uses a single operand which serves as a pointer
    to an address in zero page ($0000-$00FF) where the data to be operated
    on can be found. By using zero page addressing, only one byte is
    needed for the operand, so the instruction is shorter and, therefore,
    faster to execute than with addressing modes which take two operands.
    An example of a zero page instruction is AND $12.</p>
  </blockquote>
  
  <p>So if the operand's argument is only one byte, shouldn't it appear directly after it, and be + 1 instead of + 2? Why +2?</p>
  
  <p>This is how I think it works, which may be incorrect. Suppose our memory looks like:</p>
  
  <pre><code>-------------------------
  | 0 | 1 | 2 | 3 | 4 | 5 | &lt;- index
  -------------------------
  | a | b | c | d | e | f | &lt;- memory
  -------------------------
    ^  
     \ 
       PC
  </code></pre>
  
  <p>and our PC is <code>0</code>, pointing to <code>a</code>. For this cycle, we say that the opcode:</p>
  
  <pre><code>var pc= 0; //for example's sake
  var opcode= memory[pc]; //a
  </code></pre>
  
  <p>So shouldn't the first operand be the next slot, i.e. <code>b</code>?</p>
  
  <pre><code>var first_operand = memory[pc + 1]; //b
  </code></pre>