LMC changing the y value
<p>This is the code in JavaScript that I want to convert to LMC assembly code:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;
&lt;script&gt;
var temp = 14;
var y = 2;
temp &lt;&lt;= y;
document.write(temp);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>My task is to write a program for LMC that would produce the same results to change the y value.</p>

<p>Here is what I have so far:</p>

<pre><code>LOOP LDA COUNT
ADD ONE
STA COUNT
LDA TOTAL
ADD TEMP
STA TOTAL
LDA Y
SUB COUNT
BRZ ENDLOOP
BRA LOOP
ENDLOOP LDA TOTAL
STA TEMP
LDA TEMP
ADD TEMP
OUT
HLT
ONE DAT 001
COUNT DAT
TOTAL DAT
TEMP DAT 14
Y DAT 2
</code></pre>

<p>It works for a y value of 2 but not for any other value like 3,4 etc</p>

<p>Any thoughts?</p>