Program to Multiply two 8-bit numbers

Q. Write an 8085 program and draw a flowchart to Multiply two 8-bit numbers.(8085 Microprocessor Program)

Flowchart/Algorithm

Program

Address Mnemonics Operand Opcode Comments
2000 LXI H, 3000H 21 Load H-L pair with address 3000H.
2001 00
2002 30
2003 MOV B, M 46 Move the 1st operand from memory to reg. B.
2004 INX H 23 Increment H-L pair.
2005 MOV C, M 4E Move the 2nd operand from memory to reg. C.
2006 MVI A, 00H 3E Initialize accumulator with 00H.
2007 00
2008 ADD B 80 Add B with A.
2009 DCR C 0D Decrement reg. C (counter).
200A JNZ 2008H C2 Jump back to address 2008H if C ^ 0.
200B 08
200C 20
200D INX H 23 Increment H-L pair.
200E MOV M, A 77 Move the result from accumulator to memory.
200F HLT 76 Halt

Output

Before Execution:

3000H: 02H
3001H: 05H

After Execution:

3002H: 0AH

Program Explanation

  1. This program multiplies two operands stored in memory location 3000H and 3001H, using successive addition method.
  2. In successive addition method, the second operand is considered as the counter, and the first number is added to itself until counter decrements to zero.
  3. Let us assume that the operands stored at memory location 3000H are 02H and 3001H is 05H.
  4. Then, by using successive addition method, we get 02H + 02H + 02H + 02H + 02H = 0AH.
  5. Initially, H-L pair is loaded with the address of first memory location.
  6. The first operand is moved to register B from memory location 3000H and H-L pair is incremented to point to next memory location.
  7. The second operand is moved to register C from memory location 3001H to act as the counter.
  8. The accumulator is initialized to 00H.
  9. Register B is added to the accumulator and the result is stored in the accumulator.
  10. Register C (counter) is decremented by 1.
  11. Then, the counter is checked for zero. If it hasn’t become zero yet, then register B is again added to the accumulator, and the counter is again checked for zero.
  12. If counter becomes zero, then H-L pair is incremented and the result is moved from the accumulator to memory location 3002H.

1 thought on “Program to Multiply two 8-bit numbers”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.