Given to write a program to find in how many ways can a 32 bit number be rotated to give the same number.
mov R0, 1431655765
mov R6,R0
mov R5,31
mov R4,0
.loop :
cmp R5,0
beq .exit
lsl R2,R0,31
lsr R0,R0,1
sub R5,R5,1
or R0,R0,R2
cmp R6,R0
beq .inc
b .loop
.inc :
add R4,R4,1
b .loop
.exit:
.print R4
Though I get 0 as the answer always.Is there some error in my logic?
Here the .print instruction prints the value in a register. lsl is logical left shift lsr is logical right shift b is unconditional branching beq is branch if equal to