6502-OS/util/parity.s65

24 lines
526 B
Plaintext
Raw Normal View History

2023-12-31 14:56:24 +01:00
.export count_set_bits
;;********************************************************************************
;; @function Initialize the PS2 keyboard
;; @details
;; Count the number of set bits in Y.
;;
2024-08-08 20:39:25 +02:00
;; @modifies A, X, Y
2023-12-31 14:56:24 +01:00
;; @returns Y: The number of set bits in the byte
;;********************************************************************************
.proc count_set_bits
2024-01-03 13:08:04 +01:00
ldx #9
2023-12-31 14:56:24 +01:00
ldy #0 ; number of set bits
@loop:
dex
beq @done
ror
bcc @loop
@set:
iny
bra @loop
@done:
rts
.endproc