flat assembler
Message board for the users of flat assembler.

Index > Main > Return a value from proc

Author
Thread Post new topic Reply to topic
Killswitch



Joined: 21 Jan 2006
Posts: 20
Killswitch
Hey,

If I use the proc macro, how can I return a value from the procedure? Thanks for your help!
Post 29 Apr 2006, 08:27
View user's profile Send private message Reply with quote
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
The standard way to return a value is in the eax register but you're free to do it however you wish.

_________________
silkodyssey
Post 29 Apr 2006, 09:20
View user's profile Send private message MSN Messenger Reply with quote
Killswitch



Joined: 21 Jan 2006
Posts: 20
Killswitch
So something like this:

Code:
proc ...
 Mov [eax],1
 ret
endp
    


Would leave 1 in eax?
Post 29 Apr 2006, 12:50
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu
nope, it will put 1 into the address pointed by eax
The notation"[eax]" means " the memory location who's address is the value in eax" ...

You should use
Code:
proc ...
 mov eax,1
 ret
endp 
    

to return 1 from your procedure
Post 29 Apr 2006, 12:55
View user's profile Send private message Visit poster's website Reply with quote
Killswitch



Joined: 21 Jan 2006
Posts: 20
Killswitch
That was a silly mistake (you can't tell I'm quite a noob Razz)!

Thanks a lot for your help guys!
Post 29 Apr 2006, 13:46
View user's profile Send private message Reply with quote
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
Quote:

hat was a silly mistake (you can't tell I'm quite a noob Razz)


I think making mistakes is a very good way to learn especially when you have to go through turtuous debugging sessions to correct those mistakes. Very Happy

_________________
silkodyssey
Post 29 Apr 2006, 15:14
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.