;This program reverses a string.
INCLUDE Irvine32.inc
.data
aName BYTE "Abraham Lincoln",0
nameSize = ($ - aName) - 1
.code
main PROC
; Push the name on the stack.
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
; Display the name.
mov edx,OFFSET aName
call Writestring
call Crlf
exit
main ENDP
END main
I finished the first part of the problem which was making a Reverse String program but now I need to modify the program so the user can input a string containing between 1 and 50 characters. Im not to sure how to do this and was wondering if someone could help out. This is in assembly language btw
You can use
ReadString
fromirvine32.lib
. Therefor you have to changenameSize
to a variable and to increase the size ofaName
.I did it for you ;-) :