CS2200 Summer 2005 Practice Test 1 Preassessment 1P. Write a function that will swap two integer pointers. So if the code looked like this: int i = 42; int j = 99; int *ip = &i; int *jp = &j /* Call your function here */ __________________________________________________ printf("i=%d j=%d *ip=%d *jp=%d|n", i, j, *ip, *jp); Would print: i=42 j=99 *ip=99 *jp=42 ________ void swapIntPointers( ) { } Processor Design 2P. Compare and contrast RISC versus CISC processor architectures. Addressing Modes 3P. Explain what is meant by "addressing modes." Give examples that illustrate the different modes that you are aware of using MIPS, LC-3 or LC2200 assembler Basic Assembly Language Constructs 4P. Assume that you have the address of a block of 10 numbers in $s0 and the address of a second block of 10 numbers in $s1. Write LC- 2200 assembly code which will add the corresponding numbers from each block and store the result in the block whose address is in $s0. Calling Conventions 5P. Here is the code for fibbonacci int fib(int n) { if(n == 0 or n ==1) return 1; else { int t1, t2; t1 = fib(n-1); t2 = fib(n-2); return t1+t2; } } Write fibonacci in assembly language. Note: You must use augmentative or head recursion NOT tail recursion! Note: It might be a good idea to actually run the code to make sure you are doing it correctly. Endianess 6P. Write a program in C that will determine if a processor is Big Endian or Little Endian. Run your program on acme, lennon amd turku. Explain what is happening and why. 7P. Examine the LC-2200-8 datapath diagram for Project 1. We would like to implement a push and a pop instruction on the LC-2200-8. PUSH R POP R PUSH will automatically decrement the stack pointer ($sp) and then store the contents of R into the memory location pointed to by the stack pointer. POP will store the contents of the memory location pointed to by the stack pointer ($sp) into R and will then increment the stack pointer. Can these instructions be implemented on the existing LC-2200-8 datapath? If no, what changes would you make? In either case, existing datapath if it will work and modified datapath is that is necessary: Show the finite state machines steps required to implement this instruction. Assume that an opcode is available. Performance 8P. Explain how CPI and speedup are affected by pipelining a processor. Give examples using sample numbers to show how calculations are performed.