Ec6513 Micorprocessor Lab Manual
Ec6513 Micorprocessor Lab Manual
0042
OBJECTIVES:
Write ALP Programmes for fixed and Floating Point and Arithmetic
operations
Interface different I/Os with processor
Generate waveforms using Microprocessors
Execute Programs in 8051
Explain the difference between simulator and Emulator
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM:
To write an Assembly Language Program (ALP) for performing the addition and subtraction
operation of two 2- byte (16) numbers.
APPARATUS REQUIRED:
2. Power Supply +5 V dc 1
PROBLEM STATEMENT:
Write an ALP in 8086 to add and subtract two byte numbers stored in the memory location
1000H to 1003H and store the result in the memory location 1004H to 1005H.Also provide an
instruction in the above program to consider the carry also and store the carry in the memory location
1006H.
ALGORITHM:
1
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
FLOWCHART:
ADDITION SUBTRACTION
START
START
YES
YES
IS THERE
IS THERE ANY CY
ANY
CARRY
COUNTER = NO COUNTER =
NO COUNTER + 1 COUNTER + 1
STOP
STOP
2
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
ADDITION
PROGRAM COMMENTS
SUBTRACTION
PROGRAM COMMENTS
3
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
TEST DATA:
ADDITION
MEMORY
DATA
SUBTRACTION
MEMORY
DATA
MANUAL CALCULATION:
RESULT:
Thus an addition & subtraction of two 2-byte numbers are performed and the results are verified.
4
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM:
To write an Assembly Language Program (ALP) for performing the multiplication and division
operation of 16-bit numbers.
APPARATUS REQUIRED:
2. Power Supply +5 V dc 1
PROBLEM STATEMENT:
Write an ALP in 8086 MP to multiply two 16-bit binary numbers and store the result in the
memory location. Write instructions for dividing the data and store the result.
ALGORITHM:
5
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
6
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
FLOWCHART
MULTIPLICATION DIVISION
Start
Start
REGISTER=00 Quotient = 0
QUOTIENT = QUOTIENT+1
Multiplier=MULTIPLIER
–1
Is Dividend <
Divisor ?
NO
Is
Multiplier = Yes
0?
STORE QUOTIENT
YES STORE REMAINDER
Stop
STOP
7
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
MULTIPLICATION
PROGRAM COMMENTS
DIVISION
PROGRAM COMMENTS
8
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
TEST DATA:
MULTIPLICATION
MEMORY
DATA
DIVISON
MEMORY
DATA
MANUAL CALCULATION
RESULT:
Thus the multiplication & division of two (16 bit) byte numbers are performed and the
results are verified
9
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM:
To write an Assembly Language Program (ALP) for verifying logical operations using 16 bit
numbers.
APPARATUS REQUIRED:
S.NO ITEM SPECIFICATION QUANTITY
1. System with MASM 8086 bsased 1
package
CODE SEGMENT
ASSUME CS: CODE
ORG 1000H
START: MOV AL, 85H
MOV BL, 99H
AND AL, BL
MOV SI, 1200H
MOV [SI], AL
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE SEGMENT
ASSUME CS: CODE
ORG 1000H
START: MOV AL, 85H
MOV BL, 99H
OR AL, BL
MOV SI, 1200H
MOV [SI], AL
MOV AH, 4CH
INT 21H
CODE ENDS
END START
10
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
11
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
PUSH BX
PUSH CX
MOV BX, AX
SHL BX, 1 ; BX: = AX * 2
ADD BX, AX ; BX: = AX * 3
MOV CL, 4
SHL AX, CL ; AX: = AX * 16
ADD AX, BX ; AX: = AX * 19
POP CX
POP BX
MOV SI,1200H
MOV [SI], AL
HLT
TEST DATA:
LOGICAL OPERATION
MEMORY
DATA
MEMORY
DATA
RESULT:.
Thus the logical operations of 8086 microprocessors are performed and the results are
verified.
12
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM:
To write an Assembly Language Program (ALP) to find the largest and smallest number in a
given array.
APPARATUS REQUIRED:
2. Power Supply +5 V dc 1
PROBLEM STATEMENT:
An array of length 10 is given from the location. Find the largest and smallest number and store
the result.
ALGORITHM:
13
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
14
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
FLOWCHART
INITIALIZE COUNT
INITIALIZE COUNT
POINTER MAX = 0
POINTER MIN = 0
PONITER =
PONITER =
POINTER + 1
POINTER + 1
YES
YES
IS MAX
POINTER ?
IS MIN
NO POINTER ?
MAX = POINTER NO
MIN = POINTER
COUNT = COUNT-1
NO COUNT = COUNT-1
IS COUNT = 0
NO
?
YES IS COUNT = 0
STORE MAXIMUM ?
YES
STOP
15
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
LARGEST
PROGRAM COMMENTS
SMALLEST
PROGRAM COMMENTS
16
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
TEST DATA:
LARGEST
MEMORY
DATA
SMALLEST
MEMORY
DATA
RESULT:.
17
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM:
To write an Assembly Language Program (ALP) to sort a given array in ascending and
descending order.
APPARATUS REQUIRED:
2. Power Supply +5 V dc 1
PROBLEM STATEMENT:
An array of length 10 is given from the location. Sort it into descending and ascending order and
store the result.
ALGORITHM:
18
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
FLOWCHART
INITIALIZE POINTER
INITIALIZE POINTER
COUNT = COUNT – 1
COUNT = COUNT – 1
FLAG = 0 YES
FLAG = 0
YES IS POINTER
POINTER + 1
IS POINTER
POINTER + NO
1
NO TEMP = POINTER
POINTER = POINTER + 1
TEMP = POINTER
POINTER + 1 = TEMP
POINTER = POINTER + 1
COUNT = COUNT + 1
IS COUNT = 0
NO
IS COUNT YES
NO
=0
IS FLAG = 0
YES
NO YES
IS FLAG = 0 STOP
YES
19
STOP
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
ASCENDING ORDER:
PROGRAM COMMENTS
MEMORY
DATA
20
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DESCENDING ORDER:
PROGRAM COMMENTS
DATA
Result: Thus given array of numbers are sorted in ascending & descending order.
21
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
ALGORITHM:
22
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
FLOW CHART:
23
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
COPYING A STRING
PROGRAM COMMENTS
INPUT
MEMORY
DATA
OUTPUT
MEMORY
DATA
RESULT:
Thus a string of a particular length is moved from source segment to destination segment.
24
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM:
To search a given byte in the string and find the relative address of the byte from the starting
location of the string.
ALGORITHM:
25
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
FLOW CHART
START
NO
Move DI to BX
STOP
26
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
PROGRAM COMMENTS
MEMORY
DATA
OUTPUT
MEMORY LOCATION
DATA
RESULT:
Thus a given byte or word in a string of a particular length in the extra segment(destination) is
found .
27
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
28
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM:
ALGORITHM:
DF=0.
NO
Check for ZF=1
YES
Move the content of BL
to ES:DI
STOP
29
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
PROGRAM COMMENTS
RESULT: INPUT
MEMORY
DATA
OUTPUT
MEMORY
DATA
RESULT:
Thus a given byte or word in a string of a particular length in the extra segment(destination) is
found and is replaced with another character.
30
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
AIM :
To Write an Assembly language program to convert ASCII coded decimal value into its
equivalent Hexa demical Value .
ALGORITHM
1. Save Contents of All Registers Which Are Used In The Routine.
2. Make binary result=0.
3. Subtract 30H from the character typed on the keyboard to convert it to BCD.
4. Multiply the result by 10, and then add the new BCD digit.
5. Repeat steps 2 and 3 until the character typed is not an ASCII coded number.
6. Restore register contents.
PROGRAM
31
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
RESULTS:
INPUT
MEMORY
DATA
OUTPUT
MEMORY
DATA
RESULT:
Thus the given byte or word is converted from ASCII coded decimal value into its equivalent
Hexa decimal Value and outputs are verified.
32
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
To write an assembly language program to perform matrix addition of size 3x3 matrix.
APPARATUS REQUIRED:
2. Cable RS232C 1
PROBLEM STATEMENT:
To perform a matrix addition whose data are present at the location of ------------- and store
at the location-------------.
.DATA
M1 DB 00H,01H,10H,12H,02H,03H,0F0H,0C0H,04H
M2 DB 00H,05H,01H,02H,50H,90H,03H,04H,0AAH
M3 DB 9 DUP (0)
M4 DB ' $'
MES1 DB "THE SUM OF TWO MATRIX IS $"
.CODE
.STARTUP
MOV DX, OFFSET MES1
MOV AH,09H
INT 21H
MOV CL,0
P1:
XOR BX,BX
MOV BL,CL
MOV AL,M1[BX]
MOV DL,M2[BX]
ADD AL,DL
MOV M3[BX],AL
INC CL
CMP CL,9
JNZ P1
33
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
MOV DX,0AH
MOV AH,02H
INT 21H
MOV CL,0
MOV CH,0
PP:XOR BX,BX
MOV BL,CL
MOV AL,M3[BX]
MOV DL,AL
ROL DL,4
AND DL,0FH
ADD DL,30H
CMP DL,'9'
JBE F1
ADD DL,7H
F1:
MOV AH,02H
INT 21H
MOV AL,M3[BX]
AND AL,0FH
MOV DL,AL
ADD DL,30H
CMP DL,'9'
JBE F2
ADD DL,7
F2:
MOV AH,02H
INT 21H
MOV DX,OFFSET M4
MOV AH,09H
INT 21H
INC CH
CMP CH,3
JNZ L1
MOV DX,0AH
MOV AH,02H
INT 21H
MOV CH,0
L1:
INC CL
CMP CL,9
JNZ PP
MOV AH,4CH
INT 21H
END
34
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
OUTPUT:
00 06 11
14 52 93
F3 C4 AE
RESULTS:
INPUT
MEMORY
DATA
OUTPUT
MEMORY
DATA
RESULT:
Thus the given two 3x3 matrix A and B are added and the results are verified.
35
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
APPARATUS REQUIRED:
2. Cable RS232C 1
PROBLEM STATEMENT:
.MODEL SMALL
.DATA
PASS DB ‘ABC’
MES1 DB 10,13,’ENTER 3 CHARACTER
PASSWORD $’
MES2 DB 10,13,’PASSWORD IS CORRECT $’
MES3 DB 10,13,’PASSWORD ID WRONG $ ‘
.CODE
START: MOV AX,@DATA
MOV DS,AX
MOV AH,09H
LEA DX,MES1
INT 21H
MOV CL,00
MOV DL,OOH
XOR DI,DI
.WHILE CL!=3
MOV AH,07H
INT 21H
LEA BX,PASS
MOV AH,[BX+DI]
.IF AL==AH
36
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
ADD DL,01
.ENDIF
INC DI
INC CL
.ENDW
.IF DL==3
MOV AH,09H
LEA DX,MES2
INT 21H
.ELSE
MOV AH,09H
LEA DX,MES3
INT 21H
.ENDIF
MOV AH,4CH
INT 21H
END START
END
INPUT:
OUTPUT:
RESULT:
37
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
APPARATUS REQUIRED:
2. Cable RS232C 1
PROBLEM STATEMENT:
.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'Current System Time is : $'
TIME DB '00:00:00$' ; time format hr:min:sec
.CODE
MAIN PROC
MOV AX, @DATA ; initialize DS
MOV DS, AX
LEA BX, TIME ; BX=offset address of string TIME
CALL GET_TIME ; call the procedure GET_TIME
LEA DX, PROMPT ; DX=offset address of string PROMPT
MOV AH, 09H ; print the string PROMPT
INT 21H
38
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
GET_TIME PROC
; this procedure will get the current system time
; input : BX=offset address of the string TIME
; output : BX=current time
OUTPUT:
RESULT:
Thus the systems current date is fetched, displayed and the result is verified.
39
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
AIM:
To write ALP by interfacing 8255 with 8086 in mode 0, mode 1 and mode 2.
APPARATUS REQUIRED:
8086 kit, 8255 interface kit.
ALGORITHM:
Mode 0
1. Initialize accumulator to hold control word
2. store control word in control word register
3. Read data port A.
4. Store data from port A in memory
5. Place contents in port B
FLOWCHART START
Input to be read from port A Disable all interrupts except RST 6.5
STOP 40
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
I/O mode
D7 D6 D5 D4 D3 D2 D1 D0
BSR mode
Bit set/reset, applicable to PC only. One bit is S/R at a time. Control word:
D7 D6 D5 D4 D3 D2 D1 D0
41
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
MODE 0
PROGRAM COMMENTS
MOV AL,90H Set the control word
OUT C6,AL Send it to control port
IN AL,C0 Get the contents of port A in AL
OUT C2,AL Send the contents of port B to port address
HLT Stop
MODE 1
PROGRAM COMMENTS
MOV AL,0B0H Set the control word for mode 1
OUT C6,AL Send it to control port
MOV AL,09H Control for BSR mode
OUT C6,AL Send it to control port
MOV AL,13H Interrupt generation
OUT 30,AL
MOV AL,0AH Through 8259
OUT 32,AL
MOV AL,0FH Using IR2 interrupt(lower order count)
OUT 32,AL
MOV AL,00H Higher order count
OUT 32,AL
STI Set trap flag
HLT Stop
ISR: Subroutine
IN AL,C0 Read from Port A
OUT C2,AL Send it to Port B
HLT Stop
42
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
MODE 2
PROGRAM COMMENTS
MOV AL,0C0H Set the control word for mode 2
OUT C6,AL Send it to control port
MOV AL,09H Control for BSR mode
OUT C6,AL Send it to control port
MOV AL,13H Interrupt generation
OUT 30,AL
MOV AL,0AH Through 8259
OUT 32,AL
MOV AL,0FH Using IR2 interrupt(lower order count)
OUT 32,AL
MOV AL,00H Higher order count
OUT 32,AL
STI Set trap flag
HLT Stop
ISR: Subroutine
IN AL,C0 Read from Port A
OUT C2,AL Send it to Port B
HLT Stop
Result:
The programs for interfacing 8255 with 8085 are executed & the output is obtained for mode 0,1 & 2
43
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM :
APPARATUS REQUIRED:
4. CRO - 1
THEORY:
44
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
It is similar to mode 2, except that the output will remain high until one half for even number
count, If the count is odd, the output will be high for (count+1)/2 counts and low for (count-1)/2 counts
ALGORITHM:
Mode 2-
Mode 3-
1. Initialize channel 0 in mode 3
2. Initialize the LSB of the count.
3. Initialize the MSB of the count.
4. Trigger the count
5. Read the corresponding output in CRO.
PORT ADDRESS :
1. CONTROL REGISTER –
2. COUNTER OF CHANNEL 0 -
3. COUNTER OF CHANNEL 1 -
4. COUNTER OF CHANNEL 2 -
D7 D6 D5 D4 D3 D2 D1 D0
0 0 CHANNEL 0 0 0 LATCH
0 1 CHANNEL 1 0 1 LSB
1 0 CHANNEL 2 1 0 MSB
1 1 ----- 1 1 LSB FIRST, MSB NEXT
45
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
M2 M1 M0 MODE
0 0 0 MODE 0
0 0 1 MODE 1
0 1 0 MODE 2
0 1 1 MODE 3
1 0 0 MODE 4
1 0 1 MODE 5
PORT PIN ARRANGEMENT DEBOUNCE CIRCUIT CONNECTION
1 CLK 0
2 GATE 0 * * *
3 OUT 0
4 CLK 1
5 GATE 1
6 OUT 1
7 CLK 2
8 GATE 2
9 OUT 2
10 GND
46
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
47
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
MODEL GRAPH:
FLOW CHART
START
INITIALIZE ACCUMULATOR
WITH MODE SET WORD
STOP
RESULT:
Thus an ALP for rate generator and square wave generator are written and executed by
interfacing with timer ic8253.
48
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM:
To study interfacing technique of 8251 (USART) with microprocessor 8086 and write an 8086
ALP to transmit and receive data between two serial ports with RS232 cable.
APPARATUS REQUIRED:
THEORY:
The 8251 is used as a peripheral device for serial communication and is programmed by the
CPU to operate using virtually any serial data transmission technique. The USART accepts data
characters from the CPU in parallel format and then converts them into a continuous serial data stream
for transmission. Simultaneously, it can receive serial data streams and convert them into parallel data
characters for the CPU. The CPU can read the status of the USART at any time. These include data
transmission errors and control signals. The control signals define the complete functional definition of
the 8251. Control words should be written into the control register of 8251.These control words are split
into two formats: 1) Mode instruction word & 2) Command instruction word. Status word format is used
to examine the error during functional operation.
1...transmit enable
1...data terminal ready
1... receive enable
1... send break character
1.... reset error flags (pe,oe,fe)
1..... request to send (rts)
1...... internal reset
1....... enter hunt mode (enable search for sync characters)
49
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
1 ransmitter ready
1. receiver ready
1.. transmitter empty
1... parity error (pe)
1.... overrun error (oe)
1..... framing error (fe), async only
1...... sync detect, sync only
1....... data set ready (dsr)
50
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
ALGORITHM:
1. Initialize 8253 and 8251 to check the transmission and reception of a character
2. Initialize8253 to give an output of 150Khz at channel 0 which will
give a 9600 baud rate of 8251.
3. The command word and mode word is written to the 8251 to set up for subsequent operations
4. The status word is read from the 8251 on completion of a serial I/O operation, or
when the host CPU is checking the status of the device before starting the next I/O operation
FLOW CHART:
START
No
Is it High
Yes
STOP
51
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
PROGRAM COMMENTS
MOV AL,36 Initialize 8253 in mode 3 square wave generator
OUT CE,AL Send through port address
MOV AL,10 Initialize AL with lower value of count (clock frequency 150KHz)
OUT C8,AL Send through port address
MOV AL,00 Initialize AL with higher value of count
OUT C8,AL Send through port address
MOV AL,4E Set mode for 8251(8bit data, No parity, baud rate factor 16x & 1 stop bit)
OUT C2,AL Send through port address
MOV AL,37 Set command instruction(enables transmit enable & receive enable bits)
OUT C2,AL Send through port address
L1:IN AL,C2 Read status word
AND AL,04 Check whether transmitter ready
JZ L1 If not wait until transmitter becomes ready
MOV AL,41 Set the data as 41
OUT C0,AL Send through port address
INT 2 Restart the system
RECEIVER END
PROGRAM COMMENTS
MOV AL,36 Initialize 8253 in mode 3 square wave generator
OUT CE,AL Send through port address
MOV AL,10 Initialize AL with lower value of count (clock frequency 150KHz)
OUT C8,AL Send through port address
MOV AL,00 Initialize AL with higher value of count
OUT C8,AL Send through port address
MOV AL,4E Set mode for 8251(8bit data, No parity, baud rate factor 16x & 1 stop bit)
OUT C2,AL Send through port address
MOV AL,37 Set command instruction(enables transmit enable & receive enable bits)
OUT C2,AL Send through port address
L1: IN AL,C2 Read status word
AND AL,02 Check whether receiver ready
JZ L1 If not wait until receiver becomes ready
IN AL,C0 If it is ready, get the data
MOV BX,1500 Initialize BX register with memory location to store the data
MOV [BX],AL Store the data in the memory location
INT 2 Restart the system
RESULT: Thus ALP for serial data communication using USART 8251 is written and the equivalent
ASCII 41 for character ‘A’ is been transmitted & received.
52
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
APPARATUS REQUIRED:
ALGORITHM :
0 0 1 0 0 0 0
0 0 0 D D K K K
DD
000-2Key lockout.
53
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
1 1 0 1 1 1 0 0
1 1 0 CD CD CD CF CA
1 0 0 1 0 0 0 0
1 0 0
AI A A A A
Auto increment = 1, the row address selected will be incremented after each of read and
write operation of the display RAM.
54
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
START
FLOWCHART:
SET UP POINTER
DELAY
PROGRAM TABLE
PROGRAM COMMENTS
Start : MOV SI,1200H Initialize array
MOV CX,000FH Initialize array size
MOV AL,10 Store the control word for display mode
OUT C2,AL Send through output port
MOV AL,CC Store the control word to clear display
OUT C2,AL Send through output port
MOV AL,90 Store the control word to write display
OUT C2,AL Send through output port
L1 : MOV AL,[SI] Get the first data
OUT C0,AL Send through output port
CALL DELAY Give delay
INC SI Go & get next data
55
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
LOOK-UP TABLE:
1200 98 68 7C C8
1204 FF 1C 29 FF
1200H 1 0 0 1 1 0 0 0 98 H
1201H 0 1 1 0 1 0 0 0 68 E
1202H 0 1 1 1 1 1 0 0 7C L
1203H 1 1 0 0 1 0 0 0 C8 P
1204H 1 1 1 1 1 1 1 1 FF Space
1205H 0 0 0 0 1 1 0 0 1C U
1206H 0 0 1 0 1 0 0 1 29 S
1207H 1 1 1 1 1 1 1 1 FF Space
RESULT:
Thus the rolling message “HELP US” is displayed using 8279 interface kit.
56
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
AIM:
To write an assembly language program in 8086 to rotate the motor at different speeds.
APPARATUS REQUIRED:
4. Stepper Motor - 1
PROBLEM STATEMENT:
Write a code for achieving a specific angle of rotation in a given time and particular number of
rotations in a specific time.
THEORY:
A Stepper motor is a motor in which the rotation is in step by step manner with an angle of
rotation. The rotor in stepper motor has only discrete stationary angular. The rotary motion occurs in a
stepwise manner from one equilibrium position to the next. The stator has electromagnet with winding
on all the 4 poles. The rotor has permanent magnet with 3 pairs of poles having two poles of north and
south each. Two-phase scheme: Any two adjacent stator windings are energized. There are two magnetic
fields active in quadrature and none of the rotor pole faces can be in direct alignment with the stator
poles. A partial but symmetric alignment of the rotor poles is of course possible.
ALGORITHM:
57
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
MEMORY A1 A2 B1 B2 HEX
LOCATION CODE
4500 1 0 0 1 09 H
4501 0 1 0 1 05 H
4502 0 1 1 0 06 H
4503 1 0 1 0 0A H
FLOWCHART:
START
DELAY
DECREMENT COUNTER
YES
IS Count = 0
NO
58
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
PROGRAM TABLE
PROGRAM COMMENTS
Start: MOV DI, 1200H Initialize memory location to store the array of number
MOV CX, 0004H Initialize array size
Loop1: MOV AL,[DI] Copy the first data in AL
OUT 0C0,AL Send it through port address
MOV DX, 1010H
L1 : DEC DX Introduce delay
JNZ L1
INC DI Go to next memory location
LOOP Loop1 Loop until all the data’s have been sent
JMP Start Go to start location for continuous rotation
1200 : 09,05,06,0A Array of data’s
RESULT:
Thus the assembly language program for rotating stepper motor in both clockwise and
anticlockwise directions is written and verified.
59
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
To write an assembly language program to control the Traffic light System by interfacing 8255
– Programmable Peripheral Interface using 8086 microprocessors.
APPARATUS REQUIRED:
SL.NO ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8086 1
3. System with MASM 8086 programmer 1
4. Traffic light system 1
interfacing card
PROBLEM STATEMENT:
To write a program to control traffic light setup using the interfacing 8255PPI, in which Port
A and Port B are used.
60
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DESCRIPTION:
The board is a simple model of a traffic control system wherein the signaling lights are simulated
by the blinking ON-OFF of light emitting diodes. The signaling lights for the pedestrian crossing are
simulated by the ON-OFF control of dual color light emitting diodes.
A model of four road-four lane junctions, the board has green, yellow and red LEDs, which are
the green, orange and red signals of an actual system. Twelve LEDs are used in the board. In addition
eight dual color LEDs are used which can be made to change either to red or to orange.
The board communicates with the microprocessor trainer by means of a 26-core cable, which is
connected to the output pins of any parallel port of Vi range of trainers. The outputs are the inputs to the
buffers 7406 whose output drives the LEDs. The buffered output applied to the anode of the LEDs
decides whether it is ON or OFF.
ALGORITHM:
61
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
PORT ADDRESS:
Port A : 0CH
Port B : 0DH
Port C : 0EH
Control Reg.: 0FH
D7 -1 =I/O MODE
62
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
SAMPLE INPUTS:
4101 1A A1 64
4104 A4 81 5A 64
4108 54 8A B1 A8
410C B4 88 DA 68
4110 D8 1A E8 46
4114 E8 83 78 86 74
ALGORITHM
PROGRAM
CONTRL EQU 026H
PORTA EQU 020H
63
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DELAY: PUSH CX
MOV CX,0005H
1020 REPEAT:
MOV DX,0FFFFH
LOOP2: DEC DX
FD JNZ LOOP2
LOOP REPEAT
POP CX
RET
ORG 1100H
DB 80H,1AH,0A1H,64H,0A4H
DB 81H,5AH,64H,54H,8AH
DB 0B1H,0A8H,0B4H,88H
DB 0DAH,68H,0D8H,1AH,0E8H
DB 46H,0E8H,83H,78H,86H,74H
CODE ENDS
END
RESULT:
Thus the traffic light controller interfacing with 8086 microprocessor using 8255PPI and
the traffic signals were tested and verified.
64
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
To write an assembly language program to convert an analog signal into a digital signal using an
ADC interfacing.
APPARATUS REQUIRED:
PROBLEM STATEMENT:
The program is executed for various values of analog voltage which are set with the help of a
potentiometer. The LED display is verified with the digital value that is stored in a memory location.
THEORY:
An ADC usually has two additional control lines: the SOC input to tell the ADC when to start the
conversion and the EOC output to announce when the conversion is complete. The following program
initiates the conversion process, checks the EOC pin of ADC 0809 as to whether the conversion is over
and then inputs the data to the processor. It also instructs the processor to store the converted digital data
at RAM location.
ALGORITHM:
65
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
FLOW CHART:
START
NO
IS EOC = 1?
YES
STOP
PROGRAM TABLE
PROGRAM COMMENTS
66
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
RESULT:
ANALOG DIGITAL DATA ON LED HEX CODE IN MEMORY
VOLTAGE DISPLAY LOCATION
Thus the ADC was interfaced with 8086 and the given analog inputs were converted into its
digital equivalent.
67
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
APPARATUS REQUIRED:
PROBLEM STATEMENT:
The program is executed for various digital values and equivalent analog voltages are measured
and also the waveforms are measured at the output ports using CRO.
THEORY:
Since DAC 0800 is an 8 bit DAC and the output voltage variation is between –5v and +5v. The
output voltage varies in steps of 10/256 = 0.04 (approximately). The digital data input and the
corresponding output voltages are presented in the table. The basic idea behind the generation of
waveforms is the continuous generation of analog output of DAC. With 00 (Hex) as input to DAC2 the
analog output is –5v. Similarly with FF H as input, the output is +5v. Outputting digital data 00 and FF
at regular intervals, to DAC2, results in a square wave of amplitude 5v.Output digital data from 00 to FF
in constant steps of 01 to DAC2. Repeat this sequence again and again. As a result a saw-tooth wave
will be generated at DAC2 output. Output digital data from 00 to FF in constant steps of 01 to DAC2.
Output digital data from FF to 00 in constant steps of 01 to DAC2. Repeat this sequence again and
again. As a result a triangular wave will be generated at DAC2 output.
ALGORITHM:
Measurement of analog voltage:
68
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
Waveform generation:
Square Waveform:
STOP
69
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
INITIALIZE
INITIALIZE
ACCUMULATOR
ACCUMULATOR
SEND ACCUMULATOR
SEND ACCUMULATOR CONTENT TO DAC
CONTENT TO DAC
INCREMENT ACCUMULATOR INCREMENT ACCUMULATOR
CONTENT CONTENT
NO YES
YES
IS ACC FF
IS ACC
FF
NO
DECREMENT ACCUMULATOR
CONTENT
SEND ACCUMULATOR
CONTENT TO DAC
YES
NO
IS ACC 00
PROGRAM COMMENTS
MOV AL,7FH Load digital value 00 in accumulator
OUT C0,AL Send through output port
HLT Stop
70
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
PROGRAM COMMENTS
L2 : MOV AL,00H Load 00 in accumulator
OUT C0,AL Send through output port
CALL L1 Give a delay
MOV AL,FFH Load FF in accumulator
OUT C0,AL Send through output port
CALL L1 Give a delay
JMP L2 Go to starting location
L1 : MOV CX,05FFH Load count value in CX register
L3 : LOOP L3 Decrement until it reaches zero
RET Return to main program
PROGRAM COMMENTS
71
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
PROGRAM TABLE:
Triangular Wave
PROGRAM COMMENTS
RESULT:WAVEFORM GENERATION:
Square Waveform
Saw-tooth waveform
Triangular waveform
MODEL GRAPH:
RESULT:
Thus the DAC was interfaced with 8086 and different waveforms have been generated.
72
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
To Program the 8086microprrocessor that places a message on the screen every 10 seconds,
using INT 1A h.
APPARATUS REQUIRED:
PROGRAM STATEMENT:
CODE SEGMENT
TIMEDELAY:
MOV SP,1000H
MOV DI,10XD
TIME OUT:
MOV AH,00H
INT 1AH
MOV BX,DX
TIMER:
MOV AH, 00H
INT 1AH
SUB DX, BX
CMP DX, 182XD
JC TIMER
MOV AH, 09H
CS MOV DX,MSG
INT 21H
DEC DI
JNZ TIMEOUT
MOV AX,4C00H
INT 21H
MSG:
DB 'TEN MORE SECONDS HAVE PASSED $'
CODE ENDS
RESULT:
Thus 8086microprocessor is programmed for digital clock and the outputs are verified.
73
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
8 BIT Addition / Subtraction / Multiplication / Division – Basic Arithmetic Operations
AIM:
To write a program to add / Subtraction / Multiply and divide two 8-bit numbers using 8051
microcontroller.
ALGORITHM: Addition
1. Clear Program Status Word.
2. Select Register bank by giving proper values to RS1 & RS0 of PSW.
3. Load accumulator A with any desired 8-bit data.
4. Load the register R 0 with the second 8- bit data.
5. Add these two 8-bit numbers.
6. Store the result. START
7. Stop the program.
ALGORITHM:
N
Select Register IS CF=1 o
Bank
Y
Load A and R 0
with 8- bit datas INCREMENT THE
BORROW
REGISTER
Add A & R 0
STOP
74 STOP
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
4500 4500
75
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
ALGORITHM: Multiplication
ALGORITHM: Division
FLOWCHART:
START START
STORE
STORE RESULT QUOTIENT &
IN MEMORY REMAINDER IN
MEMORY
STOP STOP
76
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
8 Bit Multiplication
8 Bit Division
77
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
RESULT:
OUTPUT
MEMORY LOCATION DATA
4502
4503
OUTPUT
4502 (remainder)
4503 (quotient)
RESULT:
Thus the 8051 Assembly Language Program for addition / subtraction / multiplication and
division of two 8 bit numbers is executed and verified.
78
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
8 BIT Logical and Bit Manipulation
AIM:
To write an Assembly Language Program to perform logical and bit manipulation operations
using 8051 microcontroller.
APPARATUS REQUIRED:
ALGORITHM:
FLOWCHART:
START
STOP 79
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
PROGRAM TABLE
80
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
OUTPUT:
4502H (SCON) SM0 SM1 SM2 REN TB8 RB8 TI RI 0FH 20H
RESULT:
Thus the bit manipulation operation is done and verified in 8051 microcontroller.
81
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
To write an ALP to find 2’s complement, square and square root of a byte using 8051
microcontroller.
APPARATUS REQUIRED:
2’s complement
ORG 0000H
START: MOV A, # 05h
CPL A
ADD A, #01H
MOV DPTR,#4500h
MOV @DPTR, A
AGAIN: SJMP AGAIN
Square of a number
82
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
RESULT:
2’s complement
INPUT OUTPUT
A=05H at memory location 4500h =FBH
Square of a number
8600H = 7AH 8700H=24H ; 8701 = 3AH
Thus the 8051 Assembly Language Program for finding 2’ complement, square of a number and
square root of a number are executed and results are verified.
83
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
DATE:
APPARATUS REQUIRED:
PROGRAM STATEMENT:
Assume that register A has packed BCD. Write a program to convert packed BCD to two ASCII
numbers and place them in R2 and R6
Solution:
RR A ;Rotate right
ORL A, #30H ;A=32H, ASCII Char’2’
MOV R2,A ;save ASCII Char in R2
After giving these instructions, you have to use the following instructions to verify the output at
memory location.
84
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
MOV DPTR,#4500H
MOV A, R6
MOV @DPTR,A
INC DPTR
MOV A,R2
MOV @DPTR,A
STOP: SJMP STOP
RESULT:
INPUT:29H (Packed BCD) OUTPUT: 4500 = 39H(ASCII) ; 4501 = 32H (ASCII).
Thus the given packed BCD is unpacked and packed ASCII number is found and verified.
85
EC6513 MICROPROCESSOR & MICROCONTROLLER LAB DEPT OF ECE / PEC
86