6 ms·
> MS-DOS had an additional memory model known as Tiny, in which the code and data were all combined into a single 64KB segment. This was the memory model requir
by WalterBright 6y ago
> MS-DOS had an additional memory model known as Tiny, in which the code and data were all combined into a single 64KB segment. This was the memory model required by programs that ended with the .COM extension, and it existed for backward compatibility with CP/M.
The usual "tiny" memory model had all the segment registers ES DS SS CS set to the same value. It was loaded by simply copying the program file into memory and jumping to it.
At Zortech we realized that it wasn't necessary for all the segment registers to be the same - it's just that the program file needed to be less than 64Kb. This meant the code plus the statically initialized data had to be less than 64Kb. SS and DS, though, could be changed to the start of the initialized data, and had access to 64Kb beyond that, enabling significantly larger programs while still using near pointers.
- hazeii 6y agoDid that predate TurboC 1.00? I always used the tiny model in that (being an assembly programmer used to flat memory spaces it was the only way to go).
- WalterBright 6y agoProbably, as TurboC was a bit late to the game. But I'm not sure.
- russellbeattie 6y agoHeh, I was about to point to that same paragraph because of how disingenuous the term "backwards compatibility" is. I'm sure the author wasn't intentionally trying to revise history and probably didn't think about the term much, but to set the record straight, DOS wasn't a successor to CP/M, but a "quick and dirty" clone, then later an actual competitor. COM files were included in DOS to make sure programming for it was similar to programing for CP/M.[1] The story (which I'm sure many of you know) was that in 1979, Seattle Computer was selling an 8086 board, but CP/M didn't run on that CPU yet. So Tim Paterson solved the problem by whipping up QDOS to help sell more boards, cloning the architecture and APIs of CP/M directly from the manuals (without access to the actual source code).[2] The simplest sort of executable code is a COM file (doesn't get much simpler, actually), so if you're copying the way an OS works, that's pretty much where you'll start. It was about being a familiar paradigm for programmers, not some sort of cross-platform binary compatibility to an out of date OS as insinuated by the term "backwards compatible". 1. https://en.m.wikipedia.org/wiki/COM_file https://en.m.wikipedia.org/wiki/COM_file 2. http://bitsavers.org/pdf/imsai/dos-a/05_CPM_Interface_Guide_1976.pdf http://bitsavers.org/pdf/imsai/dos-a/05_CPM_Interface_Guide_...
- bawolff 6y agoIts totally reasonable to use back compat to mean "compatible with a legacy system made by someone else that our system replaced"
- toast0 6y agoSure, but it wasn't that, it was "compatable with a contemporary system that did not survive as long as our system"
- russellbeattie 6y agoAgain, I don't think the author thought about it much. But at the time, CP/M wasn't a legacy system, and COM files were integral to both systems. Imagine if the sentence was something like, "Windows 1.0 used a mouse pointer, which existed to be backwards compatible with the Mac."
- mark-r 6y agoI have a couple of friends who had that original Seattle Computer CPU board and the QDOS that came with it. I was very jealous. The sale to Microsoft came out of the clear blue.
- pvg 6y agoI'm sure the author wasn't intentionally trying to revise history and probably didn't think about the term much This sounds like you don’t think it’s disingenuous, just misinformed.
- drfuchs 6y agoAdditionally, you can segregate a large array (that never has a pointer taken to any of its elements) into a separate 64k area pointed to by ES. Since the only way to refer to an element is with ary[i], you always know when to use the ES segment override. Desperate circumstances lead to desperate measures.
- dfox 6y agoThis trick generally works, but is not guaranteed to work by DOS API. COM binary gets 4k paragraph allocation and nothing more, the fact that this allocation essentially always is at the bottom edge of free conventional memory is not even an implementation detail, it is consequence of everybody trying to be frugal with their memory allocations. ie. if there was TSR that allocates and then frees 64k region, you will get exactly this region and this trick will break and you will overwrite who knows what.
- WalterBright 6y agoAs I recall an operating system call was used to extend the memory, so it should never have broken unless a broken TSR was used. There weren't any issues with it that I know of, used it all the time for many years.
- hyperman1 6y agoTo be honest, I remember something different. Dos was originally a single process OS. So memory was allocated like a stack, at least for a .COM. Some detail:All memory above your starting address is yours. You call int 12 to find out how much base memory is installed, which in later computers was either 640K or 639K if the bios wanted a bit or storage. If you want to start another program, you first resize your part of the memory with INT 21 (ah=4D? Its too long ago, don't quote me on this) Later, there came TSRs, EMS/UMBs/high memory/... to muck this scheme up. A TSR was not allowed to allocate memory after it terminated, exactly because it runs code in another process while it should have been terminated. It had to always stay under all other programs, memory address wise. It was not allowed to do much, in fact, because DOS was not reentrant, and running int21h while running int21h had a good chance of making DOS overwrite its own variables.
- hyperman1 6y agoUPDATE: It was quite hard to find reference information about all this. I vaguely remember reading it in one of the Peter Norton books at the time, but I can't really find them. The most relevant thing I can still find on todays internet is this: https://www.pcjs.org/documents/books/mspl13/msdos/advdos/ https://www.pcjs.org/documents/books/mspl13/msdos/advdos/ chapter 3: ... the operating system simply makes the worst-case assumption and gives .COM programs everything that is available. If a .COM program wants to use the EXEC function to invoke another process, it must first shrink down its memory allocation ...
- weinzierl 6y ago>> MS-DOS had an additional memory model known as Tiny, [..] Which was by far my favourite memory model;-) Coming from the 8-bit world all this segmentation, memory model, ES: DS: SS: ES:, far pointer, near pointer stuff confused me to no end. Adding to that the memory access scheme of the graphics card (bitplanes!) made it even worse. No wonder I almost transitioned directly from 8-bit to 32-bit Linux. I still somehow think of the 16-bit (PC) era as kind of the dark ages - a lost time I don't miss much - sandwiched between the glory of 8-bit and 32-bit times.