Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # $ gcc -nostdlib -Wall -shared -fPIC hello_exit.S -Wl,-soname,libhelloexit.so.1,-export-dynamic -o libhelloexit.so.1.0
- #
- # .macro
- .macro fn name
- .global \name
- .type \name, @function
- \name:
- .endm
- .data
- hw:
- .ascii "Hello, world\n"
- .set hs, .-hw
- .text
- # very usefull function
- fn es_hello_world
- # write(1, message, 13)
- movq $1, %rax # system call 1 is write
- movq $1, %rdi # file handle 1 is stdout
- movabs $hw, %rsi # address of string to output
- movabs $hs, %rdx # number of bytes
- syscall # invoke operating system to do the write
- retq # go back
- fn os_exit
- # exit(0)
- movq $60, %rax # system call 60 is exit
- syscall # invoke operating system to exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement