Casting a constant to a pointer using SYSTEM.VAL
Posted: Thu Jan 27, 2022 10:52 pm
The Astrobe for Cortex-M compilers generate incorrect code when attempting to cast a constant value to a pointer using SYSTEM.VAL e.g:
A workaround is to first assign the constant to an INTEGER variable e.g.
Alternatively, the following syntax can be used:
Code: Select all
TYPE
GPIORegs = RECORD
CRL: INTEGER;
CRH: INTEGER;
END;
PGPIORegs = POINTER TO GPIORegs;
VAR
p: PGPIORegs;
BEGIN
p := SYSTEM.VAL(PGPIORegs, 04000000H);
...
...
Code: Select all
adr := 04000000H;
p := SYSTEM.VAL(PGPIORegs, adr);
Code: Select all
SYSTEM.PUT(SYSTEM.ADR(p), 04000000H);