PadhaikoAll subjects

Past exam question: 2082 Chaitra (Regular), Q4

Microprocessors · 6 marks

Open in the Padhaiko app

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

Question

Write a program for 8085 microprocessor to transfer eight-bit numbers from A000H to B000H if bit D6 is 1 and D2 is 0. Otherwise transfer data by complementing bit D1 and D5. Assume there are ten numbers.

Solution

Algorithm & Bit Testing Logic:

8085 Assembly Language Program:

8085 Conditional Data Transfer8085 ASM
          LXI H, A000H       ; HL = Source pointer
          LXI D, B000H       ; DE = Destination pointer
          MVI C, 0AH         ; C = 10 (loop counter)

LOOP:     MOV A, M           ; Load 8-bit number from source into A
          MOV B, A           ; Save original number in register B

          ; Test condition: D6 = 1 and D2 = 0
          ANI 44H            ; Mask bits D6 and D2 (0100 0100b)
          CPI 40H            ; Check if D6=1 and D2=0 (result == 40H)
          JZ  TRANSFER_DIR   ; If condition met, transfer directly

          ; Otherwise: complement bits D1 and D5
          MOV A, B           ; Restore original number into A
          XRI 22H            ; Complement bit D5 (20H) and bit D1 (02H)
          JMP STORE

TRANSFER_DIR:
          MOV A, B           ; Restore original number into A

STORE:    STAX D             ; Store byte at destination address [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 execution

Execution Trace for Sample Data:

Input Byte at A000HBinaryCondition (D6=1, D2=0)Action TakenResult Stored at B000H
40H0100 0000bMet (D6=1, D2=0)Transfer direct40H
44H0100 0100bFailed (D2=1)XOR with 22H44H ^ 22H = 66H
00H0000 0000bFailed (D6=0)XOR with 22H00H ^ 22H = 22H
50H0101 0000bMet (D6=1, D2=0)Transfer direct50H
Answer:

The program initializes source HL=A000H, destination DE=B000H, and counter C=0AH. For each byte, it isolates bits D6 and D2 with ANI 44H and CPI 40H. If equal, it stores the original byte directly; otherwise, it toggles bits D1 and D5 using XRI 22H before storing.

All past exam questions for Microprocessors