This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit dd828c8920cf7b43a89ece3cf10697963519d3e9 Author: Kerogit <kr....@kerogit.eu> AuthorDate: Sat Apr 5 23:41:54 2025 +0200 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. --- arch/avr/src/avr/excptmacros.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/avr/src/avr/excptmacros.h b/arch/avr/src/avr/excptmacros.h index dcfa8c4e54..a6046abf87 100644 --- a/arch/avr/src/avr/excptmacros.h +++ b/arch/avr/src/avr/excptmacros.h @@ -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