In this program we will see how to add three 16-bit numbers stored in register pairs.
Write 8085 Assembly language program to add three 16-bit numbers stored in register pair BC, DE and HL. Store the result at DE register pair.
In this program we are storing the 16-bit numbers into BC, DE and HL pair. We have DAD D instruction which helps to add HL and DE register pair, and store the result into HL pair. After that copy BC to DE, then again perform DAD D to add them. Finally using XCHG we are storing them into DE register pair.
Here we are adding 0502H + 1211H + 2133H = 3846H
|F000||01, 02, 05|| ||LXI B,0502H|| |
|F003||11, 11, 12|| ||LXI D,1211H|| |
|F006||21, 33, 21|| ||LXI H,2133H|| |
|F009||19|| ||DAD D||Add DE and HL, and Store into HL|
|F00A||50|| ||MOV D,B||Copy B to D|
|F00B||59|| ||MOV E,C||Copy C to E|
|F00C||19|| ||DAD D||Add DE and HL (Actually BC), store into HL|
|F00D||EB|| ||XCHG||Swap DE and HL|
|F00E||76|| ||HLT||terminate the program|