Add 8 Bit With Carry
Add 8 Bit With Carry
Program 10: Add two 8-bit numbers along with considering the carry. Flowchart: Start
Load H-L pair with address of first operands memory location. Move the first operand from memory to accumulator.
Add B with A.
No
If Carry?
Page 1 of 3
8085 Programs
Program: Address 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 Explanation: This program adds two operands stored in memory location 3000H and 3001H, along with considering the carry produced (if any). Let us assume that the operands stored at memory location 3000H is FAH and 3001H is 28H. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to accumulator from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register B from memory location 3001H. Register C is initialized to 00H. It stores the carry (if any). The two operands stored in register A and B are added and the result is stored in accumulator. Then, carry flag is checked for carry. If there is a carry, C register is incremented. H-L pair is incremented and the result is moved from accumulator to memory 3002H. H-L pair is again incremented and carry (either 0 or 1) is moved from register C to memory location 3003H. INR INX MOV INX MOV HLT C H M, A H M, C ADD JNC B 200D MOV INX MOV MVI A, M H B, M C, 00H Mnemonics LXI Operand H, 3000H Opcode 21 00 30 7E 23 46 0E 00 80 D2 0D 20 0C 23 77 23 71 76 Remarks Load H-L pair with address 3000H. Lower-order of 3000H. Higher-order of 3000H. Move the 1st operand from memory to reg. A. Increment H-L pair. Move the 2nd operand from memory to reg. B. Initialize reg. C with 00H. Immediate value 00H. Add B with A. Jump to address 200DH if there is no carry. Lower-order of 200DH. Higher-order of 200DH. Increment reg. C. Increment H-L pair. Move the result from reg. A to memory. Increment H-L pair. Move carry from reg. C to memory. Halt.
Page 2 of 3
8085 Programs
Page 3 of 3