Difference between revisions of "CSC231 Final Exam 2014"
Line 34: | Line 34: | ||
* Your program should use the 231Lib library to read an integer from the keyboard. This number will represent the number of disks to move. The three pegs are called A, B, and C, and the goal is to move ''N'' disk from A to B, using C as the temporary peg. | * Your program should use the 231Lib library to read an integer from the keyboard. This number will represent the number of disks to move. The three pegs are called A, B, and C, and the goal is to move ''N'' disk from A to B, using C as the temporary peg. | ||
− | * The output of the program should just be two uppercase letters | + | * The output of the program should just be two uppercase letters separated by a space, one such pair on every line, identifying the source and destination pegs for a move. |
− | * Here is an example of how your program should work | + | * Here is an example of how your program should work; the user input is highlighted. |
− | :::<source lang="text"> | + | :::<source lang="text" highlight="1,2"> |
./hanoi | ./hanoi | ||
2 | 2 | ||
Line 47: | Line 47: | ||
C B | C B | ||
</source> | </source> | ||
− | *The first | + | *The number 2, on the first line after the program is started, is the number entered by the user. Note that your program should not display a prompt. The program then prints a line-feed, and prints the number again, and then prints another line feed. In assembly, this looks like this: |
<br /> | <br /> | ||
:::<source lang="asm"> | :::<source lang="asm"> | ||
Line 61: | Line 61: | ||
<br /> | <br /> | ||
* Submit your program to Moodle, in the Final Exam, Problem 5 section. | * Submit your program to Moodle, in the Final Exam, Problem 5 section. | ||
+ | <br /> | ||
+ | =Problem 6= | ||
+ | <br /> | ||
+ | This question relates to the Tower of Hanoi program. Assume that you pass parameters to your moveDisk() function via registers, | ||
+ | and that you push eax, ebx, ecx, and edx at the beginning of moveDisk, and nothing else is pushed in moveDisk in addition to these registers. | ||
+ | |||
+ | How much stack space will your program need, approximately, when moving 32 disks (''N'' = 32)? | ||
+ | * Approximately 100 bytes | ||
+ | * Approximately 640 bytes | ||
+ | * Approximately 4096 bytes | ||
+ | * Approximately 4 billion bytes | ||
+ | * Approximately 80 billion bytes | ||
+ | Please answer this question in the Moodle Final-Exam Problem 6 section. | ||
</onlydft> | </onlydft> |