这是一道现场面试题,我一头雾水。
我被要求为 linux 编写一个 Hello world 程序..那也是 不使用系统中的任何库。我想我必须使用 系统调用或其他东西。代码应该使用 -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!
关于linux - 不使用库的 Hello World ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1690893/