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

标签 linux assembly x86-64 gnu-assembler

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

相关文章:

linux - 使用 TCPREPLAY 将时间戳添加到数据包有效负载

assembly - 学习ARM汇编哪个开发板好?

linux - Linux Scheduler 是否知道硬件中断(Scheduler Jitter)

assembly - SFENCE 属于什么指令集?

linux - 如何使用 Cron 在 Linux 中更改桌面背景

linux - 在unix中:how do i print all the lines of file 1 which contain the words of file 2

javascript - 如何调试肉桂小程序?

assembly - 如何在汇编中使用 28 位 PIO 正确从磁盘读取多个扇区?

assembly - 当 eax 包含 0 时取消引用 eax 的目的是什么?

c - 进程 fork 后会发生什么?