Last active
June 1, 2021 05:15
-
-
Save uchan-nos/9ab878c1a16b8693d88f4db07eb1f096 to your computer and use it in GitHub Desktop.
Output of OpeLa Compiler Ver.1 and Ver.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.intel_syntax noprefix | |
.code64 | |
.section .text | |
.global main | |
main: | |
push rbp | |
mov rbp, rsp | |
sub rsp, 32 | |
xor rax, rax | |
lea rax, [rbp-24] | |
push rax | |
push 0 | |
pop rdi | |
pop rax | |
mov qword ptr [rax+0], rdi | |
push rdi | |
pop rax | |
lea rax, [rbp-8] | |
push rax | |
push 1 | |
pop rdi | |
pop rax | |
mov qword ptr [rax+0], rdi | |
push rdi | |
pop rax | |
push qword ptr [rsp] | |
jmp LABEL1 | |
LABEL0: | |
pop rax | |
lea rax, [rbp-16] | |
push rax | |
push 1 | |
pop rdi | |
pop rax | |
mov qword ptr [rax+0], rdi | |
push rdi | |
pop rax | |
push qword ptr [rsp] | |
jmp LABEL5 | |
LABEL4: | |
pop rax | |
lea rax, [rbp-24] | |
push rax | |
lea rax, [rbp-24] | |
push qword ptr [rax] | |
lea rax, [rbp-8] | |
push qword ptr [rax] | |
lea rax, [rbp-16] | |
push qword ptr [rax] | |
pop rdi | |
pop rax | |
imul rax, rdi | |
push rax | |
pop rdi | |
pop rax | |
add rax, rdi | |
push rax | |
pop rdi | |
pop rax | |
mov qword ptr [rax+0], rdi | |
push rdi | |
LABEL6: | |
lea rax, [rbp-16] | |
push rax | |
lea rax, [rbp-16] | |
push qword ptr [rax] | |
push 1 | |
pop rdi | |
pop rax | |
add rax, rdi | |
push rax | |
pop rdi | |
pop rax | |
mov qword ptr [rax+0], rdi | |
push rdi | |
pop rax | |
LABEL5: | |
push 200000 | |
lea rax, [rbp-16] | |
push qword ptr [rax] | |
pop rdi | |
pop rax | |
cmp rax, rdi | |
setg al | |
movzx eax, al | |
push rax | |
pop rax | |
test rax, rax | |
jnz LABEL4 | |
LABEL7: | |
LABEL2: | |
lea rax, [rbp-8] | |
push rax | |
lea rax, [rbp-8] | |
push qword ptr [rax] | |
push 1 | |
pop rdi | |
pop rax | |
add rax, rdi | |
push rax | |
pop rdi | |
pop rax | |
mov qword ptr [rax+0], rdi | |
push rdi | |
pop rax | |
LABEL1: | |
push 10000 | |
lea rax, [rbp-8] | |
push qword ptr [rax] | |
pop rdi | |
pop rax | |
cmp rax, rdi | |
setg al | |
movzx eax, al | |
push rax | |
pop rax | |
test rax, rax | |
jnz LABEL0 | |
LABEL3: | |
pop rax | |
lea rax, [rbp-24] | |
push qword ptr [rax] | |
pop rax | |
main_exit: | |
mov rsp, rbp | |
pop rbp | |
ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* AST | |
Node_0{kDefFunc "main" | |
lhs=Node_1{kBlock "{" | |
lhs=null | |
rhs=null | |
cond=null | |
next=Node_2{kDefVar ":=" | |
lhs=Node_3{kId "s" lhs=null rhs=null cond=null next=null} | |
rhs=Node_4{kInt "0" value=0 lhs=null rhs=null cond=null next=null} | |
cond=null | |
next=Node_5{kFor "for" | |
lhs=Node_6{kBlock "{" | |
lhs=null | |
rhs=null | |
cond=null | |
next=Node_7{kFor "for" | |
lhs=Node_8{kBlock "{" | |
lhs=null | |
rhs=null | |
cond=null | |
next=Node_9{kAssign "=" | |
lhs=Node_10{kId "s" lhs=null rhs=null cond=null next=null} | |
rhs=Node_11{kAdd "+" | |
lhs=Node_12{kId "s" lhs=null rhs=null cond=null next=null} | |
rhs=Node_13{kMul "*" | |
lhs=Node_14{kId "i" lhs=null rhs=null cond=null next=null} | |
rhs=Node_15{kId "j" lhs=null rhs=null cond=null next=null} | |
cond=null | |
next=null | |
} | |
cond=null | |
next=null | |
} | |
cond=null | |
next=null | |
} | |
} | |
rhs=Node_16{kDefVar ":=" | |
lhs=Node_17{kId "j" lhs=null rhs=null cond=null next=null} | |
rhs=Node_18{kInt "1" value=1 lhs=null rhs=null cond=null next=null} | |
cond=null | |
next=Node_19{kAssign "=" | |
lhs=Node_20{kId "j" lhs=null rhs=null cond=null next=null} | |
rhs=Node_21{kAdd "+" | |
lhs=Node_22{kId "j" lhs=null rhs=null cond=null next=null} | |
rhs=Node_23{kInt "1" value=1 lhs=null rhs=null cond=null next=null} | |
cond=null | |
next=null | |
} | |
cond=null | |
next=null | |
} | |
} | |
cond=Node_24{kGT "<" | |
lhs=Node_25{kInt "200000" value=200000 lhs=null rhs=null cond=null next=null} | |
rhs=Node_26{kId "j" lhs=null rhs=null cond=null next=null} | |
cond=null | |
next=null | |
} | |
next=null | |
} | |
} | |
rhs=Node_27{kDefVar ":=" | |
lhs=Node_28{kId "i" lhs=null rhs=null cond=null next=null} | |
rhs=Node_29{kInt "1" value=1 lhs=null rhs=null cond=null next=null} | |
cond=null | |
next=Node_30{kAssign "=" | |
lhs=Node_31{kId "i" lhs=null rhs=null cond=null next=null} | |
rhs=Node_32{kAdd "+" | |
lhs=Node_33{kId "i" lhs=null rhs=null cond=null next=null} | |
rhs=Node_34{kInt "1" value=1 lhs=null rhs=null cond=null next=null} | |
cond=null | |
next=null | |
} | |
cond=null | |
next=null | |
} | |
} | |
cond=Node_35{kGT "<" | |
lhs=Node_36{kInt "10000" value=10000 lhs=null rhs=null cond=null next=null} | |
rhs=Node_37{kId "i" lhs=null rhs=null cond=null next=null} | |
cond=null | |
next=null | |
} | |
next=Node_38{kId "s" lhs=null rhs=null cond=null next=null} | |
} | |
} | |
} | |
rhs=null | |
cond=null | |
next=null | |
} | |
*/ | |
.intel_syntax noprefix | |
.global main | |
main: | |
push rbp | |
mov rbp,rsp | |
sub rsp,32 | |
xor rax,rax | |
# Node_2{kDefVar ":=" lhs=Node_3 rhs=Node_4 cond=null next=Node_5} | |
# Node_4{kInt "0" value=0 lhs=null rhs=null cond=null next=null} | |
mov eax,0 | |
mov [rbp-8],rax | |
# Node_5{kFor "for" lhs=Node_6 rhs=Node_27 cond=Node_35 next=Node_38} | |
# Node_27{kDefVar ":=" lhs=Node_28 rhs=Node_29 cond=null next=Node_30} | |
# Node_29{kInt "1" value=1 lhs=null rhs=null cond=null next=null} | |
mov eax,1 | |
mov [rbp-16],rax | |
jmp LABEL1 | |
LABEL0: # loop body | |
# Node_7{kFor "for" lhs=Node_8 rhs=Node_16 cond=Node_24 next=null} | |
# Node_16{kDefVar ":=" lhs=Node_17 rhs=Node_18 cond=null next=Node_19} | |
# Node_18{kInt "1" value=1 lhs=null rhs=null cond=null next=null} | |
mov eax,1 | |
mov [rbp-24],rax | |
jmp LABEL4 | |
LABEL3: # loop body | |
# Node_14{kId "i" lhs=null rhs=null cond=null next=null} | |
mov rax,[rbp-16] | |
# Node_15{kId "j" lhs=null rhs=null cond=null next=null} | |
mov rdi,[rbp-24] | |
# Node_13{kMul "*" lhs=Node_14 rhs=Node_15 cond=null next=null} | |
imul rax,rdi | |
# Node_12{kId "s" lhs=null rhs=null cond=null next=null} | |
mov rdi,[rbp-8] | |
# Node_11{kAdd "+" lhs=Node_12 rhs=Node_13 cond=null next=null} | |
add rax,rdi | |
# Node_10{kId "s" lhs=null rhs=null cond=null next=null} | |
lea rdi, [rbp-8] | |
# Node_9{kAssign "=" lhs=Node_10 rhs=Node_11 cond=null next=null} | |
mov [rdi+0],rax | |
LABEL5: # update | |
# Node_22{kId "j" lhs=null rhs=null cond=null next=null} | |
mov rax,[rbp-24] | |
# Node_23{kInt "1" value=1 lhs=null rhs=null cond=null next=null} | |
mov edi,1 | |
# Node_21{kAdd "+" lhs=Node_22 rhs=Node_23 cond=null next=null} | |
add rax,rdi | |
# Node_20{kId "j" lhs=null rhs=null cond=null next=null} | |
lea rdi, [rbp-24] | |
# Node_19{kAssign "=" lhs=Node_20 rhs=Node_21 cond=null next=null} | |
mov [rdi+0],rax | |
LABEL4: # condition | |
# Node_25{kInt "200000" value=200000 lhs=null rhs=null cond=null next=null} | |
mov eax,200000 | |
# Node_26{kId "j" lhs=null rhs=null cond=null next=null} | |
mov rdi,[rbp-24] | |
# Node_24{kGT "<" lhs=Node_25 rhs=Node_26 cond=null next=null} | |
cmp rax,rdi | |
setg al | |
movzx eax,al | |
test rax,rax | |
jnz LABEL3 | |
LABEL2: # update | |
# Node_33{kId "i" lhs=null rhs=null cond=null next=null} | |
mov rax,[rbp-16] | |
# Node_34{kInt "1" value=1 lhs=null rhs=null cond=null next=null} | |
mov edi,1 | |
# Node_32{kAdd "+" lhs=Node_33 rhs=Node_34 cond=null next=null} | |
add rax,rdi | |
# Node_31{kId "i" lhs=null rhs=null cond=null next=null} | |
lea rdi, [rbp-16] | |
# Node_30{kAssign "=" lhs=Node_31 rhs=Node_32 cond=null next=null} | |
mov [rdi+0],rax | |
LABEL1: # condition | |
# Node_36{kInt "10000" value=10000 lhs=null rhs=null cond=null next=null} | |
mov eax,10000 | |
# Node_37{kId "i" lhs=null rhs=null cond=null next=null} | |
mov rdi,[rbp-16] | |
# Node_35{kGT "<" lhs=Node_36 rhs=Node_37 cond=null next=null} | |
cmp rax,rdi | |
setg al | |
movzx eax,al | |
test rax,rax | |
jnz LABEL0 | |
# Node_38{kId "s" lhs=null rhs=null cond=null next=null} | |
mov rax,[rbp-8] | |
main.exit: | |
leave | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment