Assembly function question

Status
Not open for further replies.

electroRF

Member
Hi,
I wanna write an Assembly function asmFunc which takes 3 parameters.

The function will do something and will then call cFunc and would pass the same untouched three parameters to cFunc.

Since the parameters are saved in registers R0, R1, R2, it means that I can simply call cFunc, and cFunc would get the same 3 parameters, right?

Thank you.
 
There could be different calling conventions, which determine how the parameters are passed and what registers can be modified without doing harm. It all depends on the processor and on the compiler.

If you are not going to do anything after cFunc returns, the most efficient way is to jump (goto) to the beginning of cFunc. cFunc will then return to the code that called your function.
 
This is where you really need to know your compiler. I use avr-gcc all the time and the documentation and examples are awesome. If your compiler does not have a good documentation then you have a really tough job finding things out.

This is summary from the avr-gcc documentation.. maybe it gives you some idea about what you have to find out for your compiler:

Since the parameters are saved in registers R0, R1, R2, it means that I can simply call cFunc, and cFunc would get the same 3 parameters, right?

If the documentation says so.. yes. Try it.. be brave. You do debug your code don't you (with a simulator or JTAG etc.)?

Edit: For some reason I have a feeling:"do you really need to do this?".. I have read your previous posts and if this is related to them, then I think you are not solving any problems.. you are creating new ones.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…