Expert C Programming

(Jeff_L) #1

system use:


segment reserved for
F0000 to FFFFF 64 Kb for permanent ROM area BIOS, diagnostics, etc.
D0000 to EFFFF 128 Kb for cartridge ROM area
C0000 to CFFFF 64 Kb for BIOS extensions (XT hard disk)
B0000 to BFFFF 64 Kb for conventional memory display
A0000 to AFFFF

leaving

64 Kb for display memory extension

00000 to 9FFFF^ 640 Kb for application program use.


A billion and a trillion have different meanings in the U.S. and England. In the U.S. they are a
thousand million (10^9 ) and a million million (10^12 ), respectively. In England they are bigger, a million
million (10^12 ) and a million million million (1018)), respectively. We prefer the American usage
because the magnitude increments are consistent from thousand (10^3 ) to million (10^6 ) to billion (10^9 )
to trillion (10^12 ). A billionaire in England is much richer than a billionaire in the U.S.—until the
exchange rate sinks to £1,000 per $1, that is.


There's a 640 Kb limit in MS-DOS that arises from the 1 Mbyte total address space of the 8086 chip.
MS-DOS reserves six entire segments for its own use. This only leaves the 10 64-Kbyte segments
starting at address 0 available to applications (and the lowest addresses in 0 block are also reserved for
system use as buffers and MS-DOS working store). As Bill Gates said in 1981, "640 K ought to be
enough for anybody." When the PC first came out, 640Kb seemed like a tremendous amount of
memory. In fact, the first PC came configured with only 16K of RAM as standard.


Handy Heuristic


PC Memory Models


Microsoft C recognizes these memory models:


small All pointers are 16 bits, limiting code and data to a single segment each,
and the overall program size to 128 K.
large All pointers are 32 bits. The program can contain many 64-K segments.
medium Function pointers are 32 bits, so there can be many code segments. Data
pointers are 16 bits, so there can only be one 64-K data segment.
compact The other way around from medium: function pointers are 16 bits, so the
code must be less than 64K. Data pointers are 32 bits so the data can
occupy many segments. Stack data is still limited to a single 64-K
segment, though.
Free download pdf