Thanks Thaddy, your example compiles fine, but the GNU assembler chokes on the generated assembler code. Compiling the following snippet:
Type
TMyUINT16 = packed record
l:byte;
h:byte;
end;
procedure delay_ms2(const t: uint16); assembler;
label
Loop;
asm
mov XH, TMyUint16(t).h
mov XL, TMyUint16(t).l
Loop:
SBIW XL,1
BRNE Loop
end;
generates the following assembler snippet:
PsBLINK_ss_DELAY_MS2sWORD:
mov r27,r24+1
mov r26,r24
.Lj8:
sbiw r26,1
brne .Lj8
ret
.Le1:
.size PsBLINK_ss_DELAY_MS2sWORD, .Le1 - PsBLINK_ss_DELAY_MS2sWORD
The AVR assembler generates the following error:
blink_test.s: Assembler messages:
blink_test.s:19: Error: garbage at end of line
It seems as if the fpc compiler translated the line
mov XH, TMyUint16(t).h into
mov r27,r24+1. From the rest of the generated assembler code it seems as if the value passed to the procedure is loaded into r24:r25, so I suspected that the compiler was trying to generate "the next register following r24" and ended up writing r24+1 instead of r25.
If so I guess this is a bug?