Created
November 11, 2009 15:17
-
-
Save dannvix/232018 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TITLE Reversing a String | |
INCLUDE Irvine32.inc | |
.data | |
buffer BYTE 100 DUP(0) | |
byteCount DWORD ? | |
.code | |
main PROC | |
; Read string from stdin | |
mov edx, OFFSET buffer | |
mov ecx, SIZEOF buffer | |
call ReadString | |
mov byteCount, eax | |
; Push the string into stack | |
mov ecx, eax | |
mov esi, 0 | |
Push: | |
movzx eax, buffer[esi] | |
push eax | |
inc esi | |
loop Push | |
; Pop the string from stack, in reverse | |
mov ecx, byteCount | |
mov esi, 0 | |
Pop: | |
pop eax | |
mov buffer[esi], al | |
inc esi | |
loop L2 | |
; Print the string to stdout | |
mov edx, OFFSET buffer | |
call WriteString | |
call Crlf | |
exit | |
main ENDP | |
END main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment