Files
Z8C-Homebrew-Computer/OperatingSystem/monitor_v2/include/parity.s
Dennis Gunia bc1b9a399d Updated
2022-12-16 20:45:34 +01:00

16 lines
413 B
ArmAsm

; a contains data
; bc destroied
; carry is set if odd, reset if even
calc_parity:
ld c,0 ;parity data
ld b,8 ;bit counter
calc_parity_loop:
rrca
jr nc,calc_parity_loop_2 ;if not zero then skip increment
inc c
calc_parity_loop_2:
djnz calc_parity_loop
ld a,c
rra ;carry is set to bit 0 of high-counter.
;if bit1 is set -> odd # of 1s else even # of 1s
ret