Hi,
I have an array of two string elements. Is it possible to store these two elements as one element in a register?

Thanks.

Sure, if you have enough room. For example, you can store two 8-bit values in a single 16-bit register. (By "string elements" do you mean "characters"?)

A better question, though, is why do you want to do this? It doesn't sound safe.

Sure, if you have enough room. For example, you can store two 8-bit values in a single 16-bit register. (By "string elements" do you mean "characters"?)

A better question, though, is why do you want to do this? It doesn't sound safe.

Thanks for your reply. I am concatenating strings, I have only being using mips these past few days so maybe it is not the best way of going about it.

A string is way too large to hold in a single register.

Remember, a register holds the address of a string somewhere else in memory. So to concatenate two strings you need two addresses. Find the end of the target string (by modifying the address to point to the end), then copy the characters from the source addresses to the target addresses.

Hope this helps.

A string is way too large to hold in a single register.

Remember, a register holds the address of a string somewhere else in memory. So to concatenate two strings you need two addresses. Find the end of the target string (by modifying the address to point to the end), then copy the characters from the source addresses to the target addresses.

Hope this helps.

Thanks for your help, I'll give it a go!

This article has been dead for over six months. Start a new discussion instead.