Constructed the Program Flow Hash Map
This commit is contained in:
+8
-7
@@ -21,18 +21,18 @@ class VirtualMachineCompiler:
|
|||||||
"not":"@SP\nA=M-1\nM=!M\n",
|
"not":"@SP\nA=M-1\nM=!M\n",
|
||||||
"push":"{m_arg}D=M\n@SP\nM=M+1\nA=M-1\nM=D\n",
|
"push":"{m_arg}D=M\n@SP\nM=M+1\nA=M-1\nM=D\n",
|
||||||
"pop":"{m_arg}D=A\n@R13\nM=D\n@SP\nAM=M-1\nD=M\n@R13\nA=M\nM=D\n",
|
"pop":"{m_arg}D=A\n@R13\nM=D\n@SP\nAM=M-1\nD=M\n@R13\nA=M\nM=D\n",
|
||||||
"label":"",
|
"label":"({l_arg})\n",
|
||||||
"goto":"",
|
"goto":"@{l_arg}\n0;JMP\n",
|
||||||
"if-goto":"",
|
"if-goto":"@SP\nAM=M-1\nD=M\n@{l_arg}\nD;JNE\n",
|
||||||
"function":"",
|
"function":"({f_arg})\n",
|
||||||
"call":"",
|
"call":"@{r_address}\nD=A\n@SP\nAM=M-1\nM=D\n@LCL\nD=M\n@SP\nAM=M-1\nM=D\n@ARG\nD=M\n@SP\nAM=M-1\nM=D\n@THIS\nD=M\n@SP\nAM=M-1\nM=D\n@THAT\nD=M\n@SP\nAM=M-1\nM=D\n@SP\nD=M\n@5\nD=D-A\n@{arg2}\nD=D-A\n@ARG\nM=D\n@SP\nD=M\n@LCL\nM=D\n@{f_arg}\n({r_address})\n",
|
||||||
"return":""
|
"return":"@LCL\nD=M\n@R5\nM=D\nD=D-A\n@R6\nM=D\n@ARG\nAD=M\n@R13\nM=D\n@SP\nAM=M-1\nD=M\n@R13\nA=M\nM=D\n@ARG\nD=M+1\n@SP\nM=D\n@R5\nAM=M-1\nD=M\n@THAT\nM=D\n@R5\nAM=M-1\nD=M\n@THIS\nM=D\n@R5\nAM=M-1\nD=M\n@ARG\nM=D\n@R5\nAM=M-1\nD=M\n@LCL\nM=D\n@R6\nA=M\n0;JMP\n"
|
||||||
}
|
}
|
||||||
self.arguments={
|
self.arguments={
|
||||||
None:"",
|
None:"",
|
||||||
"argument":"@ARG\nD=M\n@{arg2}\nA=D+M\n",
|
"argument":"@ARG\nD=M\n@{arg2}\nA=D+M\n",
|
||||||
"local":"@LCL\nD=M\n@{arg2}\nA=D+M\n",
|
"local":"@LCL\nD=M\n@{arg2}\nA=D+M\n",
|
||||||
"static":"@{static_arg}\n",
|
"static":"@{s_arg}\n",
|
||||||
"constant":"@{arg2}\n",
|
"constant":"@{arg2}\n",
|
||||||
"this":"@THIS\nD=M\n@{arg2}\nA=D+M\n",
|
"this":"@THIS\nD=M\n@{arg2}\nA=D+M\n",
|
||||||
"that":"@THAT\nD=M\n@{arg2}\nA=D+M\n",
|
"that":"@THAT\nD=M\n@{arg2}\nA=D+M\n",
|
||||||
@@ -68,6 +68,7 @@ class VirtualMachineCompiler:
|
|||||||
file_path=file_path[:file_path.find(".")]
|
file_path=file_path[:file_path.find(".")]
|
||||||
assembly_file=open(file_path,"w")
|
assembly_file=open(file_path,"w")
|
||||||
for file in range(len(self.files_content)):
|
for file in range(len(self.files_content)):
|
||||||
|
current_function=""
|
||||||
for line in self.files_content[file]:
|
for line in self.files_content[file]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user