About ms-dos 16-bit turbo c++,, how to extends 64KB limits on 16-bit programming?
I mean, Without swapping on harddrive.
- JonathanLv 78 years agoFavorite Answer
16 bit coding under DOS basically breaks down into these categories:
1. .COM programs, where the code itself (without hard drive swapping) plus all constants and initialized data must fit inside of 64k. This limit is because the .COM file format is a pure image and while it is true that DOS allocations ALL of the available RAM for the program it can only load up one 64k segment during program-load time. It's possible for the .COM program to access more memory than 64k, but it will all be uninitialized memory. In C/C++, these programs are called "tiny model" programs. The C/C++ compiler imposes MORE limitations, by requiring all code and constants and data, initialized or uninitialized, plus all heap,and stack space to fit within 64k. This is NOT a DOS limitation, it's a compiler limitation. Technically, if you write in assembler, you can easily exceed this with .COM programs.
2. .EXE programs, which were only supported in DOS 2.0 and later. These files include patching information and other structures which allow DOS to properly allocate ONLY the needed ram for the program and to load it into memory when it is larger than 64k in code size (or data size.) These programs can have much more code than 64k, much more data as well, and so on. These programs are called "small, medium, compact, large, and huge." The C/C++ compiler will support these. The features are:
a. small model = one 64k data segment + one 64k code segment
b. medium model = one 64k data segment + more than 64k code
c. compact model = more than 64k data + one 64k code segment
d. large model = more than 64k data + more than 64k code
e. huge model = large model + individual arrays/structs bigger than 64k
In addition, DOS later came to support a number of other standards to allow even greater access to memory. These included, VCPI, EMS, XMS, and DPMI, to name just a few. DOS also included a special mechanism which allowed calls into Windows, and that provided an entirely new method for providing additional support, including the ability to create and manage Windowed programs from DOS or to access uniquely Windows function calls.
There were also a semi-special class of programs called TSRs (terminate and stay resident) that usually provided additional services.
The way these things are done is complex. If you need specific details, I can provide very exacting details since this is an area I worked on, extensively. But I'd need to know more from you, first.
- ?Lv 45 years ago
Free, not sure. Minimal cost, go to book store, find a c-compiler text book that includes the compiler; I prefer c++ by Microsoft -- an older version is better b/c it's not so bloated & confusing documentation. The 1st lesson will walk you through creating a dos program. 16-bits is no big deal; that's the norm.