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!
Mips AssemblyUsing loops?
Page 1 of 1
1 Replies - 694 Views - Last Post: 17 February 2010 - 03:48 AM
Replies To: Mips Assembly
#2
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.
Page 1 of 1
|
|

New Topic/Question
Reply
MultiQuote







|