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
cross-target.

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.

mvh.,

David


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to