0

So I have created a linked list in which each node is 72 bytes with first 64 bytes for string, next 4 for integer and the last 4 for address in which the number are arranged in a sorted order. The first 64 bytes are reserved for the string and now I am trying to sort strings.

I use $a0,0($t0) to print the strings. I am extremely confused how to exchange the contents of the string part of the node

This is my exchange code for the string

exchange:

            la $t8, 0($t1)
            la $t9, 0($t2)
            sw $t8, 0($t2)
            sw $t9, 0($t1)
Paras Pandey
  • 37
  • 1
  • 4
  • Well, you say yourself that the string may be up to 64 bytes, yet you only swap 4 bytes. So obviously you'll have to swap the rest of the string as well. Either that or have a field in the node that holds the address of the string, and then just swap the addresses rather than the actual data. Actually your current swap is broken because you're using `la` instead of `lw`, so what you're doing is `($t2) = t1`, instead of `($t2) = ($t1)`. – Michael May 31 '19 at 05:53
  • can you help me as to how I could swap addresses? I am new to mips and very confused with that partt – Paras Pandey May 31 '19 at 20:52
  • If your string has a null-terminator (which I assume it does) you can loop until you find a null byte on both strings and then return from your subroutine. – Minn Jun 01 '19 at 09:01

0 Answers0