PadhaikoAll subjects

Past exam question: 2081 Chaitra (Regular), Q3

Microprocessors · 6 marks

Open in the Padhaiko app

Topic: 8085 Programs: Arithmetic, Loops, Arrays, BCD, Multiply/Divide

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 50 H else transfer the number by resetting bit D6.

Solution

Problem Analysis & Bit Manipulation Logic:

Complete 8085 Assembly Language Program:

8085 Table Transfer with Bit Condition8085 ASM
          LXI H, 2000H       ; HL = Source table starting pointer
          LXI D, 3000H       ; DE = Destination table starting pointer
          MVI C, 0AH         ; C = 10 (loop counter)

LOOP:     MOV A, M           ; Load 8-bit number from source table into A
          CPI 50H            ; Compare A with 50H
          JC  LESS_THAN      ; If A < 50H (Carry = 1), branch to set bit D5

          ; Case: Number >= 50H -> Reset bit D6
          ANI BFH            ; Reset bit D6 (AND with 1011 1111b)
          JMP STORE_DATA

LESS_THAN:
          ; Case: Number < 50H -> Set bit D5
          ORI 20H            ; Set bit D5 (OR with 0010 0000b)

STORE_DATA:
          STAX D             ; Store modified byte at destination [DE]
          INX H              ; Increment source pointer
          INX D              ; Increment destination pointer
          DCR C              ; Decrement loop counter
          JNZ LOOP           ; Repeat until all 10 numbers are processed

          HLT                ; Stop program execution

Execution Trace for Sample Data:

Input Byte at 2000HDecimalCompare 50HOperationBinary CalculationStored at 3000H
12H18< 50HORI 20H0001 0010b | 0010 0000b = 0011 0010b32H
65H101>= 50HANI BFH0110 0101b & 1011 1111b = 0010 0101b25H
50H80>= 50HANI BFH0101 0000b & 1011 1111b = 0001 0000b10H
00H0< 50HORI 20H0000 0000b | 0010 0000b = 0010 0000b20H
Answer:

The program compares each element with 50H using CPI 50H. If carry is set (A < 50H), it sets bit D5 with ORI 20H; otherwise (A >= 50H), it clears bit D6 with ANI BFH, storing the result at the destination table.

All past exam questions for Microprocessors