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",
|
||||
"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",
|
||||
"label":"",
|
||||
"goto":"",
|
||||
"if-goto":"",
|
||||
"function":"",
|
||||
"call":"",
|
||||
"return":""
|
||||
"label":"({l_arg})\n",
|
||||
"goto":"@{l_arg}\n0;JMP\n",
|
||||
"if-goto":"@SP\nAM=M-1\nD=M\n@{l_arg}\nD;JNE\n",
|
||||
"function":"({f_arg})\n",
|
||||
"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":"@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={
|
||||
None:"",
|
||||
"argument":"@ARG\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",
|
||||
"this":"@THIS\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(".")]
|
||||
assembly_file=open(file_path,"w")
|
||||
for file in range(len(self.files_content)):
|
||||
current_function=""
|
||||
for line in self.files_content[file]:
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user