Difference between revisions of "CSC231 Homework Solutions 2017"
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 17:57, 22 April 2017 (EDT) | --[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 17:57, 22 April 2017 (EDT) | ||
---- | ---- | ||
+ | <onlydft> | ||
=Problem 1= | =Problem 1= | ||
::<source lang="asm"> | ::<source lang="asm"> | ||
Line 981: | Line 982: | ||
</source> | </source> | ||
<!-- ================================================================= --> | <!-- ================================================================= --> | ||
− | + | ||
− | =funcs.c= | + | =Homework 9: funcs.c= |
<br /> | <br /> | ||
::<source lang="c"> | ::<source lang="c"> | ||
Line 1,051: | Line 1,052: | ||
} | } | ||
</source> | </source> | ||
− | =hanoi.asm= | + | =Homework 9: hanoi.asm= |
<br /> | <br /> | ||
::<source lang="asm"> | ::<source lang="asm"> | ||
Line 1,068: | Line 1,069: | ||
;;; nasm -f elf hanoi.asm | ;;; nasm -f elf hanoi.asm | ||
;;; ld -melf_i386 -o hanoi hanoi.o 231Lib.o | ;;; ld -melf_i386 -o hanoi hanoi.o 231Lib.o | ||
− | ;;; ./hanoi | + | ;;; ./hanoi 3 |
;;; | ;;; | ||
Line 1,161: | Line 1,162: | ||
popad ; get all the original parameters back | popad ; get all the original parameters back | ||
pushad ; and push them back in the stack | pushad ; and push them back in the stack | ||
− | xchg bl, dl ; exchange | + | xchg bl, dl ; exchange source and temp |
dec eax ; eax <-- n-1 | dec eax ; eax <-- n-1 | ||
call moveDisks ; recurse | call moveDisks ; recurse |