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.
  Bakry
LVL 1
bakry99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HypoCommented:
Hi,
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;
begin
 R.AX := $13;
 intr($10,R);
end;

Procedure Textmode;
var R : registers;
begin
 R.AX := $3;
 intr($10,R);
end;

begin
 Randomize;
 Clrscr;
 writeln('Memory available : ',Memavail);
 writeln('Press any key to allocate 65535 bytes of memory');
 readkey;
 getmem(M,65535);
 clrscr;
 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');
 readkey;
 for lp := 0 to 64000 do Mem[seg(M^):ofs(M^)+lp] := random(255);
 MCGA;
 move(Mem[seg(M^):ofs(M^)],mem[SegA000:0],64000);
 readkey;
 Textmode;
 Freemem(M,65535);
end.

let's hope this helps! :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Pascal

From novice to tech pro — start learning today.