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

# 8085 ALP: transfer with bit set/reset

Microprocessor · Chapter 2: Programming with 8085 Microprocessor

- Asked in: 2068 Bhadra, 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-set-reset-bit-80h
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-2

## Question

Write a program in 8085 to transfer 8-bit number from one table to other by setting bit D5 if the number is less than 80H else transfer the number by resetting bit D6.

## Short answer

Compare each byte with 80H. If less (carry set), set bit D5 with ORI 20H; otherwise reset bit D6 with ANI BFH. Transfer ten numbers to a second table. Example: 12H becomes 32H, C5H becomes 85H.

## Answer

Compare each number with 80H using `CPI 80H`: carry is set when the number is less than 80H. If less, set D5 (OR with 20H); otherwise reset D6 (AND with BFH = 1011 1111). Then store it in the second table.

**Assumptions:** the table has 10 numbers; source table at 2000H, destination at 3000H (any addresses can be used).

```asm
        LXI  H,2000H      ; HL = source table
        LXI  D,3000H      ; DE = destination table
        MVI  C,0AH        ; number of bytes = 10
NEXT:   MOV  A,M          ; A = number
        CPI  80H          ; compare with 80H (A - 80H)
        JC   LESS         ; CY=1 -> number < 80H
        ANI  0BFH         ; number >= 80H : reset bit D6
        JMP  STORE
LESS:   ORI  20H          ; number < 80H : set bit D5
STORE:  STAX D            ; store into second table
        INX  H            ; next source byte
        INX  D            ; next destination byte
        DCR  C            ; decrement counter
        JNZ  NEXT         ; loop until all bytes are done
        HLT
```

**Examples:** 12H (< 80H) becomes 12H OR 20H = 32H. C5H (≥ 80H) becomes C5H AND BFH = 85H.

## Check yourself

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

1. After CPI 80H, how does the program know the number is less than 80H?
   A. Z = 1
   B. CY = 1
   C. S = 0
   D. CY = 0
   Answer: B. CPI computes A - 80H without storing it. A borrow (CY = 1) means A was less than 80H, so JC goes to LESS. (Key point: CPI 80H sets CY when the number is less than 80H)

2. Which pair of instructions sets bit D5 and resets bit D6?
   A. Set D5: ANI 20H; reset D6: ORI BFH
   B. Set D5: ORI 10H; reset D6: ANI 7FH
   C. Set D5: XRI 20H; reset D6: XRI 40H
   D. Set D5: ORI 20H; reset D6: ANI BFH
   Answer: D. OR with 20H (0010 0000) forces D5 to 1. AND with BFH (1011 1111) forces D6 to 0 and keeps all other bits. (Key point: Set D5 with ORI 20H; reset D6 with ANI BFH)

3. The source number is C5H. What is stored in the second table?
   A. 85H
   B. E5H
   C. C5H
   D. 45H
   Answer: A. C5H is not less than 80H, so D6 is reset: C5H AND BFH = 85H. E5H would be setting D5, which is only for numbers below 80H. (Key point: Number >= 80H: reset D6 (C5H becomes 85H))

## Related in Microprocessor

- [8085 ALP: odd parity transfer with bit change](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-odd-parity-transfer) — 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: multiplication table of a number](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-multiplication-table) — 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: exchange bits D6 and D2](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-exchange-d6-d2) — 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

- [8255A at 80H: addresses, mode 0/1 words, BSR](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-80h-addresses-control) — Instrumentation II, chapter 2
- [Compare switch and if-else-if ladder](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aswitch-vs-ifelse-ladder) — Computer Programming, chapter 5, asked 2×
- [Conditional operator vs if-else; digit sum](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aconditional-operator-vs-ifelse) — Computer Programming, chapter 5
- [Syntax of if...else](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Asyntax-if-else) — Computer Programming, chapter 5
