0% found this document useful (0 votes)
86 views5 pages

Microprocessor Lab Assignment-9 Name - Kotecha Udit Hitendra Reg. No.-20194057 Group - CS-A

The document contains code for two assembly language programs - one for calculating the Fibonacci series in 8085 microprocessor and another for binary search in 8085 microprocessor. The Fibonacci program initializes registers with starting values, uses a loop to calculate each term and store in memory locations. The binary search program initializes indexes, compares the search element to the middle element of the array in each iteration, and recursively searches higher or lower halves of the array until the element is found or not. It stores the result (1 if found, 0 if not found) at memory location 2013.

Uploaded by

UditKotecha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views5 pages

Microprocessor Lab Assignment-9 Name - Kotecha Udit Hitendra Reg. No.-20194057 Group - CS-A

The document contains code for two assembly language programs - one for calculating the Fibonacci series in 8085 microprocessor and another for binary search in 8085 microprocessor. The Fibonacci program initializes registers with starting values, uses a loop to calculate each term and store in memory locations. The binary search program initializes indexes, compares the search element to the middle element of the array in each iteration, and recursively searches higher or lower halves of the array until the element is found or not. It stores the result (1 if found, 0 if not found) at memory location 2013.

Uploaded by

UditKotecha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

MICROPROCESSOR LAB

ASSIGNMENT-9
Name – Kotecha Udit Hitendra
Reg. No.- 20194057
Group- CS-A

Q1: Write an assembly language program of fibonacci series in 8085


microprocessor.

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;

LXI H,2000; Load the HL pair to the start of array location


MOV A,M; Move the 0th index value to accumulator
CMP D
JZ END; If 0th index value matches with the value to be found,end the
search
MOV A,E; Else move the mid value to register E

GOTOMID: INX H; Moving the HL pair to the mid location of the search
array
DCR A;
JNZ GOTOMID;

MOV A,M; Move the mid value to accumulator (pointed by HL)


CMP D; Compare it with value to be searched
JZ END; If found, end the search
JC BOTTOM; If value to be searched > mid value,jump
DCR E; Else higher index = mid-1
MOV C,E
JMP LOOP; Go to the start to begin the search again on the updated array
BOTTOM: INR E; lower index = mid+1
MOV B,E;
JMP LOOP; Go to the start to begin the search again on the updated array

END: MVI A,1; Element found


STA 2013; Store to address 2013
HLT; Halt

END2: MVI A,0; Element not found


STA 2013; Store to address 2013
HLT; Halt

If element found, 1 is stored at 2013 location. Else 0 is stored at 2013 location.

You might also like