starting work on math instructions and added support for negative numbers and maybe floats

This commit is contained in:
SpookyDervish
2025-09-02 19:43:48 +10:00
parent a32598f7f0
commit 42e718d6d3
5 changed files with 127 additions and 32 deletions

19
out.asm
View File

@@ -1,24 +1,15 @@
global _start
_start:
; InstructionNode(instruction='set', parent=RootNode(statements=[..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Number])
mov rax, 123
; InstructionNode(instruction='set', parent=RootNode(statements=[..., InstructionNode(instruction='add', parent=..., arguments=[VariableReference, Number, VariablePointer]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Number])
mov rax, 100
push rax
; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), ..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, VariableReference])
; InstructionNode(instruction='add', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), ..., InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariableReference, Number, VariablePointer])
push QWORD [rsp + 0]
pop rax
add rax, -5
mov QWORD [rsp + 0], rax
; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), ..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, VariableReference])
push QWORD [rsp + 0]
pop rax
push rax
; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), ..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Number])
mov QWORD [rsp + 8], 0
; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), ..., InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, VariableReference])
push QWORD [rsp + 8]
pop rax
mov QWORD [rsp + 0], rax
; InstructionNode(instruction='end', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, VariableReference]), ...]), arguments=[VariableReference])
; InstructionNode(instruction='end', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Number]), InstructionNode(instruction='add', parent=..., arguments=[VariableReference, Number, VariablePointer]), ...]), arguments=[VariableReference])
mov rax, 60
push QWORD [rsp + 0]
pop rdi