Parity check of the bits set in each array element

In the following program example we will check each element of an array for an even or odd number of bits set to 1. If the number of set bits is even, we will save 1 in the second array; otherwise we will save 0.

Program source code

; Author: Evgeny Sergeevich Dovgopolov

src: db 2Ah, 71h, 9Ah, 1Eh, 0C9h, 56h, 0E7h, 38h, 0ADh, 0D2h
dst: db 00h, 00h, 00h, 00h, 00h , 00h, 00h , 00h, 00h , 00h

main:
    lxi     h, src     ; Load the address of the variable src into the HL register pair
    lxi     d, dst     ; Load the address of the variable dst into the DE register pair
    mvi     c, 0Ah     ; Set the loop counter C to 10

CheckLoop:
    mov     a, m       ; Copy the memory value pointed to by the HL register pair into A
    rrc                ; Rotate the value in register A one bit right without involving the CY flag
    jnc     Even       ; If C=0, then jump to the label Even

    xra     a          ; Clear register A
    jmp     Store      ; Perform an unconditional jump to the label Store

Even:
    mvi     a, 01h     ; Load the value 1 into register A

Store:
    stax    d          ; Store the value in A at the memory address pointed to by DE

    inx     h          ; Increment the HL register pair by 1
    inx     d          ; Increment the value of the DE register pair by 1
    dcr     c          ; Decrement the C counter register by 1
    jnz     CheckLoop  ; Jump to the label CheckLoop until C becomes 0

    hlt                ; Stop program execution

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".