gpt4 book ai didi

linux - 我如何开始学习 asm(gas)?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:24:44 31 4
gpt4 key购买 nike

我找到“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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com