run an assembly code on ubuntu

11,584

It works perfectly for me your code.

Did you link the final object file?

Try this: ld helloworld.o -o helloworld

Share:
11,584
mehmet6parmak
Author by

mehmet6parmak

Updated on June 07, 2022

Comments

  • mehmet6parmak
    mehmet6parmak almost 2 years

    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.