|
I have been able to pass the SimpleFunction test and have been trying to debug my code for hours.
Any advice is welcome.
Here is my call, function and return assembly code snippets. While debugging, it appeared that I am not correctly returning the "return value"...but I cant figure out the issue.
Function:
"(" + fileName + "." + className + "." + functName +")"
Call:
"@"+ fileName + "." + self.currentClass + "$ret" + str(self.retcount),
'D=A',
'@SP',
'A=M',
'M=D',
'@SP',
'M=M+1',
'@LCL',
'D=M',
'@SP',
'A=M',
'M=D',
'@SP',
'M=M+1',
'@ARG',
'D=M',
'@SP',
'A=M',
'M=D',
'@SP',
'M=M+1',
'@THIS',
'D=M',
'@SP',
'A=M',
'M=D',
'@SP',
'M=M+1',
'@THAT',
'D=M',
'@SP',
'A=M',
'M=D',
'@SP',
'M=M+1',
'@5',
'D=A',
'@SP',
'D=M-D',
'@' + nArgs,
'D=D-A',
'@ARG',
'M=D',
'@SP',
'D=M',
'@LCL',
'M=D',
'@' + fileName + "." + className + '.' + functName,
'0; JMP',
'(' + fileName + "." + self.currentClass + "$ret" + str(self.retcount) + ')',
Return:
"@LCL",
"D=M",
"@endFrame",
"M=D",
"@5",
"D=A",
"@endFrame",
"D=M-D",
"@retAddr",
"M=D",
"@SP",
"M=M-1",
"A=M",
"D=M",
"@ARG",
"A=M",
"M=D",
"@ARG",
"D=M",
"@SP",
"M=D+1",
"@endFrame",
"A=M-1",
"D=M",
"@THAT",
"M=D",
"@2",
"D=A",
"@endFrame",
"A=M-D",
"D=M",
"@THIS",
"M=D",
"@3",
"D=A",
"@endFrame",
"A=M-D",
"D=M",
"@ARG",
"M=D",
"@4",
"D=A",
"@endFrame",
"A=M-D",
"D=M",
"@LCL",
"M=D",
"@retAddr",
"A=M",
"0; JMP"
]
|