domingo, 10 de outubro de 2010

another hello world in gas, this time calling puts from libc

# another hello world example
# you can compile this like:
# $ as -o hw.o mainhw.s 
# $ gcc -o hw hw.o -lc
# $ ./hw
#
    .file "mainhw.s"
    .section .rodata 
.Lstr:                       # the address of our string
    .asciz "Hello, World"

    .text
    .type main, @function
    .globl main
main:
    pushl %ebp              # prologue of every function
    movl %esp, %ebp         # still prologue.. 
    pushl $.Lstr            # pass arguments on stack
    call puts               # puts(.Lstr)
    movl $0, %eax           # the 0 of return 0
    leave                   # epilogue of every function
    ret                     # return 
    .size main, . - main    

Nenhum comentário:

Postar um comentário