Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

assembly - How can I find how many times does 101b show in the number?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...