- 2068 Bhadra · 8 marks
8085 ALP: transfer with bit set/reset
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.
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.
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).
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.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- 8085 ALP: odd parity transfer with bit change · Microprocessor, chapter 2
- 8085 ALP: transfer data with more than 3 ones · Microprocessor, chapter 2
- 8085 ALP: multiplication table of a number · Microprocessor, chapter 2
- 8085 ALP: compare two tables of 16-bit data · Microprocessor, chapter 2
- 8085 ALP: exchange bits D6 and D2 · Microprocessor, chapter 2
- 8085 ALP: copy data within a range · Microprocessor, chapter 2
- 8255A at 80H: addresses, mode 0/1 words, BSR · Instrumentation II, chapter 2
- Compare switch and if-else-if ladder · Computer Programming, chapter 5 · asked 2×
- Conditional operator vs if-else; digit sum · Computer Programming, chapter 5
- Syntax of if...else · Computer Programming, chapter 5