Sign in Join

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

Mailing lists / fpc-pascal / 2000-10

DOS memory access via "absolute"

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Sebastian Schuberth

Hi there!

Is anyone able to tell me why the following code plots the red pixel but not the blue one, and why the locking function does not work?

----8<----
Program Test;
Uses
  CRT,GO32;
Var
  Screen:Array[0..199,0..319] Of Byte Absolute $A0000;
Begin
  WriteLn(lock_linear_region($A0000,320*200));
  ReadKey;
  Asm
    mov eax,13h
    int 10h
  End;
  Screen[0,0]:=1; { blue pixel }
  Mem[$A0001]:=12; { red pixel }
  ReadKey;
  Asm
    mov eax,03h
    int 10h
  End;
  WriteLn(unlock_linear_region($A0000,320*200));
End.
----8<----

Thanks in advance!

Sebastian Schuberth
Florian Klaempfl
to Sebastian Schuberth
Sebastian Schuberth wrote 5 lines
Hi there! Is anyone able to tell me why the following code plots the red pixel but not the blue one,

absolute uses always addressing via FS, see below.

and why the locking function does not work?

You don't have to lock memory, if you don't use interrupt handlers.

Show quoted text 21 lines
----8<---- Program Test; Uses CRT,GO32; Var Screen:Array[0..199,0..319] Of Byte Absolute $A0000; Begin WriteLn(lock_linear_region($A0000,320*200)); ReadKey; Asm mov eax,13h int 10h End; Screen[0,0]:=1; { blue pixel } Mem[$A0001]:=12; { red pixel }

Use Mem[$a000:0001] instead.
FPC uses some tricks to access dos memory (it is done via the fs selector).

Sebastian Schuberth
to Florian Klaempfl
Florian Klaempfl wrote
absolute uses always addressing via FS, see below. FPC uses some tricks to access dos memory (it is done via the fs selector).

If "absolute" uses the FS selector as you say, and DOS memory is accessed via FS, then why am I not able to use the Screen array to access DOS memory?

Sebastian Schuberth
Pierre Muller
to Sebastian Schuberth
you wrote 8 lines
Florian Klaempfl wrote: > absolute uses always addressing via FS, see below. > FPC uses some tricks to access dos memory (it is done via the fs selector). If "absolute" uses the FS selector as you say, and DOS memory is accessed via FS, then why am I not able to use the Screen array to access DOS memory?
Probably because you declare it as
   Var
  Screen:Array[0..199,0..319] Of Byte Absolute $A0000;
Try to redeclare it as
Var
  Screen:Array[0..199,0..319] Of Byte Absolute $A000:0;

This should work better!