title: How does an instruction decoder work?
body: <p>In an assignment to instruction set, we are told to write a sequence of instructions for arithmetic operations needed in different architecture models: accumulator, stack, load/store, memory/memory. </p>
  
  <p>Given:</p>
  
  <ul>
  <li>Opcode - 8 bits</li>
  <li>Memory addresses - 16 bits</li>
  <li>All registers are coded with 4 bits</li>
  <li>All data operands - 32 bits</li>
  <li>All instructions must be of an even number of bytes, i.e. 8 x N bits, where N is a natural number. </li>
  </ul>
  
  <p>AND! <strong>Addresses of registers can be packed together</strong></p>
  
  <p><strong>Question 1:</strong> When do we pack two registers together? How does the system know it's not one register coded into 4 bits? Could you please give me an example?</p>
  
  <p>Say, we are given A = B + C. Instructions needed in the load/store model for this operation:</p>
  
  <pre><code>1. load r2, B;
  2. load r3, C;
  3. add r1, r2, r3;
  4. store r1, A.
  </code></pre>
  
  <p>The 1st instruction is 28 bits long, so we need additional 4 bits.</p>
  
  <p><strong>Question 2</strong>: Does it make difference where to put the 4 bits in form of 0000? How would you make the instruction of a whole number of bytes?</p>
  
  <p>I'll appreciate your help very much. </p>