The question I need answered is, why is there a comparison failure at line 9 but not at line 8?
2nd question:
How could I fix this to support the multiplication of negative values?
The program multiplies R0 and R1 and stores the result in R2. (R0, R1, R2 refer to RAM[0], RAM[1], and RAM[2], respectively.)
Mult.asm:
0 @R2
1 M=0
2 @R0
3 D=M
4 @STEP
5 D;JNE
6 @END
7 0;JMP
8 @R2
9 D=M
10 @R1
11 D=D+M
12 @R2
13 M=D
14 @R0
15 D=M-1
16 M=D
17 @STEP
18 D;JGT
19 @END
20 0;JMP
Mult.cmp:
| RAM[0] | RAM[1] | RAM[2] |
| 0 | 0 | 0 |
| 1 | 0 | 0 |
| 0 | 2 | 0 |
| 3 | 1 | 3 |
| 2 | 4 | 8 |
| 6 | 7 | 42 |
| 6 | -7 | -42 |
| -6 | 7 | -42 |