어셈블리어 하노이탑 관련 소스 문제입니다..ㅠㅠ
include irvine32.inc
.data
cnt dd 0
n dd 0
mains byte "하노이탑에서 옮기려는 원반의 수는?? : ",0
s1 byte ": 말뚝 ",0
s2 byte "에서 말뚝 ",0
s3 byte "로 원반 ",0
s4 byte "을 이동",0
from Dword ?
to dword ?
temp dword ?
from2 dword ?
to2 dword ?
temp2 dword ?
count dd 0
.code
main proc
mov edx,offset mains
call writestring
call readint
mov n,eax
mov from,'A'
mov temp,'B'
mov to,'C'
; mov ecx,5
call hanoi
exit
main endp
hanoi proc
; mov count,ecx
; .if(ecx==0)
; exit
; .endif
.if(n==1)
inc cnt
mov eax,cnt
call writeint
mov edx,offset s1
call writestring
mov edx,offset from
call writestring
mov edx,offset s2
call writestring
mov edx,offset to
call writestring
mov edx,offset s3
call writestring
mov eax,1
call writeint
mov edx,offset s4
call writestring
.else
mov eax,from
mov ebx,to
mov edx,temp
mov from2,eax
mov temp2,ebx
mov to2,edx
dec n
call hanoi
inc cnt
mov eax,cnt
call writeint
mov edx,offset s1
call writestring
mov edx,offset from
call writestring
mov edx,offset s2
call writestring
mov edx,offset to
call writestring
mov edx,offset s3
call writestring
mov eax,n
call writeint
mov edx,offset s4
call writestring
mov eax,temp
mov ebx,to
mov edx,from
mov from2,eax
mov temp2,ebx
mov to2,edx
call hanoi
.endif
; mov ecx,count
hanoi endp
end main
이거를 실행시키면 1까지만 돌고 그 이후부터는 오류창 뜨면서 실행이 안되네요..
C소스를 바탕으로 어셈으로 제가 작성한것이다만 상담을 해보니 메모리 관련으로 오버되었다고만 가르쳐 주시고...
ㅠㅠ
아직 스스로 하기엔 부족한 실력인지라 도움을 요청해봅니다.
내일 당장에 발표인데 이거 어떻게 해야할지 난감할 따름이네요..ㅠㅠ 부탁드립니다..
댓글 달기