- Related Questions & Answers
- Program to compute LCM in 8085 Microprocessor
- C++ Program to Find LCM
- 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
- C++ Program to Compute Determinant of a Matrix
- Java program to find the LCM of two numbers
- Write a C# program to find GCD and LCM?
- C++ Program to Compute Cross Product of Two Vectors
- C++ Program to compute division upto n decimal places
- Program to find LCM of two Fibonnaci Numbers in C++
- C++ Program to Compute Discrete Fourier Transform Using Naive Approach
- C++ Program to Compute Combinations using Recurrence Relation for nCr

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

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

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

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.

**first input**

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

. . . | . . . |

8000 | 03 |

8001 | 07 |

. . . | . . . |

**second input**

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

. . . | . . . |

8000 | 23 |

8001 | 07 |

. . . | . . . |

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 |

**first output**

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

. . . | . . . |

8050 | 15 |

8051 | 00 |

. . . | . . . |

**second output**

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

. . . | . . . |

8050 | 3B |

8051 | 01 |

. . . | . . . |

Advertisements