LINUX.ORG.RU

История изменений

Исправление qulinxao, (текущая версия) :

в выше упомянутой ссылке (Быстро посчитать число ненулевых битов в uint32_t? (комментарий))

«was first published by Peter Wegner in CACM 3 (1960), 322. :

для святой ibm704

LXA ZERO,2    IR2 counts number of ones and is initializedto zero
LXA NBITS,1   NBITS containsthe number of bitsin a machine word
LDQ WORD      Load word whose ones are to be countedinto the MQ
TQP *+2       Test MQ Plus
TXI *+I,2,1   Count ones in IR2
RQL 1         Rotate MQ left
TIX *-3,1,1 Index and trransfer ifIRI > 1

There isan alternateand oftenfastermethod of counting ones where the number of instructionsexecuted depends not on the number of bitsin a machine word, but directly on the number of ones in the word tested.The method depends on the fact that ifone is subtractedfrom the least significanthitof a positivebinary number N and the logical AND operationisperformed on the numbers N and N- 1,then the resulting number has one less one in it, the least significant one having been eliminated.

Исходная версия qulinxao, :

в выше упомянутой ссылке (Быстро посчитать число ненулевых битов в uint32_t? (комментарий))

«was first published by Peter Wegner in CACM 3 (1960), 322. :

для святой ibm704

LXA ZERO,2    IR2 counts number of ones and is initializedto zero
LXA NBITS,1   NBITS containsthe number of bitsin a machine word
LDQ WORD      Load word whose ones are to be countedinto the MQ
TQP *+2       Test MQ Plus
TXI *+I,2,1   Count ones in IR2
RQL 1         Rotate MQ left
TIX *-3,1,1 Index and trransfer ifIRI > 1

There isan alternateand oftenfastermethod of counting ones where the number of instructionsexecuted depends not on the number of bitsin a machine word, but directly on the number of ones in the word tested.The method depends on the fact that ifone is subtractedfrom the least significanthitof a positivebinary number N and the logical AND operationisperformed on the numbers N and N- 1,then the resultingmmd)er has one lessone in it,the l(,as~

significantone having been eliminated.