Lab2 8051
Lab2 8051
DATA TRANSFER
OBJECTIVES:
¾ Write an ALP to transfer data from code ROM space into RAM locations.
¾ Write an ALP to transfer data from RAM locations to other RAM locations.
¾ Write an ALP to Exchange Data between Internal RAM Locations.
¾ Write an ALP to Find the Largest Element in an Array Stored in the Internal RAM location,
and Display the Result in Port2.
¾ Write an ALP to Sort an Array stored in the Internal RAM location.
¾ To experiment with a look-up table.
REFERENCE:
¾ Mazidi and McKinlay, “The 8051 Microcontroller and Embedded Systems,”.
MATERIALS:
¾ Keil 8051 simulator & trainer board.
ACTIVITY 1
Write a program to transfer a string of data from code space starting at address 200H to RAM
locations inside the CPU starting at 40H. The data representing your last name and first name is
as shown below:
MYDATA: DB "Firstname Secondname",0
Using the simulator, single-step through the program and examine the data transfer and registers.
After data has been transferred from ROM space into RAM, Write down a subroutine that copy
the data from RAM locations starting at 40H to RAM locations starting at 60H.
ACTIVITY 2
Store five different sets of data in RAM locations 40H-44h and 60H-64H. Write an
assembly language Program that will exchange the data between the above two memory
locations.
Note: Use indirect addressing mode and DJNZ.
ACTIVITY 3
Store five arrays of data in RAM locations 40H-44h. Write an assembly language
Program to find out the largest of the stored data and display the results in port2.
Note: SUBB :- Instruction used for subtraction of two no.s in 8051.
ACTIVITY 4
Store five arrays of data in RAM locations 40H-44h. Write an assembly language
Program to sort the data in Ascending order.
ACTIVITY 5
Write a program to calculate y where y = x2 + 2x + 9. x is between 0 and 9 and the look-
up table for x2 is located at the address (code space) of 200H. Register R0 has the x, and at the
end of the program R2 should have y. Use the simulator to change the x value and single-step
through the program, examining the registers as you go.
LAB 2