I have been stuck trying to figure out how to translate this pseudo code into assembly code that will run successfully using the CPUEmulator.sh in the Nand2Tetris project.
I have have been staring at it for the last 6 hours and cannot get it too run, I suspect I am not declaring my variables correctly into memory.
I will include the example that I am trying to work from as a screen shot as well as what I have done so far, the .asm code, .cmp code, .tst code as well as screenshots of the attempted run in the CPUEmulator.sh.
Example Screenshot of Psuedo -> Assembly Program
My Assembly code, the required Pseudo Code that needs to be translated into assembly + CPUEmulator error.
.CMP & .TST files I have to run my assembly with.
My understanding is that I need to initlalize ‘@n’, ‘@m’, ‘@result’, ‘@i’.
- n the multiplier and ‘m’ the multiplicand from register R0 & R1.
Enter a loop:
-
If i < n, exit the loop
-
Otherwise, add ‘m’ to ‘result’
-
i++, increment i by 1
-
Repeat
-
Store the result in reg R2
I’m unsure if I am missing something or misunderstanding how to initialize result and i. I’m at a loss.
bigtim201 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.