Passing arguments

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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



Re: Passing arguments
Quoted text here. Click to load it
Interrupt service routines should save machine flags plus any registers that
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




Re: Passing arguments
Quoted text here. Click to load it

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

--
Ron Sharp.




Re: Passing arguments

Quoted text here. Click to load it

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




Re: Passing arguments
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



Quoted text here. Click to load it

Re: Passing arguments
Quoted text here. Click to load it

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



Re: Passing arguments
On 5 Nov 2003 08:45:27 -0800, snipped-for-privacy@vigoris.net (Sean Whitesell)

Quoted text here. Click to load it

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


Site Timeline