title: Why isn't my assembly program setting r1 to the correct value?
body: <p>I am writing an assembly program on the LC3 machine.</p>
  
  <p>My assembly program is an  LC3 program that multiplies R2 and R3 and stores the result in R1.  </p>
  
  <p>Here is my source code(with comments)</p>
  
  <pre><code>;Sets pc to this address at start of program 
  .ORIG x3000
  ;R1 will store the result lets clear it(ANd with 0)
  AND R1,R1,x0
  ;R2 will be multiplied by R3, let's clear both of them 
  AND R2,R2,x0
  AND R3,R3,x0
  ;Test case 4 * 3 = 12;
  ADD R2,R2,4
  ADD R3,R3,3
  ;Add to increment zone 
  LOOP Add R1,R1,R2;
  ;Decrement the counter, in this case the 3 or R3
  ADD R3,R3,x-1
  BrP LOOP
  HALT
  .END
  </code></pre>
  
  <p>My test case is multiplying 4 * 3. The result should be 12 and that should be stored in R1. However when I run this program in my LC3 simulator, this is what i get for the output<img src="https://i.stack.imgur.com/Tg7fE.png" alt="enter image description here"></p>
  
  <p>R3 holds the correct value at the end but R1 holds -1.... Does anyone see an issue with my code? I made sure to clear R1 at the beginning and to keep adding R3 to R1 and storing the result to R1 while the counter, R3, or 3 in this case is greater than zero.</p>