Why simple exit program do not work?

Pranit Kothari

I am new to assembly language programming. I write following code,

.text
.globl _start

_start:
    movl $1,%eax
    movl $0,%ebx
    int $0x80

and use as -o JustExit.o JustExit.asm command for creating object file. (Assembly file name is JustExit.asm).

After this step I gave executable permission using,

chmod 777 ./JustExit.o

When I execute program it says,

-su: ./JustExit.o: cannot execute binary file

I am not able to understand why this simple 'exit' program is not working.

Thanks.

user703016

Assembling your source through as produces an object file which is "not yet" executable. You have to link the object file with a linker such as ld, which will then produce a fully working executable (a.out by default).

Your command line chain would look like this:

$ as -o JustExit.o JustExit.asm
$ ld JustExit.o
$ ./a.out

And it works!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why does my simple program never exit my while loop?

Why do I need to click twice to exit my python program?

Why do fseek & fputc not work in my program?

Why will the following simple grand central dispatch program not work correctly?

very simple program to draw a filled rectangle .. why it does not work ?

Why does `exit &` not work?

Why won't the program exit?

Why does the server program not exit?

Why is the exit status of a program important?

Why is my C program to do simple depreciation not working?

Python 3 - Why wont my simple program do anything with the input?

ABAP do something on program exit

why does this program not work?

why is the exit window button work but the exit button in the game does not work?

Why doesn't this Java program close on exit?

Why is this simple pygame program lagging?

Why is this simple jsp program is NOT running?

Why does this simple assembly program work in AT&T syntax but not Intel syntax?

Why a simple hello world program doesnt work java (error java.lang.unsupportedclassversion)

How do you exit PDB /and/ kill the program?

Do Racket finalizers run on program exit?

Program will not exit a do-while loop

How do I program bootstrap-3 pagination to work with simple HTML content

why does this recursion program work?

Python function exit does not work - why?

Why does my exit() command not work in python?

Can somebody explain why do I get this when I run the program? (simple Java polymorphism)

In Python 3, using Pytest, how do we test for exit code : exit(1) and exit(0) for a python program?

why monitor.exit does not work in another work?