arch/avr: fixed PC load on chips with more than 128kB program memory

The code used subi instruction to decrement the Y pointer but this
instruction only affects a byte, not a word. Fixed it by using
pre-decrement in the LD instruction instead.
This commit is contained in:
Kerogit
2025-04-27 13:07:45 +08:00
committed by Xiang Xiao
parent cc9febb453
commit dd828c8920
+4 -7
View File
@@ -465,7 +465,7 @@
#if AVR_PC_SIZE <= 16
adiw r28, REG_PC0
#else
adiw r28, REG_PC2
adiw r28, (REG_PC2+1) /* Will pre-decrement this on use */
#endif
/* Fetch and set the new stack pointer */
@@ -490,14 +490,11 @@
push r24 /* Push PC0 and PC1 on the stack (PC1 then PC0) */
push r25
#else
ld r25, y /* Load PC2 (r25) */
subi r28,1
ld r25, -y /* Load PC2 (r25) */
push r25
ld r25, y /* Load PC1 (r25) */
subi r28,1
ld r25, -y /* Load PC1 (r25) */
push r25
ld r25, y /* Load PC0 (r25) */
subi r28,1
ld r25, -y /* Load PC0 (r25) */
push r25
#endif