- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 multiply two 8-bit numbers (shift and add method)
Now let us see a program of Intel 8085 Microprocessor. In this program we will see how to multiply two numbers using shift and add methods.
Problem Statement:
Write 8085 Assembly language program to multiply two 8-bit numbers using shift and add method.
Discussion:
The shift and add method is an efficient process. In this program, we are taking the numbers from memory location 8000H and 8001H. The 16 bit results are storing into location 8050H onwards.
In this method we are putting the first number into DE register pair. The actual number is placed at E register, and D is holding 00H. The second number is taken into A. As the numbers are 8-bit numbers, then we are shifting the Accumulator contents eight times. When the carry flag is set while rotating, then the DE content is added with HL. Initially HL pair will hold 0000H. Then HL is also added with HL itself. Thus the result will be generated.
Input:
Address | Data |
---|---|
. . . | . . . |
8000 | 25 |
8001 | 2A |
. . . | . . . |
Flow Diagram:
Program:
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
F000 | 21, 00, 80 | LXI H,8000H | Point to first operand | |
F003 | 5E | MOV E,M | Load the first operand to E | |
F004 | 16, 00 | MVI D,00H | Clear the register D | |
F006 | 23 | INX H | Point to next location | |
F007 | 7E | MOV A,M | Get the next operand | |
F008 | 0E, 08 | MVI C,08H | Initialize counter with 08H | |
F00A | 21, 00, 00 | LXI H, 0000H | Clear the HL pair | |
F00D | 0F | LOOP | RRC | Rotate the acc content to right |
F00E | D2, 12, F0 | JNC SKIP | If carry flag is 0, jump to skip | |
F011 | 19 | DAD D | Add DE with HL | |
F012 | EB | SKIP | XCHG | Exchange DE and HL |
F013 | 29 | DAD H | Add HL with HL itself | |
F014 | EB | XCHG | Exchange again the contents of DE and HL | |
F015 | 0D | DCR C | Decrease C register | |
F016 | C2, 0D, F0 | JNZ LOOP | if Z = 0, jump to LOOP | |
F019 | 22, 50, 80 | SHLD 8050H | Store the result | |
F01C | 76 | HLT | Terminate the program |
Output:
Address | Data |
---|---|
. . . | . . . |
8050 | 12 |
8051 | 06 |
. . . | . . . |