Creating avr crosscompiler stops building rtl
Original Reporter info from Mantis: af0815 @afriess
-
Reporter name: Andi Friess
Original Reporter info from Mantis: af0815 @afriess
- Reporter name: Andi Friess
Description:
system.pp cannot build for avr5.
The error is in rtl\avr\avr.inc in the move procedure. This was switched in rev 42155 to assembler by laksen. It looks the line
{$define FPC_SYSTEM_HAS_MOVE}
procedure Move(const source;var dest;count:SizeInt);[public, alias: 'FPC_MOVE']; assembler; nostackframe;
asm
push r28
push r29
movw r26, r24 // Src=X
movw r28, r22 // Dest=Y
movw r30, r20 // Count=Z
cp r1, r30
cpc r1, r31
brge .Lexit // if 0 >= Count
cp r28, r26
cpc r29, r27
breq .Lexit // if dest = source
brlo .LForwardMove // if dest < source
// Add count to both pointers
add r26, r30
adc r27, r31
add r28, r30
adc r29, r31
.LBackwardMove:
ld r18, -X
st -Y, r18
sbiw Z, 1 // <--- should be sbiw ZL,1
brne .LBackwardMove
rjmp .Lexit
.LForwardMove:
ld r18, X+
st Y+, r18
sbiw Z, 1 // <--- should be sbiw ZL,1
brne .LForwardMove
.Lexit:
pop r29
pop r28
end;
sbiw according https://www.microchip.com/webdoc/avrassembler/avrassembler.wb_SBIW.html should be sbiw ZH:ZL,1
See Thread (german) https://www.lazarusforum.de/viewtopic.php?f=9&t=12420&p=110081#p110081
Steps to reproduce:
build trunk version of fpc with fpcupdeluxe with tarbget avr embedded subarch avr5
with the change to sbiw ZL,1 it works.
Additional information:
D:/data/lazdev/trunk/fpcsrc/compiler/ppcrossavr.exe -Cpavr5 -Ur -Tembedded -Pavr -XPavr-embedded- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FDD:\data\lazdev\trunk\cross\bin\avr-embedded -FE. -FUD:/data/lazdev/trunk/fpcsrc/rtl/units/avr-embedded -vw-n-h-l-d-u-t-p-c- -O2 -davr -dRELEASE -XPavr-embedded- -Xd -FlD:\data\lazdev\trunk\cross\lib\avr-embedded\avr5 -Cpavr5 -Us -Sg system.pp @system.cfg
D:\data\lazdev\trunk\fpcsrc\rtl\units\avr-embedded\system.s: Assembler messages:
D:\data\lazdev\trunk\fpcsrc\rtl\units\avr-embedded\system.s:30: Error: constant value required
D:\data\lazdev\trunk\fpcsrc\rtl\units\avr-embedded\system.s:30: Error: register r24, r26, r28 or r30 required
D:\data\lazdev\trunk\fpcsrc\rtl\units\avr-embedded\system.s:36: Error: constant value required
D:\data\lazdev\trunk\fpcsrc\rtl\units\avr-embedded\system.s:36: Error: register r24, r26, r28 or r30 required
system.pp(336) Error: Error while assembling exitcode 1
system.pp(336) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted
make[2]: *** [embedded_all] Error 2
make[1]: *** [rtl_all] Error 2
make: *** [build-stamp.avr-embedded] Error 2
Mantis conversion info:
- Mantis ID: 35752
- OS: Win10 / 64 Pro
- OS Build: Win10 / 64 Pro
- Build: 42271
- Platform: Dell XPS
- Version: 3.3.1
- Fixed in revision: 42336 (#48a7c098)
- Monitored by: » @d.ioannidis (Dimitrios Chr. Ioannidis), » @DonAlfredo (Alfred)