On 2017-08-07 18:20, Augusto Fraga Giachero wrote:
> PIC microcontrollers (PIC12/PIC14/PIC16) doesn't have a general purpose
> stack (it has a hardware stack used only to sub-routines and interrupts
> return). I don't known how the sdcc implements local variables for these
> targets (may be a software stack or fixed allocation).
> 
> Augusto

The compiler allocates memory from the general purpose registers, as far
as I can see. But the names may change if another variable is defined or
the order of definition is changed.

> 
> On 08/06/2017 07:12 PM, Maarten Brock wrote:
>>> Access to global variable is no problem, just use _varname, but how can
>>> I access local variables? Is there no other way than using the
>>> compiler-generated names (which may change if the code is changed)?
>>>
>>> BR
>>> Erlo
>> This highly depends on the target and compiler options. Local
>> variables on
>> stack don't even have a name in assembler.
>>
>> Hav you considered using static variables?
>>
>> Maarten

Not static, but a global variable. The issue with both approaches is the
variable can not be overlayed/reused in another function and memory is
sparse in the small PICs.

Erlo

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to