Saturday, September 12, 2009

Add each element of array with the elements of another array (8085)

Statement: Add 2 arrays having ten 8-bit numbers each and generate a third array of result. It is necessary to add the first element of array 1 with the first element of array-2 and so on. The starting addresses of array l, array2 and array3 are 2200H, 2300H and 2400H, respectively

Source Program:
LXI H, 2200H : Initialize memory pointer 1
LXI B, 2300H : Initialize memory pointer 2
LXI D, 2400H : Initialize result pointer
BACK: LDAX B : Get the number from array 2
ADD M : Add it with number in array 1
STAX D : Store the addition in array 3
INX H : Increment pointer 1
INX B : Increment pointer2
INX D : Increment result pointer
CPI 0AH : Check pointer 1 for last number
JNZ BACK : If not, repeat
HLT : Stop

No comments:

Post a Comment