Computer Science 301 - 2004 - Vacation Reading Test

1. What are your surname and student number? [1]

Pat Terry, 63T0844

2. What do you understand by the term "half bootstrap of a compiler"? [3]

A half-bootstrap uses a self-resident compiler hosted on and targetting one computer to produce an
equivalent self-resident compiler hosted on and targeting another computer by first producing a cross-
compiler.

3. Suppose you have available the source code (CtoP.C) and object code (CtoP.P) for self compiling C compiler that targets a Pentium (P) computer. Complete the T diagrams below to show the steps you might follow in producing a self-compiling C compiler for the newly announced Septico computer. [4]

       .--------------------------.          .--------------------------.
       |           CtoS.C         |          |          CtoS.P          |
       |   C     -------->  S-code|          |  C     --------->  S-code|
       |                          |          |                          |
       `-------.          .--------------------------.          .-------'
               |          |          CtoP.P          |          |
               |     C    |   C     -------> Pentium | Pentium  |
               |          |                          |          |
               `------------------.          .------------------'
                     |            |          |            |
 Rewrite the back    |            |  Pentium |            | We get a cross
 end of the CtoP     |            |          |            | compiler
 compiler to         |            `----------'            |
 generate S-code     |                                    | Use this to
 (do the coding of   |                                    | compile the
 this in C).         |                                    | CtoS source
                     |                  .-----------------' again
                     v                  |
       .--------------------------.     |    .--------------------------.
       |          CtoS.C          |     |    |          CtoS.S          |
       |   C     --------> S-code |     |    |   C    --------->  S-code|
       |                          |     v    |                          |
       `-------.          .--------------------------.          .-------'
               |          |          CtoS.P          |          |
               |    C     |   C     ------->   S-code|  S-Code  |
               |          |                          |          |
               `------------------.          .------------------'
                                  |          |
                                  | Pentium  |     This is the final
                                  |          |     executable required
                                  `----------'

4. Self-compiling compilers have to be able to pass a self-consistency test. Depict this test by annotating the T diagram below as it would apply to your Septico C compiler. [2]

       .--------------------------.          .--------------------------.
       |          CtoS.C          |          |         CtoS.S           |
       |   C     --------> S-Code |          |  C     ---------> S-code |
       |                          |          |                          |
       `-------.          .--------------------------.          .-------'
               |          |          CtoS.S          |          |
               |    C     |   C     ------->  S-code |  S-code  |
               |          |                          |          |
               `------------------.          .------------------'
                                  |          |            ^
                                  |  S-code  |            | should be
                                  |          |<-----------' identical
                                  `----------'


Home  © P.D. Terry