- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# 8085 Program to compute LCM

Now let us see a program of Intel 8085 Microprocessor. This program will find the LCM of two8-bit numbers.

### Problem Statement

Write 8085 Assembly language program to find LCM of two 8-bit numbers stored at location8000H and 8001H

### Discussion

In this program we are reading the data from 8000H and 8001H. By loading the number, we are storing it at C register, and clear the B register. The second number is loaded into Accumulator. Set DE as the 2's complement of BCregister. This DE is used to subtract BC from HL pair.

The method is like this:let us say the numbers are 25 and 15. When we divide the first number by second, and then if there is no remainder, then the first number is the LCM. But for this case the remainder is present. Then we will check the next multiple of 25 to check the divisibility. When the remainder becomes 0, the program terminates and the result is stored.

### Input

**first input**

Address | Data |
---|---|

. . . | . . . |

8000 | 03 |

8001 | 07 |

. . . | . . . |

**second input**

Address | Data |
---|---|

. . . | . . . |

8000 | 23 |

8001 | 07 |

. . . | . . . |

### Flow Diagram

### Program

Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|

F000 | 21, 00, 80 | LXI H, 8000H | Point 8000Hto get first number | |

F003 | 4E | MOV C, M | Load memory element to C | |

F004 | 06, 00 | MVI B, 00H | Clear B register | |

F006 | 23 | INX H | Point to next location | |

F007 | 7E | MOV A, M | Load second number to Acc | |

F008 | 2F | CMA | ComplementAcc | |

F009 | 5F | MOV E, A | Load 1's complemented form of A to E | |

F00A | 16, FF | MVI D, FFH | Load 1's complemented form of 00H | |

F00C | 13 | INX D | Increase DEregister pair | |

F00D | 21, 00, 00 | LXI H, 0000H | Load 0000Hinto HL pair | |

F010 | 09 | NEXT | DAD B | Add BC with HL |

F011 | 22, 50, 80 | SHLD 8050H | Store HL content into 8050H | |

F014 | 19 | LOOP | DAD D | Add DE withHL |

F015 | D2, 20, F0 | JNC SKIP | When CY = 0,jump to SKIP | |

F018 | 7C | MOV A, H | Get H content to A | |

F019 | B5 | ORA L | OR L with A | |

F01A | CA, 26, F0 | JZ EXIT | When HL is0000, jump to EXIT | |

F01D | C3, 14, F0 | JMP LOOP | Jump to Loop | |

F020 | 21, 50, 80 | SKIP | LHLD 8050H | Load HL from8050H |

F023 | C3, 10, F0 | JMP NEXT | Jump to NEXT | |

F026 | 2A, 50, 80 | EXIT | LHLD 8050H | Store HL pair as LCM |

F029 | 76 | HLT | Terminate the program |

### Output

**first output**

Address | Data |
---|---|

. . . | . . . |

8050 | 15 |

8051 | 00 |

. . . | . . . |

**second output**

Address | Data |
---|---|

. . . | . . . |

8050 | 3B |

8051 | 01 |

. . . | . . . |

- Related Questions & Answers
- Program to compute LCM in 8085 Microprocessor
- C++ Program to Find LCM
- Java Program to Find LCM of two Numbers
- Java program to find the LCM of two numbers
- Write a C# program to find GCD and LCM?
- C program to compute geometric progression
- C program to compute linear regression
- Program to find LCM of two Fibonnaci Numbers in C++
- C++ Program to Find the GCD and LCM of n Numbers
- Java program to compute Remainder and Quotient
- C++ Program to Compute Combinations using Factorials
- C++ Program to Compute DFT Coefficients Directly
- C Program to Compute Quotient and Remainder?
- Program to compute Log n in C
- Python program to compute a Polynomial Equation