Running 2 Youtube Channel : The Masti Adda (Fun based ) : The Knowledge Adda (Knowledge based) : Subscribe for Knowledge with Fun....
Written by @

Aim: Write an ALP to find largest element in a given array present in external memory with a starting address 4000H and size of an array is 05H and store the largest number at external memory 4500H.
Apparatus Used: Micro-controller kit.
Assumption: Five  numbers stored in memory locations starting from 4000H. We have to find largest number and stored that number at 4500H.
1. Load the R0 register with length of the array.
2. Initialize a Register B to store output.
3. Load DPTR with memory location 4000H.
4. Get first element into the Accumulator.
5.Compare A and B. If A is less than B  then jump to Next Number. If A is greater than B then move the that number (Accumulator) into B and get Next Number.
6. Decrement the R0 register each time by 1 for every data taken from the array.
7. Repeat the process till counter is reset.
8. Finally move the content of B into Register A and store largest number at 4500H.

Description of used instruction:
MOV: Used for Load and Copy the Data. This copies a byte from the source location to destination.
DJNZ: In this instruction a byte is decremented, and if result is not zero it will jump to the target address.
MOVX: This instruction transfer data between external memory and register A.
DPTR: This is Data Pointer. It is used for containing 16 bit data or memory address.
SJMP: Short Jump loop is used for indefinite loop within program basically used to end the program.
INC: This instruction adds 1 to the register or memory location specified by the operand.
0F0: These are Special Function Register address. These are used to store the address of register B.
CJNE : Compare and Jump if not equal to at a given location.

Input:   4000-09
Output: 4500-09

Procedure to look output:

·         After ending (SJMP) the program, press Enter two times.
·         You will get message “Welcome to ------KIT”.
·         Press G and Provide initial address of program as in this program, starting address is 3000 H.
·         Press Enter.
·         After pressing Enter, You will get Message “Execution Completed”.
·         Press Reset on micro-controller KIT.
·         Press M and You will get Message “Enter Address”.
·         Provide Location of Input as in this program 4000H. Press Space and write a first number and Press Space and provide second number and so on.
·         Press Enter two times again.
·         Press G and provide starting address and Press Enter.
·         You will Get Message “Execution Completed”.
·         Press M and You will Get Message “Enter Address”.
·         Provide Address for Output as in this Program 4500H and Press Space and you get Output and so on.

No comments:

Post a Comment