Question: MARIE Simulator answers only. Basically i have to create a subroutine TrimString which will remove any space characters before and after a String. For example,

MARIE Simulator answers only. Basically i have to create a subroutine TrimString which will remove any space characters before and after a String. For example, where _ represents a blank, __MARIE__ becomes MARIE after trimming it.

The String has to be trimmed in 2 phases,

The first phase removes any trailing space (i.e., spaces at the end of the string).

Your code should follow these steps to achieve the result: 1. Iterate through the string, one character at a time, until you reach the end of the string (the 0 character). This is similar to how the PrintString subroutine works, just without actually printing the characters. 2. In step 1, you found the address of the nal 0 in the string. Now iterate backwards, and replace any space character (decimal 32) with a 0, until you reach a character that is not a space character, or the beginning of the string.

The second phase removes leading space characters. This approach modifies the start address of the string, up- dating it to the rst non-space character. 1. Iterate through the string, one character at a time, until you reach a character that is not the space character (decimal 32). 2. Update the start address of the string (at label TrimStringAddr) to the address you found in step 1 (the address of the first non-space character).

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!