Mips Assembly

Using loops?

Page 1 of 1

1 Replies - 694 Views - Last Post: 17 February 2010 - 03:48 AM

#1 Guest_Mr34727*


Reputation:

Mips Assembly

Posted 17 February 2010 - 12:12 AM

I am learning Mips assembly language, and am somewhat confused on the usage of loops.

addi $t0,$0,32
loop: andi $t1,$a0,1
sub $t0,$t0,$t1
srl $a0,$a0,1
bne $a0,$0,loop
end: add $a0,$t0,$0

So this is saying (?)

# Add 32 to 0 register, put in register t0
# Put bitwise 1 and bitwise contents of $a0 into $t1
# Subtract (signed) $t1 contents from $t0 contents, put in $t0
#

From here I am alittle lost. How do the shift right and left work?


Any help on this would be greatly appreciated. thanks!

Is This A Good Question/Topic? 0

Replies To: Mips Assembly

#2 dorknexus  Icon User is offline

  • or something bad...real bad.
  • member icon

Reputation: 1189
  • View blog
  • Posts: 4,590
  • Joined: 02-May 04

Re: Mips Assembly

Posted 17 February 2010 - 03:48 AM

Each logical bitshift right is equivalent to dividing by 2. Therefore each iteration of this loop divides $a0 by two.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1