This Unit

Resources

Lecture Material

 

   Lecture Notes

Memory Map 

Read on for an overview of memory maps and memory organisation in PC systems.

Introduction

Memory Addressing

Memory Organisation

Segment 0 - Interrupt Vector Table

Segment 1 to 9 - Working Ram

Segment 10 & 11 - Video Memory

Segment 12 & 13 - ROM BIOS Extensions

Segment 14 & 15 - ROM BIOS

Past the One Megabyte Mark?

Something to Finish With!

 


Introduction

The memory map is one of the most important aspects of a system.  It shows all the memory possible for the system to address.  An old XT compatible system has one megabyte of memory workspace that is addressable by the processor.  An AT system has 16 megabytes of memory workspace because it uses what is called extended memory.  Later ATX systems have far greater amounts of memory workspace.


Memory Addressing

The PC uses a circuit design called a bus to allow communication between different parts of the computer. You can think of the bus as a sort of a "highway" with the CPU, the memory chips, the other support chips, the cards in the expansion slots connected to this highway.

There is the control bus, the address bus and the data bus.  The CPU uses the address bus to transmit an address to the memory chips.  The width of the bus determines the range of possible addresses that can be sent.  

Say we have a 16-bit address bus.  Then 216 number combinations are possible, which means that 216 different addresses can be sent on the bus.  Now, 216 = 65536, so this means that 65536 locations in RAM can be addressed.  The first byte would have the address 0, the second would have the address 1, the third would have address 2, and so on.  The last byte would have the address 65535 (because the address range is 0 to 65535.) 

Therefore, if each RAM location can hold a byte's worth of data, this means we can access 65536 bytes of memory, or 64 KB.  The addresses created using this straightforward scheme would be called physical addresses.

 

215 214 213 212 211 210 29 28 27 26 25 24 23 22 21 2
32768 16384 8192 4096 2048 1024 512 256 128 64 32 16 8 4 2 1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

1

= 6553510

 Using hexadecimal notation this is:-

 

163 162 161 16
4096 256 16 1

F

F

F

F

= 6553510

   

~Now try the activity~

Activity A

  1. If we had an 8-bit bus, 

    1. How many memory locations could we physically address?

    2. What is the memory address range?

  2. For our 8-bit bus, write down the highest memory address in hex.

  3. Convert 0xFFF to decimal

  4. Convert 0xFFFFF to decimal

    

 

Now, let's think about the problem of having more RAM than 64KB.  How is this extra RAM to be addressed?   

As an example, the Intel 8088 microprocessor used in the original IBM PC requires a more complex system.  Why?  Well, the 8088 is a 16-bit processor, which can handle 16-bit (word-sized) numbers and so can address 64K of RAM.   However Intel, when designing this chip, decided that the maximum amount of memory that could be addressed with the 8088 was to be one megabyte

So again, the question is how is the extra RAM to be addressed?

Now, one megabyte is equivalent to 220 (1048576) bytes, but we have only got 16 bit values to play with not 20.  So somehow we have to construct 20-bit addresses out of 16-bit values.

What Intel came up with was a scheme called segmented addressing.  A segmented address consists of two parts, the segment and the offset

Since we are only able to address 65536 RAM locations (64K) let's choose to have 65536 segments.  Then, if we make each segment 16 bytes long, this makes one megabyte since 16 * 64K = 1M.  Have a look at the diagram below.

We have segments 16 bytes apart and with our 16-bit address bus, each segment can be comfortably addressed, from 0 to 65535.  The first segment (segment 1) starts at physical address of 0, the second segment (segment 2) actually starts at physical address 16, the third segment (segment 3) actually starts at physical address 32 and so on.  The last segment (segment 65535) actually starts at physical address 1048560.  

However, although we can address each segment, at the moment we have no way of addressing the bytes inside each segment.  These segment only lets us access every sixteenth byte. 

To access the bytes inside a segment, an offset is used.  Using 16-bit numbers again, an offset can actually access up to 65535 bytes after the start of the segment.  We only actually need to access 16 bytes since this is the length of each segment lengths but that's fine.

Now, the segment and offset are usually written as four-digit hexadecimal numbers, with a colon between them.  So, for the segment 210 (2h) and the offset 510(5h), we would write: 0002:0005.  You should remember that hex numbers are used in this format and not decimals or binary.

Now, to calculate a physical address from segments and offsets, first work out the actual physical address of the segment by multiplying the segment address by 16 and then add the offset.

Say for example, we have the segment 210 and the offset 510, or 0002:0005.  The physical address is 2 × 16 (physical address of segment) + 5 (offset) = 3710.

~Now try the activity~

Activity B

  1. 216 - 1 = 65535.  What is this number in hex?

  2. 220 - 1 = 1048575.  What is this number in hex?

  3. Given a segment and offset of 0007:000A.  What is the physical address?

  4. The picture below shows the contents of 16 bytes of my PC's memory starting at address 0040:0000.  

    1. What is this physical address?  

    2. What is the segment:offset address of the fifth byte E8?

 

One advantages of the segmented addressing system include access to more than 64K of memory. However, segmented addresses are harder to use than physical addresses.  Another disadvantage is that storing an address takes up 32 bits, when only 20 bits are necessary to store the equivalent physical address.


Memory Organisation

Let's consider our one megabyte of memory address space.  Space must be allocated for operating system files and routines, device drivers, interrupt routines, memory space for the BIOS to use, memory space for adapter cards to use and space for your programs to run in.  So, the memory workspace must be organised in some way to allow space for all these different things.

The original designers of the PC and DOS partitioned the one megabyte address space into sixteen segments.

So, each segment in this case is 65536 bytes long (64 KB.)  

The first 10 segments (00000 to 9FFFF physical address range) is called conventional memory and is used to load operating system files, device drivers and your programs.  The interrupt vector table is also kept here.  This area is 640K in size.  

The remaining 5 segments (A0000 to FFFFF physical address range) is called reserved memory and is used by the BIOS ROM and for adapter cards with memory on them such as RAM and ROM on graphics cards and hard drive/floppy disk controllers.  This area is 384K in size.  

The memory map below shows the 16 segments of the one megabyte memory address space and how that memory is typically organised.


~Now try the activity~

Activity C

The CPU has two registers that contain the current segment:offset address.  These are the CS and IP registers.  Let's have a look at what's in these registers using DOS debug.

  1. Open up the Command Prompt.  Type in debug at the prompt.  A different prompt will appear, the - prompt, letting you now you are using the debug program.

  2. Now type r cs      when the colon appears just enter again.

    The number that is returned after CS is the value that is held in the segment address register.  In my case the current segment address is 0CD4.

  3. Now type r ip       when the colon appears just enter again.

    The number that is returned after IP is the value that is held in the offset register.  In my case the current offset is 0100.

  4. Now type d 0CD4:0100 or your own segment:offset number.  Here is what is displayed

 

 

What are your CS:IP registers currently set to?  

Did you get anything interesting in that address location in RAM?

Type q at the prompt to get out of debug

 

 

Now let's have a look at each segment in slightly more detail.

 

    Segment 0 - Interrupt Vector Table

The 1st 1KB of conventional memory holds the Interrupt Vector Table, located at segment:offset 0000:0000 through 0000:03FF.  256 addresses of 4 bytes each are held here and each address is called an interrupt vector.  Each address contains another address -  the address of the Strategy Routine for that interrupt. 

Various programs (the BIOS, ROM BIOS Extensions and user programs) store addresses into the interrupt vector table.  This means they are declaring they will handle any interrupts whose address they have changed to point to themselves. This is called hooking an interrupt. 

Parts of the operating system may also reside in this segment (some parts may reside elsewhere in memory.) In addition, many status bytes are stored in this segment that store information about the keyboard, disk drives, video display, and other components.

 

    Segment 1 to 9 - Working RAM

Any memory left over in the first segment 0, in addition to segments 1 to 9 which takes us up to the 640K limit of conventional memory, can be used as working RAM - memory used by programs. 

 

    Segment 10 & 11 -  Video Memory

These two segment are used as display memory for graphics cards.  VGA graphics adapters can use this memory space as well as older CGA and EGA cards.  A video adapter has its own memory mapped into this area.  Also, when your computer needs to send information to your display, it writes it to these segments.  If memory in this area is changed, the image displayed on screen changes too.  

You may be wondering how graphics cards with 1MB or more can use this small 128 KB area.   The answer is in a method known as paging.  Paging works by swapping the information stored in graphic card memory into and out of these segments as the data needs to be accessed. 

  

    Segment 12 & 13 - ROM BIOS Extensions

These are programs stored in ROM chips.  Usually, each expansion card has a ROM chip that contains a program which is dedicated to the control of the card.  ROM BIOS extension programs are executed at boot time.  What happens?  It is likely that initialization code is executed and a strategy routine address is stored in the interrupt vector table.

~Now try the activity~

Activity D

Let's see some information on the graphics card -  stored in the ROM BIOS Extension segment

  1. Use DOS debug have a look at address C000:0

Type d again at the prompt

What info did you get?]

Type q at the prompt to get out of debug

 

 

    Segment 14 & 15 ROM BIOS

The BIOS ROM is a chip on the motherboard. This chip holds routines for the POST (power on self test), starting the boot process and contains essential information about the system.    

When the computer is powered on, the processor automatically begins code execution at 0×FFFF:0000 near the top of the reserved memory area.  It is from here that the CPU takes the next instruction to be executed -  the BIOS initialization code probably .  After this, the code contains instructions to scan bootable drives looking for a copy of an operating system to load and run.  

~Now try the activity~

Activity E

Let's view some BIOS system information about the system BIOS -  stored in the ROM BIOS segment

  1. Type in d FFFF:5 L 8

The output indicates that my system BIOS was created on 31st January 2002.

Did you get anything interesting in that address location in RAM?

Type q at the prompt to get out of debug

 

   


Past the One Megabyte Mark?

Memory above the one megabyte limit is called Extended memory and is available to applications that are aware of it.  Extended memory is made available to applications via DOS using an interrupt call, INT 15(hex).  INT 15 is a "software" interrupt provided by DOS to supply extended memory to application programs that can make use of it.

Look at the memory map below for a Pentium II ATX system.  There are some similarities in the conventional and reserved memory areas to the map shown earlier for the AT system.  However, the amount of RAM available is 128 megabytes of which 127 megabytes is extended memory.


Something to Finish With!

Here is some assembly code for rebooting your computer - like pressing CTRL ALT DELETE.  

Note: It only works in DOS , not in a Command Prompt run from within Windows!

 

E 40:72 34 12
R CS  

FFFF
R IP 

0000
G

Go on - try it now!

That is folks!!

 

 

 Site Home

Unit Home  

This Unit 

Unit Information

Overview

Assessment

Syllabus

Assignments

Scheme of Work

Resources

Information

Blackboard

Learning Center

Reading

Utilities

Links

Lecture Materials

Tutorials & Notes

Activities

Quizzes

Site Home Top Unit Home

ADR 2002