Arm Community
Site
Search
User
Site
Search
User
Support forums
Arm Development Studio forum
Concept of Scratch and Preserved Registers
Jump...
Cancel
Locked
Locked
Replies
4 replies
Subscribers
119 subscribers
Views
18335 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
How was your experience today?
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
Concept of Scratch and Preserved Registers
Muhammad Ahsan
over 12 years ago
Hi,
I am confused in understanding the difference between scratch and preserved registers. I have read the development guide of IAR Embedded Workbench but the topic was written in such a way that I could not get the real sence of it.
Any help or if possible some example that can help me differenciating between the both will be regarded.
Thanks in advance
Top replies
Martin Weidmann
over 12 years ago
+1
Note: This was originally posted on 5th April 2011 at http://forums.arm.com I've not used IAR's tools, but I'm assuming it follows the AAPCS (Procedure Call Standard for the ARM Architecture). The AAPCS...
Parents
Muhammad Ahsan
over 12 years ago
Note: This was originally posted on 5th April 2011 at
http://forums.arm.com
@ttfn thanks for your detailed reply. Actually what I am unable to understand is that we have two groups of registers r0-r3 and r4-r11. I know that r0-r3 can be used for passing parameters while the remaining cann't. I am passing 4 arguments to the function foo called by main as in your example. Inside function foo I am doing some calculations which involve r0-r6. after return I want to have the same values in all registers as they were before calling foo. Do I need to push r4-r6 on stack before calling foo and then pop them back after return to have the same register values or it will be done automatically as they are called preserved registers. I have seen in the stack window that r0-r3 are pushed to stack, when they are used as parameters.
I hope you got my point.
Cancel
Vote up
0
Vote down
Cancel
Reply
Muhammad Ahsan
over 12 years ago
Note: This was originally posted on 5th April 2011 at
http://forums.arm.com
@ttfn thanks for your detailed reply. Actually what I am unable to understand is that we have two groups of registers r0-r3 and r4-r11. I know that r0-r3 can be used for passing parameters while the remaining cann't. I am passing 4 arguments to the function foo called by main as in your example. Inside function foo I am doing some calculations which involve r0-r6. after return I want to have the same values in all registers as they were before calling foo. Do I need to push r4-r6 on stack before calling foo and then pop them back after return to have the same register values or it will be done automatically as they are called preserved registers. I have seen in the stack window that r0-r3 are pushed to stack, when they are used as parameters.
I hope you got my point.
Cancel
Vote up
0
Vote down
Cancel
Children
No data