Question: Write an assembly program that reverses a string ( maximum length 1 5 ) . Sample Output: Enter a string : Hello The reversed string
Write an assembly program that reverses a string maximum length Sample Output:
Enter a string :
Hello
The reversed string is:
olleH
Hint:
Remember that when a StringBuffer is stored in memory, two additional bytes are included. The first byte
indicates the maximum capacity of the StringBuffer, and the second byte indicates how many characters
the user actually inputted.
Using the instruction LEA, you can obtain the address of the first byte of the StringBuffer that indicates
the maximum capacity. Increasing that address by one will point to the second byte, which is the byte that
indicates how many characters the user actually inputted. If you increase it one more time, you will point
to the first character of the StringBuffer.
For this exercise, your objective is to find how to reference the last character and start printing backward
until you reach the first character. The equivalent Java code appears as follows:
String myStrBr "Hello";
forint i myStrBrlength; i ; i
System.out.printlnmyStrBrcharAti;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
