CDA3101-F11-HW3-KEY

CDA3101-F11-HW3-KEY - CDA 3101 Organization of Computer...

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

View Full Document Right Arrow Icon
CDA 3101 Organization of Computer Systems Fall 2011 Homework #3 (40 points total) - KEY Assigned: Wednesday 28 September 2011 Due: at the start of lecture on Wednesday 12 October 2011 This assignment has three parts. Please start each part on a new page . Print NEATLY and put your name and section number on each page . Show your work. Please scan or Xerox- copy your homework before turning it in, and staple all pages together with a metal staple. Part I. Pointers and Numbers 1. Short Answer (8 pts, 2 pt per item) Define the following (one sentence): 1.1. Pointer A pointer is a variable that contains a memory address. 1.2. Referencing Operator (give short example) A referencing operator returns the memory address of a variable. Ex: If c is a variable, then &c returns the memory address of c. 1.3. Dereferencing Operator (give short example) A dereferencing operator, applied to pointers, returns the contents of the memory address that is contained in the pointer variable. For example, if p is a pointer, then *p returns the contents of M[p]. As another example, if a variable c = 24, then *(&c) returns the value 24. 1.4. Two’s Complement Number Representation Two’s complement is a binary technique of representing numbers that has (a) one zero representation, (b) leading sign bit replicated rightward, and (c) ready hardware implementations for addition and multiplication 2. Number Representations (8 pts, 2 pt per problem) Calculate the following for the decimal number -12345 10 (show all work): 2.1. Signed-Magnitude Representation -12345 10 = 5 10 + 40 10 + 300 10 + 2000 10 + 10,000 10 = 101 2 + 101000 2 + 100101100 2 + etc. = 1 11000000111001 2 [sign bit emboldened] 2.2. One’s Complement Representation Invert the bits from signed-magnitude: 111000000111001 2 000111111000110 2
Background image of page 1

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

View Full DocumentRight Arrow Icon
CDA 3101 Organization of Computer Systems Fall 2011 2.3. Two’s Complement Representation 1: Convert the magnitude to binary, pad to 16 bits: 12345 10 0011 0000 0011 1001 2 2: Invert the bits (one’s complement): 0011 0000 0011 1001 2 1100 1111 1100 0110 2c 3: Add one 1100 1111 1100 0110 2c + 1 1100 1111 1100 0111 2c 2.4. Hexadecimal Representation Assume that we are representing the two’s complement form in hex 1100 1111 1100 0111 2c 1100 = 12 = C, 1111 = 15 = F, C, 0111 = 7 So the hex representation is CFC7 16 3. MIPS Programming of a Number Generator (9 pts, 3 pts per part) 3.1. Design (in high-level code such as C) a procedure to recursively compute the ratios of the first 20 Fibonacci numbers ( Hint: F = {1, 1, 2, 3, 5, 8, …} and the ratios converge to the transcendental number = 1.618) Math : fib(i) = fib(i-1) + fib(i-2), where fib(0) = 0, fib(1) = 1 frat(i) = fib(i) / fib(i-1), where frat(0) = 0 and frat(1) = 1 C : int fib(int n) float frat(k) {if n == 0 return 0; { if k == 0 return 0; if n == 1 return 1; if k == 1 return 1; fib(n-1) return fib(k) / fib(k-1) } } 3.2. Write a MIPS program that implements the HLL code you wrote in item 3.1, above.
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.

This note was uploaded on 12/10/2011 for the course CDA 3101 taught by Professor Small during the Fall '08 term at University of Florida.

Page1 / 11

CDA3101-F11-HW3-KEY - CDA 3101 Organization of Computer...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online