Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # We need some data. Let's add some data
- .data
- world:
- .ascii " World!\0"
- # We need to give our program a name for c to find
- .text
- .global _hello_world
- _hello_world:
- # Set up the stack frame!
- pushl %ebp
- movl %esp, %ebp
- movl 8(%ebp), %esi # Putting ( ) arround an address is like dereferencing
- leal world, %edi
- # We want to do a loop that runs 5 times to move Hello into our string
- # Lets push 0 into a register to use for a counter
- movl $0, %ecx
- again:
- cmp $5, %ecx
- je exit
- movb (%esi), %eax
- movb %eax, (%edi)
- inc %esi
- inc %edi
- inc %ecx
- jmp again
- exit:
- # Put our return string in eax register for return
- leal world, %eax
- movl %ebp, %esp
- popl %ebp
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement