News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Bit combinations

Started by smertniki, January 12, 2010, 09:35:32 PM

Previous topic - Next topic

dedndave

QuoteCradle snatcher...

she's the best thing in my life
the only good luck i have ever had   :bg

WryBugz

Quote from: dedndave on January 13, 2010, 09:11:13 PM
QuoteCradle snatcher...

she's the best thing in my life
the only good luck i have ever had   :bg

The miracle is not the age. The miracle is that they tolerate us.

smertniki

Dave,

I modified the range to various bigger values and the code ran perfectly, but when I expanded the size of the combinations to 3 - C0000000h, the code entered in a infinite loop.
How would the hex values to generate, let's say: combinations(25,5) - 53.130?

Regards,

dedndave

the limit value in ECX should be 10000000h for 3 bits width

in order to do more than 2 set bits, you are going to have to play some tricks
you do have another register to use (EDI) - so that could be used to get 3 set bits with another inner loop
after that, it is going to be a different routine altogether, because the simplicity gets lost - lol

if you want a routine that can generate all kinds of combinations, i might be inclined to try a recursive routine
that is a subroutine that calls itself
that is a little bit of an advanced technique for a beginner, though   :P

another approach (that isn't as pretty), would be to set up a counter and test the bit count
that is not as fast, but the code would be fairly easy to write

the question that pops into my head is - what are you going to do with the result data
how it is to be used may help determine the approach