User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 456,494 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,690 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 2292 | Replies: 7
Reply
Join Date: Sep 2007
Posts: 12
Reputation: -EquinoX- is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
-EquinoX- -EquinoX- is offline Offline
Newbie Poster

MIPS printing integer problem

  #1  
Sep 22nd, 2007
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??
Last edited by -EquinoX- : Sep 22nd, 2007 at 11:29 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: MIPS printing integer problem

  #2  
Sep 22nd, 2007
What about it?

Use the appropriate instruction to load a half word, and increment your address pointer by 2 rather than 4.
Reply With Quote  
Join Date: Sep 2007
Posts: 12
Reputation: -EquinoX- is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
-EquinoX- -EquinoX- is offline Offline
Newbie Poster

Re: MIPS printing integer problem

  #3  
Sep 22nd, 2007
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
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: MIPS printing integer problem

  #4  
Sep 22nd, 2007
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.
Reply With Quote  
Join Date: Sep 2007
Posts: 12
Reputation: -EquinoX- is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
-EquinoX- -EquinoX- is offline Offline
Newbie Poster

Re: MIPS printing integer problem

  #5  
Sep 22nd, 2007
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?
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: MIPS printing integer problem

  #6  
Sep 23rd, 2007
> 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
Reply With Quote  
Join Date: Sep 2007
Posts: 12
Reputation: -EquinoX- is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
-EquinoX- -EquinoX- is offline Offline
Newbie Poster

Re: MIPS printing integer problem

  #7  
Sep 24th, 2007
Originally Posted by Salem View Post
> 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??
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: MIPS printing integer problem

  #8  
Sep 24th, 2007
> 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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 3:22 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC