Tech Support > Computer Hardware > Microprocessors > Passing arguments
Passing arguments
Posted by Sean on November 5th, 2003


If I pass an argument using r0 to r3, how can I keep from overwritting a
register that might be used someplace else such as during an interupt
routine?


Sean


Posted by tanya on November 5th, 2003


"Sean" <seanw@vigoris.net> wrote in message
news:3fa86639@news.vigoris.net...
they alter on the stack, and restore these on exit.
Apart from ISRs, if you are coding in assembly language, or mixing this with
C, you *must* be aware of who does what with particular registers.
If you wish to preserve a register that a subroutine will overwrite, the
subroutine can always push it on the stack on entry, and restore it on exit.
Alternatively, you can get the calling routine to do it.

I hope that is of some help.

Tanya




Posted by Android Cat on November 5th, 2003


Sean wrote:
Always make sure that your interrupt routines save/restore any registers
or flags that they use?

--
Ron Sharp.




Posted by Tauno Voipio on November 5th, 2003



"Sean" <seanw@vigoris.net> wrote in message
news:3fa86639@news.vigoris.net...
An interrupt routine is responsible to save and restore all the processor
state (including registers) it's clobbering.

Next time tell which processor you're using. It's much easier to give
meaningful replies to very chip-architecture dependent questions like this
if it were known which chip it is.

Tauno Voipio
tauno voipio @ iki fi




Posted by Sean Whitesell on November 5th, 2003


You have all answered my question and I greatly appreciate it. The
processor is, FYI, an ARM 7. But I see how the solution is genericly
used.


Thanks,

Sean



"Sean" <seanw@vigoris.net> wrote in message news:<3fa86639@news.vigoris.net>...

Posted by Arie de Muynck on November 5th, 2003


"Sean Whitesell" <seanw122@vigoris.net> wrote in message
news:d122ada9.0311050845.5b783abb@posting.google.c om...
Get the ATPCS document from the ARM wbsite:
http://www.arm.com/support/566FQ9/$File/ATPCS.pdf

It describes in detail the standard for parameter passing, register saving
etc in the ARM and Thumb modes.

Regards,
Arie de Muynck



Posted by Anton Erasmus on November 5th, 2003


On 5 Nov 2003 08:45:27 -0800, seanw122@vigoris.net (Sean Whitesell)
wrote:

The ARM switches in a different bank of registers for some of the
registers in interrupt mode. Hence if you have only one level of
interrupts it is not necessary to save all the registers.

Regards
Anton Erasmus



Similar Posts