Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,405 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,471 people online right now. Registration is fast and FREE... Join Now!




Reversing a words bit sequence in MIPS assembly language

 
Reply to this topicStart new topic

Reversing a words bit sequence in MIPS assembly language

enpey
1 Sep, 2008 - 04:12 AM
Post #1

D.I.C Head
**

Joined: 2 May, 2007
Posts: 59



Thanked: 1 times
My Contributions
Hi all,

I am having some trouble getting a bit sequence reversal procedure up and running in MIPS. Our requirement is that it needs to be done using logical commands (sll, and, xor etc), ie without arithmetic.

The way I am thinking at the moment is masking to obtain the bit I want, then shifting it. However, I am getting stuck with how to shift the bit the required amount (And the direction).
Below is shown what I am thinking, with the line I am unsure of is commented with "THIS LINE HERE".
What I would like to do is be able to automatically shift the bit by an amount determined by what position it is in.
Comments relate to first run through (That is, incorrect after "b loop" is executed).

CODE


add $t0, $zer0, $zero # $t0 = 0
addi $t0, 1 # setting $t0 to 1(base_ten)
lw    $t1, memory_loc # loading word into $t0
loop:
and $t2, $t1, $t0 # isolate bit in 0 position
sll $t2,31 # THIS LINE HERE
sll $t0, 1 # shifts bit left by one position in $t0, now $t0 = 2(base_ten)
b loop


Any help would be greatly appreciated,
enpey
User is offlineProfile CardPM
+Quote Post

enpey
RE: Reversing A Words Bit Sequence In MIPS Assembly Language
4 Sep, 2008 - 06:10 PM
Post #2

D.I.C Head
**

Joined: 2 May, 2007
Posts: 59



Thanked: 1 times
My Contributions
No worries.

Got it solved
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:56AM

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