EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Register variable in C

Started by g0tty0 December 12, 2007
Hi,
Is it possible to force compiler to place a local non-static variable
to general purpose register?
I'm using IAR EW430 v4.10A.

Best regards,
Max

Beginning Microcontrollers with the MSP430

I don't quite understand your question. Do you want a local variable
to be stored in a specific R4 to R15 general purpose register
permanently? What for?

I think this is possible declaring the variable as '__regvar' and
compiler options --regvar_r4 and/or --regvar_r5. However this seems to
be used to store a frequently used static variable.
I've never used this option. You may want to experiment with it and
tell us how it went.

Regards,
Michael Kusch

--- In m..., "g0tty0" wrote:
>
> Hi,
> Is it possible to force compiler to place a local non-static variable
> to general purpose register?
> I'm using IAR EW430 v4.10A.
>
> Best regards,
> Max
>
Hi g0tty0 or Max (mmmm I am confused).

If you want that one of your local variable be in a
register you can use the instruction in C "resgister"
or use the parameter of the function (if you are using
IAR). I think is the better option to alocate
avariable in a register if you use a C compiler.

Note: Read the documentation of "register" and the
form how the compiler manage the parameters of the
function.

Best regards.

--- g0tty0 wrote:

> Hi,
> Is it possible to force compiler to place a local
> non-static variable
> to general purpose register?
> I'm using IAR EW430 v4.10A.
>
> Best regards,
> Max

____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

The 2024 Embedded Online Conference