home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PASTUT34
/
MEMMAP.TXT
< prev
next >
Wrap
Text File
|
1993-06-12
|
3KB
|
58 lines
MACHINE AND PROGRAM MEMORY MAPS.
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Each microcomputer has a Central Processor Unit (CPU) and Random Access
Memory (RAM). The RAM is used to store the Operating System, including the
input/output facilities, the user programs and data. Each of these items of
information must be stored in a defined way in RAM. This is achieved by
sending an address (16-bit or more) along a set of parallel connections,
known as the Address bus, whilst the data is sent along the Data bus. Only
that particular location on the memory 'chips' is alerted by the address
signal to receive the data.
Whilst for most programming purposes the user is unaware of the memory
locations being used by the system, it is sometimes desirable to know the
memory allocation. This information is provided by the manufacturer of the
hardware and the associated operating system in the form of a Memory Map.
The map for an MS-DOS machine is shown on the sketch provided. Further
details can be found in 'Advanced MSDOS Programming' by Ray Duncan,
published by Microsoft.
Although the computer handles binary information, it is more convenient
for the human to use the hexadecimal notation, in which 4 bits take the
values from 0 to 9 and on via A,B...to F(=15 in decimal). Addresses are
conveniently handled by using 4 hexadecimal digits, which range from 0000
to FFFF. This last address FFFF is 65535 in decimal or 64K - 1 ( where
1K = 1024). With the earlier microcomputers which had 64K or less of
memory, clearly four hexadecimal digits were sufficient to define all
possible addresses. With the modern PC with some 640K, or more, of memory,
an extended form of address is required. This is achieved by means of a
pair of 4 hexadecimal digits, the first referred to as the Segment address
and the second as the Offset address. For an 8088 processor, the segment
address is shifted left by four bits (equivalent to multiplying by 16) and
added to the offset to give a 20-bit address, which allows values up to
1024K or 1 Megabyte.
It is generally unwise to invade the area of memory occupied by the
operating system, but the area for the user program may be usefully
manipulated, especially for machine code instructions. For Turbo Pascal
the Memory Map for the program area is shown on page 180 of the Reference
Guide.
Since the offset value ranges over 64K, the size of each segment is 64K.
The diagram shows there are Code segments, Data segments and Stack segments.
When a .EXE file is loaded DOS creates a 256-byte area for the Program
Segment Prefix. The segment address of PSP is stored in the predeclared
word variable 'PrefixSeg'.
Each module (main program and each unit) has its own code segment. The main
program occupies the first code segment; the code segments that follow it
are occupied by the units (in reverse order from how they are listed in the
USES clause), and the last code segment is occupied by the run-time library
(the system unit). Although the size of a single code segment cannot exceed
64K, the total size of the code is limited only by the available memory.
MEMMAP.TXT
18.4.90