View Issue Details

IDProjectCategoryView StatusLast Update
0029758FPCCompilerpublic2017-12-31 06:24
ReporterChristo CrauseAssigned ToJeppe Johansen 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformEmbeddedOSAVROS Version
Product Version3.1.1Product Build33130 
Target Version3.2.0Fixed in Version3.1.1 
Summary0029758: Invalid(?) assembler generated to reference a procedure parameter on AVR
DescriptionWhen compiling the attached test.pas file, the generated test.s file contains a line:
  mov r27,r24+1

which causes avr-as to generate the following error:
[0.051] Executing "/usr/bin/avr-as" with command line "-mmcu=avr5 -o test.o test.s"
test.s: Assembler messages:
test.s:7: Error: garbage at end of line

This line seems to correspond to the assembler code:
  mov XH, TMyUint16(counter).h

from line 18 in test.pas.
Steps To ReproduceCompile attached test.pas file with:
path/to/ppcrossavr -Tembedded -Wpatmega328 -Cpavr5 -Pavr -va -a -n @./.fpc.cfg test.pas
Additional InformationAVR cross compiler compiled from trunc (33130) using fpc 3.0 as starting compiler with command line:
make clean crossall OS_TARGET=embedded CPU_TARGET=avr SUBARCH=avr5 BINUTILSPREFIX=avr- CROSSOPT="-O3 -XX -CX" FPC=~/fpc/compiler/ppc386

Host: Debian Linux
avr-as version 2.24
TagsAVR
Fixed in Revision37864
FPCOldBugId
FPCTarget
Attached Files
  • test.pas (715 bytes)
    program test;
    
    type
      TMyUINT16 = packed record
      {$IFDEF ENDIAN_LITTLE}
        l:byte;
        h:byte;
       {$ELSE}
        h:byte;
        l:byte;
        {$ENDIF}
      end;
    
    procedure delayloop(const counter: uint16); assembler;
    label
      Loop;
    asm  
      mov XH, TMyUint16(counter).h
      mov XL, TMyUint16(counter).l
    Loop:
      SBIW XL,1
      BRNE Loop
    end; 
    
    const
      countervalue = ((16000000 div 1000) - 5) div 4;  // counter value for 1 ms delay
      PB5 = (1 shl 5);
      
    var
      i: uint16;
      
    begin
      DDRB := DDRB or PB5; // Set pin 5 of port B to output
      
      while true do 
      begin
        i := 500;
        repeat 
          delayloop(countervalue);
          dec(i);
        until i = 0;
        
        PORTB := PORTB XOR PB5;  // toggle pin 5 of port B on/off
      end;
    end.
    
    test.pas (715 bytes)
  • test.s (2,792 bytes)

Activities

Christo Crause

2016-02-29 06:35

reporter  

test.pas (715 bytes)
program test;

type
  TMyUINT16 = packed record
  {$IFDEF ENDIAN_LITTLE}
    l:byte;
    h:byte;
   {$ELSE}
    h:byte;
    l:byte;
    {$ENDIF}
  end;

procedure delayloop(const counter: uint16); assembler;
label
  Loop;
asm  
  mov XH, TMyUint16(counter).h
  mov XL, TMyUint16(counter).l
Loop:
  SBIW XL,1
  BRNE Loop
end; 

const
  countervalue = ((16000000 div 1000) - 5) div 4;  // counter value for 1 ms delay
  PB5 = (1 shl 5);
  
var
  i: uint16;
  
begin
  DDRB := DDRB or PB5; // Set pin 5 of port B to output
  
  while true do 
  begin
    i := 500;
    repeat 
      delayloop(countervalue);
      dec(i);
    until i = 0;
    
    PORTB := PORTB XOR PB5;  // toggle pin 5 of port B on/off
  end;
end.
test.pas (715 bytes)

Christo Crause

2016-02-29 06:36

reporter  

test.s (2,792 bytes)

Thaddy de Koning

2016-02-29 10:46

reporter   ~0090471

Last edited: 2016-02-29 11:30

View 4 revisions

Both Christo and I have been trying over the weekend.
It may just be that we overlooked something specific to AVR.
I checked some other platforms with similar code and on e.g. ARM or Intel the code is valid.
Also, we got (some of) the code to compile, so it may be a tool chain failure.

[edit]
See http://forum.lazarus.freepascal.org/index.php/topic,31718.msg203698/topicseen.html#new

Issue History

Date Modified Username Field Change
2016-02-29 06:35 Christo Crause New Issue
2016-02-29 06:35 Christo Crause File Added: test.pas
2016-02-29 06:36 Christo Crause File Added: test.s
2016-02-29 10:46 Thaddy de Koning Note Added: 0090471
2016-02-29 10:46 Thaddy de Koning Note Edited: 0090471 View Revisions
2016-02-29 10:50 Thaddy de Koning Note Edited: 0090471 View Revisions
2016-02-29 11:30 Thaddy de Koning Note Edited: 0090471 View Revisions
2016-03-06 14:23 Jonas Maebe Summary Invalid(?) assembler generated to reference a procedure parameter => Invalid(?) assembler generated to reference a procedure parameter on AVR
2017-07-12 13:15 Christo Crause Tag Attached: AVR
2017-12-29 15:02 Jeppe Johansen Fixed in Revision => 37864
2017-12-29 15:02 Jeppe Johansen Status new => resolved
2017-12-29 15:02 Jeppe Johansen Fixed in Version => 3.1.1
2017-12-29 15:02 Jeppe Johansen Resolution open => fixed
2017-12-29 15:02 Jeppe Johansen Assigned To => Jeppe Johansen
2017-12-29 15:02 Jeppe Johansen Target Version => 3.2.0
2017-12-31 06:24 Christo Crause Status resolved => closed