X-Apparently-From: Message-ID: <000201c05f1d$039dfdf0$271e0404@dbcooper> From: "Patrick Moran" To: References: <20001202 DOT 051149 DOT -616891 DOT 0 DOT domanspc AT juno DOT com> Subject: Re: BASIC & EMS (was: Optimizing CONFIG.SYS...) Date: Tue, 5 Dec 2000 14:44:21 -0700 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0015_01C05EC9.DB4789F0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.3018.1300 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.3018.1300 Reply-To: opendos AT delorie DOT com This is a multi-part message in MIME format. ------=_NextPart_000_0015_01C05EC9.DB4789F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hello Robert, Well, there is someone around here that actually understands memory above 1MB. There are a couple of things though that are not exactly the real case. I am sure you know about them but did not include them for simplicity. However, for anyone to really understand what is going on, they will have to learn the complicated parts as well. I will addrss this below. ----- Original Message ----- From: "Robert W Moss" To: Sent: Saturday, December 02, 2000 6:11 AM Subject: Re: BASIC & EMS (was: Optimizing CONFIG.SYS...) > Blood Pressure Pat, Blood Pressure. Frustration is what it is, but that probably does cuase high blood pressure. > From my Novell Dos 7 unleashed Book, by Jonathan Kamin, Sams Publishing: That is a great book, I use it as my bible for DRDOS 7.0 and later. I uploaded the diskette that came with it to Club DR DOS so everyone can get it and see the examples formultiple boot configurations, which is far better than M$. It also contains some utilities. > Extended Memory: > > "If you have an 80286-or-higher CPU, you can have extended memory in > addition to conventional memory. Extended memory, from the point of view > of the CPU, > simply is additional memory with addresses that begin at the one megabyte > boundary. What makes this memory "extended" (insted of just memory) is > DOS. Other operating systems, which don't have DOS's limitations, simply > regard that memory as contiguous with conventional memory, and don't > require the electronic aacrobatics that DOS does to get at it. Yes this is true, however, the memory above 1MB is protected memory and does didtinguist it from conventional memory. 32 bit and some 16 bit OSes see this as flat memory. > Because you are using DOS, unless you manage this memory properly > there's not a whole lot you can do with it. You have to use an > extended-memory manager conforming to the Extended Memory Specification > (XMS) if you want to use this memory for anything other than a RAM disk > or some types of disk cache. (It follows that you need an XMS memory > Manager to access the High Memory Area, or HMA. Without a memory > manager, a program that attempts to use extended memory won't be aware of > other programs using it. As a result, the programs may stomp all over > each other's data, causing massive problems. Fortunately, Novell DOS 7 > can take care of that problem for you. That is exactly what happened in the early days of the 286 systems. People wrote programs and decided that all of that memory was theirs to use any way they wanted. They had no reguard for anybody else's possible use of that area. Of course! Their program was the only program you would ever use on a PC! egos, egos, egos. > The HMA: > > The high memory area, or HMA, is the first 64K just above the first > megabyte - that is, the first 64K of extended memory. What makes this > area special is that, due to a quirk in the way 80286-and -higher CPUs > address memory, DOS can see what's in it as though it were the first 64K > of conventional memory. Because of this quirk, various programs can use > the HMA to store chunks of code that otherwise would have to be in > conventional memory. DOS can store part of its code in this area (with > your assistance). Certain other programs also can make use of this area, > including MS Windows, DESQview, and the Framework programs. The catch is > that only one program can have access to the HMA at a time, even if it > uses only part of that area. This is where things need to be further explained. It is these quirks that allow for HMA. The part you omitted is the 16 bytes, yes a measly 16 bytes. Without this 16 byte quirk there would be no HMA. I am only going to discuss the 8086/88 and the 286 CPUs, the the same is true for later CPUs but they have other features. I am only going to talk about conventional memory and HMA and use the term REAL MODE for the pupose of the operation of the 80286 as an 8086. So we are basically talking about real mode, but the 8086 did not have real mode it was only one mode and that is the same as 286 and above real mode. The 8086 had 20 address lines: A0-A19. The 80286 had 24 address lines: A0-A23. Each line represents a bit in the CPU's program pointer register. However, the way this is accomplished in the 8086 is what gets complicated and where the quirks come out in relation to the 286. Each hexidecimal number represents 4 bits. You can have 16 and only 16 different combinations of 0's and 1's (binary) in 4 bits. Let's take a look: Binary Decimal Octal Hexadecimal combination 0000 0 0 0 1 0001 1 1 1 2 0010 2 2 2 3 0011 3 3 3 4 0100 4 4 4 5 0101 5 5 5 6 0110 6 6 6 7 0111 7 7 7 8 1000 8 10 8 9 1001 9 11 9 10 1010 10 12 A 11 1011 11 13 B 12 1100 12 14 C 13 1101 13 15 D 14 1110 14 16 E 15 1111 15 17 F 16 I showed octal so you could see that it has digits 0-7 for comaprision of how different base number systems work. Now if we add a second 4 bits or nibble and make a full byte of data each value contained in this additional 4 bits or nibble with have a multiplier value of 16, Let's look at a few examples: 0001 0000 is 16 i.e. 1 x 16 = 16 0010 0000 is 32 i.e 2 x 16 = 32 0011 0000 is 48 i.e. 3 x 16 = 48 1000 0000 is 128 i.e 8 x 16 = 128 1111 0000 is 240 i.e 15 x 16 = 240 Now if we put values into the lower 4 bits, we just add their value to the higher 4 bits. thus: 0001 0010 is 18 i.e. 1 x 16 + 2 0001 1000 is 24 i.e 1 x 16 + 8 1000 0110 is 134 i.e. 8 x 16 + 6 1111 1111 is 255 i.e. 15 x 16 + 15 or 240 + 15 = 255 This keeps working this way throughout the whole memory system. The next 4 bits will have a multiplies of 16 x 16 or 256. The next 4 bits (16 bits total) will have a multiplier of 16 x 16 x 16 or 4096. Thus 15 x 4096 = 61440 and 15 x 256 = 3840 and 15 x 16 = 240 and 15 x 1 + 15. 61440 + 3840 + 240 + 15 = 65535 and we have 65536 possible numbers from 0000-FFFF in hexadecimal which is the maximum amount you can have in a 16 bit register This is what most 8 bit computers could use for total memory that the CPU could address directly. Now if we take 1 and double it we have 2, if we double 2 we will have 4, if we double 4 we will have 8, if we double 8 we will have 16, if we double 16 we will have 32, if we double 32 we will have 64, if we double 64 we will have 128, if we double 128 we will have 256, if we double 256 we will have 512, if we double 512 we will have 1024. 1024 is what we call a K or kilobyte. Now if we divide 65536 by 1024 we will have exactly 64. Thus this is why the 8 bit computers had a maximum memory of 64K. They really had 65536 bytes of memory, but we use shorthand call kilobytes and call it 64K or 64 kilobytes of RAM. In binary each place higher to the left is two times higher than the value of the one ton the right of it. Binary mutlipies each digit by 2, decimal multiplies each digit by 10, thus we have 10, 100, 1000, 10,000, 100,000, 1,000,000, etc. In octal we multiply each digit by 8. In hexadecimal we multiply each digit by 16. Thus we have 16, 256, 4096, 65564. So an 8 bit processor can handle 0000-FFFF which is 65536 possible numbers or combinations. You need to understand this to understand the rest. Let's take a look at K or Kilobyte. We got to 1024 at the tenth place of binary. If we abreviate 1024 to 1K and double that 10 times we will have the following: 1, 2, 4, 8 ,16 , 32, 64, 128, 256, 512, 1024. 1024K, which we aberviate as 1 megabyte. 1 megabyte is actually 1024 x 1024. This same sequence of numbers will go on and on. In the IBM we generally count 64KBYTE pages of memory. 16 x 65536 = 1024 x 1024 or 1024K or 1 megabyte. There are 16 pages of 64k in an IBM PC 8086 computer. Remeber I said that 4 bits has 16 possible combinations. So when we add 4 bits to the 16 bits that we had with an 8 bit microprocessor, we will have 20 bits or 20 address lines that can address 1 megabyte of memory. The 8086 has 20 address lines and the program pointer has 20 bits. Now here comes the really confusing parts of how the 8086 addresses memory. The 8086 is basically 2 8 bit processor with 16 address lines each connected in parallel or side by side in the integrated circuit. (IC) This should give us 32 bits or 32 address lines. But this is not the way it was done with the two 16 bit program pointers. I hate having to use text to do this. HTML is so much better. Well I tried, and this piece of crap OE is just that a piece of crap and it fif what I expected. It looks great untin I save it. Then I looked at it again before I sebt it. I could not make heads or tails of the diagram I originally typed into the message. So I went to DOS and did it in a REAL text editor. I'll now try and import the text file. The last time I did that, the stupid piece of crap OE made FOUR copies of it! What a piece of crap, the only editor I have ever worked with that was a worse piece of crap was EDLIN! If it does not work, I'll just leave it the way it comes out so everyone can see what a piece of crap OE is and attach a small text file that works right. 15 Offset 0 |-------------------------------------| | Base Pointer | |------------------|------------------| | | | | | Appended | 15 | | 0<----zeros---->| |---------------------------------|------------------| | Segment Register | | 0 | 0 | 0 | 0 | |---------------------------------|------------------| 19 ^ | ^ 0 | | | | | | |----|-----|---------| | | | | | | | | | | |--|-----|-----| | | | Adder | | | |------|-------| | | | | | | | 19 | 0 |-------------------------------|--------------------| | A19-A0 Address bits | |----------------------------------------------------| 20 bit address The lower 4 bits of the Segment register is hardwaied to zeros inside the chip. the adder is where we need to look to see how the quirks occur. If you look at the above diagram, (probably won't come out worth a crap using text) you can see if we add the 4 bits from the Offset pointer to the segment register they will remain the same at the address bus, becuase when you add zero to something you add nothing, so the redult is unchanged. The same is true for the uppermost bits of the segment register, because there are no bits from the Offset pointer to add to them. So when someone programs they use this type of addressing: xxxx:xxxx this represents the 16 bits of each of the two registers and they are added together by the internal adder in the chip. You can see this adder between the two registers above. Now lets look at what xxxx:xxxx really means: xxxx0 the left most digits before the : which is the Segment register. + 0xxxx the right most digits after the : which is the offest pointer. The result is a number that will look like this on the address bus: xxxxx or five hexidecimal digits or 20 bits. It is this very arangement that causes the quirks. Let's look at a couple of examples before I show some quirks, 0000:FFFF will be the top of the first 64k in the computer: 00000 + 0FFFF ------------ 0FFFF We always use leading zeros in binary and hexadecimal to show the total number of places involved. This makes it easier to look at and follow. Another example: F000:FFFF this is the top of the first 1MB. Let's take a look: F0000 + 0FFFF ----------- FFFFF That is all 20 bits now have 1's which is the highest number that can be put into 20 bits. This is equal to 1 megabyte. These two examples look neat, but what if we make a couple of changes. Let's put a 1 somewhere in the segment address in the first example: 0100:FFFF let's see what happens now: 01000 + 0FFFF ----------- 10FFF We are now 4096 bytes higher in address than we were in the first example. Let's do the same thing in the second example, we will put a one in the same location of the segment register. F100:FFFF F1000 + 0FFFF ----------- 100FFF Wooopps, we now have 21 address lines, but we don't have them physically, so what happens to that leading one which represents a value of x1MB (times 1MB) DOS and the 8086 will not see this leading one so the leading one is basically dropped off and forgotten about and the result will be this: 100FFF minus 100000 = 00FFF Now lets figure out where we wound up in memory. 15 x 256 = 3840, 15 X 16 = 240, 1 x 15 = 15. 3840 + 240 + 15 = 4095 in decimal. Hmmmm we are back near the beginning of our memory. We just overwrote some critcal data in lower memory (lower memory is memory below 64K) our computer just crashed. Now we can see it is possible for the 8086 to exceed 1MB of memory, but we do not have the hardware to do it, we need another address line to do it, We don't have one. BUT we do have a 21st address line in the 80286, as it has 24 of them. The 21st address line is A20 in the 80286 CPU. Hmmmm A20, seems like I have heard of that before, oh yes, when I set up the CMOS it wants to know if I want the A20 set to slow or fast. What is the A20 anyway???? This is called the A20 gate. It is physically located in the keyboard ROM on the mother board. The 8086 computers did not have this gate because they did not have a 21st address line. The 80286 and later CPUs do have this address line. If this gate is turned off, the 80286 will act just like an 8086 and wrap around to low memory. However if we turn the gate on, we will now have use of the 21st address line. This is where some of the quirks start. We already crashed the 8086 system and if we did not have the A20 gate turned on we also crashed the 80286 system. If we did have it turned on, we are looking at memory above 1MB. Now before we go any further let's take a look at something first. The highest address we can put into the segment register is FFFF, but this is really FFFF0. FFFF0 is just 16 bytes below 1MB. This is an extremely important quirk in a 286 or higher system. We know two things or at least we should know them. For DOS to access anything above 1MB it has to start in conventional memory. To put anything usefull into HMA we have to have contiguous starting in conventional memory. We do have both, we have 16 bytes of conventional memory and it keeps going right going above 1MB. So the only things left to do is to turn on the A20 gate and have some memory manager that will allow DOS to use the FFFF:0000 through FFFF:FFFF range of memory. FFFF0 FFFF0 + 00000 + 0FFFF ----------------------------- FFFF0 - 10FFEF This is a 64K range from 16 bytes below 1MB to 16 bytes below 1MB + 64K. > Expanded Memory: > > Expanded memory is no different in kind from other types of memory > already discussed, but what you can do with it is. Expanded memory is > memory that is managed according to the Lotus-Intel-Microsoft Expanded > Memory Specification (called LIM-EMS for short). The current version is > generally referred to as LIM-EMS 4.0, or just LIM 4.0 or EMS 4.0. > > If you have an 80386-or-higher CPU, you can use a memory manager to > emulate expanded memory using the extended memory that's already > installed in your system. If you have an 8088 or 80286, you can add an > expanded-memory board, and gain access to that expanded memory by using > the device driver that came with the board. Unless you have an > 80386-or-higher CPU or a special memory-management chip set (such as > NeAT, SCAT, or LeAP), you must use an expanded memory board to get There was also a VLSI chipset that would also do this. There were also some plug in 80286 modules that plugged into the 8086 CPU socket. A similar thing was done with 286's with a 386 plugin card, like the All Charge using an SX chip. > expanded memory. You can't get it from extended memory. This is because > managing expanded memory requires some additional circuitry not found on > the 80286. This circuitry, which is built into the 80386 and into the > memory-management chip sets, is not otherwise available on XTs or ATs. > > Expanded memory, like extended memory managed with an XMS memory driver, > is memory that can be made accessible to DOS. However, the method for > doing so is different from the one used for XMS memory. Ideally, you set > aside a 64K block of addresses in upper memory to be used as a page > frame. Y ou might think of this as a sort of viewing screen that can be > made to focus on anything that's in expanded memory. It looks at > expanded memory in upmto four 16K chunks, thereby making up to 64K at a > time of whatever's in expanded memory available to DOS. (If you don't > have a 64K block of upper -memory addresses, you can sometimes use four > 16K pages instead of a page frame." You are supposed to be able to do this, but I have yet to see an EMM386, QEMM, Headroom or others do this. Maybe they can, I just have never seen it done and have not seen documentation on how to do it with any of them. > Protected Mode: > > "The 80286 introduced a new operating mode called protected mode. In > protected mode , the 80286 could address up to 16M of memory. However, > most PC users used AT-class computers in reak mode, in which the > processor essentially emulated an 8088. To take advantage of the > additional (extended) memory that the 80286 couls address, DOS extenders > were developed. Just for clairity, that is 16 bit protected mode for the 80286. > These allowed programs to access extended memory "behind the back" of > DOS. Two standards developed for accessing protected mode: > > * VCPI (the Virtual Control Program Interface) > * DPMI (the DOS Protected Mode Interface) > > Because the latter had the marketing clout of MS behind it , it has > become the more common standard. It is used by MS Windows, among other > programs. Yes just like everything else Gates does he made it incompatible with Quaterdeck's VCPI which was developed first. BTW If you look at memory with a good memory program, it will show that DRDOS also uses VCPI. I have not checked to see if it is there without DPMI turned on, but as I understand it Desqview will not work with it. But that may just have been with the Novell DOS 7.0. At least that is what Quaterdeck's tips claim. I did notice that a lot of their docs were referring to DRDOS 6.0 and just seemed to include Novell DOS with it, because QD said that DRDOS and NOVELL DOS could not use HMA as well as QEMM could. That was not true for Novell DOS 7.0, because I could get more memory and have slightly larger DV windows by letting Novell DOS load into HMA. So they may have just clumped it all together without really checking and separating the two versions of DR/Novell DOS. In actuallity, QEMM did use more HMA that did DOS, but it did not effeciently put the DOS stuff into UMB and the result was that DRDOS did a better job if it was loaded into HMA. I never bothered to track down the exact reason why, but QD was wrong about getting more conventional memory and larger windows in DV by letting QEMM use HMA. > Novell DOS 7 includes a DPMI interface (technically, a DPMI host) to > manage the use of extended memory by programs that use it . On a PC with > an 80386-or-higher CPU, the DPMI host gives DPMI client programs access > to extended memory, and switches between real and protected modes as > needed. Programs that require DPMI services generly comprise > programmers' tools, but Borlands's Paradox database program is one > application that also makes use of these services. Thus, switching is much faster than shoving 500k+ through a 64K window. > Novell DOS 7 also invludes a new feature called DOS Protected Mode > Services (DPMS). This allows TSR programs - if they're designed to use > these services = to operate almost entirely outside of conventional > memory. They merely have to leave a few bytes of code in upper memory to > tell DOS where to find the rest of the program. This frees additi;onal > upper memory for programs that can't use the new seravices. The Stacker > compressed drive management program, NWCache, DELWATCH, and the NetWare > Desktop Server all make use of DPMS, and can therefore run in protected > mode. This means not only that they run outside of conventional memory, > but that they run while you're using your foreground program. Yes and Task manager is also loaded up there except for a few K that is left in conventional. > Virtual 8086 Mode: > > The 80386 -or-higher CPUs introduced yet another operating mode: virtual > 8086 mode. In this mode, the processor is, in effect, divided into a > series of seperate 8086-based computers, each operating in real mode, > each with its own screen, keyboard, and segment of memory. Yes and this is one of the things someone said I was wrong about. Each one is basically a seperate 8086 computer and they all run simualtaneously. i.e multitask and multiuser. Each user can have his own computer running on the same physical computer. Each can also passwoord protect his/her computer so no one else can access it, or shut their process down. > How does > this work? Well, noter the word virtual. You have lnly one program > active on your screen at a time , and the keyboard is attached to that > program. The other 8086 computers have virtual screens and keyboards, > and run in the background while you're working in the foreground program. > This is what's known as multitasking, another feature built into Novell > DOS 7. To use this feature , you need a control program to manage the > multitasking. MS Windows in 80386 Enhanced Mode is one such progaram: > DESQview is another. And Novell DOS 7 includes a third: the Task > Manager. > > What does this have t;o do with memory? Well, you can multitask programs > only as long as they are in memory... somewhere. The number of programs > you can multitask depends on how much memory you have , how large your > programs are, and how you allocate the memory for multitasking. Among > other things, you must load the DPMI host in order to use the Task > Manager for multitasking, and you must leave certain areas of memory free > for it to function properly. " It also is not resticted to 32MB like expanded memory is. As for area of memory that must be free, I am not aware of any. I have had all of the UMB loaded and a bunch of conventional when I had PNW server loaded and running Task manager. There could not have been much free memory any place for it to use. I had to play with the order in which the various parts of PNW wee loaded to get the bulk of it in UMB. Not only PNW, but I had to play with not loading some drivers and/or TSRs high to get the most use of UMB. I had UMB well loaded with a few small things still in conventional memory. As I recall I was down to someting 530K to 560K with all of this loaded and running Task Manager with each window. Also each virtual computer can also share EMS/XMS memory. They can all access that memory and if properly managed, and not interfere with another processes also using extended and/or expanded memory. > Hope this does not confuse to many people lurking out there in the > shadows while this great big hairy conflict rushes on & on & on....... It will because it is so hard for most people to understand without reading a good book about it several times. Even then, there are things that still are not clear. Even after you understand it, you sometimes still forget little facts here and there unless you work with it almost everyday. The book "DOS beyond 640K" is a very good book that explains most of it. I need to get a newer edition, to check out the newer stuff concerning the pentiums. I understnd that they have a 1MB paging capability as well as the 4K. I got into a discussion about paging in a Linux echo and was unaware that the pentiums could do that. I am not sure why anyone would want to use it, but it might be useful for large systems with a lot of users. Possibly someone like cdrom.com could make use of it. > On Fri, 1 Dec 2000 03:57:12 -0700 "Patrick Moran" > writes: > > Okay, what the hello is XMS meory? I asked ,that to see what the answer would be, because the messages I got seemed to have things all mixed up. But at least one other person on this list understands it as I do. It will be interesting to see the responces to your message. I was just about ready to give up on the subject. Pat P.S. Yep it's a piece of crap. At least it didn't put it in four times this times, BUT I haven't sent it yet!!!!! piece of crap. ------=_NextPart_000_0015_01C05EC9.DB4789F0 Content-Type: text/plain; name="8086.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="8086.txt" 15 Offset 0 |-------------------------------------| | Base Pointer | |------------------|------------------| | | | | | Appended | 15 | | 0<----zeros---->| |---------------------------------|------------------| | Segment Register | | 0 | 0 | 0 | 0 | |---------------------------------|------------------| 19 ^ | ^ 0 | | | | | | |----|-----|---------| | | | | | | | | | | |--|-----|-----| | | | Adder | | | |------|-------| | | | | | | | 19 | 0 |-------------------------------|--------------------| | A19-A0 Address bits | |----------------------------------------------------| 20 bit address ------=_NextPart_000_0015_01C05EC9.DB4789F0-- _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com