Cs 216, Midterm exam, (from 2005) But expect some C

Open book You may consult your textbook, my printed class notes, and one page of information you have prepared. You may also use a printed dictionary. You may not use a calculator or any other electronic device. Do not copy any wrong answers!



  1. Convert this signed hexadecimal number to decimal, show your work: 0xFFFFFE60





  2. Convert the decimal number 444 to binary (or hexadecimal), show your work:




  3. Given that $a0 contains an integer, If it is negative, put its absolute value in $v0, and put 0 (zero) in $v1. However, if $a0 is positive, put the remainder of dividing by 128 in $v1, and the square of the quotient in $v0. Note that $v0 and $v1 must still be as specified when the end of your section of code is finished. (You are not to write a whole program, just the instructions to do as asked.)



  4. The following are pseudo-instructions. Please implement them with assembly language instructions which are not marked with a 'dagger' (and thus correspond to machine language instructions.)

    not $v0, $t0
    bgt $t0,'@', maybeLetter


  5. Here is a loop. What do you expect the output to be?

  6. la   $a0, another
    li $v0, 4
    loop:	
       syscall
    sub $a0,5
     sub $v0,3
    bne $v0, 1, loop

    li $v0,10
    syscall
    	.data
    string: .asciiz "Help!"
    another: .asciiz "I need somebody\n”
  7. Write MIPS code containing a loop to do the following:

    Suppose that $a0 points to an array of 365 words, containing daily temperatures. Make $v0 be the count of days of extreme temperature, that is, less than -10 or greater than +25


  8. Write a program in C to add together corresponding elements of 2 arrays of the same size, and print each resulting number, and then the sum of all of them. The data might be defined like this:
    #define	SIZE	7
    int a[SIZE] = { 1, 3, 5, 7,   9, 88, -1};
    int b[SIZE] = {11,-5, 5, 3, -29, -8, 43};
    


Solutions available Wednesday