Was missing an indirect lookup on segment pushes

master
Nemo 3 years ago
parent 32242242cb
commit c46f739aed
  1. 7
      projects/07/MemoryAccess/BasicTest/BasicTest.asm
  2. 1
      projects/07/MemoryAccess/BasicTest/BasicTest.out
  3. 2
      vm/CodeWriter.php

@ -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

@ -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 |

@ -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"

Loading…
Cancel
Save