Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > global start, g...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 4574 of 4646
Post > Topic >>

global start, global main or anything I want?

by phoenix <spamtrap@[EMAIL PROTECTED] > Mar 16, 2008 at 10:51 AM

Hello guys,
I am a complete newbie who is trying to learn assembly. I am using
NASM and working on Linux.
I have written a (very) simple program that calculates ah+al.
Here it is the code:

-----------------------------------------------
; this file is called ass.s

segment .data
number1		db	5
number2		db	7

segment .text
	global prog
prog:
	push	ebp
	mov	ebp,esp
	xor	eax,eax
	mov	al,[number1]
	mov	ah,[number2]
	add	al,ah
	xor	ah,ah
	pop	ebp
	ret

-------------------------------------------------

So I type in the terminal: nasm -f elf ass.s -o ass.o
and then I type: gcc ass.o -o assexe

An error message appears:
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o: In function
`_start':
(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status


If the label (in the program) is called main (and not prog), there's
no error message.
If the label is called start, the error message appears again.

My question is: can I choose whatever label names in my program,
without having all these error messages? Or am I forced to always
insert a label called "main" in my code?

Thank you and sorry for my english!




 8 Posts in Topic:
global start, global main or anything I want?
phoenix <spamtrap@[EM  2008-03-16 10:51:20 
Re: global start, global main or anything I want?
Tim Roberts <spamtrap  2008-03-16 21:25:30 
Re: global start, global main or anything I want?
Terence <spamtrap@[EM  2008-03-16 14:19:02 
Re: global start, global main or anything I want?
Frank Kotler <spamtra  2008-03-16 21:58:37 
Re: global start, global main or anything I want?
Robert Redelmeier <red  2008-03-16 22:32:37 
Re: global start, global main or anything I want?
phoenix <spamtrap@[EM  2008-03-17 03:25:33 
Re: global start, global main or anything I want?
Frank Kotler <spamtra  2008-03-17 21:27:21 
Re: global start, global main or anything I want?
phoenix <spamtrap@[EM  2008-03-19 01:01:59 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 7:56:51 CDT 2008.