diff --git a/rtl/avr/setjump.inc b/rtl/avr/setjump.inc index 65b03529fa..62a7922e61 100644 --- a/rtl/avr/setjump.inc +++ b/rtl/avr/setjump.inc @@ -18,6 +18,7 @@ function fpc_setjmp(var S : jmp_buf) : shortint;assembler;[Public, alias : 'FPC_ asm mov r26,r24 mov r27,r25 +{$ifndef CPUAVR_16_REGS} st x+,r1 st x+,r2 st x+,r3 @@ -33,8 +34,13 @@ function fpc_setjmp(var S : jmp_buf) : shortint;assembler;[Public, alias : 'FPC_ st x+,r13 st x+,r14 st x+,r15 +{$endif CPUAVR_16_REGS} st x+,r16 st x+,r17 +{$ifdef CPUAVR_16_REGS} + st x+,r18 + st x+,r19 +{$endif CPUAVR_16_REGS} st x+,r28 st x+,r29 @@ -65,6 +71,7 @@ procedure fpc_longjmp(var S : jmp_buf;value : shortint);assembler;[Public, alias asm mov r26,r24 mov r27,r25 +{$ifndef CPUAVR_16_REGS} ld r1,x+ ld r2,x+ ld r3,x+ @@ -80,8 +87,13 @@ procedure fpc_longjmp(var S : jmp_buf;value : shortint);assembler;[Public, alias ld r13,x+ ld r14,x+ ld r15,x+ +{$endif CPUAVR_16_REGS} ld r16,x+ ld r17,x+ +{$ifdef CPUAVR_16_REGS} + ld r18,x+ + ld r19,x+ +{$endif CPUAVR_16_REGS} ld r28,x+ ld r29,x+ diff --git a/rtl/avr/setjumph.inc b/rtl/avr/setjumph.inc index 47369170a9..927db7ff6f 100644 --- a/rtl/avr/setjumph.inc +++ b/rtl/avr/setjumph.inc @@ -16,7 +16,14 @@ type jmp_buf = packed record - r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16,r17,r28,r29,splo,sphi,pclo,pchi : byte; +{$ifndef CPUAVR_16_REGS} + r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15, +{$endif CPUAVR_16_REGS} + r16,r17, +{$ifdef CPUAVR_16_REGS} + r18,r19, +{$endif CPUAVR_16_REGS} + r28,r29,splo,sphi,pclo,pchi : byte; {$ifdef CPUAVR_3_BYTE_PC} pchighest : byte {$endif CPUAVR_3_BYTE_PC} diff --git a/rtl/embedded/Makefile b/rtl/embedded/Makefile index 7179578b96..d6e3a3328c 100644 --- a/rtl/embedded/Makefile +++ b/rtl/embedded/Makefile @@ -385,6 +385,10 @@ endif endif ifeq ($(ARCH),avr) CPU_SPECIFIC_COMMON_UNITS=intrinsics +ifeq ($(SUBARCH),avrtiny) +CPU_UNITS=attiny4 attiny5 attiny9 attiny10 attiny20 attiny40 +CPU_UNITS_DEFINED=1 +endif ifeq ($(SUBARCH),avr25) CPU_UNITS=attiny44a attiny26 attiny48 attiny10 attiny84a attiny2313 attiny461 attiny43u \ attiny24a attiny88 attiny40 attiny861 attiny85 attiny20 attiny24 attiny9 \ diff --git a/rtl/embedded/Makefile.fpc b/rtl/embedded/Makefile.fpc index da345e59ae..1f0a799d95 100644 --- a/rtl/embedded/Makefile.fpc +++ b/rtl/embedded/Makefile.fpc @@ -101,6 +101,10 @@ endif ifeq ($(ARCH),avr) CPU_SPECIFIC_COMMON_UNITS=intrinsics +ifeq ($(SUBARCH),avrtiny) +CPU_UNITS=attiny4 attiny5 attiny9 attiny10 attiny20 attiny40 +CPU_UNITS_DEFINED=1 +endif ifeq ($(SUBARCH),avr25) CPU_UNITS=attiny44a attiny26 attiny48 attiny10 attiny84a attiny2313 attiny461 attiny43u \ attiny24a attiny88 attiny40 attiny861 attiny85 attiny20 attiny24 attiny9 \ diff --git a/rtl/embedded/avr/start.inc b/rtl/embedded/avr/start.inc index 1c36d848cf..b49c475533 100644 --- a/rtl/embedded/avr/start.inc +++ b/rtl/embedded/avr/start.inc @@ -1,5 +1,9 @@ _start: +{$ifdef CPUAVR_16_REGS} + clr r17 +{$else CPUAVR_16_REGS} clr r1 +{$endif CPUAVR_16_REGS} // load stack pointer ldi r30,lo8(_stack_top) @@ -16,8 +20,13 @@ rjmp .LCopyDataLoopEntry .LCopyDataLoop: - lpm r0, Z+ - st X+, r0 +{$ifdef CPUAVR_16_REGS} + //!!!! FIXME? lpm r0, Z+ + //!!!! FIXME? st X+, r0 +{$else CPUAVR_16_REGS} + lpm r16, Z+ + st X+, r16 +{$endif CPUAVR_16_REGS} .LCopyDataLoopEntry: cpi XL, lo8(_edata) @@ -35,7 +44,11 @@ jmp .LZeroBssLoopEntry {$endif RELBRANCHES} .LZeroBssLoop: +{$ifdef CPUAVR_16_REGS} + st X+, r17 +{$else CPUAVR_16_REGS} st X+, r1 +{$endif CPUAVR_16_REGS} .LZeroBssLoopEntry: cpi XL, lo8(_bss_end)