gpt4 book ai didi

linux - 在 ubuntu 上运行汇编代码

转载 作者:IT王子 更新时间:2023-10-29 00:19:51 26 4
gpt4 key购买 nike

我正在尝试运行的代码如下。我使用 nasm util 将其转换为目标文件。当我尝试执行时,它说“无法执行二进制文件”。

我运行命令:nasm -f elf -o helloworld.o helloworld.asm

segment .data
msg db "Hello, world!",10
len equ $ - msg

segment .text
global _start

_start:
mov eax,4
mov ebx,1
mov ecx,msg
mov edx,len
int 80h

mov eax,1
mov ebx,0
int 80h

这是我在汇编中的第一个程序,除了编译一些我没有使用 ubuntu
基本的 C 程序。我需要一些帮助谢谢大家。

最佳答案

它非常适合我你的代码。

您是否链接了最终目标文件?

试试这个:ld helloworld.o -o helloworld

关于linux - 在 ubuntu 上运行汇编代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3909848/

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