[fpc-devel] Freepascal in microcontrollers

Marco van de Voort marcov at stack.nl
Wed Feb 27 09:55:54 CET 2008


> You can avoid cryptic language constructs in the main source code.
> 
> I did not yet use the preprocessor in Pascal but a standard way to 
> access memory mapped ports in C is something like this (from the top of 
> my head):
> 
> #define _port = 0x87

const _port=$87;
 
> #define ByteIO(p) *(((volatile unsigned char)*)(p))

A bit cryptic, but I guess this is

function ByteIO(var p):puchar; inline;

begin
  result:=puchar(@p);
end;

> #define port=ByteIO(_port)

const port = puchar(_port); // !??!?

>  ByteIO(_port) = 0x55;
> 
> may look queer to some watchers, but
> 
>  port = 0x55;

port^:=$55;





More information about the fpc-devel mailing list