Question about preserving caller register values

Beta Testing discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Question about preserving caller register values

#1 Post by Dany » 26 May 2015 17:23

Hi, as you probably have seen I am busy with the CRTOS library for PIC32 (http://www.mikroe.com/forum/viewtopic.php?f=172&t=64439).

Q1:

I think that the task context I do save is too big, after all the context switching in CRTOS looks to the caller (a task) as a simple function call (the "yield" to the scheduler).

So my question is: which register values do I have to preserve inside a called procedure (e.g. the yield procedure) (should be the same as any other arbitrary called procedure), and which register values can be changed inside a called procedure without the need to restore them afterwards.

I have seen that the compiler, in a function, saves RA (which is normal, if deeper calls happen), but also e.g. R25, R26 etc if it uses them, but not R30. Can you please provide such a list?

I also experienced that, when I try to "Restore" R1 (used as GP by the compiler), the CRTOS library does not work any more. I do not know why, my knowledge of the MIPS is very poor at the moment. Anyone knows?


Q2:

An extra question: I see that the compiler initializes GP outside the actual ram addresses: in the mini32 system with usb bootloader (P32MX534F064H with 16 Kbytes of Ram), the GP is initialized at $A0008000, while ram resides from $A0000000 to $A0003FFF.
This also means that in instructions as "SB R2, Offset(_Task0_ID+0)(GP)", the ofset of the variable is negative (or am I mistaking?)
I was actually expecting that the GP would point to the ram base address... so why is above done the way it is done?
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Question about preserving caller register values

#2 Post by Dany » 28 May 2015 20:30

No reply? I know I am asking about the inner space of the compiler, but still... :( :(
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for PIC32 Beta Testing”