
September 20th, 2007, 02:52 PM
|
|
Contributing User
|
|
Join Date: Nov 2006
Posts: 82
  
Time spent in forums: 2 Days 3 h 48 m 14 sec
Reputation Power: 4
|
|
|
My first assembly program
This is my first assembly program that I've written without the help of a tutorial and alas it isn't working. Every time I run it I get this error:
Code:
exec format error: ./test
It's just a simple program that takes a number, doubles it and exits where I should then see the return value with echo $?. Here's the code: (sorry about the weird comment indentions, it looks different in gedit)
Code:
.section data
.section text
.globl _start
_start:
pushl $4 # push parameter on stack
call double # call double (push return address on stack)
addl $4, %esp # move %esp back above parameter
movl %eax, %ebx # move answer to %ebx
movl $1, %eax # move exit call to %eax
int $0x80 # system call (exit)
.type double, @function
double:
pushl %ebp # push old %ebp on stack
movl %esp, %ebp # store old %esp in %ebp
movl 8(%ebp), %eax # move parameter into %eax
imull $2, %eax # multiply %eax by 2
movl %ebp, %esp # restore old %esp
popl %ebp # restore old %ebp
ret # pop return address
What did I do wrong?
[edit] Oh nvm, I found it. I forgot to put a dot before data and text. [/edit]
Last edited by dustpyle_x3 : September 20th, 2007 at 06:31 PM.
|