Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » Embedded Systems

Assembly language program in 8085 microprocessor to multiply two 16 bit numbers



Here, we are going to write an assembly language program in 8085 microprocessor to multiply two 16 bit numbers?
Submitted by Ayush Sharma, on November 05, 2018

Problem statement:

Write an assembly language program in 8085 microprocessor to multiply two 16 bit numbers.

Assumption:

  1. Starting address of program: 2000
  2. Input memory location: 2050, 2051, 2052, 2053
  3. Output memory location: 2054, 2055, 2056, 2057

Algorithm:

  1. Load the first data in HL pair.
  2. Move content of HL pair to stack pointer.
  3. Load the second data in HL pair and move it to DE.
  4. Make H register as 00H and L register as 00H.
  5. ADD HL pair and stack pointer.
  6. Check for carry if carry increment it by 1 else move to next step.
  7. Then move E to A and perform OR operation with accumulator and register D.
  8. The value of operation is zero, then store the value else goto step 3.

Program:

ADDRESSMNEMONICSCOMMENTS
2000LHLD 2050Load H-L pair with address 2050
2003SPHLSAVE IT IN STACK POINTER
2004LHLD 2052Load H-L pair with address 2052
2007XCHGEXCHANGE HL AND DE PAIR CONTENT
2008LXI H,0000HH<-00H,L<-00H
200BLXI B,0000HB<-00H,C<-00H
200EDAD SP
200FJNC 2013JUMP NOT CARRY
2012INX BINCREMENT BC BY 1
2013DCX DDECREMENT DE BY 1
2014MOV A,EA<-E
2015ORA DOR THE CONTENT OF ACCUMULATOR AND D REGISTER
2016JNZ 200EJUMP NOT ZERO
2019SHLD 2054L<-2053,H<-2054
201CMOV L,CL<-C
201DMOV H,BB<H
201ESHLD 2056L<-2055,H<-2056
2021HLTENDS THE PROGRAM

Explanation: Registers B, C, D, E, H, L and accumulator are used for general purpose.

  1. LHLD 2050: load HL pair with address 2050.
  2. SPHL: save the content of HL in stack pointer.
  3. LHLD 2052: load H-L pair with address 2052.
  4. XCHG: exchange the content of HL pair with DE.
  5. LXI H, 0000H: make H as 00H and L as 00H.
  6. LXI B, 0000H: make B as 00h and C as 00H.
  7. DAD SP: ADD HL pair and stack pointer.
  8. JNC 2013: jump to address 2013 if there will be no carry.
  9. INX B: increments BC register with 1.
  10. DCX D: decrements DE register pair by 1.
  11. MOV A, E: move the content of register E to accumulator.
  12. ORA D: or the content of accumulator and D register.
  13. JNZ 200E: jump to address 200E if there will be no zero.
  14. SHLD 2054: store the result to memory address 2054 and 2055 from HL pair register.
  15. MOV L, C: move the content of register C to L.
  16. MOV H, B: move the content of register B to H.
  17. SHLD 2056: store the result to memory address 2056 and 2057 from HL pair register.
  18. HLT: terminates the program.





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates



© https://www.includehelp.com (2015-2018), Some rights reserved.