COA LAB 2 3 4 Experiments Manual
COA LAB 2 3 4 Experiments Manual
number in an array
10. CMP AL, BL subtract the value of BL register from AL and it modify flag registers
13. LOOP 040E runs loop till CX not equal to Zero and decrease the value of CX by 1
Example:
LAB NO 3(b) Assembly language program for adding to two arrays
Problem Statement
Write a program in 8086 microprocessor to find out the sum of two arrays of 8-bit n numbers,
where size “n” is stored at offset 500 and the numbers of first array are stored from offset 501
and the numbers of second array are stored from offset 601 and store the result numbers into
first array i.e offset 501.
Algorithm
1. Store 500 to SI and 601 to DI and Load data from offset 500 to register CL and set register CH
to 00 (for count).
2. Increase the value of SI by 1.
3. Load first number (value) from next offset (i.e 501) to register AL.
4. Add the value in register AL by value at offset DI.
5. Store the result (value of register AL ) to memory offset SI.
6. Increase the value of SI by 1.
7. Increase the value of DI by 1.
8. Loop above 5 till register CX gets 0.
Program
MEMORY ADDRESS MNEMONICS COMMENT
400 MOV SI, 500 SI←500
403 MOV CL, [SI] CL←[SI]
405 MOV CH, 00 CH←00
407 INC SI SI←SI+1
408 MOV DI, 601 DI←601
40B MOV AL, [SI] AL←[SI]
40D ADD AL, [DI] AL=AL+[DI]
40F MOV [SI], AL AL->[SI]
411 INC SI SI←SI+1
412 INC DI DI←DI+1
413 LOOP 40B JUMP TO 40B IF CX!=0 and CX=CX-1
415 HLT End
Explanation
Problem: Write an assembly language program in 8085 microprocessor to separate odd and
even numbers from the given list of 50 numbers. Store odd nos in another list starting from
memory location 2100H. Store even nos in another list starting from memory location 2200H.
Starting address of the list is 2000H.
Explanation:
A number is said to be odd if its least significant bit is 1 otherwise it is even. Therefore to
identify whether the number is even or odd, we perform AND operation with 01 by the help of
ANI instruction. If the number is odd then we will get 01 otherwise 00 in the accumulator. ANI
instruction also affects the flags of 8085. Therefore if accumulator contains 00 then zero flag
gets set otherwise it gets reset.
Example:
Algorithm:
2028H DCR C