Quiz 8

This quiz covers Chapter 7 of Tanenbaum. Please allow yourself up to 1 hour to take the quiz, and return it to me by 10:00 AM, Tuesday, December 2, if you would like for me to mark it. I will post my answers via the course homepage later that day.

  1. The Mac-1 assembler encounters the following program fragment:
           JUMP MAIN
    PMUL:  DESP 2
           LODL A
           JNZE ANOTZ
           LOCO 0
           JUMP DONE
    ANOTZ: LODL B
           JNZE BNOTZ
           LOCO 0
           JUMP DONE
    BNOTZ: LOCO 0
    
    Assuming a two-pass approach:

    1. Show the content of the symbol table after the first pass.

      Name   Addr
      ------ ----
      PMUL      1
      ANOTZ     6
      BNOTZ    10
      

    2. Show the content of the symbol table after the second pass.

      Name   Addr
      ------ ----
      PMUL      1
      ANOTZ     6
      BNOTZ    10
      MAIN      ?
      A         ?
      B         ?
      DONE      ?
      

    3. Which symbols, if any, would be undefined after the second pass?

      MAIN, A, B, DONE.

  2. Using the Mac-1 example above, assume that the assembler is producing a load module.

    1. How many words long is the code section of the module?

      11.

    2. Assuming all symbols are global, what symbols and offsets would be in the Entry point table?

      Entry Point Offset
      ----------- ------
      PMUL             1
      ANOTZ            6
      BNOTZ           10
      

    3. Assuming all symbols are global, what symbols and offsets would be in the external reference table?

      Symbol Offset
      ------ ------
      MAIN        0
      A           2
      B           6
      DONE        5
      DONE        9
      

    4. What would be the content of the relocation dictionary?

      Offset
      ------
           3
           7
      

  3. A linker encounters a load module with the relocation constant 2048 (decimal). The module contains this additional information:

    With this example in mind, answer the following questions:

    1. What is the linear virtual address of PROD?

      2080.

    2. Assuming X, Y, and Z are in a module whose relocation constant is 1024, and whose individual offsets are 0, 256, and 512 (respectively), explain in detail how the external reference information is used. What locations in the linear address space would be updated with what values?

      For each entry in the external reference table, the value for the external reference would be calculated by adding the defining module's relocation constant to the individual symbol's offset. The locations in the current module would then be updated with the appropriate value, where the location is calculated by adding the current module's relocation constant to the external reference's offset. Locations 2150, 2157, 2152, 2159, 2154, 2161 would be updated with the values 1024, 1024, 1280, 1280, 1536, 1536, respectively.

    3. Assuming that the locations whose offsets are 100, 103, 108, and 112 bytes from the beginning of the module contain the values 110, 110, 120, and 120 (respectively), explain in detail how the relocation dictionary is used. What locations in the linear address space would be updated with what values?

      These locations contain values that must be adjusted by the value of the relocation constant. Locations 2148, 2151, 2156, 2160 would be updated with the values 2158, 2158, 2168, 2168.

Copyright © 1997, Ray Ontko (rayo@ontko.com).
If you're curious about why I copyright, see Peter Suber's Why Copyright Web Documents?.