Welcome to Dream.In.Code
Become an Expert!

Join 149,606 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,904 people online right now. Registration is fast and FREE... Join Now!




MIPS Printing Integer from a 2-byte integer

 
Reply to this topicStart new topic

MIPS Printing Integer from a 2-byte integer

EquinoX
22 Sep, 2007 - 06:44 AM
Post #1

D.I.C Head
**

Joined: 19 Jan, 2007
Posts: 63


My Contributions
So say I have an array which is like this:

CODE

.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??
User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: MIPS Printing Integer From A 2-byte Integer
22 Sep, 2007 - 07:22 AM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
what does it currently display?
it shouldn't matter that much, eg:
2 byte: 11111111 11111111
4 byte: 00000000 00000000 11111111 11111111

as long as the value fits in 2 bytes.

would this help you by chance?
get the leading bit and clear it (and 0)
shift in the leading bit, shift in a 2 byte 0 (15, not all 16 for the leading bit) value, then shift your 2 byte integer (all 16)
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 11:58PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month