[fpc-devel] AVR assembler code consistency checking

Christo christo.crause at gmail.com
Fri Jan 5 11:24:26 CET 2018


On Wed, 2018-01-03 at 18:10 +0100, Florian Klämpfl wrote:
> Am 03.01.2018 um 15:48 schrieb Christo:
> > 
> > I'm trying to implement some error checking for assembler code for the AVR target (e.g.
> > issues
> > 32007, 32109 and 32261).  After stepping through the compiler code a couple of times it
> > seems as
> > if there isn't a proper assembler constraint check build into the GAS parser in fpc. 

> No. This is indeed left to the assembler.

> > Is there a better location in the compiler to implement some assembler consistency checks?

> fpc/compiler/avr/raavar.pas:TAVRInstruction.ConcatInstruction

Attached find a patch for review which checks consistency of operands for the instructions NOP,
CP and SBIW. I haven't added new error messages yet, I try to re-use messages if they seem appropriate. It appear as if it would be easier in the long run to create some kind of generic operand constraint array and iterate over this?

At some point (much later) I also want to add range checks for branch type instructions (rjmp,
breq etc) to make sure that the branch distance is within reach of the instruction.  I suppose
this check will have to be implemented in finalizeavrcode since here the offsets of instructions
seem to be calculated? 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raavr.patch
Type: text/x-patch
Size: 2209 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180105/0c42c10b/attachment.bin>


More information about the fpc-devel mailing list