Sign in to follow this  
l jsym l

Question in Assembly Language

Recommended Posts

Hey, I have to write a program, and yes it is for a class, that just reverses a string using a Palindrome. I was just wondering if anyone could help me understand how to make my call to ReadString write into my BYTE buffer.

I call ReadString and for some reason its not writing it into the data i want it to. I understand if no one wants to help me because it is for a class but I was just wondering. I understand how to do most of this I just must be missing a statement or two?

I'm just confused...thank you much.

TITLE Palindrome    (Palindrome.asm)

; Palindrome.asm -- Create a program that gets a sentence from the user.
; The program then uses a stack to reverse the string and print
; the reversed string out.


CR EQU 0Dh ; ASCII Carriage Return Character
LF EQU 0Ah ; ASCII Line Feed Character
EOS EQU 0h ; Zero-terminated

strPrompt BYTE "Please enter a string to be reversed...", CR, LF, EOS
buffer BYTE 20 DUP( "#" ), EOS
target BYTE ?

main PROC

; procedure to get input
mov edx, OFFSET strPrompt ;print heading
call WriteString
call getInput
call showOutput

main ENDP

getInput PROC


mov edx, OFFSET buffer
mov ecx, SIZEOF buffer
call ReadString

mov esi, 0

movzx eax, buffer[esi]
push eax
inc esi
;call DumpRegs
loop L1

mov ecx, SIZEOF buffer
mov esi, 0

pop eax
mov buffer[esi], al
inc esi
loop L2

getInput ENDP
showOutput PROC


;print reversed string
mov edx, OFFSET buffer
call WriteString

showOutput ENDP
END main ;ends with main as starting procedure

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this