---
title: "8085 ALP: odd parity transfer with bit change"
subject: "Microprocessor"
chapter: 2
key: "semester_4/microprocessor:alp-8085-odd-parity-transfer"
source: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8085-odd-parity-transfer
site: BCT Engineering
---

# 8085 ALP: odd parity transfer with bit change

Microprocessor · Chapter 2: Programming with 8085 Microprocessor

- Asked in: 2069 Poush, 8 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8085-odd-parity-transfer
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-2

## Question

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.

## 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.

## Answer

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.

```asm
        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.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. How does the program test whether a byte has odd parity?
   A. CPI 51H sets P = 1 for odd parity, then JPE
   B. ORA A sets the flags without changing A; P = 1 means even parity, so JPO jumps for odd parity
   C. ANI 01H tests bit D0; if it is 1 the byte has odd parity
   D. RRC moves each bit into carry and JC counts the 1s
   Answer: B. ORA A leaves A unchanged but updates the flags. The 8085 sets P = 1 for an even number of 1s, so JPO (jump if parity odd) catches odd-parity bytes. (Key point: ORA A sets the parity flag; JPO detects odd parity (P = 0))

2. For an even-parity byte, which instructions clear bit D5 and set bit D3, and what does 03H become?
   A. ANI 0DFH then ORI 08H; 03H becomes 0BH
   B. ORI 20H then ANI 08H; 03H becomes 08H
   C. ANI 08H then ORI 0DFH; 03H becomes DFH
   D. ANI 0DFH then ORI 08H; 03H becomes 23H
   Answer: A. DFH = 1101 1111 clears only D5 when ANDed, and 08H sets only D3 when ORed. 03H AND DFH = 03H, then OR 08H = 0BH. (Key point: Clear D5 with ANI DFH, set D3 with ORI 08H)

3. Why is CPI 51H / JZ DONE placed before the parity test?
   A. Because CPI is needed to set the parity flag
   B. So that 51H is transferred and then the program stops
   C. So the program stops when it reads the end marker 51H, without transferring it
   D. Because 51H has even parity and must be modified first
   Answer: C. 51H marks the end of the data. Checking it first means the loop stops at the marker and 51H itself is never stored at the destination. (Key point: End marker 51H is tested first and not transferred)

## Related in Microprocessor

- [8085 ALP: transfer with bit set/reset](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-set-reset-bit-80h) — Microprocessor, chapter 2
- [8085 ALP: interchange two bits of bytes](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-interchange-bits) — Microprocessor, chapter 2
- [8085 ALP: transfer data with more than 3 ones](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-ones-greater-than-3) — Microprocessor, chapter 2
- [8085 ALP: compare two tables of 16-bit data](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-compare-tables-1ffffh) — Microprocessor, chapter 2
- [8085 ALP: divide two bytes](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-divide-bytes) — Microprocessor, chapter 2
- [8085 ALP: copy data within a range](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-copy-range) — Microprocessor, chapter 2

## Related in other subjects

- [Parity bits and 3-bit odd parity generator](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aparity-odd-generator-3bit) — Digital Logic, chapter 4, asked 2×
- [(4,3) even parity code is linear, odd parity is not](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Aeven-odd-parity-linear-block) — Communication Systems, chapter 8
- [C program: sum of two 8-bit BCD numbers](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-bcd-sum-c) — Embedded System, chapter 9
- [3-bit even parity generator and 4-bit checker](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Aparity-generator-checker) — Digital Logic, chapter 4
