8085 program to multiply two 16-bit numbers - GeeksforGeeks

19 Feb, 2021
Problem – Write an assembly language program in 8085 microprocessor to multiply two 16 bit numbers. 
Assumption –  
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 –  
Load the first data in HL pair.  Move content of HL pair to stack pointer.  Load the second data in HL pair and move it to DE.  Make H register as 00H and L register as 00H.  ADD HL pair and stack pointer.  Check for carry if carry increment it by 1 else move to next step.  Then move E to A and perform OR operation with accumulator and register D.  The value of operation is zero, then store the value else goto step 3.  
Load the first data in HL pair.  
Move content of HL pair to stack pointer.  
Load the second data in HL pair and move it to DE.  
Make H register as 00H and L register as 00H.  
ADD HL pair and stack pointer.  
Check for carry if carry increment it by 1 else move to next step.  
Then move E to A and perform OR operation with accumulator and register D.  
The value of operation is zero, then store the value else goto step 3.  
Program – 
 
Explanation – Registers B, C, D, E, H, L and accumulator are used for general purpose.  
LHLD 2050: load HL pair with address 2050.  SPHL: save the content of HL in stack pointer.  LHLD 2052: load H-L pair with address 2052.  XCHG: exchange the content of HL pair with DE.  LXI H, 0000H: make H as 00H and L as 00H.  LXI B, 0000H: make B as 00h and C as 00H  DAD SP: ADD HL pair and stack pointer.  JNC 2013: jump to address 2013 if there will be no carry.  INX B: increments BC register with 1.  DCX D: decrements DE register pair by 1.  MOV A, E: move the content of register E to accumulator.  ORA D: or the content of accumulator and D register.  JNZ 200E: jump to address 200E if there will be no zero.  SHLD 2054: store the result to memory address 2054 and 2055 from HL pair register.  MOV L, C: move the content of register C to L.  MOV H, B: move the content of register B to H.  SHLD 2056: store the result to memory address 2056 and 2057 from HL pair register.  HLT: terminates the program.  
LHLD 2050: load HL pair with address 2050.  
SPHL: save the content of HL in stack pointer.  
LHLD 2052: load H-L pair with address 2052.  
XCHG: exchange the content of HL pair with DE.  
LXI H, 0000H: make H as 00H and L as 00H.  
LXI B, 0000H: make B as 00h and C as 00H  
DAD SP: ADD HL pair and stack pointer.  
JNC 2013: jump to address 2013 if there will be no carry.  
INX B: increments BC register with 1.  
DCX D: decrements DE register pair by 1.  
MOV A, E: move the content of register E to accumulator.  
ORA D: or the content of accumulator and D register.  
JNZ 200E: jump to address 200E if there will be no zero.  
SHLD 2054: store the result to memory address 2054 and 2055 from HL pair register.  
MOV L, C: move the content of register C to L.  
MOV H, B: move the content of register B to H.  
SHLD 2056: store the result to memory address 2056 and 2057 from HL pair register.  
HLT: terminates the program.  
 
mayank5464942
suryapandey0211
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Architecture of 8085 microprocessor
Pin diagram of 8086 microprocessor
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Direct Access Media (DMA) Controller in Computer Architecture
Difference between SRAM and DRAM
Memory mapped I/O and Isolated I/O
Introduction of Control Unit and its Design
Difference between Hardwired and Micro-programmed Control Unit | Set 2
General purpose registers in 8086 microprocessor
Computer Organization | Basic Computer Instructions