Tutorialspoint.dev

8085 program to multiply two 8 bit numbers

Problem – Multiply two 8 bit numbers stored at address 2050 and 2051. Result is stored at address 3050 and 3051. Starting address of program is taken as 2000.

Example –



Algorithm –

  1. We are taking adding the number 43 seven(7) times in this example.
  2. As the multiplcation of two 8 bit numbers can be maximum of 16 bits so we need register pair to store the result.

Program –

Memory Address Mnemonics Comment
2000 LHLD 2050 H←2051, L←2050
2003 XCHG H↔D, L↔E
2004 MOV C, D C←D
2005 MVI D 00 D←00
2007 LXI H 0000 H←00, L←00
200A DAD D HL←HL+DE
200B DCR C C←C-1
200C JNZ 200A If Zero Flag=0, goto 200A
200F SHLD 3050 H→3051, L→3050
2012 HLT

Explanation – Registers used: A, H, L, C, D, E

  1. LHLD 2050 loads content of 2051 in H and content of 2050 in L
  2. XCHG exchanges contents of H with D and contents of L with E
  3. MOV C, D copies content of D in C
  4. MVI D 00 assigns 00 to D
  5. LXI H 0000 assigns 00 to H and 00 to L
  6. DAD D adds HL and DE and assigns the result to HL
  7. DCR C decreaments C by 1
  8. JNZ 200A jumps program counter to 200A if zero flag = 0
  9. SHLD stores value of H at memory location 3051 and L at 3050
  10. HLT stops executing the program and halts any further execution

Read next: Assembly language program (8085 microprocessor) to add two 8 bit numbers



This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter