woops, optimization
This commit is contained in:
19
out.asm
19
out.asm
@@ -4,38 +4,23 @@ section .data
|
||||
section .text
|
||||
global _start
|
||||
_start:
|
||||
; InstructionNode(instruction='set', parent=RootNode(statements=[..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Boolean]), LabelDecleration, InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='inequal', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='if', parent=..., arguments=[VariableReference, LabelReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Int])
|
||||
mov rax, 0
|
||||
push rax
|
||||
; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), ..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Boolean]), LabelDecleration, InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='inequal', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='if', parent=..., arguments=[VariableReference, LabelReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Int])
|
||||
mov rax, 0
|
||||
push rax
|
||||
; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), ..., LabelDecleration, InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='inequal', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='if', parent=..., arguments=[VariableReference, LabelReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Boolean])
|
||||
push 1
|
||||
; LabelDecleration
|
||||
.loop:
|
||||
; InstructionNode(instruction='add', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Boolean]), LabelDecleration, ..., InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='inequal', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='if', parent=..., arguments=[VariableReference, LabelReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[Int, VariableReference, VariablePointer])
|
||||
mov rax, 1
|
||||
mov rbx, [rsp + 16]
|
||||
add rax, rbx
|
||||
mov QWORD [rsp + 16], rax
|
||||
; InstructionNode(instruction='add', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Boolean]), LabelDecleration, InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), ..., InstructionNode(instruction='inequal', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='if', parent=..., arguments=[VariableReference, LabelReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[Int, VariableReference, VariablePointer])
|
||||
mov rax, 1
|
||||
mov rbx, [rsp + 8]
|
||||
add rax, rbx
|
||||
mov QWORD [rsp + 8], rax
|
||||
; InstructionNode(instruction='inequal', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Boolean]), LabelDecleration, InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), ..., InstructionNode(instruction='if', parent=..., arguments=[VariableReference, LabelReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[Int, VariableReference, VariablePointer])
|
||||
mov rax, 100000
|
||||
mov rbx, [rsp + 16]
|
||||
mov rax, 100000000
|
||||
mov rbx, [rsp + 8]
|
||||
cmp rax, rbx
|
||||
setne al
|
||||
movzx rax, al
|
||||
mov QWORD [rsp + 0], rax
|
||||
; InstructionNode(instruction='if', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Boolean]), LabelDecleration, InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='inequal', parent=..., arguments=[Int, VariableReference, VariablePointer]), ..., InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariableReference, LabelReference])
|
||||
mov eax, [rsp + 0]
|
||||
test eax, eax
|
||||
jnz .loop
|
||||
; InstructionNode(instruction='end', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Boolean]), LabelDecleration, InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='add', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='inequal', parent=..., arguments=[Int, VariableReference, VariablePointer]), InstructionNode(instruction='if', parent=..., arguments=[VariableReference, LabelReference]), ...]), arguments=[VariableReference])
|
||||
mov rax, 60
|
||||
mov rdi, [rsp + 8]
|
||||
syscall
|
||||
|
Reference in New Issue
Block a user