[fpc-pascal] Pascal Ardiono (avr) library

Joost van der Sluis joost at cnoc.nl
Sun Apr 4 13:03:40 CEST 2021


Op 04-04-2021 om 12:50 schreef Joost van der Sluis via fpc-pascal:
> I came across some issues while doing this, but I can not remember all 
> of them.

Another one: (Also constant propagation)

-O4, {$WRITEABLECONST OFF}

# [19] a := DigitalPinToBitMask[5];
	lds	r18,(TC_sARDUINO_ss_DIGITALPINTOBITMASK+5)
# Var a located in register r18
	# Register r18 allocated
	# Register r18 released
# [20] a := 32;
	ldi	r18,32

First, the compiler could remove line 19 completely.

Secondly, (TC_sARDUINO_ss_DIGITALPINTOBITMASK+5) is a constant with 
value 32. So why the lds, and not ldi? (ie: line 19 and 20 are exactly 
the same!)

btw: the value of a was not used in this example, so a warning was 
raised. But the compiler could also throw this piece of code away 
altogether....

Regards,

Joost.


More information about the fpc-pascal mailing list