这是一个现场采访问题,我很困惑.
我被要求为linux编写一个Hello世界程序
而不使用系统中的任何库.我想我必须使用
系统调用或某些东西..代码应该使用-nostdlib和
-nostartfiles选项..
如果有人可以帮助,会很好
解决方法
$cat > hwa.S
write = 0x04
exit = 0xfc
.text
_start:
movl $1,%ebx
lea str,%ecx
movl $len,%edx
movl $write,%eax
int $0x80
xorl %ebx,%ebx
movl $exit,%eax
int $0x80
.data
str: .ascii "Hello,world!\n"
len = . -str
.globl _start
$as -o hwa.o hwa.S
$ld hwa.o
$./a.out
Hello,world!
