Using "MEM" in Borland Pascal

How can i use procedure 'MEM' in Borland Pascal "in Protected Mode" ..?
I use it before in "Real Mode" ...
 but my Program not Work in Protected Mode with Runtime Error (216).

 Thanks Full.
Who is Participating?
HypoConnect With a Mentor Commented:
I've had the same problem as you have a couple of years ago... I tried to write to the videobuffer in a putpixel routine but it didn't work... later on I started to learn how protected mode worked, and I found out how to do it.

However, the sollution to access the videobuffer in protectedmode was very easy, all I had to do was replacing the segment $A000 with pascal's builtin value called SegA000,

in protected mode, mem[$A000:X] := 10; will result in a runtime error but mem[segA000:X] := 10 works fine.

So... If you want to acess the videobuffer use: SegA000,
the Textmode Buffer: SegB800,
the Data segment: DSeg,
the Code segment: CSeg,
the Stack segment: SSeg.

anyway... here's is a little example that shows you how you can use mem in borland pascal protected mode.

Program test;

uses crt,dos;

Type MemoryBlock = array[1..65535] of byte;

var M  : ^MemoryBlock;
    Lp : word;

Procedure MCGA;
var R : registers;
 R.AX := $13;

Procedure Textmode;
var R : registers;
 R.AX := $3;

 writeln('Memory available : ',Memavail);
 writeln('Press any key to allocate 65535 bytes of memory');
 writeln('Memory available : ',Memavail);
 writeln('Press any key to fill the allocated memory with random bytes');
 writeln('and move the allocated memory to the MCGA screen memory');
 for lp := 0 to 64000 do Mem[seg(M^):ofs(M^)+lp] := random(255);

let's hope this helps! :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.