Question

Given a string let's say "Long Numbers" when I plug this in a ASCII calculator I am given this

0x4c 0x6f 0x6e 0x67 0x4e 0x75 0x6d 0x62 0x65 0x72 0x73

and

1001100110111111011101100111 1001110111010111011011100010110010111100101110011

It's my first time using MIPS and I can't find a guide only that teaches how to work with this.

So, I am given 32 bits but it seems that "Long Numbers" is way more that 32 bits? So lets say "Long Numbers" is in memory.

If I wanted to print "Long Numbers", how will that work?

I'm confused about address and data bus, data transfer if it's more than a BYTE, and how it would print since doesn't print only take one address in memory?

I know how to data gets transferred if it's only a BYTE. If more than that I get confused.

Was it helpful?

Solution

I think the issue is understanding how data is actually stored in memory, as opposed to how it's abstracted when using a high-level language. From your confusion over how the string is stored in memory, I think that's where you should start.

At the level you're operating on in MIPS, there is no "string" (only Zuul). There's not really an "int" or a "float" in the way you're used to thinking of them, either. There's just bits (1/0) which are grouped together in standard ways to compose the data types you're used to using. For reasons your professor will be telling you about, we use groups of 8 bits, which we call a "byte".

Each of those characters in your string can be represented in a byte. Take a look at http://www.asciitable.com/ to see the standard for how that is done. So the 'L' is represented by a string of bits that corresponds to the hex value 0x4c, which just happens to be decimal value 76.

That value is stored in a single byte in RAM. The next letter ('o', represented by hex value 0x6f) is stored in the next sequential byte. The next letter is stored in the next byte, all the way through the last one. If you had to come up with a name for that chain of sequential bytes, you might call it a "string" of characters. :)

As @Michael said, you need to know that a zero-terminated ASCII string (also called an ASCIIZ string) has an additional character at the end. That character is represented by hex value 0x00 (plain old zero), and you'll see it referenced as '\0'.

One other thing. You need to find a better ASCII-to-Hex translation tool. The one you used didn't treat the "space" character correctly. A space corresponds to ASCII character 0x20 (decimal 32). If you leave it out, your string is "LongNumbers". If you try putting 0x00 in there, your string will end after "Long".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top