go to previous page   go to home page   go to next page

Answer:

The text segment.

Reversing a String

Traditionally a segment of machine instructions is called "text". It becomes a "process" when it starts executing. (This is analogous to the phrase "text of a play" and "performance of a play").

Here is a classic example of using a stack. The user enters a string, then the program reverses the string and writes it out. To understand how the program works inspect the following diagram. The string "Hello" is pushed onto the stack, character by character, starting with the 'H'. Then the characters are popped from the stack back into the original string buffer. The last character pushed is the first one out. This reverses the order of the characters.

stack of characters

We will always push and pop full words (four bytes). Each character on the stack will be contained in the low order byte of a fullword.

QUESTION 10:

(Review: ) What does the following instruction do? lbu $t0,string