Okay so say I have an array which is like this:

.data

values:
      .half -17
      .half  16
      .half 153

and I want to print it as

-17
16
153


How do I do this?? If it is stored in a 4 byte of integer then it would be very easy to do, but not it's stored as a 2-byte integer.

In a 4 -byte integer I just quadruple starting from the first array address and then print the array, but how about this one?? Can someone help me??

What about it?

Use the appropriate instruction to load a half word, and increment your address pointer by 2 rather than 4.

Okay I happen to fix this problem, but now how do I represent the number to ASCII characters?? Is there any particular instructions in MIPS that will allow me to do this? Thanks

Do you have access to a library function which does it for you, or are you supposed to roll your own code and just use an OS 'output character' function?

It's just divide by 10 and modulo 10 in a loop.

no, I am not able to use a function or any such thing. I am asked to write my own code??

What do you mean divide by 10 and modulo 10 in a loop?? When will the loop stop? Can you give me an example? Say that I have a number 65, how do I get an A from that?

> Say that I have a number 65, how do I get an A from that?
I thought you wanted to turn 17 into "17"

> What do you mean divide by 10 and modulo 10 in a loop?
As in if you have 123, then /10 gives you 12 and %10 gives you 3
Then you do the same thing with 12
And you stop when you get to 0

> Say that I have a number 65, how do I get an A from that?
I thought you wanted to turn 17 into "17"

> What do you mean divide by 10 and modulo 10 in a loop?
As in if you have 123, then /10 gives you 12 and %10 gives you 3
Then you do the same thing with 12
And you stop when you get to 0

OK so how do I print the ASCII characters then?? how do I turn 65 to an A?? I still don't get what you mean by divide and modulo, say that I finish that step.. what am I suppose to do? Print the remainder or what??

> how do I turn 65 to an A?
Well if you imagine some character output function, then
outch 65 and outch 'A' will do the same thing where the system uses the ASCII character set.

> Print the remainder or what??
Yes, print the remainder.

Of course, you'll then notice that the number is printed out in reverse, but let's get the first step sorted out OK.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.