深未来技术原创,http://deepfuture.iteye.com
1、使用GCC编译
.section .data
output:
.asciz "http://deepfuture.iteye.com\n"
.section .text
.global main
main:
push $output
call printf
addl $4,%esp
push $0
call exit
# gcc -o test test.s
# ./test
http://deepfuture.iteye.com
2、使用汇编器编译,使用动态链接-dynamic-linker,要求后跟SO库,可使用find / -name ld*.so来寻找链接库,每个LINUX版本不一样,链接库不一样,笔者用的是puppy linux,链接库名为ld-linux.so.2
.section .data
output:
.asciz "http://deepfuture.iteye.com\n"
.section .text
.global _start
_start:
push $output
call printf
addl $4,%esp
push $0
call exit
# as -o test.o test.s
# ld -lc -dynamic-linker /lib/ld-linux.so.2 -o test test.o
# ./test
http://deepfuture.iteye.com