In this program we will see how to add a blocks of data using 8085 microprocessor.
Write 8085 Assembly language program to add N 1-byte numbers. The value of N is provided.
In this problem we are using location 8000H to hold the length of the block. The main block is stored from address 8010H. We are storing the result at location 9000H and 9001H. The 9000H holding the lower byte, and 9001H is holding the upper byte.
Repeatedly we are taking the number from the memory, then adding it with accumulator and increase the register E content when carry flag is set. Initially E is cleared.
Address | Data |
---|---|
. . . | . . . |
8000 | 08 |
. . . | . . . |
8010 | AF |
8011 | 2E |
8012 | 7C |
8013 | 81 |
8014 | 2C |
8015 | BF |
8016 | FB |
8017 | 1C |
. . . | . . . |
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
F000 | 21, 00, 80 | LXI H,8000H | Load the address to get count of numbers | |
F003 | 4E | MOV C, M | Load C with the count value | |
F004 | 21, 10, 80 | LXI H, 8010H | Load HL with the starting address | |
F007 | AF | XRA A | Clear accumulator | |
F008 | 5F | MOV E, A | Clear the E register also | |
F009 | 86 | LOOP | ADD M | Add Memory content with Accumulator |
F00A | D2, 0C, F0 | JNC SKIP | When Carry flag is 0, skip next task | |
F00D | 1C | INR E | Increase E, when C flag is set | |
F00E | 0D | SKIP | DCR C | Decrease C register by 1 |
F00F | 23 | INX H | Point to next location | |
F010 | C2, 09, F0 | JNZ LOOP | When Zero is false, go to LOOP | |
F013 | 21, 00, 90 | LXI H,9000H | Load address to store result | |
F016 | 77 | MOV M, A | Save accumulator content | |
F017 | 23 | INX H | Increase HL pair | |
F018 | 73 | MOV M, E | Store carry | |
F019 | 76 | HLT | Terminate the program |
Address | Data |
---|---|
. . . | . . . |
9000 | DC |
9001 | 03 |
. . . | . . . |