
March 26th, 2010, 08:34 AM
|
|
Registered User
|
|
Join Date: Mar 2010
Location: Hampshire, UK
Posts: 11
Time spent in forums: 4 h 44 m 59 sec
Reputation Power: 0
|
|
|
Shift the register through the carry bit, if the carry is set then increment another register
; assembler psuedo code (makes no assumptions about register size)
; if the register are less than 16 bits then you will have to put the test value into the accumulator in to parts or use multiple registers.
; value in to test in A
LD B,0 ; bit counter
LD C,16 ; loop counter
LOOP:
SHLC A ; shift A left through carry
JRNC NOADD
INC B ; count this bit
NOADD:
DEC C ; next bit
JRNZ LOOP
|