AVR incorrect instructions generated for a variable at absolute 0 when passed as a var parameter
Original Reporter info from Mantis: ccrause @ccrause
-
Reporter name: Christo Crause
Original Reporter info from Mantis: ccrause @ccrause
- Reporter name: Christo Crause
Description:
Newer type controllers in the avrxmega3 subarch can have a peripheral (e.g. VPORTA) mapped to address 0. Incorrect instructions are generated when passing such a variable as a var parameter to a procedure, see steps to reproduce.
The problem appears to be that the compiler assumes ref.offset should not be 0 to be a reference referring to an absolute address. Attached a patch that implements extra checks to handle this situations.
Steps to reproduce:
program test;
procedure test1(var a: byte);
begin
end;
var
r: byte absolute 0;
begin
test1(r);
end.
The instructions generated for passing the reference to r to the proecdure call test1 is incorrect:
# [10] begin call FPC_INIT_FUNC_TABLE .Ll5: # [11] test1(r); mov r18,r19 // r19 is uninitialized mov r25,r19 mov r24,r18 call PsTEST_ss_TEST1sBYTE .Ll6: # [12] end.
call fpc_do_exit
Mantis conversion info:
- Mantis ID: 38861
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 49344 (#5e1e6c24)