Jump to content
  • Advertisement
Sign in to follow this  
l jsym l

Question in Assembly Language

This topic is 2778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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.


INCLUDE Irvine32.inc

.data
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 ?


.code
main PROC

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




exit
main ENDP

;--------------------------------------------------------------------------------------------------
getInput PROC

.data


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


mov esi, 0

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


mov ecx, SIZEOF buffer
mov esi, 0

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



ret
getInput ENDP
;--------------------------------------------------------------------------------------------------------------
showOutput PROC

.data


.code
;print reversed string
mov edx, OFFSET buffer
call WriteString


ret
showOutput ENDP
END main ;ends with main as starting procedure

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!