CS 2521 Study Questions: Exam 1

Fall 2009

Revisions:

None yet.

Material covered:

Chapter 1: Computer Abstractions and Technology

Coverage: Ch 1.1-1.6, SPEC CPU benchmark (pp. 48-50), Ch 1.8-1.9

Chapter 2: Instructions: Language of the Computer

Coverage: Ch 2.1-2.3; 2.6-2.9

Alignment & Endian-ness
Programming assignments: 0, 1, 2

Homework questions due: Wednesday, 7 October 2009 [15 pts]:

Homework is due at the start of class on the due date. Late homeworks will not be accepted. Homeworks must be type-written, and not hand-written. Keep a copy of your homework, and bring this with you the day of the quiz/exam review (i.e., the day the homework is due). This should help you in the review session.

For the homework, do the following 15 of the study questions:

Q #1 [1 pt]
Q #7 [1 pt]
Q #8 [1 pt]
Q #9 [1 pt]
Q #10 [1 pt]
Q #11 [1 pt]
Q #12 [1 pt]
Q #16 [1 pt]
Q #22 [1 pt]
Q #25 [1 pt]
Q #27 [1 pt]
Q #28 [1 pt]
Q #29 [1 pt]
Q #32 [1 pt]
Q #35 [1 pt]


    Chapter 1: Computer Abstractions and Technology

  1. What is an assembler?
  2. Define: Instruction Set Architecture (ISA).
  3. Is ISA the same as assembly language? Yes or No? Explain.
  4. How does machine language differ from assembly language?
  5. According to the textbook, what are the five classical components of a computer? What does each one do?
  6. Which of the following have exhibited exponential improvement over the past few decades?
  7. Can CPI be used to compare the performance of different CPU's? Yes or No. Explain.
  8. Does CPI depend on the programmer (i.e., the human that wrote the program)? Yes or No. Explain.
  9. Does CPI depend on instruction set architecture? Yes or No. Explain.
  10. What is the instruction count of the following MIPS assembly language program:
    	.data
    bytes: .asciiz "abc123\n"

    .text
    main:
    # This code will successively put the
    # bytes of "bytes" into the register
    # $s0, from left to right, stopping
    # when we hit "\n" (10).

    # put address of our string into $t0
    la $t0, bytes
    li $t1, 10
    Next:
    lb $s0, 0($t0)
    beq $s0, $t1, End
    # increment address ($t0) to reference
    # next character
    addi $t0, $t0, 1 # $t0=$t0+1
    j Next
    End:
  11. Suppose that a computer task takes 90 seconds, and 30% of that task can be optimized. Use Amdahl's law to determine the maximum performance improvement that can be achieved. Show your work.
  12. Is MIPS (Millions of Instructions per Second) a general-purpose metric for comparing the performance of CPU's? Yes or No. Explain.
  13. What unit of measurement is likely the best for comparing performance across CPU's? Explain.
  14. Improvements in a processor lead to a reduction in execution time for a program from 7 seconds to 5 seconds. What is the percentage improvement for performance?
  15. Which of factors in the performance equation are most likely to be affected by the following changes to a processor? (a) Adding more powerful instructions; (b) Improvements in transistor technology; (c) Large scale reorganizations, such as pipelining
  16. In a certain processor, 20% of the executed instructions are branches and jumps, 20% are loads and stores, and 60% are arithmetic and logical instructions (e.g., add, sub, and, or). Branches and jumps execute in 3 cycles, loads and stores execute in 5 cycles, and arithmetic and logical operations execute in 4 cycles. What is the effective CPI?
  17. An incremental modification of the above processor reduces the cycle count for arithmetic and logical instructions from 4 cycles to 3 cycles. This modification increases the cycle time by 10%. No new instructions are added so the instruction count is unchanged. What is the overall percentage improvement in performance?
  18. With a specific instruction mix, the current version of a processor spends 45% of its time on arithmetic and logic instructions, 30% on loads and stores, and 25% on branches. With the same instruction mix, modifications to the circuitry improve performance on loads and stores by 50% and performance on branches by 25%. The performance on arithmetic and logic instructions is unchanged. What is the overall performance improvement, expressed as a percentage? Show your work.
  19. Chapter 2: Instructions: Language of the Computer

  20. Clearly distinguish between a machine register and a word of RAM.
  21. What is the word length in MIPS?
  22. Assume that variables are stored in registers in the following, and give MIPS assembly code corresponding to the following C code:
    a = 10;
    c = 0;
    e = a + 20;
    a = a + c;
    d = a – e;
  23. Repeat the last question, assuming that variables are stored in RAM. Give complete assembly language code (e.g., that will run on our PIC32 board-- you don't have to assemble or test your program).
  24. Assuming that variables are stored in registers, give MIPS assembly code corresponding to the following C code:
    a = 10;
    b = a * 16;
  25. Give assembly language code that will toggle the state of all bits in a register. I.e., if a bit is 1, it should change to 0, and if it is 0, it should change to 1.
  26. What is the resulting state of the $t0 register after these instructions finish executing:
    li $t1, 0x1234
    andi $t0, $t1, 0x00ff
  27. Explain why this result is observed.
  28. What is the resulting state of the $t0 register after these instructions finish executing:
    li $t1, 0x0034
    ori $t0, $t1, 0x1200
  29. Explain why this result is observed.
  30. Assuming that variables are stored in registers, convert the following C language code into MIPS assembly code:
     	if (a == b) {
    		c = 10
    	} else {
    		c = 20;
    	}
        
  31. Assuming that variables are stored in registers, convert the following C language code into MIPS assembly code:
    	a = 0;
    	do {
    		a++
    	} while (a < 10);
    
  32. Convert the following C language code into MIPS assembly code:
    	int func2(int b) {
    		return b*3;
    	}
    	int func1(int a) {
    		return func2(a+1);
    	}
    	// Also code a call to func1: func1(5)
  33. In general terms, describe how a while loop is implemented in assembly language. How does a do-while loop differ?
  34. When a subprogram is about to be called, what does the calling code need to do first? What MIPS instruction is used to call a subprogram? What instruction is used to return from the subprogram?
  35. Is the MIPS register $zero the same as ASCII '0' (ASCII zero)? Yes or No. Explain.
  36. What is the meaning of the instruction: beq $t1, 1, Label ?
  37. Suppose you have a structure (record) in assembly language that is declared as follows:
      struct:   double  0.0   # struct.d
                float   1.0   # struct.f
                word    15    # struct.i
                byte    'x'   # struct.c
            
    What is the total size of the structure? What are the displacements (starting addresses) for each of its members?
     
  38. Suppose that a word of RAM memory located at address 0x1020 contains a value you want. Give an instruction that will place the value at this address into register $t0.