AVR [patch] Sometimes registers r0 or r1 are pushed for avrtiny
Original Reporter info from Mantis: ccrause @ccrause
-
Reporter name: Christo Crause
Original Reporter info from Mantis: ccrause @ccrause
- Reporter name: Christo Crause
Description:
When calling a function from an interrupt handler the compiler sometimes insert push/pop instructions for r0 & r1, obviously leading to assembler errors. The code below is an example which triggers this problem.
This problem can be fixed by removing r0, r1 from the volatile register set, see attached patch.
Steps to reproduce:
Compile test program with
/fpc/3.3.1/compiler/ppcrossavr -n @/fpc/3.3.1/fpc.cfg -Wpattiny10 test.lpr
program test;
function Sound1(t: uint32): byte;
begin
end;
var
t: uint32;
procedure genSound; alias: 'TIM0_OVF_ISR'; interrupt;
begin
OCR0A := Sound1(t);
end;
begin
end.
Additional information:
Compiler/assembler output:
Free Pascal Compiler version 3.3.1 [2020/10/06] for avr
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Embedded
Compiling test.lpr
test.lpr(3,10) Warning: Function result does not seem to be set
test.lpr(8,3) Warning: Variable "t" read but nowhere assigned
Assembling test
test.s: Assembler messages:
test.s:70: Error: register name or number from 16 to 31 required
test.s:71: Error: register name or number from 16 to 31 required
test.s:87: Error: register name or number from 16 to 31 required
test.s:88: Error: register name or number from 16 to 31 required
test.lpr(19) Error: Error while assembling exitcode 1
test.lpr(19) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
Mantis conversion info:
- Mantis ID: 37914
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 47102 (#b8c707ed)