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 >
Text File  |  1993-06-12  |  3KB  |  58 lines

  1.               MACHINE AND PROGRAM MEMORY MAPS.
  2.               ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  3.  
  4. Each microcomputer has a Central Processor Unit (CPU) and Random Access
  5. Memory (RAM). The RAM is used to store the Operating System, including the
  6. input/output facilities, the user programs and data. Each of these items of
  7. information must be stored in a defined way in RAM. This is achieved by
  8. sending an address (16-bit or more) along a set of parallel connections,
  9. known as the Address bus, whilst the data is sent along the Data bus. Only
  10. that particular location on the memory 'chips' is alerted by the address
  11. signal to receive the data.
  12.  
  13. Whilst for most programming purposes the user is unaware of the memory
  14. locations being used by the system, it is sometimes desirable to know the
  15. memory allocation. This information is provided by the manufacturer of the
  16. hardware and the associated operating system in the form of a Memory Map.
  17. The map for an MS-DOS machine is shown on the sketch provided. Further
  18. details can be found in 'Advanced MSDOS Programming' by Ray Duncan,
  19. published by Microsoft.
  20.  
  21. Although the computer handles binary information, it is more convenient
  22. for the human to use the hexadecimal notation, in which 4 bits take the
  23. values from 0 to 9 and on via A,B...to F(=15 in decimal). Addresses are
  24. conveniently handled by using 4 hexadecimal digits, which range from 0000
  25. to FFFF. This last address FFFF is 65535 in decimal or 64K - 1 ( where
  26. 1K = 1024). With the earlier microcomputers which had 64K or less of
  27. memory, clearly four hexadecimal digits were sufficient to define all
  28. possible addresses. With the modern PC with some 640K, or more, of memory,
  29. an extended form of address is required. This is achieved by means of a
  30. pair of 4 hexadecimal digits, the first referred to as the Segment address
  31. and the second as the Offset address. For an 8088 processor, the segment
  32. address is shifted left by four bits (equivalent to multiplying by 16) and
  33. added to the offset to give a 20-bit address, which allows values up to
  34. 1024K or 1 Megabyte.
  35.  
  36. It is generally unwise to invade the area of memory occupied by the
  37. operating system, but the area for the user program may be usefully
  38. manipulated, especially for machine code instructions. For Turbo Pascal
  39. the Memory Map for the program area is shown on page 180 of the Reference
  40. Guide.
  41.  
  42. Since the offset value ranges over 64K, the size of each segment is 64K.
  43. The diagram shows there are Code segments, Data segments and Stack segments.
  44. When a .EXE file is loaded DOS creates a 256-byte area for the Program
  45. Segment Prefix. The segment address of PSP is stored in the predeclared
  46. word variable 'PrefixSeg'.
  47.  
  48. Each module (main program and each unit) has its own code segment. The main
  49. program occupies the first code segment; the code segments that follow it
  50. are occupied by the units (in reverse order from how they are listed in the
  51. USES clause), and the last code segment is occupied by the run-time library
  52. (the system unit). Although the size of a single code segment cannot exceed
  53. 64K, the total size of the code is limited only by the available memory.
  54.  
  55.  
  56. MEMMAP.TXT
  57. 18.4.90
  58.