I need to find out how many times does the sequence 101b shows in a 16 bit number. But I need to find also the ones that are far away.
For example: in the number 01010101 it appears 4 times. Because 3 are part of it and the fourth one (if index 0 is the left bit) is composed of the 3 bits at index 1, 4, and 7.
Because you can relate to it as symmetrical 101b sequence.
It seems really complicated, but does it really? I think it might just be a little tricky.
I managed to find out how many times it shows regularly, like the 3 that you can see in the example number. But I don't know how can I find the symmetrical ones.
EDIT:My teacher did mean rotation and I misunderstood the problem, thanks for everyone for the help though
mov cx,15
Check:
push dx;the number that I need to check
and dx,0111b
cmp dx,101b
jne Again
Again:
pop dx
shr dx,1
loop check
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…