Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 29, 2010 20:07:56

Rick J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] Clobbered registers


In msp430-gcc-4.4.5, is there any way to override the default clobbered
registers for a function? I have a small assembly routine which uses only R15
and R14, and I would like to be able to free up R12 and R13 for the calling
function to use.
--
Rick Jenkins <r***@*artmantech.com>
Hartman Technicahttp://www.hartmantech.comPhone +1 (403) 230-1987
221 35 Avenue. N.E., Calgary, Alberta, Canada T2E 2K5


Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

#2 Dec. 31, 2010 14:58:28

Peter B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] Clobbered registers


Per the abi <http://mspgcc.sourceforge.net/manual/c1225.html> (which I
haven't validated, but is probably still mostly right):

r12, r13, r14, and r15 - are call clobbered (in general) registers. If you
are interfacing C with assembler language, you do not have to save these
registers, except in interrupt service routines.

I don't know of a way to annotate a declaration so that the caller is aware
it does not need to save the registers you're not using. If you could write
the routine in C and allow it to be inlined, it's possible that
optimizations would eliminate the saves.

Peter

On Wed, Dec 29, 2010 at 2:06 PM, Rick Jenkins <r***@*artmantech.com> wrote:
> In msp430-gcc-4.4.5, is there any way to override the default clobbered
> registers for a function? I have a small assembly routine which uses only
R15
> and R14, and I would like to be able to free up R12 and R13 for the
calling
> function to use.
> --
> Rick Jenkins <r***@*artmantech.com>
> Hartman Technicahttp://www.hartmantech.com> Phone +1 (403) 230-1987
> 221 35 Avenue. N.E., Calgary, Alberta, Canada T2E 2K5
>
>

> Mspgcc-users mailing list
> Mspgcc-us***@*ists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/mspgcc-users>
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

#3 Jan. 4, 2011 13:30:12

J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[Mspgcc-users] Clobbered registers


Yes, there is a way: recompile mspgcc with a different configuration. :)

No, seriously, what you can do is to execute the call to your function
with inline-assembly code (write a macro if you want).
This way, the compiler will not know that a call takes place and
won't assume the registers clobbered.
You should, however, declare any register you
_do_ clobber as clobbered in the asm instruction.


I _think_ the compiler-generated calls to the multiply/divide functions
taken from gcclib are called without this clobbering.
(There is a comment about the different call convention for these functions)
But I doubt there is a way to declare this for self-defined functions.

JMGross

----- Urspr√ľngliche Nachricht -----
Von: Rick Jenkins
Gesendet am: 29 Dez 2010 21:06:10

In msp430-gcc-4.4.5, is there any way to override the default clobbered
registers for a function? I have a small assembly routine which uses only R15
and R14, and I would like to be able to free up R12 and R13 for the calling
function to use.
--
Rick Jenkins <r***@*artmantech.com>
Hartman Technicahttp://www.hartmantech.comPhone +1 (403) 230-1987
221 35 Avenue. N.E., Calgary, Alberta, Canada T2E 2K5



Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/mspgcc-users

Offline

Board footer

Moderator control

Enjoy the 17th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support