| | |
Counting 1's in 16 bit word
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
0
#2 Oct 24th, 2009
I'm VERY VERY rusty on a 68HC12
Or branch around if carry is set and then increment inx with x=bit count
Assembly Syntax (Toggle Plain Text)
ldy #16 ;Loop 16 times Loop: asld ; Carry <- A <- B <- 0 MSB in carry psha ? ; a = Sum adda a,0 ; a=a+0+carry ? ; Sum = a pula dey bne $Loop
Or branch around if carry is set and then increment inx with x=bit count
Assembly Syntax (Toggle Plain Text)
ldy #16 ;Loop 16 times ldx #0 Loop: asld ; Carry <- A <- B <- 0 MSB in carry bcc $L1 ; Jump if bit clear inx ; 1 more bit $L1: dey bne $Loop
![]() |
Similar Threads
- Counting Occurences of a Word in a Text File (C#)
- Problems with my Nibble Swap (Java)
- Counting strings in a word (Python)
- a function that scans a word returning bits (C++)
- Word Descrambler.... (C++)
- Is my machine 32 bit machine?? (C)
Other Threads in the Assembly Forum
- Previous Thread: 80x86 Word Memory Access
- Next Thread: Simple Operating System
| Thread Tools | Search this Thread |





