Multiply Two 8 Bit Numbers
Multiply Two 8 Bit Numbers
Multiply Two 8 Bit Numbers
Load H-L pair with address of first operands memory location. Move the first operand from memory to register B.
Stop
Add B with A.
Decrement register C.
No
Is C = 0?
Page 1 of 3
8085 Programs
Program: Address 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F Explanation: This program multiplies two operands stored in memory location 3000H and 3001H, using successive addition method. In successive addition method, the second operand is considered as counter, and the first number is added with itself until counter decrements to zero. Let us assume that the operands stored at memory location 3000H is 02H and 3001H is 05H. Then, by using successive addition method, we get 02H + 02H + 02H + 02H + 02H = 0AH. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to register B from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register C from memory location 3001H to act as counter. Accumulator is initialized to 00H. Register B is added with accumulator and the result is stored in accumulator. Register C (counter) is decremented by 1. Then, counter is checked for zero. If it hasnt become zero yet, then register B is again added with accumulator, and counter is again checked for zero. INX MOV HLT H M, A ADD DCR JNZ B C 2008H MOV INX MOV MVI B, M H C, M A, 00H Mnemonics LXI Operand H, 3000H Opcode 21 00 30 46 23 4E 3E 00 80 0D C2 08 20 23 77 76 Remarks Load H-L pair with address 3000H. Lower-order of 3000H. Higher-order of 3000H. Move the 1st operand from memory to reg. B. Increment H-L pair. Move the 2nd operand from memory to reg. C. Initialize accumulator with 00H. Immediate value 00H. Add B with A. Decrement reg. C (counter). Jump back to address 2008H if C 0. Lower-order of 2008H. Higher-order of 2008H. Increment H-L pair. Move the result from accumulator to memory. Halt.
Page 2 of 3
8085 Programs
If counter becomes zero, then H-L pair is incremented and the result is moved from accumulator to memory location 3002H.
Page 3 of 3