Microprocessor_&_Microcontroller_Lab_Manual_(CSE)
Microprocessor_&_Microcontroller_Lab_Manual_(CSE)
LAB MANUAL
Semester: IV
Batch: 2020-24
Prepared By:
R N Shukla & Kapol Nashine
Verified By:
SCHOOL OF ENGINEERING
Department of Computer Science and Engineering
O P JINDAL UNIVERSITY
O P JINDAL KNOWLEDGE PARK, PUNJIPATRA, RAIGARH-496109
Microprocessor 8086:
Microcontroller 8051:
a) EMU8086 is the emulator of 8086 (Intel and AMD compatible) microprocessor and integrated assembler with
tutorials for beginners. The emulator runs programs like the real microprocessor in step-by-step mode. It shows
registers, memory, stack, variables and flags.
click emulate button (or press F5). The program then attempts to assemble and save the executable to c:\
emu8086\MyBuild. If the assembler succeeds in creating the file, the emulator ll also automatically load it into
memory & displayed two more window of ‘emulator’ & ‘original source code’.
7) You can then click single step (or press F8) to step through the code one instruction at a time, or click run to
simulate program directly with/ without various delays (0-1-100-200-300-400ms). Also observe status of registers,
flags, stack, vars, memory on the emulator screen. You can also click step back (or press F6) to see what happens
when reversing those changes.
Aim: -To write a program to perform two 8 bit addition and subtraction.
Requirement apparatus: - Experiment kit Anshuman XPO-86, SMPS, PC & EMULATOR OF 8086
Program:-
Result:
For 8 bit addition
AH 05H AH 08H
BH 03H CH 08H
AH 05H AH 02H
BH 03H CH 02H
Viva Questions:
1. What is a Microprocessor?
2. What is Instruction Set?
3. What are the features of Intel 8086 ?
4. What is Logical Address?
5. What is The Effective Address?
Result:
For 16bit addition
AX 1234H AH 2468H
BX 1234H CH 2468H
AX 2345H AX 1111H
BX 1234H CX 1111H
Viva Questions:
1. What is Physical Address?
2. What are the flags in 8086?
3. Why crystal is a preferred clock source?
4. What is Tri-state logic?
5. What happens when HLT instruction is executed in processor?
Result:
AX 0006 H [200H] 03 H
BX 0002 H [201H] 00 H
Viva Questions:
What is Program counter?
What is 1st / 2nd / 3rd / 4th generation processor?
Name the processor lines of two major manufacturers?
How many bit combinations are there in a byte?
Have you studied buses? What types?
Result:
AX 0FFF H [200H] 10 H
BX 00FE H [201H] 1F H
Viva Questions:
What is the Maximum clock frequency in 8086?
What is meant by Maskable interrupts?
What is Non-Maskable interrupts?
What are the different functional units in 8086?
What are the various segment registers in 8086?
Result:
INPUT OUTPUT(AL)
[200H] 44H
[201H] 25H
[202H] 06H
[203H] 76H
[204H] 56H
[205H] 38H
[206H] 77H
[207H] 02H 87H
[208H] 12H
[209H] 67H
[20AH] 60H
[20BH] 05H
[20CH] 87H
[20DH] 35H
[20EH] 07H
Viva Questions:
Which Stack is used in 8086?
What is SIM and RIM instructions?
What are the different types of Addressing Modes?
What are the General Data Registers & their uses?
Result:
INPUT OUT PUT(AL)
[200H] 44H
[201H] 25H
[202H] 06H
[203H] 76H
[204H] 56H
[205H] 38H
[206H] 77H
[207H] 02H 02H
[208H] 12H
[209H] 67H
[20AH] 60H
[20BH] 05H
[20CH] 87H
[20DH] 35H
[20EH] 07H
Viva Questions:
What are Segment Registers & their uses?
What are Flag registers?
What does the 8086 Architecture contain?
What are Data Copy/Transfer Instructions?
Result:
INPUT OUTPUT
[200H] 01H
[201H] 01H
[202H] 01H
[203H] 01H
[204H] 01H
[205H] 01H
[206H] 01H
[207H] 01H
[208H] 01H
AX 13H
[209H] 01H
[20AH] 01H
[20BH] 01H
[20CH] 01H
[20DH] 01H
[20EH] 01H
[20FH] 01H
[210H] 01H
[211H] 01H
[212H] 01H
[213H] 01H
Viva Questions:
What are Machine Control Instructions?
What are Flag Manipulation Instructions?
What is an Interrupts.
Microprocessor & Microcontroller Lab CSE
Experiment No. 07
Program: -To write an assembly language program to solve following arithmetic equation: 3AX+5DX+BP
Requirement apparatus: - Experiment kit Anshuman XPO-86, SMPS, PC & EMULATOR OF 8086
Program:-
Result:
INPUT OUT PUT(AX)
[200H] 02H
(AX) 1BH
[201H] 03H
(DX)
[202H](BP) 06H
Viva Questions:
What is an Opcode?
What is an Operand?
Explain the difference between a JMP and CALL instruction?
What is meant by Polling?
What is meant by Interrupt?
Result:
INPUT OUT PUT
Viva Questions:
What is an Instruction?
What is Microcontroller and Microcomputer?
What is Assembler?
Experiment No. 09
Aim: -To write a program to arrange a data block in descending order.
Requirement apparatus: - Experiment kit Anshuman XPO-86, SMPS, PC & EMULATOR OF 8086
Program:-
Result:
INPUT OUT PUT
Viva Questions:
What is the use of HLDA?
Explain about "LEA"?
Difference between "Shift" and "Rotate".
Microprocessor & Microcontroller Lab CSE
Difference between JMP and JNC?
Step 2: To initiate the programming you must create a project using the keil Uvision IDE
The option to create a new project will be available under the project tab in the toolbar. Next, you have to store the
project in a folder and give a suitable name to it.
Step 4:
For writing code: Select New file (or Ctrl+N) from file drop down menu. On Right Hand Side is the
editor where the code can be written.
Once the code is written, and save project with the extension (.C or .ASM):
For Assembly :
Step 8:
For Debuging: Debug drop down Menu and select “Start/Stop Debug Session”.
Here you simulate the program in SIMULATOR mode here you can see Yellow arrow
mark that will move step while pressing F11.
Experiment No.10
Aim: WAP in assembly to perform different arithmetic operations on two numbers.
Requirements: Keil µvision IDE
Program:
ORG 00H
MOV R1, #25H
MOV R2, #02H
ACALL plus //CALLING SUBROUTINE FOR ADDITION
ACALL minus //CALLING SUBROUTINE FOR SUBTRACTION
ACALL mult //CALLING SUBROUTIE FOR MULTIPLICATION
ACALL divi //CALLINING SUBROUTINE FOR DIVISON
ORG 10H
plus: ACALL LOAD
ADD A, B
MOV R3, A
MOV 32H, R3
RET
ORG 20H
minus: ACALL LOAD
SUBB A, B
MOV R3, A
MOV 33H, R3
RET
ORG 30H
mult: ACALL LOAD
MUL AB
MOV R3, A
MOV 34H, R3
RET
ORG 40H
divi: ACALL LOAD
DIV AB
MOV R3, A
MOV 35H, R3
RET
END
Loading into R1,R2 Loading into Reg. A &B Result of Addition in R3 Result of
Subtraction in R3
Viva Questions:
Intel 8051 follows which architecture?
What is the difference between Harvard Architecture and von Neumann
Architecture?
8051 was developed using which technology?
Why 8051 is called an 8-bit microcontroller?
Aim : Find the largest number out of a string of 5 numbers Requirements: Keil µvision IDE
ORG 00H
CLR C ; CLEAR CY FLAG
MOV R2,#02H ; Move Into R2 The Number Of Bytes In Each Nmber
MOV R0,#40H ; R0 POINTS TO THE LOW BYTE OF THE 1ST NO.
MOV R1,#50H ; R1 POINTS TO THE LOW BYTE OF THE 2ND NO.
SETB PSW.3 ; SWITCH TO BANK 1
MOV R0,#60H ;USE R0 OF BANK 1 AS POINTER TO THE RESULT
CLR PSW.3 ; RETURN TO BANK 0
BACK: MOV A,@R0 ; BRING ONE BYTE OF THE 1ST NO INTO A
CPL A ; 1'S COMPLIMENTS
ADD A,#01 ; 2'S COMPLIMENTS
MOV @R0, A ; 2'S COMPLIMENTS NO MOV FROM A TO ADDRS GIVEN BY R0
MOV A,@R1 ; BRING ONE BYTE OF THE 1ST NO INTO A
CPL A ; 1'S COMPLIMENTS
ADD A,#01 ; 2'S COMPLIMENTS
ADD A,@R0 ; ADD ONE BYTE OF THE 2ND NO
INC R0 ; INCREMENT 1ST NO
INC R1 ; INCREMENT 1ST NO
SETB PSW.3 ; SWITCH TO BANK 1
MOV @R0,A ; SIGN NUMBER ADDITION RESULT STORE OF IN MEMORY LOC
INC R0 ; Increment R0 For Address Of Next Addition Result
CLR PSW.3 ; RETURN TO BANK 0
DJNZ R2, BACK ; Repeat Until All Two Sign ;Bytes (16 ;Bit) Have Been Added
SETB PSW.3
DEC R0
DEC @R0
END
AIM: Write a microcontroller 8051 program to transfer the bytes into RAM locations starting at
50h, assuming that rom space starting at 240h contains CHHATTISGARH by using –
a) a counter, b) null char for end of string.
Program:
;a) a Counter
ORG 00H
MOV DPTR,#MYDATA ; LOAD ROM POINTERT
MOV R0,#50H ; LOAD RAM POINTER
MOV R2,#12 ; LOAD COUNTER
BACK: CLR A
MOVC A,@A+DPTR ; MOVE DATA FROM CODE SPACE
MOV @R0,A ; SAVE IT IN RAM
INC DPTR ; INCREMENT ROM POINTER
INC R0 ; INCREMENT RAM POINTER
DJNZ R2,BACK ; LOOP UNTIL COUNTER=0
HERE: SJMP HERE
ORG 240H
MYDATA: DB "CHHATTISGARH"
END
ORG 0000
MOV DPTR, #MYDATA ; LOAD ROM POINTER
Program:
ORG 00H
MOV TMOD,#01H
COMP: CPL P1.5
MOV R0, #0C8H
JUMP: MOV TH0,#02H
MOV TL0,#18H
SETB TR0
AGAIN: JNB TF0,AGAIN
CLR TR0
CLR TF0
DJNZ R0,JUMP
SJMP COMP
END
Program:
#include <reg51.h>
sbit sw = P1^1; // SETTING SWITCH AS PORT 1.1
sbit out = P1^2;// SETTING OUTPUT AS PORT 1.2
void t0delay(char ch) // delay function
{
TMOD = 0x01; // TIMER 0 MODE-1 , 16 BIT TIMER
if(ch == '0') //CHECKING SWITCH CONDITION
{ // FOR 500Hz
out = 1;
t0delay('1'); // CALLING t0delay function FOR 1000Hz
out = 0;
t0delay('1');
}
else
{
out = 0;
t0delay('0');// CALLING t0delay FOR 500Hz
out = 1;
t0delay('0');
}
}
}
Result:
Result:
//P1^0 Status will change by EXT intrrupt 0 by using clock of frequency 990HZ at Port3 pin 2
#include <reg51.h>
void Ext_int_init()
{
EA = 1;
EX0 = 1;
IT0 = 1;
}
void External0_ISR() interrupt 0
{
led = ~led;
}
void main()
{
Ext_int_init();
while(1);
}
Result:
}
//INIT FUNCTION OF LCD
void lcd_init()
{
CMD(0x38); // Initialising two array lines of lcd
CMD(0x0E); // display on cursor blinking
CMD(0x01); // clear screen
CMD(0x80); // 1st line of lcd
}
void main()
{
int i;
char a[]={"WELCOME TO CLASS"}; // Storing Character in String form using array
lcd_init();
DATA('H'); // Sending to the LCD character by Character to the first line of LCD
DATA('E');
DATA('L');
DATA('L');
}
while(1);
}
Result:
#include<reg51.h>
#include<stdio.h>
void delay(void);
sbit motor1_pin_1 = P2^0;
sbit motor1_pin_2 = P2^1;
sbit motor2_pin_1 = P2^2;
sbit motor2_pin_2 = P2^3;
void main()
{
do
{
motor1_pin_1 = 1;
motor1_pin_2 = 0; // Motor1 Rotates Anit Clockwise
motor2_pin_1 = 1;
motor2_pin_2 = 0; // Motor2- Rotates Anit Clockwise
delay();
motor1_pin_1 = 1;
motor1_pin_2 = 1; //Motor1 Stop
motor2_pin_1 = 1;
motor2_pin_2 = 1; //Motor2 Stop
delay();
motor1_pin_1 = 0;
motor1_pin_2 = 1; // Motor1 Rotates Clockwise
motor2_pin_1 = 0;
motor2_pin_2 = 1; //Motor2 Rotates Clockwise
delay();
motor1_pin_1 = 1;
motor1_pin_2 = 0; // Motor1 Rotates Anit Clockwise
motor2_pin_1 = 0;
motor2_pin_2 = 1; //Motor2 Rotates Clockwise
delay();
motor1_pin_1 = 0;
motor1_pin_2 = 1; // Motor1 Rotates Clockwise
motor2_pin_1 = 1;
motor2_pin_2 = 0; // Motor2- Rotates Anit Clockwise
delay();
motor1_pin_1 = 0;
motor1_pin_2 = 0; //Stop Motor1
motor2_pin_1 = 0;
motor2_pin_2 = 0; //Stop Motor2
delay();
}while(1);
}
void delay()
{
Result: