0% found this document useful (0 votes)
293 views

Add 8 Bit With Carry

This program adds two 8-bit numbers stored in memory locations 3000H and 3001H, considering any carry. It loads the address of the first number into H-L, moves the first number to A and increments H-L. It then loads the second number into B, initializes C to 0 and adds A and B, incrementing C if there is a carry. It stores the result in memory 3002H, increments H-L and stores the carry in memory 3003H before halting.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
293 views

Add 8 Bit With Carry

This program adds two 8-bit numbers stored in memory locations 3000H and 3001H, considering any carry. It loads the address of the first number into H-L, moves the first number to A and increments H-L. It then loads the second number into B, initializes C to 0 and adds A and B, incrementing C if there is a carry. It stores the result in memory 3002H, increments H-L and stores the carry in memory 3003H before halting.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

8085 Programs

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.

Move the result from accumulator to memory.

Increment H-L pair.

Increment H-L pair to point to next memory location.

Move the carry from register C to memory.

Stop Move the second operand from memory to register B.

Initialize register C with 0.

Add B with A.

No

If Carry?

Yes Increment register C.

Increment H-L pair.

Gursharan Singh Tatla

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.

Gursharan Singh Tatla

Page 2 of 3

8085 Programs

Output: Before Execution: 3000H: 3001H: FAH 28H

After Execution: 3002H: 3003H: 22H 01H

Gursharan Singh Tatla

Page 3 of 3

You might also like