[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] push r1, pop r0

From: David Brown
Subject: Re: [avr-gcc-list] push r1, pop r0
Date: Thu, 9 Nov 2017 18:44:28 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

On 09/11/17 17:49, Szikra Istvan wrote:
> Hi David, 
> What is exactly wrong with my code?
> Thanks by the way for __get_PSP and all your help.

This is getting into ARM stuff, and is therefore off-topic for the
avr-gcc list (as you noted below).  But the principles are fairly

The "register __ASM" version of __get_PSP is for ARM's compiler (from
Keil), not for gcc.  With gcc you should not use register asm constructs
for registers that are in use otherwise by the compiler - there are only
a few registers that are safe to use for asm variables.  The code might
well work correctly - but it is not a reliable way to handle it.

In particular, trying to use sp directly as a register variable may go
badly wrong if the code needs to change or use sp in some way.  The
single instruction you saved with this construct is totally negligible,
and would probably disappear entirely in any real use of reading SP.
Dangerous hacks and micro-optimisations like this are not worth it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]