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