{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

CDA3101Exam1Soln

# CDA3101Exam1Soln - CDA 3101 Exam1(Fall 2006 Time 1 hr 30...

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

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

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

View Full Document
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 jal foo addi \$a0, \$v0,0 li \$v0, 1 syscall li \$v0, 10
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern