News for hackers. Stuff that matters.
Re:Counting set bits in an interesting way by mmphosis on Saturday April 30, 2022 @03:32PM (#31218565)
; http://forum.6502.org/viewtopic.php?t=1206

     LDX #$00  ; clear bit count
  loop
     ASL       ; shift a bit
     BCC skip  ; did one shift out?
     INX       ; add one to count
  skip
     BNE loop  ; repeat till zero
     RTS
Re:Counting set bits in an interesting way by mark-r on Saturday April 30, 2022 @04:15PM (#31218889)
You could remove one branch by doing add 0 with carry instead of the increment.
Re:Counting set bits in an interesting way by mmphosis on Saturday April 30, 2022 @04:53PM (#31219225)
; yes, A becomes the counter, and shift a zero page byte

  byte  EQU $EB
        STA byte
        LDA #$00
        CLC
  loop
        ADC #$00
        LSR byte
        BNE loop
        ADC #$00
        RTS