Question
I need to create a code in assembly that will READ AN IMPUT FROM THE USER and reverse the string using an array as you
I need to create a code in assembly that will READ AN IMPUT FROM THE USER and reverse the string using an array as you can see being called in my code below. The purpose of the array is so the program knows which character to swap with which character in the loop called afterward. First with Last, Second to Second to the last, etc.. For example if the user imputs "Hello" output is "olleH"; "abcdef" outputs "fedcba"... etc. Please do not give me a a different version of your own type of code. I would like my variables and calls to remain the same and simply have my code fixed and additional comments if applicable to get a better way of learning. Thank you.
Here is my code so far: -----------------------------------------------------------------------------------------------------------------------
INCLUDE Irvine32.inc
.data MAX = 80 myString BYTE MAX+1 DUP (?) myLength DWORD ? numLoops DWORD ?
.code Main PROC call Clrscr
mov edx,OFFSET myString ;buffer size -1 mov ecx,MAX call ReadString call StrLength ;stores string length in eax
mov myLength,eax
xor edx,edx mov ebx,2 div ebx
mov numLoops,eax ;ebx is left, edx is right, ecx current mov ebx,OFFSET myString mov edx,OFFSET myString add edx,myLength dec edx
mov ecx,numLoops
L1: mov eax,0 mov al,[numLoops] mov [eax],al dec numLoops inc eax call WriteString call Crlf
;inc ebx ;dec edx loop L1 mov numLoops,OFFSET myString mov ebx, 1 mov ecx, myLength-ebx call DumpRegs exit main ENDP
END main ------------------------------------------------------------------------------------------------
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started