diff --git a/generators/x86_64.py b/generators/x86_64.py index 09d7f82..894ea4d 100644 --- a/generators/x86_64.py +++ b/generators/x86_64.py @@ -25,7 +25,7 @@ class X86_64Generator(Generator): def get_variable(self, var_name: str, reg: str): self.push( - f"QWORD [rsp + {(self.stack_size - self.variables.get(var_name)["stack_loc"] - 1) * 8}]" + f"QWORD [rsp + {(self.stack_size - self.variables.get(var_name)['stack_loc'] - 1) * 8}]" ) self.pop(reg) @@ -60,7 +60,7 @@ class X86_64Generator(Generator): if type(node.arguments[1]) == NumberNode: self.lines.append(f"mov rax, {node.arguments[1].value}\n\t") self.push("rax") - + else: self.lines.append("; FUCK\n\t") #raise NotImplementedError(f"A generate method hasn't been made for the \"{node.instruction}\" instruction.") \ No newline at end of file diff --git a/out b/out index c73a515..e5db3ec 100644 Binary files a/out and b/out differ diff --git a/out.asm b/out.asm index 11e323b..2b25660 100644 --- a/out.asm +++ b/out.asm @@ -1,15 +1,17 @@ global _start _start: - ; InstructionNode(instruction='set', parent=RootNode(statements=[..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Number]) - mov rax, 6 + ; InstructionNode(instruction='set', parent=RootNode(statements=[..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='add', parent=..., arguments=[VariableReference, Number, VariablePointer]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Number]) + mov rax, 66 push rax - ; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), ..., InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Number]) - mov rax, 7 + ; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), ..., InstructionNode(instruction='add', parent=..., arguments=[VariableReference, Number, VariablePointer]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Number]) + mov rax, 69 push rax - ; InstructionNode(instruction='end', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), ...]), arguments=[VariableReference]) + ; InstructionNode(instruction='add', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), ..., InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariableReference, Number, VariablePointer]) + ; FUCK + ; InstructionNode(instruction='end', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='add', parent=..., arguments=[VariableReference, Number, VariablePointer]), ...]), arguments=[VariableReference]) mov rax, 60 - push QWORD [rsp + 0] + push QWORD [rsp + 8] pop rdi syscall \ No newline at end of file diff --git a/test2.grnd b/test2.grnd index e3bd493..c6708e2 100644 --- a/test2.grnd +++ b/test2.grnd @@ -1,3 +1,4 @@ -set &x 6 -set &y 7 -end $y \ No newline at end of file +set &x 66 +set &y 69 +add $x 1 &x +end $x \ No newline at end of file