Advertisement
Guest User

Untitled

a guest
Mar 17th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # We need some data. Let's add some data
  2.    .data
  3.    world:
  4.        .ascii "      World!\0"
  5. # We need to give our program a name for c to find
  6.    .text
  7.    .global _hello_world
  8. _hello_world:
  9.    # Set up the stack frame!
  10.    pushl %ebp
  11.    movl %esp, %ebp
  12.  
  13.    movl 8(%ebp), %esi # Putting ( ) arround an address is like dereferencing
  14.    leal world, %edi
  15.    # We want to do a loop that runs 5 times to move Hello into our string
  16.    # Lets push 0 into a register to use for a counter
  17.    movl $0, %ecx
  18. again:
  19.    cmp $5, %ecx
  20.    je exit
  21.    movb (%esi), %eax
  22.    movb %eax, (%edi)
  23.    inc %esi
  24.    inc %edi
  25.    inc %ecx
  26.    jmp again
  27. exit:
  28.    # Put our return string in eax register for return
  29.    leal world, %eax
  30.    movl %ebp, %esp
  31.    popl %ebp
  32.    ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement