8

I'm developing software for the IBM PC with an 8086 processor. I want my program to use all available memory.

I know that I can use DOS int 21h function AH=48h to allocate all available conventional memory between 0 and 640K. But how do I allocate and use all RAM between 640K and 1024K?

Maybe there is not much RAM there, only video memory, which can be very small (less than 68K in total). Nevertheless, I want to use everything available.

As a historical curiosity, were there any IBM PC 8086 systems with more than 640K of RAM in use?

10
  • 2
    The IBM PC and XT used the 8088 processor. Software compatible with the 8086, but not hardware compatible. The AT used the 80286 processor. The PS/2 model 30 used the 8086 - that's the only machine in the PC line that I know of that used the 8086. So while it makes no real difference in software, really this should all be 8088. Dec 23, 2022 at 16:07
  • 1
    Thank you for the clarification. In this question I'm interested in IBM PC and PS/2 systems (and also campatibles) using either the 8086 or 8088 processor.
    – pts
    Dec 23, 2022 at 16:21
  • 1
    @pts Do the computers have memory past 640KB or not? That solely determines if there is anything you can use, and what kind of memory determines how you can use it.
    – Justme
    Dec 23, 2022 at 16:43
  • 3
    @pts: Are you assuming that an 8086/88 machine would commonly be fitted with 1MB of motherboard RAM, because that would be simple and cheap? I have to tell you that in the pre-AT era, that much RAM was not cheap at all, and even in the AT and 386 eras, this would have been very unusual. It did start to happen in the 486 era. Dec 23, 2022 at 17:14
  • 3
    @JohnDallman: My motherboard, which was quite typical, used eighteen 256Kx1 and eighteen 64Kx1 chips, though it was also common to use eighteen 256Kx1, two 64Kx4, and one 64K1. I don't think any mass-market 8088-based machines still were being produced by the time that 768K would be cheaper than 640K.
    – supercat
    Dec 23, 2022 at 20:36

2 Answers 2

16

Assuming there is usable memory between 640K and 1024K (which would be rather unusual in an 8086 PC), I would recommend using DOS 5.0 or later and adding UMBs to the memory allocation strategy (there are two steps involved: add UMBs to the memory chain with 0x5803, then set the allocation strategy to include them with 0x5801). You would combine this with separate drivers to add UMBs — e.g. UMBHERC.SYS to repurpose a HGC’s video buffer, QRAM.SYS combined with a hardware EMS card, or even UMB.SYS if you have a memory board capable of backfilling RAM between 640K and 1024K.

A blunter strategy would be to try changing values in upper memory and seeing what sticks, but that would be far more fragile.

There are many discussions of adding upper memory to 8086 PCs on forums, see for example this thread using a Tandy 1000.

Another possibility is to add memory mapped between 0xA0000 and 0xB7FFFF to the conventional memory allocation chains, either using memory expansion cards mapped to those addresses, or using video buffers if a compatible graphics card is installed and the corresponding video modes are never used (e.g. you have a VGA and only run text-mode programs). DR DOS’s MEMMAX can do this, as can many other memory management utilities.

As a historical curiosity, were there any IBM PC 8086 systems with more than 640K of RAM in use?

Yes, there have been quite a few. Any 8086 PC with an EMS board would qualify. In fact using an EMS board would be a much safer and time-appropriate solution to RAM problems on an 8086 PC.

(There have been many 8086 DOS systems with more than 640K of RAM directly accessible to DOS, as “conventional” memory in a contiguous block; see Who set the 640K limit?)

5
  • If there is no memory, it can't be used or added to be allocatable in DOS. And certainly a system with 512 kB of RAM and an EMS card can't even have 640 kB as EMS card likely has only 64kB page when not used for EMS. Sure 512 kB plus megabytes of EMS is possible but the user programs need EMS support to use it.
    – Justme
    Dec 23, 2022 at 11:01
  • 5
    Yes, which is why I also explain how to make UMBs available. “User programs need EMS support” — well yes of course, but the OP is talking about writing a program, so that program could support EMS if appropriate. Dec 23, 2022 at 11:12
  • 1
    Yes but you can't make UMBs available if there is no memory, only if there really is memory. And on a 8086 system, there likely is no device installed that can provide the memory. I see you changed the wording that if the assumption is there is memory, it can be taken into use, which is great.
    – Justme
    Dec 23, 2022 at 11:23
  • FYI I don't care whether the memory is continuous or not. Lots of 1K chunks are also fine for me.
    – pts
    Dec 23, 2022 at 16:04
  • @Justme: I would expect many expansion cards that were designed to bring a motherboard up to 640K could be fairly easily modified to add chunks of RAM anywhere in the upper address space by cutting some traces and adding some wires. It might be necessary to add something like a 74LS00 (quad NAND gate--about the cheapest electrically-compatible logic chip back then), but I doubt it.
    – supercat
    Dec 23, 2022 at 20:38
10

The short answer is, there is no usable RAM there so you can't use any. If you have an MDA video card, it has only 4096 bytes of video memory, and for 80x25 screen, it uses 4000 bytes already, so there is 96 bytes that are not visible. If you need more memory then you need to add memory, either just plain memory cards that can provide memory, or an EMS card which can add paged memory.

The 8086 can only address 1024 kilobytes, and when making the 5150 PC, IBM decided to split that so that up to 640 kB of RAM is possible and the rest of the memory, 384 kB is reserved for system use and expansion cards.

Some non-IBM systems could allow to have more memory and start the expansion memory area later, but if they were compatible with PC graphics there could only be up to 64k or 96k more before the start of video memory area.

Typically there is only up to 640 kilobytes, either all of it on the motherboard or in some cases some of it in the expansion slots. You can't even assume you have the maximum amount installed.

So, assuming there is a video card installed, you can use it for reading and writing, but it would be slower to read and write than main memory and everything you store there will visible on screen, as that is the purpose of video memory. Only later cards such a Hercules, EGA and VGA had more memory than needed to show on one page.

So if there is no special RAM cards that add general memory to the 384k reserved area, then there is no memory.

Typically, you would not be able to use the video memory in any meaningful way to store arbitrary data, and that memory would typically not be visible by DOS, not without tricks.

7
  • 1
    If you, for example have a VGA card that is being used in CGA Mode, you might be able to set the map select register to 0, effectively mapping memory from $A0000 to $BFFFF into the PC's memory map. As long as you are only using CGA text mode, you might be able to use the (relatively slow) video memory from $A0000 to $B8000 as program or data memory.
    – tofro
    Dec 23, 2022 at 12:29
  • 2
    @tofro This not about how much memory a card has, as even a VGA has 256kB. This is about how you can make the card show up in CPU memory space, and standard VGA can be mapped to A0000 and B0000 simultaneously in a 128k window but both 64k windows access the card identically, there is no way you can address the VGA memory in any other way. Maybe an SVGA card allows different areas of memory to be mapped to A0000 and B0000 windows, but realistically, finding an SVGA card that works in a 8086 system and using it specially to extend DOS memory to go past 640k is kind of stretch.
    – Justme
    Dec 23, 2022 at 16:37
  • 3
    @Justme: I doubt it would be that hard to find a VGA card that could be adapted to suit the purpose, but it would probably be just as easy to find a purpose-designed RAM expansion card that would fit the bill.
    – supercat
    Dec 23, 2022 at 20:39
  • 2
    All of the VGA's 256k of memory can be used at least in unchained mode. Turn off chain-4 mode to have access to 4 pages of 320x200x8bpp video memory. What's sent to the video output and visible on the screen doesn't have to be the same thing that's visible to the CPU at address A0000. The non-visible video memory could be used for things not related to graphics. Maybe not a typical non-AT setup though. Dec 24, 2022 at 3:08
  • 2
    "purpose-designed RAM expansion card that would fit the bill." - is the Lotus Intel Microsoft Expanded Memory Specification (already mentioned) which allowed bank switching of 16K pages in a 64K block of the upper memory.
    – Jasen
    Dec 24, 2022 at 3:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .