Linux 在 ubuntu 上运行汇编代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3909848/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
run an assembly code on ubuntu
提问by mehmet6parmak
The code i am trying to run is bellow. I use nasm util to convert it into object file. When i tried to execute it says "can not execute binary file".
我试图运行的代码如下。我使用 nasm util 将其转换为目标文件。当我尝试执行时,它说“无法执行二进制文件”。
I run the command: nasm -f elf -o helloworld.o helloworld.asm
我运行命令: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
it is my first program in assembly and i did not use ubuntu except compiling some
basic c programs. i need some help thanks all.
这是我在汇编中的第一个程序,除了编译一些
基本的 c 程序外,我没有使用 ubuntu 。我需要一些帮助谢谢大家。
采纳答案by jyz
It works perfectly for me your code.
它非常适合我你的代码。
Did you link the final object file?
您是否链接了最终的目标文件?
Try this: ld helloworld.o -o helloworld
尝试这个: ld helloworld.o -o helloworld