Shop Learn P1 Docs P2 Docs Events
Is it possible to implement "absolute" keyword from Pascal? — Parallax Forums

Is it possible to implement "absolute" keyword from Pascal?

pik33pik33 Posts: 1,860
edited 2022-01-16 18:20 in BASIC (for Propeller)

Or maybe there is something already implemented with this functionality?

A very convenient thing I use everyday while programming in fpc/Lazarus.

var a:integer;
var b:array[0..3] of byte absolute a;
var c:integer absolute $deadbeef;

In Basic syntax it may look like this:

dim a as integer
dim b(4) as ubyte absolute a
dim c as integer absolute $deadbeef

In FreePascal this places the variable b at the same place in the memory as variable a. Variable c is placed in the memory at the address $deadbeef

What can it be used for? The first syntax gives automatic type conversion. I write this here and now because I have now this problem - send and receive bytes from serial while the data are longs. Two arrays, one for bytes, one for longs, placed at the same place does this automatically without any complex messing with pointers and conversions.

The second syntax is very convenient if you need to use hardware registers. The P2 doesn't need it as it has all of its registers already defined, but I use this while bare metal programming the RPi.


  • FlexBasic doesn't have anything like that now. It does sound like a feature of that sort would be useful. I'll look into it.

Sign In or Register to comment.