Open OccupyMars2025 opened 1 month ago
@R14
is related to the bugdef writeReturn(self)
def writeReturn(self):
, when you implement the part of # retAddr = *(frame-5) // puts the return address in a temporary variable, store it in R14
, you get a problemset sp 317,
set local 317,
set argument 310,
set this 3000,
set that 4000,
set argument[0] 1234,
set argument[1] 37,
set argument[2] 9,
set argument[3] 305,
set argument[4] 300,
set argument[5] 3010,
set argument[6] 4010,
def writeReturn(self):
, replace the original implementation of # retAddr = *(frame-5) // puts the return address in a temporary variable, store it in R14
with the following code# original implementation
# retAddr = *(frame-5) // puts the return address in a temporary variable, store it in R14
self.output.append('@5\n')
self.output.append('D=A\n')
self.output.append('@R13\n')
self.output.append('A=M-D\n')
self.output.append('D=M\n')
self.output.append('@R14\n')
self.output.append('M=D\n')
# modified implementation
# retAddr = *(frame-5) // puts the return address in a temporary variable, store it in R14
self.output.append('@END\n')
self.output.append('D=A\n')
self.output.append('@R14\n')
self.output.append('M=D\n')
commit: https://github.com/OccupyMars2025/Nand2Tetris/commit/dd9ce202eae687dfda1eac92c36f2f36a0be29c5