 Open in App
Not now

# 8085 program to multiply two 16-bit numbers

• Difficulty Level : Expert
• Last Updated : 07 Jun, 2022

Problem: Write an assembly language program in 8085 microprocessor to multiply two 16 bit numbers.

Assumption:

• The starting address of program: 2000
• Input memory location: 2050, 2051, 2052, 2053
• Output memory location: 2054, 2055, 2056, 2057

Example:

```INPUT:
(2050H) = 04H
(2051H) = 07H
(2052H) = 02H
(2053H) = 01H
OUTPUT:
(2054H) = 08H
(2055H) = 12H
(2056H) = 07H
(2057H) = O0H```

Result:  Hence we have multiplied two 16-bit numbers.

### Algorithm:

1. Load the first data in the HL pair.
2. Move content of HL pair to the stack pointer.
3. Load the second data in the HL pair and move it to DE.
4. Make H register as 00H and L register as 00H.
5. ADD HL pair and stack pointer.
6. Check for carrying if carry increment it by 1 else moves to the next step.
7. Then move E to A and perform OR operation with accumulator and register D.
8. If the value of the operation is zero, then store the value else go to step 3.

### Explanation:

Registers B, C, D, E, H, L, and accumulator are used for general purposes.

1. LHLD 2050: load HL pair with data of address 2050and 2051.

2. SPHL: save the content of HL in the stack pointer.

3. LHLD 2052: load H-L pair with data of addresses 2052 and 2053.

4. XCHG: exchange the content of the HL pair with DE.

5. LXI H, 0000H: make H as 00H and L as 00H.

6. LXI B, 0000H: make B as 00h and C as 00H

9. INX B: increments BC register with 1.

10. DCX D: decrements DE register pair by 1.

11. MOV A, E: move the content of register E to the accumulator.

12. ORA D: or the content of accumulator and D register.