我找到“hello world”并写了它。 纳米你好.s
这段代码
.data
msg:
.string "Hello, world!\n"
len = . - msg
.text
global _start
_start:
movl $len,%edx
movl $msg,%ecx
movl $1,%ebx
movl $4,%eax
int $0x80
movl $0,%ebx
movl $1,%eax
int $0x80
我已经完成 as -o hello.o hello.s
我报错了
hello.s:6: Error: no such instruction: global _start
delete global _start.
我已经完成了
ld -s -o hello.o hello*
error
ld: hello: No such file: No such file or directory
我哪里弄错了?
p/s debian, amd64.
最佳答案
试试 .globl _start
或 .global _start
。
如果您遇到入口点问题,您可以尝试不带下划线的 start
。
最后,如果您正在制作 64 位可执行文件,您可能需要使用不同的系统调用接口(interface),不是 int 0x80
而是 syscall
。更多关于 here .
关于linux - 我如何开始学习 asm(gas)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14901689/