Microprocessor Lab Assignment-9 Name - Kotecha Udit Hitendra Reg. No.-20194057 Group - CS-A
Microprocessor Lab Assignment-9 Name - Kotecha Udit Hitendra Reg. No.-20194057 Group - CS-A
ASSIGNMENT-9
Name – Kotecha Udit Hitendra
Reg. No.- 20194057
Group- CS-A
CODE:
LXI H, 3050
MVI D, 10 ; D is counter(D=10)
MVI B,00 ; B=00
MVI C,01 ; C=01
MOV M,B ; Copy the content of B at memmory location 3050 that is 00
INX H ; Increment the HL pair that is 3051
MOV M,C ; Copy the content of C at memory location 3051 that is 01
LOOP: MOV A,B ; Now A=B=00
ADD C ; A=A+C => A=0+1=1
MOV B,C ; B=C=>1
MOV C,A ; C=A=>1
INX H ; Increment the HL pair that is 3052
MOV M,A ; Copy the contents of A at memory location 3052 that is 01
DCR D ; Decrement counter that become 9
JNZ LOOP ; Go to LOOP if value of counter is not zero
HLT ; Terminate the program execution if counter become 0
OUTPUT:
Q2: Write an assembly language program of binary search in 8085
microprocessor.
CODE:
LDA 2012; load the element to be searched
MOV D,A; move the element to be searched to register D
LXI H,2000; pointing the register pair to the start of the array
MVI B,0; starting index of array
MVI C,10; ending index of array
LOOP: MOV A,C;move end index of array to accumulator
CMP B; if start index > end index, end the search (element not found)
JC END2
ADD B; otherwise A = (B+C)/2 i.e.mid value
MVI E,0; quotient of (B+C)/2
DIVIDE: INR E; Division of (B+C) by 2
SUI 2;
JP DIVIDE;
DCR E;
GOTOMID: INX H; Moving the HL pair to the mid location of the search
array
DCR A;
JNZ GOTOMID;