[英]run an assembly code on ubuntu
The code i am trying to run is bellow. 我试图运行的代码是吼叫。 I use nasm util to convert it into object file.
我使用nasm util将其转换为目标文件。 When i tried to execute it says "can not execute binary file".
当我试图执行它时说“无法执行二进制文件”。
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 这是我在汇编中的第一个程序,除了编译一些之外我没有使用ubuntu
basic c programs. 基本的c程序。 i need some help thanks all.
我需要一些帮助,谢谢大家。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.