'Left Shift subroutine in LC3 not working for when the value in R3 is 0
I have to write a subroutine to calculate the value stored at R2 to left-shift by the value stored at R3 (R2 << R3). The result is saved at R3. So far I have this:
leftSHIFT ADD R0,R2,R2
ADD R3,R3,#-1
BRz MyEXIT
ADD R2,R0,#0
BRnzp leftSHIFT
MyEXIT ADD R3,R0,#0
RET
Now this code works correctly for other inputs like 004<003=032 . However, what I'm getting is 001<000=000 when I should be getting 001<000=001
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
