Problem – Write an assembly language program to add hexadecimal numbers stored in continuous memory or in an array.
Assumption – Suppose the size of the array is stored at memory location 2050 and the base address of the array is 2051. The sum will be stored at memory location 3050 and carry will be stored at location 3051.
- Load the base address of the array in HL register pair.
- Use the size of the array as a counter.
- Initialise accumulator to 00.
- Add content of accumulator with the content stored at memory location given in HL pair.
- Decrease counter on each addition.
|2000||LDA 2050||A <- |
|2003||MOV B, A||B <- A|
|2004||LXI H, 2051||H <- 20 and L <- 51|
|2007||MVI A, 00||A <- 00|
|2009||MVI C, 00||C <- 00|
|200B||ADD M||A <- A+M|
|200C||INR L||M <- M+1|
|2010||INR C||C <- C+1|
|2011||DCR B||B <- B-1|
|2015||STA 3050||3050 <- A|
|2018||MOV A, C||A <- C|
|2019||STA 3051||3051 <- A|
|201C||HLT||Terminates the program|
- LDA 2050: load accumulator with content of location 2050
- MOV B, A: copy contents of accumulator to register B
- LXI H, 2051: store 20 to H register and 51 to L register
- MVI A, 00: store 00 to accumulator
- MVI C, 00: store 00 to register C
- ADD M: add accumulator with the contents of memory location given in HL register pair
- INR L: increase address by 1
- JNC 2011: if not carry, jump to location 2011 otherwise to the location given in PC
- INR C: increase content of register C by 1
- DCR B: decrease content of register B by 1
- JNZ 200B: if not zero, jump to location 200B otherwise to the location given in PC
- STA 3050: store contents of accumulator to memory location 3050
- MOV A, C: copy contents of register C to accumulator
- STA 3051: store contents of accumulator to memory location 3051
- HLT: terminates the program
- 8085 program to search a number in an array of n numbers
- 8085 program to count total odd numbers in series of 10 numbers
- 8085 program to count total even numbers in series of 10 numbers
- 8085 program to add 2-BCD numbers
- 8085 program to add two 8 bit numbers
- 8085 program to add two 16 bit numbers
- 8085 program to swap two 8-bit numbers
- 8085 program to multiply two 16-bit numbers
- 8085 program to sum of two 8 bit numbers without carry
- 8085 program to divide two 8 bit numbers
- 8085 program to multiply two 8 bit numbers
- 8085 program to divide two 16 bit numbers
- 8085 program to find the sum of series of even numbers
- 8085 program to find the sum of first n natural numbers
- 8085 program to subtract two 16-bit numbers with or without borrow
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : prakritibharali