{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

SampleExam1Sol - CDA 3101 Exam1(Fall 2006 Time 1 hr 30 mins...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CDA 3101 Exam1 (Fall 2006) Time: 1 hr. 30 mins. Honor Code Statement On my honor, I have neither given nor received unauthorized aid on this exam . _______________________ ________________________ Signature UFID 1. (a). (10 points) Write (in binary) the IEEE 754 single-precision representation of the number 20.75 10 . Show all work. 0 1000 0011 0100 1100 0000 0000 0000 000 (b). (5 points) Say f 1 , f 2 , f 3 , …., f n are the consecutive decimal numbers that can be represented in the interval 4 10 to 8 10 . Find the values f i+1 – f i , i=1..(n-1), assuming IEEE 754 double-precision floating point representation is used. You can leave your answer in powers of 2. Show all work. (8-4)/2 52 =2 -50
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2. (40 points) Implement the recursive function foo() given below in the MIPS assembly language. Be sure to follow the procedure call conventions (pass arguments in $a0- $a3, pass return values in $v0-$v1, saving appropriate registers) appropriately. (Assume that the value of x entered is always small enough so that the output of foo will fit 32-bit 2’s complement representation) int foo(int x) { int ret; if (x <= 0) return 1; else { ret = x * foo(x-2); return ret; } } Also, write a short main function that i. prompts the user to enter the integer x ii. calls the foo( ) function iii. and prints the value returned by the foo( ) function. .data Prompt: .asciiz "\n Please Input a value for x = " .globl main .text main: li $v0, 4 la $a0, Prompt syscall li $v0, 5 syscall add $a0, $v0,$zero addi $sp, $sp, -4 sw $ra, 0($sp) jal foo lw $ra, 0($sp) addi $sp, $sp, 4 addi $a0, $v0,0 li $v0, 1 syscall jr $ra foo: blez $a0, base addi $sp,$sp, -8 sw $a0,0($sp)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}