ADDITION
GIVEN TWO DATA STORED AT MEMORY LOCATION x AND x+1. PERFORM ADDITION ON m(x) AND m(x+1) AND STORE THE RESULT AT LOCATION x+2.
THEORY : The first 8 bit data is brought to the accumulator A from the memory location and the second 8-bit data is also brought from another memory location to B. The addition is done using ADD. The result is sorted in the desired location(2002). The addition (ADD) instruction affects flags depending on the result.
ALGORITHM :Step 1: LXI H,2000h, to load the address in H-L register pair using LXI H from 16-bit location 2000h.Step 2: MOV A, M to move the value of 2000h memory address value into the accumulator.Step 3: INX H, to increase the value of the H-L register pair to get the next memory location.Step 4: MOV B, M to move the value of the 2001h memory location to register B.Step 5: INX H, done to the H-L pair of the register will be increased and pointed to store the addition result.Step 6: ADD B, for we need to perform addition with the value of accumulator with the content of B register and store the result into the accumulator.Step 7: MOV M, A; for that value of accumulator value will be stored into H-L register pair with the pointed location.Step 8: HLT; to stop the program.
IMPLEMENTATION :
Location | Mnemonics | Hex Code |
---|---|---|
3000 | LXI H | 21 |
3001 | 00 | 00 |
3002 | 20 | 20 |
3003 | MOV A,M | 7E |
3004 | INX H | 23 |
3005 | MOV B,M | 46 |
3006 | INX H | 23 |
3007 | ADD B | 80 |
3008 | MOV M,A | 77 |
3009 | HLT | 76 |
INPUT AND OUTPUT :
Location | Input |
---|---|
2000 | 20 |
2001 | 30 |
Location | Output |
---|---|
2002 | 50 |
DISCUSSION :
In this program we perform the addition task where we stored two values in different memory location (2000h and 2001h) and we use the ADD operation in the 8085 microprocessor. Firstly we load the value of memory location to accumulator then the second value load into B register to perform the addition (ADD B) in between Accumulator and B register. The resultant value will store at location 2002h. Which was being pointed by increamenting the value of H L register pair (INX H). To store the Accumulator value to memory location by using MOV M, A. The result value was 8 bits (1 byte), and when result is 8-bit then carry flag will not be enable but when the result will exceed 8-bit range then carry flag will be enable or set. As per location 2000h & 2001h store values 20h and 30h respectively. The result will be shown at location 2002 i.e. (20h+30h) = 50h.
Comments
Post a Comment