Passing arguments

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

Reply to
Sean
Loading thread data ...

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

Reply to
tanya

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

--
Ron Sharp.
Reply to
Android Cat

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

Reply to
Tauno Voipio

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

Reply to
Sean Whitesell

Get the ATPCS document from the ARM wbsite:

formatting link
$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

Reply to
Arie de Muynck

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

Reply to
Anton Erasmus

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.