Difference between revisions of "CSC231 Final Exam 2010"
(10 intermediate revisions by the same user not shown) | |||
Line 7: | Line 7: | ||
Make sure you reference all work/resources you use in your documentation. | Make sure you reference all work/resources you use in your documentation. | ||
+ | |||
+ | Files submitted past the deadline will not be graded. | ||
</tanbox> | </tanbox> | ||
− | + | <br /> | |
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | __TOC__ | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
<onlydft> | <onlydft> | ||
− | =Problem #1: Recursive GCD= | + | =Problem #1: Recursive GCD (1 point)= |
The following algorithm can be used to find the greatest common denominator of two integers, or ''GCD''. The GCD of two integers ''m'' and ''n'' is the largest integer that divides both of them with a remainder of 0. The GCD of 5 and 6 is 1. The GCD of 10 and 12 is 2. The GCD of 12 and 20 is 4. | The following algorithm can be used to find the greatest common denominator of two integers, or ''GCD''. The GCD of two integers ''m'' and ''n'' is the largest integer that divides both of them with a remainder of 0. The GCD of 5 and 6 is 1. The GCD of 10 and 12 is 2. The GCD of 12 and 20 is 4. | ||
Line 32: | Line 43: | ||
=Problem #2: Debugging Utility Functions= | =Problem #2: Debugging Utility Functions= | ||
− | ==Part 1== | + | ==Part 1 (1.5 points)== |
Write an assembly language program that does '''not''' use the driver.c or asm_io.asm files and that displays a 32-bit integer in binary, hexadecimal, and in decimal. When the number is displayed in decimal it is displayed as an ''unsigned'' '''int'''. For example, 0x80000000 should display as 2147483648. | Write an assembly language program that does '''not''' use the driver.c or asm_io.asm files and that displays a 32-bit integer in binary, hexadecimal, and in decimal. When the number is displayed in decimal it is displayed as an ''unsigned'' '''int'''. For example, 0x80000000 should display as 2147483648. | ||
Line 61: | Line 72: | ||
mov ebx, table | mov ebx, table | ||
mov ecx, N | mov ecx, N | ||
+ | for: | ||
mov eax, [ebx] | mov eax, [ebx] | ||
Line 82: | Line 94: | ||
:where nextLine is a function that brings the cursor to the next line. | :where nextLine is a function that brings the cursor to the next line. | ||
− | ==Part 2== | + | ==Part 2 (1 point)== |
− | Add a fourth function called '''printRegs''' to your program that will display all the registers in hex | + | Add a fourth function called '''printRegs''' to your program that will display all the registers in hex, in unsigned decimal, and in signed decimal formats. |
Here is an example of the call and its output: | Here is an example of the call and its output: | ||
− | + | call printRegs | |
eax: 00000000 0 0 | eax: 00000000 0 0 | ||
ebx: 00001000 4096 4096 | ebx: 00001000 4096 4096 | ||
ecx: 0fabbcde 262913246 262913246 | ecx: 0fabbcde 262913246 262913246 | ||
− | + | edx: 0000fffe 65534 65534 | |
esi: 00001132 4402 4402 | esi: 00001132 4402 4402 | ||
edi: ffffffff 4294967295 -1 | edi: ffffffff 4294967295 -1 | ||
Line 100: | Line 112: | ||
Your function should display the value the registers hold before the call is made to printRegs. Your function should return to the calling program without having changed the value of any of the registers. | Your function should display the value the registers hold before the call is made to printRegs. Your function should return to the calling program without having changed the value of any of the registers. | ||
− | ==Part 3== | + | ==Part 3 (0.5 point)== |
Add a new feature to the '''printRegs''' function so that it displays the flag bits. | Add a new feature to the '''printRegs''' function so that it displays the flag bits. | ||
Line 135: | Line 147: | ||
Make sure that your function displays the status of the bits as they stand before the function is called, and make sure that whatever your function does, when it returns to the caller the status bits are in the same state they were before the function was called. | Make sure that your function displays the status of the bits as they stand before the function is called, and make sure that whatever your function does, when it returns to the caller the status bits are in the same state they were before the function was called. | ||
− | You will need the pushf and popf instructions. Pushf pushes a doubleword containing the flags register in the stack. Popf pops it back. | + | You will need the '''pushf''' and (maybe) the '''popf''' instructions. Pushf pushes a doubleword containing the flags register in the stack. Popf pops it back. |
=Requirements= | =Requirements= | ||
Line 149: | Line 161: | ||
submit final final2.asm | submit final final2.asm | ||
− | |||
</onlydft> | </onlydft> |
Latest revision as of 09:38, 4 December 2014
This final exam is take-home. It is open-books, open-notes, and open-Web. It is due a week after it is made available, at 12:00 p.m. on Monday December 20, 2010.
You cannot discuss the details of this exam with anyone except your instructor. The TAs are not allowed to help you out in any way. No question will be answered in person after 12:00 a.m. on 12/13/10. Instead, if you have questions regarding the exam, send them via email to thiebaut@cs.smith.edu, and the question and its answer will be broadcast back to the hole class via email. The exam is given under the rules of the Smith College Honor Code.
Make sure you reference all work/resources you use in your documentation.
Files submitted past the deadline will not be graded.