Difference between revisions of "CSC231 Final Exam 12/08"
(→Part 2 (1 point)) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
---- | ---- | ||
+ | <onlydft> | ||
=Take Home Exam= | =Take Home Exam= | ||
− | This exam is due on Dec 19, at '''noon'''. | + | <font color="purple">This exam is due on Dec 19, at '''noon'''. |
This exam is given under the rules of the ''honor code''. You have access to all your notes, to books, and to the Web. You cannot, however, discuss the details of the exam with anybody other than your instructor. Questions regarding the exam can only be asked in class, or via email. In case you send a question via email, the text of your question in its entirety and the answer to it will be broadcast back to the whole class, so be careful not to divulge too much in your questions. In this fashion, everybody will have access to the same information and same clarifications. | This exam is given under the rules of the ''honor code''. You have access to all your notes, to books, and to the Web. You cannot, however, discuss the details of the exam with anybody other than your instructor. Questions regarding the exam can only be asked in class, or via email. In case you send a question via email, the text of your question in its entirety and the answer to it will be broadcast back to the whole class, so be careful not to divulge too much in your questions. In this fashion, everybody will have access to the same information and same clarifications. | ||
+ | </font> | ||
=Problem #1 (2 points)= | =Problem #1 (2 points)= | ||
Line 56: | Line 58: | ||
Write the Tower of Hanoi program in assembly. Store your program in a file called '''hanoi.asm'''. | Write the Tower of Hanoi program in assembly. Store your program in a file called '''hanoi.asm'''. | ||
− | Your program should display the number of disks ''N'' used, and then the series of moves that need to be taken to move all the disks from one peg to the other. | + | Your program should display the number of disks ''N'' used, and then the series of moves that need to be taken to move all the disks from one peg to the other. Here is an example: |
− | + | <code><pre> | |
+ | Towers of Hanoi game | ||
+ | Number of disks = 4 | ||
+ | move disk from A to C | ||
+ | move disk from A to B | ||
+ | move disk from C to B | ||
+ | move disk from A to C | ||
+ | move disk from B to A | ||
+ | move disk from B to C | ||
+ | move disk from A to C | ||
+ | move disk from A to B | ||
+ | move disk from C to B | ||
+ | move disk from C to A | ||
+ | move disk from B to A | ||
+ | move disk from C to B | ||
+ | move disk from A to C | ||
+ | move disk from A to B | ||
+ | move disk from C to B | ||
+ | |||
+ | </pre></code> | ||
+ | |||
+ | Make the program use a global variable that defines how many disks are used: | ||
<code><pre> | <code><pre> | ||
section .data | section .data | ||
− | N | + | N dd 4 |
</pre></code> | </pre></code> | ||
− | Use | + | Use 4 for N when you submit your program. Of course your program should work for other values of N! (Make sure that your program degrades gracefully, i.e. it shouldn't crash if N is set to 1, to 0, or to a negative number! |
+ | |||
Store your answers to Part 1 in the header of the program and submit it as follows: | Store your answers to Part 1 in the header of the program and submit it as follows: | ||
Line 107: | Line 131: | ||
For the written parts, you are allowed and encouraged to use the computer to generate your answer. This means that you shouldn't hesitate to write programs, use programs (eXcel for example), or whatever other tool you have access to. In this case, include copies of the programs or screen captures illustrating the data that help you make your case. | For the written parts, you are allowed and encouraged to use the computer to generate your answer. This means that you shouldn't hesitate to write programs, use programs (eXcel for example), or whatever other tool you have access to. In this case, include copies of the programs or screen captures illustrating the data that help you make your case. | ||
+ | |||
+ | </onlydft> |