This is the code in JavaScript that I want to convert to LMC assembly code:
<!DOCTYPE html>
<html>
<body>
<script>
var temp = 14;
var y = 2;
temp <<= y;
document.write(temp);
</script>
</body>
</html>
My task is to write a program for LMC that would produce the same results to change the y value.
Here is what I have so far:
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
It works for a y value of 2 but not for any other value like 3,4 etc
Any thoughts?