Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Title flipTest
- INCLUDE Irvine32.inc
- ;################################################
- SwapIt PROTO :DWORD,:DWORD
- stringLengthProc PROTO :DWORD
- ;################################################
- .data
- mes1 BYTE "Enter a 5 digit string: ",0
- inName DWORD 3 dup(0)
- math1 BYTE 2
- lpString:DWORD
- dwLength:DWORD
- ;################################################
- .code
- ;************************************************
- getNameProc PROC
- push edx
- mov edx,offset mes1
- call WriteString
- mov edx,offset inName
- mov ecx, sizeof inName
- call ReadString
- pop edx
- ret
- getNameProc ENDP
- ;************************************************
- ;stringLengthProc PROC lpString:DWORD
- ;returns the string length in EAX
- push ecx
- push edi
- mov al,0
- mov ecx,-1
- mov edi,lpString
- repnz scasb
- mov eax,-2
- sub eax,ecx
- pop edi
- pop ecx
- call SwapIt offset inName,eax
- ret
- stringLengthProc ENDP
- ;************************************************
- SwapIt PROC
- push ecx
- push edx
- mov ecx,dwLength
- mov edx,lpString
- dec ecx
- add ecx,edx
- jmp short SwpIt1
- SwpIt0: mov al,[edx]
- mov ah,[ecx]
- mov [ecx],al
- mov [edx],ah
- dec ecx
- inc edx
- SwpIt1: cmp ecx,edx
- ja SwpIt0
- pop edx
- pop ecx
- ret
- SwapIt ENDP
- ;************************************************
- main PROC
- call getNameProc
- INVOKE stringLengthProc,offset inName
- ; INVOKE SwapIt,offset inName,eax
- mov edx,offset inName
- call WriteString
- call Crlf
- exit
- main ENDP
- ;################################################
- END main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement