Section 11.3
Review Questions

Approaches to Relocation

  1. The following CSC-1 program needs to be moved in memory. Relocate it, and its accompanying data, to location 3600.
               Mem addr           Contents of memory
               --------           ------------------
                  2400               LOD 2409
                  2401               ADD 2408
                  2402               SUB 2411
                  2403               ADD 2410
                  2404               STD 2406
                  2405               JZ  2400
                  2406               HLT
                  2407               NUM 17
                  2408               NUM 4
                  2409               NUM 0
                  2410               NUM 1032
                  2411               NUM 1
answer...
Mem addr           Contents of memory
--------           ------------------
   3600               LOD 3609
   3601               ADD 3608
   3602               SUB 3611
   3603               ADD 3610
   3604               STD 3606
   3605               JZ  3600
   3606               HLT
   3607               NUM 17
   3608               NUM 4
   3609               NUM 0
   3610               NUM 1032
   3611               NUM 1
  1. Now do the same kind of relocation by rewriting operand addresses when all you see are numbers in memory!
               Mem address          Contents       Contents in binary
               -----------          ---------      ------------------
                  2400                2409          0000100101101001
                  2401               14696          0011100101101000
                  2402               18795          0100100101101011
                  2403               14698          0011100101101010
                  2404                6502          0001100101100110
                  2405               39264          1001100101100000
                  2406               63744          1111100100000000
                  2407                  17          0000000000010001
                  2408                   4          0000000000000100
                  2409                   0          0000000000000000
                  2410                1032          0000010000001000
                  2411                   1          0000000000000001
answer...
you can't! you don't know which contents are instructions or data!
  1. The point of the preceding exercise was not to drive you mad! Can you guess what the point really was?
answer...
To show you that relocation is quite tricky, especially in a stored program computer where there is no difference between data and instructions in memory.
  1. Rewriting addresses in programs might be feasible if what conditions were met by the code? In other words, how would the instructions and data have to be structured so as to make this workable?
answer...
The assembler and linker programs could be told what the starting address would be at run-time and it could create the code accordingly.
  1. Define what the stored program concept is.
answer...
Programs are made up of instructions. Instructions are encoded in binary and kept in main memory, along with regular data. There is no physical difference between an instruction and a piece of data.
  1. Who is usually credited with inventing (discovering?) the stored program concept?
answer...
John von Neumann
  1. Distinguish between logical address and physical address.
answer...
A logical address is a virtual address, one that the program thinks is real but is not. A physical address is a real memory address that the MAR and memory can understand and work with.
  1. Match:
                   virtual address                         physical address
               
                   real address                            logical address
answer...
    virtual address ->logical address
    real address    ->physical address
  1. Why is it important to have as fast an adder circuit as possible?
answer...
because it will be used every time a logical address is translated into a physical one
  1. How is relocation done today? (They don't rewrite programs.)
answer...
by adding together a base address and an offset. To relocate the program, put a different value into the base address register.
  1. What is a page of memory?
answer...
A fixed number of contiguous words in memory, such as 1024 bytes.