CS-201 Homework #4 recover

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (4 votes)

We are providing a file called hw4main.c which contains functions main and foo. This code calls a function recover, which you will create and submit in a file called hw4.c. As you can see, function foo is called recursively several times after doing some sort of a funny computation to mix up the numbers. The exact number of times that foo recurses is data dependent. After recursing several levels down, foo will call a function named recover, which you will write. Your function will do some printing and then return, after which all the calls to foo will complete and return. Function foo is passed several values. Your task is to write the function recover, which will print the arguments named “a”, “b”, and “c”. You are to print the arguments to all calls to foo and return. Unfortunately recover is passed no arguments and your code will be tested using our version of hw4main.c. You are free to create and include in hw4.c additional helper functions which recover may invoke. Restriction: Function recover and any other functions you write may only call putchar. You may also call printf to print strings like “foo called with args\n” and “ a: ”, but don’t use it to print the hex numbers. You may not invoke any other library routines. Your code must print the arguments in exactly the following format and must print the arguments in hexadecimal. Here is some sample output for this program. Your code should print the arguments in the order the functions were invoked. In other words, the first set of arguments to be printed is from the initial call that main makes. % hw4 11223344 12345 20 5 main called with a = 11223344, b = 12345, c = 20, countDown = 5 foo called with args a: 00AB4130 b: 3039 c: 14 foo called with args a: 0156B259 b: 6066 c: 18 foo called with args a: 02AD04D4 b: C0D4 c: 69 Homework #4 CS-201 / Porter Page 2 of 2 foo called with args a: FAA5C97C b: 81C0 c: 06 foo called with args a: 0AB41339 b: 0387 c: 70 foo called with args a: 156825F5 b: 077E c: D9 foo returns 527497991 The file hw4main.c is at cs.pdx.edu/~harry/cs201/hw4main.c. Submit a single file named hw4.c. It will be compiled and tested on the PSU Linux machines with the following commands. When tested, we will of course call it with a different set of values than the example, to make sure it recovers the arguments correctly. gcc -Wall -O1 -m32 -S hw4main.c gcc -Wall -O1 -m32 -S hw4.c gcc -m32 hw4main.s hw4.s -o hw4 This is an individual project, not a group project. You must work alone to create and write all code you submit. You are not to share code or debug other students’ code or look at other people’s code. Copying code from the web or anywhere else is totally cheating. Submission: Send a single email to ereed@pdx.edu. Include as a single attachment, the file hw4.c with Subject: CS201, HW4, Grading: Your program should produce the correct output. Therefore, your grade will be based on its simplicity, clarity, and efficiency.