Test #1 Review Sheet

Here's a review sheet for the first test. The ommission of a topic does not mean it is not on the test. You are responsible for class lectures 00-06, homework assignments 1-3, and most of lab1.

Note that the existence of an exam #1 review sheet does not imply the existence of a review sheet for exams #2, #3, and #4. Also, I credit the Bryant and O'Hallaron textbook and slides as providing problems #1 and #2.

Questions

  1. Which of the following are true. x and y are of type int. ux and uy are of type unsigned int.
  2. Write a c-expression to yield a bit string of w-length that sequentially contains w-(k+j) 0's, k 1's, and j 0's.
  3. Write a c-expression that yields a mask 0xFFFF...FF00FF using each of the following operations once: ~ << |
  4. Write a c-expression that yields a mask 0xFFFF...FF00FF using each of the following operations once: ~ ^
  5. Hard and I will not cover myself: Without using control constructs (for, if, etc.), write a function to count the number of binary 0's in a 32-bit integer. For example 0b1111...11110000 would return the integer 4. Restrict yourself to straightline C code, similar to lab 1. Think about how to decompose the problem into multiple operations with results stored in clearly labeled variables.
  6. Given a floating point format with 1 sign bit, 5 exponent bits, and 5 fraction bits:
  7. What is the difference between a normalized and denormalized floating point number? What are the three types of denormalized floating point numbers?
  8. How many exponent and significand bits are there in an IEEE single-precision (32-bit) floating point number?
  9. Which register does the x86 architecture use to return a value from a subroutine?
  10. Does gcc push operands from right to left or from left to right?
  11. Write C-code for the following assembly:
    	.file	"for.c"
    	.text
    .globl foo
    	.type	foo, @function
    foo:
    	pushl	%ebp
    	movl	%esp, %ebp
    	subl	$4, %esp
    	movl	$0, -4(%ebp)
    .L2:
    	cmpl	$99, -4(%ebp)
    	jle	.L5
    	jmp	.L3
    .L5:
    	movl	12(%ebp), %eax
    	addl	%eax, 8(%ebp)
    	leal	-4(%ebp), %eax
    	incl	(%eax)
    	jmp	.L2
    .L3:
    	movl	8(%ebp), %eax
    	leave
    	ret
    	.size	foo, .-foo
    	.section	.note.GNU-stack,"",@progbits
    	.ident	"GCC: (GNU) 3.3.4"
    		

Home

Valid XHTML 1.1!