Question: ASM using the Irvine Library: Create an empty string (null terminated array of characters) that will hold up to 50 BYTES. Prompt the user to

ASM using the Irvine Library: Create an empty string (null terminated array of characters) that will hold up to 50 BYTES. Prompt the user to input a string and store their input into the empty string you created. Use a loop and indirect addressing to reverse the elements of the string in place.

Do not copy the elements to any other array. Use the StrLen procedure found in the Irvine library to make the program as flexible as possible. This will allow for the size of the string to be easily changed in the future. In other words do NOT simply hard code a value of 50. You must compute the size of the string.

To use the strlen procedure you place the offset of the string in the edx register as you would with the WriteString procedure. After calling the StrLen procedure the size of the string will be in the eax register.

Once you have reversed the string inline output it to the screen using the WriteString procedure.

Commenting:

You are required to comment every line of code you write. Failure to comment will force a grade reduction of 25%

A Strategy For Solving Problem

This problem asks you to reverse a string inline. This means that you are not supposed to copy characters to another string or array. The best way to approach this is to have addressing that will refer to the first character in the string and addressing that will refer to the last character in the string. You simply swap the characters and each location then increment the address at the front and decrement the address at the end.

There are a couple of ways to determine how much to loop. The first way is to simply divide the length of the string in half. The second way involves checking to see if the address of the end becomes less than or equal to the address at the beginning. Since we haven't covered decisions yet you should probably just divide the length of the string by two.

Division

We haven't really covered division yet but it is a pretty simple thing to do.

move into the eax the value you want divided

move into another register that value you want to divide by.

Then simply use div:

The result will be in the eax and the remainder will be in the edx.

Here is an example

mov edx, 0

mov eax 20

mov ecx, 3

div ecx ;Divide eax by 3

eax will have 6 and the the edx will have 2. 20 / 3 is 6 with a remainder of two.

When you are finished your program should run like this:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!