Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. When i tried to execute it says "can not execute binary file".

I run the command: 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.

like image 561
mehmet6parmak Avatar asked Oct 11 '10 20:10

mehmet6parmak


People also ask

What assembly language does Ubuntu use?

x86 Assembly Language Programming with Ubuntu.


1 Answers

It works perfectly for me your code.

Did you link the final object file?

Try this: ld helloworld.o -o helloworld

like image 137
jyz Avatar answered Oct 20 '22 00:10

jyz