Waldek Hebisch wrote:
[ Charset ISO-8859-1 unsupported, converting... ]
Hi there,
It looks like it's not possible to declare a pointer to char and initialise it to the video memory, e.g.
type VideoMemory: ^char;
var VideoMemory := 0x80000;
Excuse the syntax if its wrong, I'm new to Pascal. :-)
The following shows how to store a character at address 0x80000:
program VideoMemory; type VideoMemory = ^char;
var VideoMemoryVar : VideoMemory value VideoMemory($80000); begin VideoMemoryVar^ := 'a'; end .
Note that it depends on your OS what will be at the address 0x80000. If you try to access video memory after entering protected mode, but before you initialize memory management your OS will crash.
Also variables and pointer types used to access hardware should be marked `volatile', but I just noticed that currently GPC does not allow this...
It does, but as an "attribute" (in order to reduce syntax pollution for a very rarely used feature). program VideoMemory; type VolatileChar = char attribute (volatile); VideoMemory = ^VolatileChar; procedure p; var VideoMemoryVar : VideoMemory value VideoMemory($80000); c: Char; begin c := VideoMemoryVar^; c := VideoMemoryVar^; c := VideoMemoryVar^; c := VideoMemoryVar^; c := VideoMemoryVar^; c := VideoMemoryVar^; c := VideoMemoryVar^; c := VideoMemoryVar^; c := VideoMemoryVar^; end; begin p end. (The procedure body is there to look at the generated assmebler code and see the multiple accesses, which vanish without the attribute when compiling with optimization.) Frank -- Frank Heckenbach, f.heckenbach@fh-soft.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE D101 CD02 4C9D 0FE0 E5E8