Comparing strings in MIPS assembly?

If it were me, I'd create a list of pointers to the strings. That is, a list of the addresses of each string. Then you'd write a subroutine the compares two strings given their pointers.

Then, when you need to swap the strings, you simply swap the actual pointers You want to avoid swapping the strings themselves, since they may well be tightly packed, thus you'd have to do a lot of shifting to move the holes of memory around. Pointers are simple to swap. You could swap strings more easily if they were all of a fixed length (or less), then you wouldn't have to worry about moving the memory holes around But sorting the pointer list is really the hot tip To compare strings, the simplest way is to iterate over each character of each string, and subtract them from each other.

If the result is 0, they're equal. If not, then if the result is > 0, then the first string is before the other string, otherwise the second string is lower and you would swap them. If you run out of either string before the other, and they're equal all the way to that point, the shorter string is less than the longer one.

If it were me, I'd create a list of pointers to the strings. That is, a list of the addresses of each string. Then you'd write a subroutine the compares two strings given their pointers.

Then, when you need to swap the strings, you simply swap the actual pointers. You want to avoid swapping the strings themselves, since they may well be tightly packed, thus you'd have to do a lot of shifting to move the holes of memory around. Pointers are simple to swap.

You could swap strings more easily if they were all of a fixed length (or less), then you wouldn't have to worry about moving the memory holes around. But sorting the pointer list is really the hot tip. To compare strings, the simplest way is to iterate over each character of each string, and subtract them from each other.

If the result is 0, they're equal. If not, then if the result is > 0, then the first string is before the other string, otherwise the second string is lower and you would swap them. If you run out of either string before the other, and they're equal all the way to that point, the shorter string is less than the longer one.

I'm using the align directive for each string, meaning that I use . Align 5 for each string so they are essentially fixed length. – James Smith Oct 12 at 4:39 @James Smith, that is an incorrect assumption.

– Sparafusile Oct 12 at 17:32.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions