Was missing an indirect lookup on segment pushes

This commit is contained in:
Nemo 2020-06-02 04:16:13 +05:30
parent 32242242cb
commit c46f739aed
3 changed files with 8 additions and 2 deletions

View File

@ -119,6 +119,7 @@ D=M
@R11
M=D // end pop temp 6 (L13)
@LCL
A=M
D=M
@SP
A=M
@ -132,6 +133,7 @@ D=D+A // D = segment+index
@R13 // save it to R13
M=D // write @THAT+5 to R13
@R13
A=M
D=M
@SP
A=M
@ -152,6 +154,7 @@ D=D+A // D = segment+index
@R13 // save it to R13
M=D // write @ARG+1 to R13
@R13
A=M
D=M
@SP
A=M
@ -172,6 +175,7 @@ D=D+A // D = segment+index
@R13 // save it to R13
M=D // write @THIS+6 to R13
@R13
A=M
D=M
@SP
A=M
@ -185,6 +189,7 @@ D=D+A // D = segment+index
@R13 // save it to R13
M=D // write @THIS+6 to R13
@R13
A=M
D=M
@SP
A=M
@ -219,5 +224,5 @@ A=A-1
M=D+M
@SP
M=M-1 // end add (L24)
@222
@227
0;JMP

View File

@ -1 +1,2 @@
|RAM[256]|RAM[300]|RAM[401]|RAM[402]|RAM[3006|RAM[3012|RAM[3015|RAM[11] |
| 472 | 10 | 21 | 22 | 36 | 42 | 45 | 510 |

View File

@ -180,13 +180,13 @@ class CodeWriter {
}
$this->write([
$register,
"A=M",
"D=M",
]);
break;
case 'temp':
$register = $this->resolveTemp($index);
// TODO FIX
$this->write([
"$register // temp $index",
"D=M"