[fpc-devel] AVR assembler code consistency checking
Florian Klämpfl
florian at freepascal.org
Sat Jan 6 16:03:37 CET 2018
Am 05.01.2018 um 11:24 schrieb Christo:
> 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?
Well, yes, the other architectures with inline assembler checking (i.e. x86) use the tables of the
internal assembler for 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.
This should be checked by the assembler reader.
> I suppose
> this check will have to be implemented in finalizeavrcode since here the offsets of instructions
> seem to be calculated?
finalizeavrcode is used only to fix code generated by the compiler. It should not be used for error
checking imo.
More information about the fpc-devel
mailing list