15

Can I have more than 640 KB conventional RAM under some DOS?

I'm looking at an 80186 PC that has RAM at address A0000. Video RAM starts at B0000 as expected for a Hercules; A0000 is just more main memory. There's no Extended BIOS Data Area near 9F000 either; the EBDA is located somewhere above F4000.

Can I just change the early boot sequence to patch the BDA to say memsize = 704 instead of 640 before DOS starts, or is that nonsensical despite the memory literally being there?

Actually trying it on FreeDOS yielded:

A:\>mem /c

Modules using memory below 1 MB:

  Name            Total          Conventional       Upper Memory
  --------  ----------------   ----------------   ----------------
  SYSTEM      66,640   (65K)     66,640   (65K)          0    (0K)
  COMMAND     80,912   (79K)     80,912   (79K)          0    (0K)
  Free       573,104  (560K)    573,104  (560K)          0    (0K)

Memory Type         Total      Used       Free
----------------  --------   --------   --------
Conventional          704K       144K       560K
Upper                   0K         0K         0K
Reserved              320K       320K         0K
Extended (XMS)         64K        64K         0K
----------------  --------   --------   --------
Total memory        1,088K       528K       560K

Total under 1 MB      704K       144K       560K

Largest executable program size       560K (572,976 bytes)

What's with the XMS memory? That's just high memory (100000-10FFEF).

I'm thinking there's some slight problem with this. The system freaks out when I load the high memory driver.

13
  • 2
    Related: How to use all memory on an IBM PC with 8086, Who set the 640K limit? — DOS computers with more than 640KiB of conventional memory were a thing in the early days. Commented Mar 5 at 9:00
  • "I'm thinking there's some slight problem with this. The system freaks out when I load the high memory driver." Do you mean Himem(X)? XMS drivers cannot work on an 186 CPU.
    – ecm
    Commented Mar 5 at 10:14
  • 2
    Beware of software hardcoding segment 0xA000 to access video memory. It might not only fail to display anything, but also corrupt other programs’ memory. Commented Mar 5 at 10:55
  • 2
    anecdotally I can rember having 800+k on my 80186 back then in DOS 2.11
    – PlasmaHH
    Commented Mar 5 at 12:33
  • 1
    Using mem /d might reveal more about how DOS allocates memory. Commented Mar 5 at 17:28

4 Answers 4

12

Yes, you can. Normally if there is RAM at A0000 there should be no issues. I used to do it all the time with my PC-Speed emulator on the Atari ST. As all the UMA holes were filled with the RAM of the host Atari the longest contiguous RAM it detected was 736 KiB when setting the graphics to CGA (B8000 start of graphics) or 704 KiB in monochrome emulation (B0000 start of graphics). Fortunately I did not need to persuade the BIOS to count the memory beyond 640KiB, that was automatic the case in the emulation drivers.

As for HMA, the 80186 cannot address it as it only has 20 address pins. It was only from 80286 on that it was possible to address that area as it requires the 21st pin to be high. The infamous GATE-A20 was added to AT to be able to force A20 (21st address pin) to 0 to simulate the wrap-around behaviour you would get on a PC with 8086/80186 when addressing FFFF:0010 (on 8086 it's == to 0x00000, on 80286 it's 0x100000 unless gate-A20 is active). Old versions of MS-DOS actively used this wrap-around behaviour of the end segments - that's why IBM came up with the gate-A20 circuit.

13

Yes, you can have more than 640KB of conventional memory in some DOS.

FreeDos already seems to work for you, as you have 704KB of conventional memory according to MEM. And apparently an IBM 5150 with DOS 2.00 can be made to support 736KB.

Machines with earlier than 286 CPU and actual system RAM at A000H-AFFFH were not that common. They might have come with customized DOS if standard MS-DOS or PC-DOS did not support it, or a driver to utilize it.

There were TSRs such as 704k.com which could expand the DOS memory allocation structure to 704k if it did not otherwise detect or use the memory correctly.

There is no way to load HIMEM.SYS or EMM386.EXE on a 80186 CPU because it's technically a 8086 with some added instructions.

So as the CPU memory space it can access is limited to 1MB, it cannot have the 65520 bytes of HMA, so FreeDos and the MEM program it comes with simply shows it as unavailable, just like the reserved area is unavailable.

Technically everything beyond 1MB could be called extended memory which can only be accessed by a 286 CPU or above. It just happens that in DOS the 65520-byte part of extended memory which can be accessed by DOS itself or 16-bit real mode programs got the name HMA. But you need the HIMEM.SYS driver to enable the hardware (GATE A20) access to HMA before you can use it in DOS.

8

TL;DR: 186 machines are different

DOS is not restricted to 640 KiB, but may use the full 1 MiB of real mode address space as RAM.

Also, 80186 based PCs (*1)have usually only limited IBM-PC compatibility (*2). While all plain DOS software will run fine, any direct hardware access may or may not work. Most prominent is being direct video writes (*3). Additionally many software checking to distinguish 8088 based (XT) systems from 80286 based (AT) machines mistake the 80186 often as 286 and conclude running on an AT type hardware, expecting feature (like A20/HMA) which are not present on a 186.

Last but not least, writing to (imagined) HMA on any real mode x86 (*4) will most likely crash the system in a reliable manner.


The Questions

Can I have more than 640k conventional RAM under some DOS?

Not just 'some' DOS, but every DOS. DOS can use all physical memory there is on a real mode x86. It's the hardware that defines how much of the possible 1024 KiB are available as conventional memory. See as well Stephen's fine answer about the topic.

I'm looking at this 80186 PC that has RAM at address A0000. Video RAM starts at B0000 as expected for a Hercules; A0000 is just more main memory.

It was quite common for (early) non-IBM x86 PCs to offer more RAM. For example the Tandy 2000 could give up to 768 KiB of DOS-RAM (*5) while the SIEMENS PC-D offered up to 960 or 992 KiB, depending on BIOS version (*6). Both being 80186, but the same is true for 8086 machines. A good example being the Seattle Computer Product's S100 based 8086 CPU board - the very computer MS-DOS was developed on.

There's no bios extended data near 9F000 either; the bios extended data area is located somewhere above F4000.

Which is perfectly normal, as EBDA can resist anywhere in memory. 9F000h is only the default location on IBM PS/2 machines. The segment of EBDA is held in a word BDA at 40:0E

Can I just change the early boot sequence to patch the bios data area to say memsize = 704 instead of 640 before DOS starts, or is that nonsensical despite the memory literally being there.

DOS will use whatever amount the provider specific part of BIOS reports as paragraphs(*7) If no amount provided, MS-DOS will scan memory starting at 32 KiB (08000h) in paragraph sized steps. See for reference DOS 2's SYSINIT.ASM, documented in SYSINIT.TXT.

  • Systems with writable memory mapped I/O, like video cards, will always provide that value.
  • PC-DOS uses the BDA value also reported by INT 12h

Actually trying it on FreeDOS [...]

Well, the FreeDOS kernel is, or better can be compiled for 80186 use and should run file even on less than 100% IBM compatible machines. The same is not true for drivers and applications. You need to only load drivers that work with a real mode PC, usually those that work fine on an 8088.

What's with the XMS memory? That's just high memory (100000-10FFEF).

Not really, as the 80186 can not access memory above 1 MiB. Thus there can be no XMS. That's a feature only 286 and later have. This looks rather like a DOS configured to assume this being a 286 (*8).

I'm thinking there's some slight problem with this. The system freaks out when I load the high memory driver.

Well, most likely you're using drivers not made for that computer and/or CPU, drivers expecting a direct IBM-PC clone and a 286 or later, not recognizing being run on a 186.

An 80186 does not and can not have a HMA.

Accessing HMA works only on a 286 and later, due them providing more address lines than a 8086 (*9). The 80186 does not have those additional address lines. Using an address of 0FFFFh:10h, which on a 286 would result in absolute address 100000, the first usable HMA byte, will on a 186 warp and produce address 00000h.

As a result any write to HMA will either destroy the interrupt vectors, BDA, DOS data or DOS itself. Installing an HMA driver will of course put up some data structures, right there, reliably crashing the system with the next occurring interrupt.


*1 - Before the 286 was settled as standard for better-than-XT PCs, several companies used the 80186 with it's improved performance and high integration, much like Intel intended. Wikipedia has a shortlist of the most common 80186 based PC.

*2 - Plain 186 PC need in addition to be distinguished from such featuring IBM-PC like external components (VGA, interfaces) as well as similar SoC, like the NEC V40, based on a core with an 186 compatible instruction set, but IBM-PC like peripherals - they may add another level of confusion when identified as 186 instead of their exact variant

*3 - A bad habit forced due DOS prior to DOS2.0 and ANSI.SYS not really offering a device independent video interface, so BIOS access had to be used. Except, the original PC being already a rather slow machine and video output using BIOS was not exactly great.

*4 - That is any 8086, 8088, 80186, 80188, V20, V30 or similar

*5 - The Tandy 2000 is often seen providing 704 KiB using a driver that reserves the area at 0B0000h for an MDA emulation to enable higher IBM-PC compatbility.

*6 - The PC-D could have physical 1024 KiB of RAM, but top 64 were reserved by BIOS for its own code as well as an optional (never produced) colour graphics card. Later BIOS versions freed those 32 KiB,

*7 - This may differ from the amount provided by ROM-BIOS via INT 12h.

*8 - Some simple CPU test routines identify 186 as 286. Mostly done by programmers not aware of other than close IBM clones.

*9 - And the fine A20 gate disabled. See the OSDev-Wiki for programming details.

8
  • Since I know some assembly I should be able to check whether there is high memory with a few CPU instructions, right? gist.github.com/joshudson/d2708ea169a8cb853c391cb292556ae3 Outputs CPU is 8086/80186 A20 gate is definitely off
    – Joshua
    Commented Mar 5 at 14:43
  • A 186 does not have an A20 line, thus there can never be any HMA - and no A20 gate either. Also, checking the flag register may fail on some x86 compatible processors. The correct way to check for CPUs is a bit more complex than that.
    – Raffzahn
    Commented Mar 5 at 14:51
  • 1
    @Joshua see e.g. reverseengineering.stackexchange.com/q/19394/11644 — 8086/80186 can be distinguished by checking large shifts, 80286 can be identified by checking flags. Commented Mar 5 at 15:29
  • 1
    @Joshua No, the other way around, some non-286 may be identified as 286. IIRC this includes the NEC version with on board EMS, where 2^15 marks emulation on/off. The routine of Stephens link (same as my second), does in addition doublecheck if it's really a 286 by looking at protected mode flags, which makes a difference to just looking at top flag.
    – Raffzahn
    Commented Mar 5 at 16:06
  • 1
    BIOS could have been made vastly more efficient if it had included functions to output up to a line at a time specifying one byte per character plus a single attribute, or character-output pairs. Such a function could easily output one line per frame without "snow" even on stock PC with CGA; indeed, even two lines per frame would be easy, but 25 frames to draw a full screen would be good enough for many purposes.
    – supercat
    Commented Mar 5 at 17:53
3

You're looking at an MS-DOS computer, not a PC-DOS computer.

In the general case, at least up until a few years after the PC was launched in '81, MS-DOS computers did not, in the general case, have a BIOS or memory-mapped video and so could have up to 1Mb RAM. They also usually shipped with a tailored version of MS-DOS, which included things like a manufacturer-customised variant of fdisk which- in at least some cases- didn't adhere to the "one primary partition with everything else in an extended partition" convention.

You emphatically cannot rely on anything shipped with PC-DOS running on it, and that applies- in particular- to anything that assumed a particular layout of memory above segment a000h or assumed an AT-compatible A20 gate switched by the keyboard controller (which in your case you probably have not got).

That applies to anything based on an 80186 (e.g. from Research Machines or IIRC Apricot) and also- in spades- to anything based on "mostly-compatible but enhanced" chips from NEC.

6
  • mov ax, 4305h; int 2fh results in bl=1 ; however mov ax, 4306h; int 2fh results in bl=94h (A20 still enabled). Thus "(which in your case you probably have not got)." is true but not the way you expect.
    – Joshua
    Commented Mar 5 at 19:05
  • @Joshua You said you have a 186 CPU, so your system has no concept of Gate A20 as it does not even have that many address lines, and you said you were not able to load HIMEM or other XMS memory driver, so you can't call XMS driver functions, or expect them to do or return anything sensible even if you try to call them. You should trace the call who returns with BL=94h, but it does not matter because there can be no HMA and thus A20 does not matter. Generally if HMA is owned by DOS it is highly likely it wants to keep it enabled at all timed so it might as well say it can't be disabled anyway.
    – Justme
    Commented Mar 5 at 21:20
  • @Justme: You can argue until your blue in the face or you can read the first comment on Raffzahn's answer where I run a direct test and find that 0:0 and FFFF:10 have different contents. The processor can't be a 286 because the top 4 bits of flags are frozen at 1 but can access high memory.
    – Joshua
    Commented Mar 5 at 22:29
  • @Joshua Which exact PC it is then? 186 PCs were not 100% IBM compatible anyway. If there is no wraparound then it means the CPU has larger address bus than a 80186 and is not limited to 1024KB of memory. Whether or not there is any memory or not beyond 1024KB is another thing.
    – Justme
    Commented Mar 6 at 6:09
  • @Joshua I was there, and I remember machines like the Tava Flyer. I stick to my position. Commented Mar 6 at 7:44

You must log in to answer this question.

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