Fyit MP Practical Mannual Final
Fyit MP Practical Mannual Final
Fyit MP Practical Mannual Final
Practical 1: Store the data byte 32H into memory location/ Exchange the contents of memory
locations
Practical No. 1 A) Store the data byte 32H into memory location 2000H.
Aim: Store the data byte 32H into memory location 2000H.
Algorithm:
Step 3: Halt.
Program:
Alternate method:
Output:
Sample problem:
Conclusion:
1
Practical no.1B) Exchange the contents of memory locations 2000H and 4000H.
Aim: Exchange the contents of memory locations 2000H and 4000H.
Algorithm:
Step 1: Initialize HL pair with memory location 2000h where a number is stored.
Step 2: Get the contents of memory location into register B.
Step 3: Initialize HL pair with memory location 4000h where a number is stored.
Step 4: Get the contents of memory location into register A i.e. Accumulator.
Step 5: Move the contents of Register B into memory.
Step 6: Store the contents of Accumulator into memory location 2000h.
Program:
1. LDA 2000H : "Get the contents of memory location 2000H into accumulator"
Alternate method:
2
Output:
Sample problem:
Conclusion:
3
Practical no.2 Add two 8-bit numbers
Aim: Add the contents of memory locations 4000H and 4001H and place the result in memory location 4002H.
Algorithm:
Program:
1. LXI H 4000H
2. MOV A, M
3. INX H
4. ADD M
5. INX H
6. MOV M, A
7. HLT
Output:
Sample problem:
Conclusion:
4
Practical no.3 Subtract two 8-bit numbers
Aim: Subtract the contents of memory location 4001H from the memory location 2000H and place the result in
memory location 4002H.
Algorithm:
Program:
1. LXI H, 4000H
2. MOV A, M
3. INX H
4. SUB M
5. INX H
6. MOV M, A
7. HLT
Output:
5
Sample problem:
Conclusion:
6
Practical no.4 Add two 16-bit numbers
Aim: Add the 16-bit number in memory locations 4000H and 4001H to the 16-bit number in memory locations
4002H and 4003H. The most significant eight bits of the two numbers to be added are in memory locations 4001H
and 4003H. Store the result in memory locations 4004H and 4005H with the most significant byte in memory location
4005H.
Algorithm:
1. "Get first I6-bit number in HL"
7
20. "Store I6-bit result in memory locations 4004H and 4005H"
Program:
1. LHLD 4000H
2. XCHG
3. LHLD 4002H
4. MOV A, E
5. ADD L
6. MOV L, A
7. MOV A, D
8. ADC H
9. MOV H, A
11.HLT
Alternate method:
5. SHLD 4004H : Store I6-bit result in memory locations 4004H and 4005H.
8
Output:
Sample problem:
Conclusion:
9
Practical no.5 Add contents of two memory locations
Aim: Add the contents of memory locations 4000H and 4001H and place the result in the memory locations
4002Hand 4003H.
Algorithm:
Program:
1. LXI H, 4000H
2. MOV A, M
3. INX H
4. ADD M
5. INX H
6. MOV M, A
7. MVIA, 00H
10
8. ADC A
9. INX H
10. MOV M, A
11. HLT
Output:
Sample problem:
Conclusion:
11
Practical no.6 Subtract two 16-bit numbers
Aim: Subtract the 16-bit number in memory locations 4002H and 4003H from the 16-bit number in memory
locations 4000H and 4001H. The most significant eight bits of the two numbers are in memory locations 4001H and
4003H. Store the result in memory locations 4004H and 4005H with the most significant byte in memory location
4005H.
Algorithm:
Program:
1. LHLD 4000H
2. XCHG
3. LHLD 4002H
4. MOV A, E
5. SUB L
6. MOV L, A
7. MOV A, D
8. SBB H
12
9. MOV H, A
11. HLT
Output:
Sample problem:
Conclusion:
13
Practical no.7 Finding one’s complement of a number
Aim: Find the l’s complement of the number stored at memory location 4400H and store the complemented
number at memory location 4300H.
Algorithm:
2. "Complement number"
Program:
1. LDA 4400B
2. CMA
3. STA 4300H
4. HLT
Output:
Sample problem:
Conclusion:
14
Practical no.8 Finding Two’s complement of a number
Aim: Find the 2′s complement of the number stored at memory location 4200H and store the complemented number
at memory location 4300H
Algorithm:
5. HLT
Program:
1. LDA 4200H
2. CMA
3. ADI, 01 H
4. STA 4300H
5. HLT
Output:
Sample problem:
Conclusion:
15
Practical no.09 Right shift, bit of data (8 bit and 16 bit)
Aim: Write a program to shift an eight bit data four bits right. Assume data is in register C.
Program:
MVI C,10H
1. MOV A, C
2. RAR
3. RAR
4. RAR
5. RAR
6. MOV C, A
7. HLT
Output:
Sample problem:
Conclusion:
16
Practical no.10 Left Shifting of a 16-bit data
Aim: Program to shift a 16-bit data 1 bit left. Assume data is in the HL register.
Program:
LXI H,1025H
DAD
HLT
Output:
Sample problem:
4. ----------------------------
Conclusion:
17
Practical 11
AIM: Design and develop a reprogrammable embedded computer using 8051
microcontrollers and to show the following aspects.
a. Programming
b. Execution
c. Debugging
Apparatus: Keil uvision 4.0.
R/ W EPROM EPROM
Switch LCD
8051
Motor
Interface
Steps-
1.First open Keil IDE software.
2.Go to new project.
3. Give name of project (do not add any .asm or c.extesion).
4. Now save your project after that select your microcontroller Atmel 89C51.
5. Now go to file and select new file.
6. Now save this editor file in the same folder where you save your project.
Algorithm-
19
Expected Output-
CONCLUSION-
20
Practical 12
Configure timer control registers of 8051 and develop a program to generate
given time delay.
Aim: Write an embedded C 8051 program to generate time delay for 1 second using the
timer control register. Demonstrate the delay by interfacing 8 LEDs with parallel port
P0, and blinking the LEDs with 1 s delay.
Algorithm-
1. Initialize Port 0 as output port.
2. Send a low value to the port 0 to turn off the LED. i.e. Move the data value
00 to port 0. This will switch off the LEDs connected at port 0.
3. Call delay function which will wait for calculated time interval.
4. Send active high value to the port 0 to turn on the LED. i.e. Move the data
value FF to port 0 this will glow all the LEDs connected at port 0.
5. Call delay
6. Repeat steps 2 – 5 in infinite loop.
21
Hardware connections
Circuit Dig of interfacing the LEDs with 8051 microcontroller using port1
22
Steps in Execution-
Open suitable development environment and create a new project. Add a new C file to
the project and save it as timer.c
Write the appropriate code. Build the hex file.
Use Flash Magic software to load the program in 8051 microcontroller. Execute the
program and observe output.
Embedded C Code -
#include<reg51.H>
void Delay(void);
void main(void)
{
while(1)
{
P1 = 0xFF; // Make all bits of P1 high
Delay();
P1 = 0x00; // Make all bits of P1 low
Delay();
}
}
void Delay(void)
{
int j;
int i;
for(i = 0; i < 1000; i++)
{
}
for(j = 0; j < 1000; j++)
{
}
}
23
Expected Output
CONCLUSION-
24
Practical 13
Port I / O: Use one of the four ports of 8051 for O/P interfaced to eight LED’s. Simulate binary
counter (8 bit) on LED’s
Aim: Write an embedded C program to configure Port 1 of 8051 microcontroller as output port.
Construct a binary counter output at port 1 of 8051. The counter should start counting from 00 H to
FF H. Demonstrate the output using 8 bit LED interface.
Algorithm-
2. Move the binary data value 00000000 to port1 this will switch off the LEDs connected at port1.
3. Call delay function which will wait for calculated time interval.
5. Call delay
Hardware Connection-
25
Embedded C Code –
#include<REG51.H>
void main()
unsigned char x;
unsigned int i;
P1=0X00;
while(1)
for(x=0;x<10;x++)
P1=seg[x];
for(i=0;i<60000;i++);
26
Expected Output-
CONCLUSION-
27
Practical 14
Algorithm-
Hardware Connections-
Same as 3 (a)
Embedded C Code
#include <reg51.h>
void main(void)
{
while(1)
{
P1=0xAA; // pattern to turn on alternate LEDs
ToDelay();
P1=0x55; // Reverse the sequence.
ToDelay();
}
}
void ToDelay()
{
unsigned int i,j;
for (j =0; j<24; j++)
for(i=0;i<1000;i++);
}
28
Expected Output-
1.Four LEDs ON and four LEDs OFF; or alternate nibbles. (F0H and 0FH)
CONCLUSION-
29
Practical 15
Flash Magic
Software required to use the hex file in the embedded systems is flash magic. Run
the flash magic software. Following interface appears
Step 1
Select the communication device as 89V51RD2. This is the NXP microcontroller
used for executing the embedded system programs.
Step 2
Select the appropriate COM port. If a serial cable is used to connect the TKbase kit
to the PC at the default serial port, this would be a COM1 port. It can be checked
from control panel – hardware and sound – Device Manager - ports
Step 3
Select COM1 and baud rate as 9600.
30
If a USB to serial converter is used to connect the PC with the TKbase trainer, the
device drivers would be installed for a relevant COM port.
This can be checked in the Device manager. Select the relevant COM port. Baud
rate for this communication will however, remain 9600.
Step 4
Select the default None (ISP) interface.
Step 5
From options – Advance options – hardware config tab, uncheck the marks for use
DTR for control RST as well as Assert DTR and RTS while COM port open option.
This is shown below
31
Step 6
Choose to erase all flash memory contents to make place or
to load the fresh program into 8051 memory.
Step 7
Browse and select the compiled and build program in the form of hex file.
Choose the verify after programming option in step4. Do not
check any other option.
Step 8
Connect the TKbase trainer kit with the PC using relevant port.
Use the serial data cable, or USB to serial converter or bridge for
this connection. Do necessary hardware connections.
Step 9
Give power to the kit. Press the reset button on the kit. Then click
on the start button of the flash magic interface as shown above.
After the software prompts to reset device in ISP mode, press
reset again.
Step 10
Now the hex file is downloaded. Press reset again to execute
the downloaded program.
CONCLUSION-
32
33