Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old September 20th, 2007, 02:52 PM
dustpyle_x3 dustpyle_x3 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 82 dustpyle_x3 User rank is Corporal (100 - 500 Reputation Level)dustpyle_x3 User rank is Corporal (100 - 500 Reputation Level)dustpyle_x3 User rank is Corporal (100 - 500 Reputation Level)dustpyle_x3 User rank is Corporal (100 - 500 Reputation Level) 
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > My first assembly program


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway