Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can be expended and Extended memory accessed?

Status
Not open for further replies.

SirShahzad

Instructor
Jan 23, 2001
9
0
0
FR
Hi,
I want to know that is there any code possible in C or C++ in DOS mode for accessing memory
1- expended
2- extended

IF YES THEN PLEASE tell me the code.
thanx.
 
Yes... I used to do this all the time for DOS programs. There are actually a number of ways to access the extended and expanded memory areas, but all of them require either a library function from a memory manager or some tricky programming. This is because DOS only understands a 20-bit address space, but the hardware understands 24 bits or more (depending on the hardware itself). This is further complicated by the CPU mode that DOS operates in: unprotected mode (windows operates in protected mode). This changes the mapping of the software to hardware address space.

The problems aren't over yet: It's relatively easy to switch the CPU into protected mode, but now that it's there, it *protected*! and it is nearly impossible (286) to switch it back or relatively hard (386 and above). In fact, the 286 motherboards had to have a special reset capability because the ONLY way to get the processor back into unprotected mode after accessing extended memory was to RESET THE CPU!!! [3eyes] Of course, this was rather slow and required a flag so the BIOS would know why it just got reset and how to get back to your program without all the normal reset stuff.

OK, enough rambling. The real answer you are probably looking for is... (ready?):
It depends!

1) Some compilers have library functions to help with this.
2) If you have a DOS extender loaded in your DOS system, there may be API functions you can call for that.
3)If you are actually calling a DOS program from Windows, you may be able to use a Windows function to do the work for you (in this mode you are really still in protected mode, but inside a "virtual-86" environment)
4) etc...

My advice is to research your compiler and your operating environment a little more.

Not quite what you wanted,... [neutral]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top