Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-10

variable declarations with 'absolute' syntax

9 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Looking at the FPC Language Reference for Variable Declaration syntax:

http://www.freepascal.org/docs-html/ref/refse21.html

Specifically, ABSOLUTE declarations. The documentation gives this example:

var
  curterm1 : integer;
  curterm6 : integer absolute curterm1;

Now according to the syntax diagram the syntax after ABSOLUTE can be an Identifier or an Integer Expression. So the above is an example where an Identifier is used. So what is (code example) of valid syntax when the Integer Expression syntax is used?

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Marco van de Voort
to Graeme Geldenhuys

In our previous episode, Graeme Geldenhuys said:

Show quoted text 16 lines
Looking at the FPC Language Reference for Variable Declaration syntax: http://www.freepascal.org/docs-html/ref/refse21.html Specifically, ABSOLUTE declarations. The documentation gives this example: var curterm1 : integer; curterm6 : integer absolute curterm1; Now according to the syntax diagram the syntax after ABSOLUTE can be an Identifier or an Integer Expression. So the above is an example where an Identifier is used. So what is (code example) of valid syntax when the Integer Expression syntax is used?

IIRC on Dos you can use addresses in [segment:offset] notation.

Reply by email

Tomas Hajny
to Graeme Geldenhuys
Graeme Geldenhuys wrote
On 2015-10-13 at 22:13, Michael Ring wrote: > There's a lot of use in embedded targets: Ah, thank you. Finally an answer I can understand. :)

The case of MS-DOS using it e.g. to provide direct access to the video adapter memory ($B800:0000), low-level information maintained by BIOS ($40:xxx), etc., as already mentioned by someone else (Marco?) is in principle the same as use cases relevant for embedded targets.

Tomas

Reply by email

Marco van de Voort
to Tomas Hajny

In our previous episode, Tomas Hajny said:

Show quoted text 8 lines
>> There's a lot of use in embedded targets: > > Ah, thank you. Finally an answer I can understand. :) The case of MS-DOS using it e.g. to provide direct access to the video adapter memory ($B800:0000), low-level information maintained by BIOS ($40:xxx), etc., as already mentioned by someone else (Marco?) is in principle the same as use cases relevant for embedded targets.

Yes, but I thought it was square brackets, not parentheses. Address is linearized using seg*16+ofs and addressed via %fs (for go32v2, for i8086 it probably is used as is)

Reply by email

Mark Morgan Lloyd
to Marco van de Voort
Marco van de Voort wrote 11 lines
In our previous episode, Tomas Hajny said: >>> There's a lot of use in embedded targets: >> Ah, thank you. Finally an answer I can understand. :) > The case of MS-DOS using it e.g. to provide direct access to the video > adapter memory ($B800:0000), low-level information maintained by BIOS > ($40:xxx), etc., as already mentioned by someone else (Marco?) is in > principle the same as use cases relevant for embedded targets. Yes, but I thought it was square brackets, not parentheses. Address is linearized using seg*16+ofs and addressed via %fs (for go32v2, for i8086 it probably is used as is)

[Checks] No bracket or parentheses in the case of Turbo Pascal, but I'd point out that the syntax was $B800:$0000 i.e. the absolute address was two concatenated 16-bit words rather than a colon being acceptable in the middle of a 32-bit word. Modula-2 IIRC was about the same.

The C crowd would probably like to use (square) brackets on account of their array semantics, and in the general case it's arguable whether defining an absolute variable is better or worse than defining a pointer with an absolute initial value. I suppose that a compiler/linker could potentially interpret an absolute declaration as indicating that that location should not be swapped/overlaid/relocated.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Tomas Hajny
to Marco van de Voort: In our previous episode, Tomas Hajny said: Yes, but I thought it was square brackets, not…
Marco van de Voort wrote 13 lines
In our previous episode, Tomas Hajny said: > >> There's a lot of use in embedded targets: > > > > Ah, thank you. Finally an answer I can understand. :) > > The case of MS-DOS using it e.g. to provide direct access to the video > adapter memory ($B800:0000), low-level information maintained by BIOS > ($40:xxx), etc., as already mentioned by someone else (Marco?) is in > principle the same as use cases relevant for embedded targets. Yes, but I thought it was square brackets, not parentheses. Address is linearized using seg*16+ofs and addressed via %fs (for go32v2, for i8086 it probably is used as is)

There are no parentheses nor brackets when used with "absolute":

---------------
var
Shifts1: byte absolute $40:$17; (* shift status as set by BIOS *) Shifts2: byte absolute $40:$18; (* (extended and normal) *) ===============

Brackets are used when using the other option for direct memory access - accessing the memory as array via Mem[] / MemW[].

Tomas

Reply by email