Skip to main content

8085 ALP: odd parity transfer with bit change

Short answer

Check for end marker 51H (not transferred). Use ORA A and JPO to detect odd parity: copy byte unchanged if odd; else clear bit D5 (AND DFH) and set bit D3 (OR 08H) then store. Example: 07H stays 07H, 03H becomes 0BH.

Write a program in 8085 to transfer bytes of data with odd parity from location 9205H to A200H, else transfer the data by clearing bit D5 and setting bit D3. The end of the data bytes is indicated by 51H in the data.

A byte has odd parity when it contains an odd number of 1s. After ORA A the 8085 parity flag P = 1 for even parity, so JPO (jump if parity odd) detects odd parity. The end marker 51H is tested first and is not transferred.

Algorithm

  1. HL → 9205H (source), DE → A200H (destination).
  2. Read a byte; if it equals 51H, stop.
  3. Test parity (ORA A). If odd, store it unchanged.
  4. If even, clear D5 (AND with DFH = 1101 1111) and set D3 (OR with 08H), then store.
  5. Advance both pointers and repeat.
        LXI  H,9205H      ; HL = source pointer
        LXI  D,0A200H     ; DE = destination pointer
NEXT:   MOV  A,M          ; get data byte
        CPI  51H          ; end of data?
        JZ   DONE         ; yes -> stop (51H is not transferred)
        ORA  A            ; set flags, P=1 for even parity
        JPO  STORE        ; odd parity -> transfer unchanged
        ANI  0DFH         ; even parity: clear bit D5
        ORI  08H          ; and set bit D3
STORE:  STAX D            ; store byte at destination
        INX  H            ; next source byte
        INX  D            ; next destination location
        JMP  NEXT
DONE:   HLT

Example: 07H (three 1s, odd) is copied as 07H. 03H (two 1s, even) becomes 03H AND DFH = 03H, OR 08H = 0BH. 20H (one 1, odd) is copied as 20H.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Microprocessor chapter 2 questions →