I need to write a program where the user input their name, the program will tell them 'Hello,' and then show the user's name backwards.
This is what I have:
INCLUDE Irvine32.inc .data pleaseEnter BYTE 'Please enter your name: ', 0 StringName BYTE 30 DUP(0) yourName BYTE 'Hello, ', 0 StringReversed BYTE 30 DUP(0) reverseName BYTE 'Here is your name backwards: ', 0 StringSize = ($ - StringReversed) - 1 .code main PROC mov edx, OFFSET pleaseEnter call WriteString mov edx, OFFSET StringName mov ecx, SIZEOF StringName - 1 call ReadString call CRLF mov edx, OFFSET yourName call WriteString mov edx, OFFSET Stringname call WriteString call CRLF call CRLF mov edx, OFFSET reverseName call WriteString mov ecx, StringSize mov esi, 0 L1: movzx eax, StringName[esi] push eax inc esi Loop L1 mov ecx, StringSize mov esi, 0 L2: pop eax mov StringReversed[esi], al inc esi Loop L2 mov edx,OFFSET StringName call WriteString call CRLF exit main ENDP END main
Everything works, except where it should reverse the name.
I've played around with the program several times, but it either ends up where the name is shown normally, with the 'Here is your name backwards: ' written backwards, with the space after that statement kept blank, among other problems.
I know it is a simple overall mistake, but I keep missing it.
I'm more used to C#, so it confuses me.