In-Class portion of CST222 Final Exam

  1. For the integer value "-5" (minus five), show how it would be represented in a twelve-bit word, using each of the following representation schemes:
    1. sign-magnitude
    2. ones-complement
    3. twos-complement
    4. excess notation

  2. For the integer value "-2047" (minus 2^11), show how it would be represented in a twelve-bit word, using each of the following representation schemes:
    1. sign-magnitude
    2. ones-complement
    3. twos-complement
    4. excess notation

  3. Using twos-complement representation only, explain what happens when the following pairs of numbers are added together in binary:
            2047
              +4
            ----
    
    
           -2047
              +4
            ----
    
    
           2047
          +2047
           ----
    

  4. Show the IEEE floating-point single-precision representation, in binary (and/or hexadecimal), for each of the following:
    1. 1.0

    2. 0.5

    3. 0.75

    4. 0.625

    5. 64

    6. 64.5


  5. How many decimal digits of precision are lost when a double-precision value for PI (3.14159265....) is copied from double to float?


  6. How much precision is gained when each of the following values is accurately represented in double precision, rather than single-precision floating point.
    1. PI

    2. 1/3

    3. 1/2

    4. 1.5

    5. 1.1

    6. 11


    To answer the following questions, first, change the instructions for the "take-home" final preparation, as follows:

    • Use %r5 instead of %r1
    • Use %r3 instead of %r31
    • Use %r17 instead of %r7
    • Use location 0x708 instead of 0x800.
    • Use location 0xCCC instead of 0x400.
    • Use value 0x10203 instead of 0x10101.

    Below is a copy of the take-home preparation, with the above changes made.

    Now, answer the following questions:

  7. Show the 32-bit machine code for each modified instruction, in both hexadecimal digits and binary bits.

  8. For each of these instructions (you may refer to them as A1, A2, A3, B1, B2, ...) show the 41-bit expanded code for it.

  9. For each of these instructions, describe the sequenced of events, in terms of who sends what to whom (CPU and/or a register; RAM and/or a particular memory address) on the address bus and on the data bus.


Write ARC assembly language instructions that cause the following sequence to occur:
  1. Set the %r5 register to contain ASCII string "AjAx".
    Set the lowest-numbered programmable register to contain ASCII string "NoTe".
    [Note that the A is UPPER-CASE, but the consonants are lower-case.]

  2. Store the value into memory at location 0x708.
    Store the value into memory at location 0x800.

  3. Now, set the same register to contain a string of four blanks. [No change.]

  4. Add the value 0x10203 to the value in memory at location 0x708.
    Add the value 0x10101 to the value in memory at location 0x800.

  5. Fetch the (modified) value at memory location 0x708 into register %r3.
    Fetch the (modified) value at memory location 0x800 into the highest-numbered programmable register.

  6. Perform an exclusive OR between these two registers, with the result going into register %r17, and then store this result into memory location 0xCCC.
    Perform an exclusive OR between these two registers, with the result going into register 7 (seven), and then store this result into memory location 0x400.
    NOTE:
  • Contents of the memory and the registers are unknown at the start of this sequence.
  • Use only these three programmable registers.
  • Some of these steps may require more than one instruction
  • Avoid adding unnecessary instructions.
  • write the instructions in ARC assembly language, and also in hexadecimal if you can.
    ALSO:
  • Add a label for each "task" letter (see above). (This will help you keep track of which is which.)
  • For each instruction, add a comment describing what is changed (the register number or the memory location), and exactly what value (in hex) is stored into it.

EXAMPLE:
!(This is an example of the STYLE to be used; the instructions are incorrect.)
    A:
        sethi    66666666,  %r0    ! register r32 is set to 0x12345678
        mov      ax, ds            ! 0x9999 is stored in [0x444]
    B:  ld       %sp, %r3          ! 0x8888 is stored in register 3
    C:  ...

TAKE-HOME PREPARATION FOR THE FINAL EXAM

Prior to the final exam (in class, on Tuesday 5/19), be sure to UPLOAD this code to your folder at http://suffolk.li/ with the file name "final-xyz.asm" (where "xyz" are YOUR initials!)

For the in-class final, you will be asked to modify these instructions, and re-upload the result.
There will also be further questions about how the processor actually decodes and executes these instructions, using the "microarchitecture" (as described in chapter 5 of the textbook), as well as some questions on other topics.

You MAY use the ARC simulator for this take-home preparation.
(No simulator on Tuesday, but the in-class exam will be open-book & open-notes.)