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 reverse the bits of a byte and store the reversed bit at external memory 4500H.
Apparatus Used: Micro-controller kit.
Assumption: Suppose a byte is stored at 4000H and we have reversed its bit.
                        12=0001 0010 after reversing it will become
                        48=0100 1000
  • ·         Initialize the location to store the byte.
  • ·         Initialize a Register R1 to store output.
  • ·         Initialize the counter as the number of bits.
  • ·         Get byte into the Accumulator.
  • ·         Rotate the content of accumulator left with carry.
  • ·         Exchange the content of accumulator to register R1.
  • ·         Rotate the content of accumulator right with carry.
  • ·         Exchange the content of accumulator to register R1 again.
  • ·         Repeat the process till counter is reset.
  • ·         Finally move the content of R1 into Register A and store reversed 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.

RLC: Rotate accumulator left with carry.

RRC: Rotate accumulator Right with carry.

XCH: Exchange the content of accumulator with register.


Input:  4000-12 (0001 0010)
Output: 4500-48 (0100 1000)

Procedure to find 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 number.
·         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