Section 11.3: Approaches to Relocation (Frame 5)                     [prev][home][     ]

Today's approach is to add every address that the user program generates to the contents of a register. This base address register contains the address of the beginning of the user program in real memory. In Fig. 11.2.1, program A starts at location 2500, so the base address register would contain 2500 when A is running. B starts at 3600, so any address it generates has to be added to 3600, which will be the contents of the base address register. In the ALU's hardware, there is only one base address register, necessitating that every time a user program is restarted this base address register has to be reloaded with the base address of the now currently active program. In this way, when program A starts running instructions at logical word 0, the computer really retrieves the instruction from physical word 2500. Compilers and linkers can generate code starting at address 0, oblivious to where it will actually be at run time.

The method of computing physical addresses, i.e. adding logical addresses to the contents of a base address register, as described above is the standard one for certain types of systems, mostly older and simpler one, where all of a user's program and data can reside in main memory and it is stored contiguously, i.e. all together. Later systems break up a user's program into chunks called pages and a much more complex method of translating addresses must be employed. We will look at that in the next chapter.