Test #2 Review Sheet

Here's a review sheet for the second test. The ommission of a topic does not mean it is not on the test. You are responsible for class lectures 00-14, homework assignments 1-6 and all of lab1 and lab2. A problem similar to the one similar to the homework 6 problem on this review sheet may appear on the test.

You probably want to look over review sheet #1.

Questions

  1. Write C-code for the following assembly:
    
    foo:
    	pushl	%ebp
    	movl	%esp, %ebp
    	movl	8(%ebp), %eax
    	leal	-33(%eax), %edx
    	cmpl	$6, %edx
    	jbe	.L12
    .L2:
    	popl	%ebp
    	addl	$10, %eax
    	ret
    .L12:
    	jmp	*.L8(,%edx,4)
    .L8:
    	.long	.L3
    	.long	.L2
    	.long	.L4
    	.long	.L5
    	.long	.L6
    	.long	.L2
    	.long	.L7
    	.text
    .L7:
    	popl	%ebp
    	movl	$166, %eax
    	ret
    .L3:
    	popl	%ebp
    	movl	$66, %eax
    	ret
    .L4:
    	popl	%ebp
    	movl	$37, %eax
    	ret
    .L5:
    	popl	%ebp
    	movl	$34, %eax
    	ret
    .L6:
    	popl	%ebp
    	movl	$46, %eax
    	ret
    		
  2. Write a Y86 routine for the below C code. Note that you can look at the course notes for help on this.
      int len1 (int a[]) {
        int len;
        for (len = 0; a[len]; len++)
          ;
        return len;
      }
    
  3. Trace the execution of the following Y86 instruction: addl %eax, %edx. See page 283 for the answer format. See page 259 for a list of icodes and ifuns. Also, see page 261 for a listing of register codes.

Home

Valid XHTML 1.1!