Created
October 31, 2020 10:55
-
-
Save sebbekarlsson/8eb4908898fca0794a7803772bd28a6d to your computer and use it in GitHub Desktop.
This file contains 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
hello = (x: string, y:string, z:string) => { | |
print(x); | |
print(y); | |
print(z); | |
return 0; | |
}; | |
main = (argc: int, argv: Array<string>):int => { | |
foo:string = "the first string\n"; | |
bar:string = "the second string\n"; | |
far:string = "the third string\n"; | |
hello(foo, bar, far); | |
return 0; | |
}; |
This file contains 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
.section .text | |
.globl _start | |
_start: | |
movl %esp, %ebp | |
call main | |
movl %eax, %ebx | |
movl $1, %eax | |
int $0x80 | |
subl $8, %esp | |
.globl hello | |
hello: | |
pushl %ebp | |
movl %esp, %ebp | |
subl $12, %esp | |
pushl 8(%ebp) #happening | |
call print | |
addl $0, %esp | |
pushl 12(%ebp) #happening | |
call print | |
addl $0, %esp | |
pushl 16(%ebp) #happening | |
call print | |
addl $0, %esp | |
pushl $0 | |
jmp return_statement | |
movl %esp, -8(%ebp) | |
.globl main | |
main: | |
pushl %ebp | |
movl %esp, %ebp | |
subl $20, %esp | |
subl $24, %esp | |
movl $0x0, 20(%esp) | |
movl $0x0a, 16(%esp) | |
movl $0x0676e6972, 12(%esp) | |
movl $0x074732074, 8(%esp) | |
movl $0x073726966, 4(%esp) | |
movl $0x020656874, 0(%esp) | |
movl %esp, -16(%ebp) | |
subl $24, %esp | |
movl $0x0, 20(%esp) | |
movl $0x0a67, 16(%esp) | |
movl $0x06e697274, 12(%esp) | |
movl $0x07320646e, 8(%esp) | |
movl $0x06f636573, 4(%esp) | |
movl $0x020656874, 0(%esp) | |
movl %esp, -20(%ebp) | |
subl $24, %esp | |
movl $0x0, 20(%esp) | |
movl $0x0a, 16(%esp) | |
movl $0x0676e6972, 12(%esp) | |
movl $0x074732064, 8(%esp) | |
movl $0x072696874, 4(%esp) | |
movl $0x020656874, 0(%esp) | |
movl %esp, -24(%ebp) | |
pushl -24(%ebp) #happening | |
pushl -20(%ebp) #happening | |
pushl -16(%ebp) #happening | |
call hello | |
addl $0, %esp | |
pushl $0 | |
jmp return_statement | |
movl %esp, -12(%ebp) | |
print: | |
pushl %ebp | |
movl %esp, %ebp | |
pushl 8(%esp) | |
call strlen | |
addl $4, %esp | |
movl 8(%esp), %ecx | |
movl %eax, %edx | |
movl $4, %eax | |
movl $1, %ebx | |
movl %ebp, %esp | |
popl %ebp | |
int $0x80 | |
ret | |
return_statement: | |
popl %eax | |
movl %ebp, %esp | |
popl %ebp | |
ret | |
.type strlen, @function | |
strlen: | |
pushl %ebp | |
movl %esp, %ebp | |
movl $0, %edi | |
movl 8(%esp), %eax | |
jmp strlenloop | |
strlenloop: | |
movb (%eax, %edi, 1), %cl | |
cmpb $0, %cl | |
je strlenend | |
addl $1, %edi | |
jmp strlenloop | |
strlenend: | |
movl %edi, %eax | |
movl %ebp, %esp | |
popl %ebp | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment