Procedures

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2006
Posts: 10
Reputation: julesjacobs is an unknown quantity at this point 
Solved Threads: 0
julesjacobs julesjacobs is offline Offline
Newbie Poster

Procedures

 
0
  #1
Jun 26th, 2006
What is the best way to create/call procedures? Which argument-passing-styles are available?

Thanks in advance,

Jules
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,780
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 744
Team Colleague
Narue's Avatar
Narue Narue is online now Online
Code Goddess

Re: Procedures

 
0
  #2
Jun 26th, 2006
>Which argument-passing-styles are available?
Um, all of them.

>What is the best way to create/call procedures?
It depends on your needs. It could be as simple as a jmp there and back to a full call/ret pair with a stack frame and all of the glitz and glitter that high level languages provide.

What are you trying to do?
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 10
Reputation: julesjacobs is an unknown quantity at this point 
Solved Threads: 0
julesjacobs julesjacobs is offline Offline
Newbie Poster

Re: Procedures

 
0
  #3
Jun 26th, 2006
I'm trying to find out what the best method is for a stack based language. I have a book about assebly that says that the best way is to save registers on the stack, call procedure, and when it's done, pop the registers back. I don't think this is good for me because most data isn't in the registers, but on the stack.

I thought about the "marking return addresses" method you said in the other post, but I don't what's the best way to do it.

For example if the stack is:

bottom => top
data:6 addr:234 data:3

And we're at the end of a procedure, should I move down the stack pointer until there is an address (so skip data:3, and move to addr:234), and jmp? Then the data above needs to be restored so the stack should look like this now:

data:6 data:3

(the addr:234 should be taken out)

I don't know if this is a good/natural way to do it because it looks really ugly.

Also, I assume that you meant that I reserve the first bit of everything on the stack to indicate if this is an addr or data. (so 1 means addr and 0 means data for example).
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 19
Reputation: huffstat is an unknown quantity at this point 
Solved Threads: 0
huffstat huffstat is offline Offline
Newbie Poster

Re: Procedures

 
0
  #4
Jun 29th, 2006
Thats the assembly language game, keeping track of what is on the stack and where it is. Oh yea, the stack is only so big. No stack overflows allowed or you are in trouble.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 10
Reputation: julesjacobs is an unknown quantity at this point 
Solved Threads: 0
julesjacobs julesjacobs is offline Offline
Newbie Poster

Re: Procedures

 
0
  #5
Jun 30th, 2006
Narue said that I should mark the address of return values on the stack. I'm not sure if this is a good way, but couldn't I just use 2 stacks, and change the stack pointer to switch to the other stack? (I would need to store the other stack pointer in an other register then). Or this it better to mark the values? (eg, set the first bit to 0 if it is a return address, set it to 1 if it is a value/pointer).
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC