#include <P16F877A.inc>
num1 equ 0x30
count equ 0x40
result equ 0x50
oddparity equ 0x51
evenparity equ 0x52
org 0x00
clrf result
clrf oddparity
clrf evenparity
movlw 0xA7
movwf num1
movlw 0x08
movwf count
loop:
btfsc num1,0 ; Check LSB of num1
incf result ; Increment result if bit is 1
rrf num1,1 ; Rotate right num1
decfsz count,1 ; Decrement count
goto loop ; Repeat until count is zero
btfsc result,0 ; If result LSB is 1 (odd number of 1s)
incf oddparity ; Increment odd parity
btfss result,0 ; If result LSB is 0 (even number of 1s)
incf evenparity ; Increment even parity
l1: goto l1 ; Infinite loop
end