Relationship between program addresses and memory addresses

  • The relationship between program addresses and memory addresses depends on:

    • How the program is placed in the memory

  • When the (whole) program is stored in memory at memory location 0:

    • Memory address = Program address

Relationship between program addresses and memory addresses

  • The relationship between program addresses and memory addresses depends on:

    • How the program is placed in the memory

  • When the program is stored in memory at a different memory location:

    • Memory address = f(Program address)    f( ) is a map/function

Implementation of the Virtual Memory Technique

  • The CPU sends out addresses to (1) fetch an instruction or (2) read/write a variable in the computer program:

    • The address used/sent out by the CPU is always a program address
       

Implementation of the Virtual Memory Technique

  • Memory bytes/cells are selected/identified by a address on the address bus:
     

    • The address used/sent into the address bus is always a memory address
       

Implementation of the Virtual Memory Technique

  • A computer implements the Virtual Memory Technique by mapping a program address to a memory address using a (dynamic) mapping function (implemented in hardware):

    • The Memory Management Unit (MMU) is the device that implements this mapping function

Example of the Virtual Memory technique

  • The CPU executes the current instruction and suppose the instruction needs to use a variable in the program location 4000:

Example of the Virtual Memory technique

  • The execution of the current instruction will cause the CPU to fetch the variable at program address 4000:

Example of the Virtual Memory technique

  • Suppose this variable is stored in memory at memory address 2000:
     

Example of the Virtual Memory technique

  • The MMU will (must) map the program address 4000 to memory address 2000 so that the CPU can retrieve the correct value from memory:

Summary of the Virtual Memory technique

  • Items in a computer program are identified by a program address

  • Memory cells in the computer memory are identified by a memory address

  • A program can be placed in memory in an arbitrary location

  • In order to find program items stored in memory using a program address, we must use a dynamic (time-varying) mapping function

  • The dynamic (time-varying) mapping function known as the Virtual Memory technique