Title 스택의 활용
INCLUDE Irvine32.inc
.data
inputStr BYTE "Enter Your Name : ",0
resultStr BYTE "Reverse String : ",0
aName BYTE 80 DUP(?)
byteCount DWORD ?
nameSize = ($ - aName) - 1
.code
main PROC
;이름 입력
mov edx,OFFSET inputStr
call WriteString
;이름 입력
mov edx, offset aName
mov ecx, sizeof aName
call ReadString
mov byteCount, eax
call Crlf
; 스택에 푸시
mov ecx,nameSize
mov esi,0
L1:
movzx eax, aName[esi]; get character
push eax; push on stack
inc esi
Loop L1
; Pop the name from the stack, in reverse,
; and store in the aName array.
mov ecx,nameSize
mov esi,0
L2:
pop eax; get character
mov aName[esi], al; store in string
inc esi
Loop L2
mov edx,OFFSET resultStr
call WriteString
mov edx, offset aName
call WriteString
mov edx, OFFSET aName
call WriteString
mov edx, offset aName
mov ecx, LENGTHOF aName
call ReadString
mov byteCount, eax
call Crlf
exit
main ENDP
END main