MPMC Lab Manual
MPMC Lab Manual
ORS AND
MICROCONTROL
LERS LAB
MICROPROCESSORS & MICROCONTROLLERS
LAB MANUAL
B.TECH
(III YEAR – II SEM)
(2022-23)
Prepared by:
Mr. KDK Ajay, Asst. Professor
VISION
MISSION
QUALITY POLICY
1
R20Autonomous III B. TechIISemester MPMCLabManual
PROGRAMME EDUCATIONAL OBJECTIVES
To provide knowledge based services to satisfy the needs of society and the industry by
providing hands on experience in various technologies in core field.
To make the students to design, experiment, analyze, interpret in the core field with
the help of other multi disciplinary concepts wherever applicable.
To educate the students to disseminate research findings with good soft skills and
become a successful entrepreneur.
PSO2
To nurture the students in designing, analyzing and interpreting required in research
and development with exposure in multi disciplinary technologies in order to mould them
as successful industry ready engineers/entrepreneurs
PSO3
To empower students with all round capabilities who will be useful in making nation
strong in technology, education and research domains.
2
R20Autonomous III B. TechIISemester MPMCLabManual
PROGRAM OUTCOMES (POs)
Engineering Graduates will be able to:
3
R20Autonomous III B. TechIISemester MPMCLabManual
Course Objectives:
● To develop and execute variety of assembly language programs of Intel 8086
including arithmetic and logical, sorting, searching, and string manipulation
operations.
● To develop and execute the assembly language programs for interfacing Intel 8086
with peripheral devices.
● To develop and execute simple programs on 8051 micro controller.
Course Outcomes:
After going through this course the student will be able to
4
R20Autonomous III B. TechIISemester MPMCLabManual
LABORATORY RULES
General Rules of Conduct in Laboratories:
1. You are expected to arrive on time and not depart before the end of a laboratory.
2. You must not enter a lab unless you have permission from a technician or lecturer.
3. You are expected to comply with instructions, written or oral, that the laboratory
Instructor gives you during the laboratory session.
4. You should behave in an orderly fashion always in the lab.
5. You must not stand on the stools or benches in the laboratory.
6. Keep the workbench tidy and do not place coats and bags on the benches.
7. You must ensure that at the end of the laboratory session all equipment used is stored
away where you found it.
8. You must put all rubbish such as paper outside in the corridor bins. Broken
components should be returned to the lab technician for safe disposal.
9. You must not remove test equipment, test leads or power cables from any lab
without permission.
10. Eating, smoking and drinking in the laboratories are forbidden.
11. The use of mobile phones during laboratory sessions is forbidden.
12. The use of email or messaging software for personal communications during
laboratory sessions is forbidden.
13. Playing computer games in laboratories is forbidden.
Specific Safety Rules for Laboratories:
1. You must not damage or tamper with the equipment or leads.
2. You should inspect laboratory equipment for visible damage before using it. If there is a
problem with a piece of equipment, report it to the technician or lecturer. DONOT return
equipment to a storage area
3. You should not work on circuits where the supply voltage exceeds 40 volts without very
specific approval from your lab supervisor. If you need to work on such circuits, you should
contact your supervisor for approval and instruction on how to do this safely before
commencing the work.
4. Always use an appropriate stand for holding your soldering iron.
5. Turn off your soldering iron if it is unlikely to be used for more than 10 minutes.
6. Never leave a hot soldering iron unattended.
7. Never touch a soldering iron element or bit unless the iron has been disconnected
from the mains and has had adequate time to cool down.
8. Never strip insulation from a wire with your teeth or a knife, always use an appropriate
wire stripping tool.
9. Shield wire with your hands when cutting it with a pliers to prevent bits of wire flying
about the bench.
5
R20Autonomous III B. TechIISemester MPMCLabManual
INDEX
PART-A
1. Introduction to MASM 7
PART-B
6
R20Autonomous III B. TechIISemester MPMCLabManual
PART-A
1. INTRODUCTION TO MASM
EDITOR
An editor is a program, which allows you to create a file containing the assembly
language statements for your program. As you type in your program, the editor stores the
ASCII codes for the letters and numbers in successive RAM locations. When you have typed in
all of your programs, you then save the file on a floppy of hard disk. This file is called source
file. The next step is to process the source file with an assembler. In the MASM /TASM
assembler, you should give your source file name the extension, .ASM
ASSEMBLER
An assembler program is used to translate the assembly language mnemonics for
instructions to the corresponding binary codes. When you run the assembler, it reads the
source file of your program from the disk, where you saved it after editing on the first pass
through the source program the assembler determines the displacement of named data items,
the offset of labels and pails this information in a symbol table. On the second pass through the
source program, the assembler produces the binary code for each instruction and inserts the
offset etc that is calculated during the first pass. The assembler generates two files on floppy or
hard disk. The first file called the object file is given the extension. OBJ. The object file contains
the binary codes for the instructions and information about the addresses of the instructions.
The second file generated by the assembler is called assembler list file. The list file contains
your assembly language statements, the binary codes for each instructions and the offset for
each instruction. In MASM/TASM assembler, MASM/TASM source file name ASM is used to
assemble the file. Edit source file name LST is used to view the list file, which is generated,
when you assemble the file.
LINKER
A linker is a program used to join several object files into one large object file and
convert to an exe file. The linker produces a link file, which contains the binary codes for all the
combined modules. The linker however doesn’t assign absolute addresses to the program, it
assigns is said to
7
R20Autonomous III B. TechIISemester MPMCLabManual
be reloadable because it can be put anywhere in memory to be run. In MASM/TASM,
LINK/TLIN8K source filename is used to link the file.
DEBUGGER
A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot are debug it the debugger allows you to look
at the contents of registers and memory locations after your program runs. It allows you to
change the contents of register and memory locations after your program runs. It allows you to
change the contents of register and memory locations and return the program. A debugger
also allows you to set a break point at any point in the program. If you inset a breakpoint the
debugger will run the program up to the instruction where the breakpoint is set and stop
execution. You can then examine register and memory contents to see whether the results are
correct at that point. In MASM/TASM, td filename is issued to debug the file.
DEBUGGER FUNCTIONS:
6. We can trace the program step by step with the help of F7.
7. We can execute the program completely at a time using F8
8
R20Autonomous III B. TechIISemester MPMCLabManual
COMMAND SYNTAX
Assemble A [address]
Compare C range address
Dump D [range]
Enter E address [list]
Fill F range list
Go G [=address] [addresses]
Hex H value1 value2
Input I port
Load L[address] [drive][first sector]
[number]
Move M range address
Name N[pathname][argument list]
Output O port byte
Proceed P [=address][number]
Quit Q
Register R[register]
Search S range list
Trace T [=address][value]
Unassembled u [range]
Write W[address][drive][first sector]
[number]
MS-MASM:
Microsoft’s Macro Assembler (MASM) is an integrated software package Written by
Microsoft Corporation for professional software developers. It consists of an editor, an
assembler, a linker and a debugger (Code View). The programmer’s workbench combines these
four parts into a user-friendly programming environment with built in on line help. The
following are the steps used if you are to run MASM from DOS
9
R20Autonomous III B. TechIISemester MPMCLabManual
STEP3: Directory changing (create a folder with your branch and no in D drive)
Change the current directory to your won directory suppose your folder in D drive type
the following commands to change the directory at command prompt type D: hit enter now
you are in D drive type cd folder name hit the enter
Example: D cd ece10
Now we are in folder cse10
1
R20Autonomous III B. TechIISemester MPMCLabManual
If there are any errors in the program assembler reports all of them at the command
prompt with line no’s, if there are now bugs your ready to link the program. To link the
program type the following line at command prompt Link program name,,,,, (5 commas)
Example: Link
add,,,,, OR
Example: link add.obj
After linking you are ready to execute the program. To execute the program type the following
command
Debug program name.exe hit the enter
Example: Debug add.exe
Now you entered into the execution part of the program here you have to execute the
program instruction by instruction (debugging) first of all press the r key(register) hit the enter
key it’ll displays all the registers and their initial values in HEXDECIMAL note down the values of
all the register which are used in the program. To execute the next instruction press t key
(TRACE) hit the enter it’ll execute that instruction and displays the contents of all the register.
You have to do this until you reach the last instruction of the program. After execution you
have to observe the results (in memory or registers based on what you have written in the
program).
A list file contains your code starting address and end address along with your program
.For every program assembler generates a list file at your folder, programname.lst (ex. Add.lst)
you should copy this to your lab observation Opening a list file
Edit
programname.lst
Example. Edit
add.lst
1
R20Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO.2
16 BIT ARITHMETIC OPERATIONS
AIM: Write an ALP to 8086 to perform 16-bit arithmetic operations in various Addressing Modes
ALGORITHM:
FLOW CHART:
START
AXOPR1
AXAX+OPR2 SUMAX
STOP
1
R20Autonomous III B. TechIISemester MPMCLabManual
PROGRAM:
EXTRA SEGMENT
SUM DW ?
EXTRA ENDS
CODE
SEGMENT
START: MOV AX, DATA
MOV DS, AX ; REGISTER ADDRESING
MODE MOV AX, OPR1 ; DIRECT ADDRESSING
MODE ADD AX, OPR2 ; DIRECT ADDRESSING
MODE MOV SUM, AX ; DIRECT ADDRESSING
MODE INT 03H
CODE
ENDS
END
START
END
(B) 16-bit subtraction using different addressing
modes ALGORITHM:
1
R20Autonomous III B. TechIISemester MPMCLabManual
FLOW CHART:
START
PROGRAM:
AXOPR1
ASSUME CS:CODE, DS: DATA,ES:EXTRA
STOP
DATA SEGMENT
OPR1 DW
5169H OPR2
DW 1000H
DATA ENDS
EXTRA
SEGMENT
DIFF DW ?
EXTRA ENDS
CODE
SEGMENT
START: MOV AX, DATA
MOV DS, AX ; REGISTER ADDRESIING
MODE MOV AX, EXTRA
MOV ES, AX ; REGISTER ADDRESIING
MODE MOV BX, OFFSET OPR1 ; DIRECT ADDRESSING
MODE MOV AX, [BX] ; BASE ADDRESSING
MODE/
SUB AX, OPR2 ; DIRECT ADDRESSING MODE
MOV DIFF, AX ; DIRECT ADDRESSING
MODE INT 03H
CODE
ENDS
END
START
END
1
R20Autonomous III B. TechIISemester MPMCLabManual
(C) 16-bit Multiplication using different addressing modes
ALGORITHM:
START
AXOPR1 BXOPR2
STOP
1
R20Autonomous III B. TechIISemester MPMCLabManual
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES:
EXTRA DATA SEGMENT
OPR1 DW
5169H OPR2
DW 1000H
DATA ENDS
EXTRA
SEGMENT
RES DW 2
DUP(0) EXTRA
ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX ; REGISTER ADDRESIING
MODE MOV AX,EXTRA
MOV ES, AX ; REGISTER ADDRESIING
MODE MOV SI,OFFSET OPR1
MOV AX,[SI] ; INDEXED ADDRESSING
MODE MOV BX,OPR2 ; DIRECT ADDRESSING
MODE MUL BX ; REGISTER ADDRESSING
MODE MOV RES, AX ; DIRECT ADDRESSING
MODE MOV RES+2, DX ; DIRECT
ADDRESSING MODE INT 03H
CODE
ENDS
END
START
END
1
R20Autonomous III B. TechIISemester MPMCLabManual
(D) 16-bit Division using different addressing
modes ALGORITHM:
Step I : Initialize the data & extra segment
memory. Step II : Load the first number into DX:AX
registerpair. Step III : Load the second number into BX
register.
Step IV : Divide DX:AX pair by BX.
FLOW CHART:
START
LOAD THE NUMBERS INTO RESPECTIVE REGISTERS
DIVISION OF DX:AX BY BX
STOP
1
R20Autonomous III B. TechIISemester MPMCLabManual
PROGRAM:
ASSUME CS: CODE, DS:DATA,
ES:EXTRA DATA SEGMENT
OPR1 DD
74105169H OPR2
DW 7875H
DATA ENDS
EXTRA
SEGMENT
DIVQ
DW ?
DIVR
DW ?
EXTRA ENDS
CODE
SEGMENT
START:MOV AX, DATA
MOV DS, AX ; REGISTER ADDRESIING
MODE MOV AX, EXTRA
MOV ES, AX ; REGISTER ADDRESIING
MODE MOV SI, OFFSET OPR1
MOV AX, [SI] ; INDEXED ADDRESSING
MODE/ MOV DX, [SI+2] ; INDEXED
ADDRESSING MODE MOV BX, OPR2 ;
DIRECT ADDRESSING MODE DIV BX
; REGISTER ADDRESSING
MODE MOV DIVQ , AX
MOV DIVR ,
DX INT 03H
CODE
ENDS
END
START
1
R20Autonomous III B. TechIISemester MPMCLabManual
END
1
R20Autonomous III B. TechIISemester MPMCLabManual
Result:
UNSIGNED
NUMBERS INPUT:
OPR1 =
OPR2 =
OUTPUT: ALL RESULTS ARE STORED IN EXTRA SEGMENT
(ES) SUM =
DIFF
=
MUL
=
MUL
+2=
DIVQ
=
DIVR
=
Exercise Questions:
1) Write an assembly language program for the expression ax+b
2) Write an assembly language program for the squaring of 16 bit Hexa Decimal number.
3) Write an assembly language program for the factorial of 8 bit Hexadecimal number.
Viva Question:
1) What is meant by microprocessor?
2) What is meant by accumulator?
3) What is meant by assembler directive?
4) What are segment Registers?
5) What is the use of INT 03H instruction ?
2
R20Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
2
R20Autonomous III B. TechIISemester MPMCLabManual
2
R20Autonomous III B. TechIISemester MPMCLabManual
2
R20Autonomous III B. TechIISemester MPMCLabManual
2
R20Autonomous III B. TechIISemester MPMCLabManual
2
R20Autonomous III B. TechIISemester MPMCLabManual
2
R20Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO.3
SORTING AN ARRAY FOR
8086
AIM: Write and execute an ALP to 8086 processor to sort the given 16-bit
numbers in Ascending and Descending order.
TOOLS: PC installed with MASM 6.11
ALGORITHM:
2
R20Autonomous III B. TechIISemester MPMCLabManual
FLOW CHART: START
DXCOUNT-1
BACK: CXDX
AX[SI]
TRUE
IF
AX < [SI+2]
FALSE
EXCHANGE
[SI] &[SI+2]
INCREMENT SI BY 2
FALSE
IF CX=0
TRUE
DECREMENT DX
FALSE
IF
DX=0
TRUE
STOP
2
R20Autonomous III B. TechIISemester MPMCLabManual
PROGRAM:
ASCENDING ORDER
MOV DS,AX
MOV
DX,COUNT-1 BACK:
MOV CX,DX
MOV SI, OFFSET
LIST AGAIN: MOV AX,[SI]
CMP AX,
[SI+2] JC
GO
XCHG AX,
[SI+2]
XCHG AX,
[SI]
GO:INC SI
INC SI
LOOP
AGAIN
DEC DX
JNZ
BACK
INT
2
R20Autonomous III B. TechIISemester MPMCLabManual
03H
CODE
ENDS
END
START
END
3
R20Autonomous III B. TechIISemester MPMCLabManual
Result:
DESCENDING ORDER
ALGORITHM:
3
R20Autonomous III B. TechIISemester MPMCLabManual
FLOW CHART:
START
DXCOUNT-1
BACK : CXDX
AGAIN: AX[SI]
TRUE
IF
AX > [SI+2]
FALSE
INCREMENT SI BY 2
FALSE
IF CX=0 ?
TRUE
DECREMENT DX
FALSE
IF DX=0 ?
TRUE
STOP
3
R20Autonomous III B. TechIISemester MPMCLabManual
DESCENDING ORDER
PROGRAM:
ASSUME CS: CODE,
DS:DATA DATA
SEGMENT
LIST DW
0125H,0144H,3001H,0003H,0002H
COUNT EQU 05H
DATA ENDS
CODE
SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV
DX,COUNT-1
BACK:MOV CX,DX
MOV SI,OFFSET
LIST AGAIN:MOV AX,
[SI]
CMP AX,
[SI+2] JAE
GO
XCHG AX,
[SI+2]
XCHG AX,
[SI]
GO:INC SI
INC SI
LOOP
AGAIN
DEC DX
3
R20Autonomous III B. TechIISemester MPMCLabManual
JNZ
BACK
INT
03H
CODE
ENDS
END
START
END
3
R20Autonomous III B. TechIISemester MPMCLabManual
Result:
Exercise Questions:
1) Write an assembly language program for finding the maximum number in array of
five16 bit hexadecimal numbers?
2) Write an assembly language program for finding the minimum number in array of
five 16 bit hexadecimal numbers?
Viva Questions:
1) What is the use of SI Register?
2) What is the use of XCHG instruction?
3) What is the use of CX Register ?
4) What is the use of JNZ instruction?
3
R20Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
3
R20Autonomous III B. TechIISemester MPMCLabManual
3
R20Autonomous III B. TechIISemester MPMCLabManual
3
R20Autonomous III B. TechIISemester MPMCLabManual
3
R20Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 4
SEARCH ING FOR CHARACTER IN A
STRING
AIM: Write an ALP for searching for a number or character in a string for 8086.
TOOLS: PC installed with MASM 6.11
ALGORITHM:
4
R20Autonomous III B. TechIISemester MPMCLabManual
NO
SEARCH FOR CHARACTER
YES
STOP
4
R20Autonomous III B. TechIISemester MPMCLabManual
Program:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
STRING DB
'MRCET$' SLEN
EQU ($-STRING)
CHAR DB 'E'
MSG1 DB 'THE CHARACTER IS FOUND$'
MSG2 DB 'THE CHARACTER IS NOT
FOUND$'
DATA ENDS
CODE
SEGMENT
START: MOV AX, DATA
MOV DS,
AX MOV
ES, AX LEA
SI, STRING
MOV CX,
LEN MOV
AL, CHAR
CLD
REPNE SCASB
JNZ EXIT
LEA DX,
MSG1
MOV AH,
09H INT
21H
JMP
GOTOEND EXIT:
LEA DX, MSG2
MOV AH,
4
R20Autonomous III B. TechIISemester MPMCLabManual
09H INT
21H
GOTOEND: MOV AH, 4CH
INT
21H CODE
ENDS END
START END
4
R20Autonomous III B. TechIISemester MPMCLabManual
Exercise Questions:
1) Write an assembly language program for the password verification?
Viva Questions:
1) What is the use of SCASB Register?
2) What is the use of REPNE instruction?
3) What is the relation of CX Register with REPNE?
4
R20Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
4
R20Autonomous III B. TechIISemester MPMCLabManual
4
R20Autonomous III B. TechIISemester MPMCLabManual
4
R20Autonomous III B. TechIISemester MPMCLabManual
4
R20Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO.5
STRING MANIPULATIONS FOR
8086
AIM: To write an assembly language program to move the block of data from a source
BLOCK to the specified destination BLOCK.
A) BLOCK TRANSFER
ALGORITHM:
Step I : Initialize the Data segment (DS) & Extra segment (ES)
Step II : Load the offset address of source and destination the string into SI and DI.
Step III : Load the number of elements of the string into Count register(CL)
Step IV : Clear Direction flag (DF) to make SI and DI into auto increment
4
Movethecharacterbycharacterfromsourcetodestinationt
illtheend
START
PROGRAM:
Move the character by character from source to destination till the end
STOP
5
R20Autonomous III B. TechIISemester MPMCLabManual
STRING1 DB ?
EXTRA ENDS
CODE
SEGMENT
START:
MOV
AX,DATA
MOV DS,AX
MOV AX,
EXTRA MOV
ES,AX
MOV SI,OFFSET
STRING MOV
DI,OFFSET STRING1
MOV CL,COUNT
CL
D REP
MOVSB
INT
03H CODE
ENDS END
START
END
RESULT:
5
R20Autonomous III B. TechIISemester MPMCLabManual
B) REVERSE STRING
Step I : Initialize the Data segment (DS) & Extra segment (ES)
Step II : Load the offset address of source and destination the string into SI and DI.
Step III : Load the number of elements of the string into Count Register (CX)
Step IV : Add CX to DI to Point to last location of the memory
Step V : move the character by character from source to destination till the end
Step VI : Stop & Terminate the program
START
FLOW CHART:
Load the offset address of source and destination the string into SI and DI.
Move the character by character from source to destination till the end
STOP
5
R20Autonomous III B. TechIISemester MPMCLabManual
PROGRAM:
MOV DS, AX
MOV AX,
EXTRA MOV
ES, AX
MOV SI, OFFSET
STRING1 MOV DI,
OFFSET STRING2
MOV CX, STRLEN-1
ADD
DI, CX
MOV
DL,'$'
MOV ES:
[DI],DL AGAIN:
DEC DI
MOV AL,DS:[SI]
MOV ES:
[DI],AL INC
5
R20Autonomous III B. TechIISemester MPMCLabManual
SI
DEC
CX JNZ
AGAIN
INT 3H
RESULT:
INPUT: '
MICROPROCESSOR’
OUTPUT:
‘ROSSECORPORCIM’
5
R20Autonomous III B. TechIISemester MPMCLabManual
C) LENGTH OF THE STRING
AIM: To write an assembly language program to find the length of the given string.
TOOLS: PC installed with MASM 6.11
ALGORITHM:
Step I : Initialize the data segment (DS)
Step II : Initialize the counter CL with 0
Step III : Move stating address of the string to SI register
Step IV : Move the each character from memory to to Accumulator (AL)
Step V : Compare AL with last character of the string i.e $ and increment CL until ZF=0
Step VII : Store the result
START
Step VIII : Stop.
FLOW CHART:
Initialization of Data Segment
Move the each character from memory to to Accumulator (AL) and Increment C
NO
ZF=0?
YES
Decrement CL
STOP
5
R20Autonomous III B. TechIISemester MPMCLabManual
Program:
ASSUME CS:CODE,
DS:DATA DATA
SEGMENT
STRING1 DB 'MICROPROCESSOR AND INTERFACING
LAB$' SLENGTH DB 0
DATA ENDS
CODE
SEGMENT
START: MOV AX,
DATA MOV
DS, AX SUB
CL, CL
MOV SI, OFFSET
STRING1 CLD
BACK: LODSB
I
N
C
C
L
CODE ENDS END START
C
M
P
A
L
,
'
$
'
5
R20Autonomous III B. TechIISemester MPMCLabManual
J S
N L
Z E
N
B G
A T
C H
K ,
D C
E L
C
I
C N
L T
M
O 0
V 3
H
LAB OUTPUT:
5
R20Autonomous III B. TechIISemester MPMCLabManual
D) STRING COMPARISON
ALGORITHM:
Step I : Initialize the data segment (DS) & extra Segment as per requirement
Step II : Load the offset address of source and destination of the string into SI and DI.
Step III : Initialize the counter register CX with length of source string
Step IV : Clear Direction flag (DF) to make SI and DI into auto increment mode
Step V : Compare source string with destination string until the characters are not
equal or up to last last character
Step VII : If ZF=0 the strings are equal or otherwise the strings are not equal
Step VIII : Stop.
5
R20Autonomous III B. TechIISemester MPMCLabManual
FLOW CHART:
START
Load the offset address of source and destination the string into SI and DI.
Compare source string with destination string until the characters are not equal or up to last
NO
ZF=0
YES
START
5
R20Autonomous III B. TechIISemester MPMCLabManual
Program:
ASSUME CS: CODE, DS:DATA,
ES:EXTRA DATA SEGMENT
STRING1 DB 'MRCET'
STRLEN EQU ($-
STRING1)
SNOTEQUAL DB 'STRINGS ARE
UNEQUAL$' SEQUAL DB 'STRINGS ARE
EQUAL$'
DATA ENDS
EXTRA
SEGMENT
STRING2 DB
'MRCET' EXTRA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV
AX,EXTRA
MOV ES,AX
MOV SI,OFFSET
STRING1 MOV
DI,OFFSET STRING2
CLD
MOV
CX,STRLEN REPZ
CMPSB
JZ FORW
MOV AH,
09H
MOV DX, OFFSET
SNOTEQUAL INT 21H
JMP
EXITP FORW:
MOV AH,09H
MOV DX, OFFSET
SEQUAL INT 21H
6
R20Autonomous III B. TechIISemester MPMCLabManual
EXITP: MOV AH, 4CH
INT 03H
CODE
ENDS
END
START
RESULT: INPUT: OUTPUT:
6
R20Autonomous III B. TechIISemester MPMCLabManual
(E) STRING INSERTION
AIM: To Write and execute an Assembly language Program (ALP) to 8086 processor to insert or
delete a character/ number from the given string.
ALGORITHM:
Step I :Initialize the data segment (DS) & extra segment (ES)
Step II :Load the offset address of source and destination of the string into SI and
DI. Step III :Initialize the counter register CX with length of first part of source
string Step IV : Copy the first part of STRING1 in to STRING3 of extra segment
Step VI : Copy the STRING2 in to STRING3 of extra segment after first string of STRING1
Step VII: Load the new offset address of source of the STRING1 into SI
6
R20Autonomous III B. TechIISemester MPMCLabManual
FLOW CHART:
START
Load the offset address of source and destination string into SI and DI.
Initialize the counter register CX with length of first part of source string
Clear Direction flag (DF) to make SI and DI into auto increment mode
Copy the STRING2 in to STRING3 of extra segment after first string of STRING1
STOP
6
R20Autonomous III B. TechIISemester MPMCLabManual
Program:
ASSUME
CS:CODE,DS:DATA,ES:EXTRA
DATA SEGMENT
STRING1 DB 'MICROPROCESSOR INTERFACING
LAB$' STRING2 DB ‘AND ’
STRLEN EQU ($-
STRING1) ORG 0070H
DATA ENDS
EXTRA
SEGMENT
ORG 0010H
STRING3 DB 38
DUP(0) EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX,
EXTRA MOV
ES, AX
MOV SI, OFFSET
STRING1 MOV DI,
OFFSET STRING3 CLD
MOV CX,
15 REP
MOVSB
CLD
MOV SI, OFFSET
STRING2 MOV CX,4
REP MOVSB
MOV SI, OFFSET
STRING1 ADD SI,15
MOV CX,
6
R20Autonomous III B. TechIISemester MPMCLabManual
15 REP MOVSB
INT 3H
6
R20Autonomous III B. TechIISemester MPMCLabManual
CODE
ENDS
END
START
RESULT:
INPUT: STRING1: 'MICROPROCESSOR INTERFACING LAB'
STRING2:‘AND ’
OUTPUT: STRING3: ‘MICROPROCESSOR AND INTERFACING LAB'
6
R20Autonomous III B. TechIISemester MPMCLabManual
MOVSB
CLD
MOV SI, OFFSET
STRING1 ADD SI, 19
6
R20Autonomous III B. TechIISemester MPMCLabManual
E
P
M O
O V
V S
B
C
X I
, N
T
1
5 0
3
R H
RESULT:
INPUT: STRING1: MICROPROCESSOR AND INTERFACING
LAB' OUTPUT: STRING2: 'MICROPROCESSOR INTERFACING LAB'
Exercise Questions:
1) Write an assembly language program for the palindrome of a given string?
2) Write an assembly language program for the display of given string?
Viva Questions:
1) What are the string manipulation instructions?
2) What are the repeat instructions?
3) What is the use of DUP instruction?
4) What is the meaning of ORG assembler Directive?
6
R20Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
6
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
7
R20Autonomous III B. TechIISemester MPMCLabManual
8
R20Autonomous III B. TechIISemester MPMCLabManual
PART-B
INTRODUCTION TO HARDWARE EXPERIMENTS
8086 Programs can also executed by using ADM TK_µP Trainer kits. The Assembly
language programs (ALP) can be executed by the following steps
1. UxAsm
2. TKµP
1. UxAsm: It is used to translate the Assembly language program in to Machine language
(Hex File).The input file to the UxAsm is .asm and one of the output files is hex
file
Procedure for UXASM:
1. Go to start and select UXAsm
2. Verify the license by observing the following window and click “OK”
8
R20Autonomous III B. TechIISemester MPMCLabManual
3. Go to file and select “open source” and browse the source file(.ASM file)
8
R20Autonomous III B. TechIISemester MPMCLabManual
5. Again go to file select “New Project”
6. To add source file click on “Add File” and browse the source file and provide the
source file path with .Uxa extension in the Project and press Tab and Press “Save” and
click on “OK”
8
R20Autonomous III B. TechIISemester MPMCLabManual
7. Observe the following window and double click on path of the File to view the program
8
R20Autonomous III B. TechIISemester MPMCLabManual
9. To compile the program, click on “C” and observe the following window
10. If any errors, Fix the errors, click on “OK” and click on “B” to build the program
8
R20Autonomous III B. TechIISemester MPMCLabManual
TKμP
INTRODUCTION:
TKμP is an ideal trainer cum development boards for Microprocessors like Z80, 8032,
8085, 8088 and 8086. All interface is provided through 10 pin polarized Box Headers. TKμP user
interface software communicates with the TKμP hardware through PC parallel port LPT1 and
provides fast download of hex files. The PC user interface can open multiple windows for
memory Dump and List. Multiple dump windows is also useful to study memory move
operations and programs.
TKμP is made up of three sections:
⮚ 8255 IO expander.
● 8-Leds indicator.
8
R20Autonomous III B. TechIISemester MPMCLabManual
Procedure for TKµP
3. The following window will be displayed and go to window, select tile to avoid the
overlap of windows
8
R20Autonomous III B. TechIISemester MPMCLabManual
4 .To clear the garbage data from dump window, go to Listmem and select fillmem
5. To clear the data from dump window, enter start and, end address and fill the data with 00
8
R20Autonomous III B. TechIISemester MPMCLabManual
7. Browse the hex file from the source and click on “Load”
10. To verify the output, change the “SW-PP PROGRAM” switch to execution mode and
verify output
8
R20Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 6
DIGITAL CLOCK DESIGN USING
8086
TOOLS:
i. UXASM
ii. TKUP
iii. TKUP86 KIT
iv. FRC CABLE
PROGRAM:
#INCLUDE "TKUP86.DEF"
;******* INCLUDE EXTERNS NOW
;******* START CODING
HERE ORG 0FFFF0H
JMPF 0F000H,0F000H ; the basic reset
jump ORG 0FF000H
START: MOV SP,STKPTR CALL
INIT8255 MOV AL,0CH MOV
[0200H], AL MOV AL, 00H
NXTHR: MOV CX, 003CH NXTMNT:
MOV BX,003CH NXTSEC: CALL SECDLY
MOV DX,PA8255 MOV AL,
07H OUT DX,AL
DEC BX
JNE NXTSEC
; load stack pointer
; initialize 8255
9
R17Autonomous III B. TechIISemester MPMCLabManual
MOVDX,PA8255
MOV
AL,38H
OUT
DX,AL
DEC CX
JNE NXTMNT
MOV DX,
PA8255 MOV
AL, 0C0H OUT
DX, AL
MOV AX,
[0200H] DEC
AX
MOV
[0200H], AX
JNE NXTHR
SECDLY: PUSH
AX
PUSH
BX
PUSH
CX
PUSH
DX
MOV CX, 1234H
DLY: NOP
NOP
LOOP
DLY
POP
DX
POP
9
R17Autonomous III B. TechIISemester MPMCLabManual
MOVDX,PA8255
CX
POP
BX
POP
AX
RET
;******* initialize 8255
INIT8255
MOV AL,080H
MOV DX,
CMD8255 OUT
DX,AL
MOV AL,00H
9
R17Autonomous III B. TechIISemester MPMCLabManual
MOVDX,PA8255
OUT DX,AL
MOV
DX,PB8255
OUT DX,AL
MOV
DX,PC8255
OUT DX,AL
RET
RESULT: INPUT:
OUTPUT:
Exercise Questions:
1) Write an assembly language program for the different clock rates to display the
clock on the LCD.
Viva Questions:
9
R17Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
94
R17Autonomous III B. TechIISemester MPMCLabManual
95
R17Autonomous III B. TechIISemester MPMCLabManual
96
R17Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 7
PROGRAM FOR INTERFACING ADC&DAC TO 8086
TOOLS:
i. UXASM
ii. TKUP
iii. TKUP86 KIT
iv. FRC CABLE
v. ADC KIT
PROGRAM:
; CONNECT BH4 (PORT A) TO DAC BH1A
; CONNECT BH5 (PORTB) TO DAC BH2B
; CONNECT CRO PROBES TO CND1_1 OF DAC
#INCLUDE
"TKUP86.DEF" DATA
SEGMENT
PORTA EQU
9000H PORTC
EQU 9004H
CNTLPRT EQU
9006H MEM DW
2000H
DATA ENDS
CODE
SEGMENT
ASSUME CS: CODE, DS:
DATA START: MOV AX,
DATA
MOV DS, AX
MOV DX,
CNTLPRT MOV
AL, 98H
97
R17Autonomous III B. TechIISemester MPMCLabManual
OUT DX,
AL MOV
AL, 01H
OUT DX,
AL
98
R17Autonomous III B. TechIISemester MPMCLabManual
MOV AL, 00
OUT DX, AL
MOV DX,
PORTC
CHK: IN AL,
DX AND
AL, 80H
JZ CHK
MOV DX,
PORTA IN AL,
DX
MOV MEM,
AL INT 03H
CODE
ENDS
END
START
RESULT: INPUT :
OUTPUT :
PROGRAM:
; CONNECT BH4 (PORT A) TO DAC BH1A
; CONNECT BH5 (PORTB) TO DAC BH2B
; CONNECT CRO PROBES TO CND1_1 OF DAC
#INCLUDE "TKUP86.DEF"
99
R17Autonomous III B. TechIISemester MPMCLabManual
ORG 0FFFF0H
JMPF 0F000H,0F000H
10
R17Autonomous III B. TechIISemester MPMCLabManual
ORG 0FF000H
MOV AL,080H
MOV
DX,CMD8255
OUT DX,AL
MOV AL,00H
MOV
DX,PA8255
OUT DX,AL
MOV
DX,PB8255
OUT DX,AL
MOV
DX,PC8255
OUT DX,AL
RPT: MOV AL,00H
MOV
AL,0FFH AGAIN: MOV
DX, PA8255
OUT DX,
AL CALL
DELAY
CALL
DELAY
CALL
DELAY
CALL
DELAY
CALL
DELAY
CALL
DELAY
INC AX
10
R17Autonomous III B. TechIISemester MPMCLabManual
JNE
AGAIN
JMP
RPT
DELAY: MOV CX,
0FF00H NXT2: MOV
BX, 1234H NXT:
NOP
N
O
P
N
O
P
N
O
P
N
O
P
10
R17Autonomous III B. TechIISemester MPMCLabManual
DEC
BX
JNE
NXT
RET
RESULT: INPUT :
OUTPUT :
Exercise Questions:
1) Write an assembly language program to convert a saw tooth wave into digital.
2) Write an assembly language program for the generation of triangular wave
Viva Questions:
10
R17Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
10
R17Autonomous III B. TechIISemester MPMCLabManual
10
R17Autonomous III B. TechIISemester MPMCLabManual
10
R17Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 8
PARALLEL COMMUNICATION BETWEEN TWO
MICROPROCESSORS USING 8255
AIM: Write an ALP for parallel communication between two microprocessors using 8255
TOOLS:
i. UXASM
ii. TKUP
iii. TKUP86 KIT
iv. FRC CABLE
PROGRAM: FOR DATA IN KIT
#INCLUDE
"TKUP86.DEF"
ORG 0FFFF0H
JMPF
0F000H,0F000H
ORG 0FF000H
MOV AL,080H
MOV
DX,CMD8255
OUT DX,AL
MOV AL,00H
MOV
DX,PA8255
OUT DX,AL
MOV
DX,PB8255
OUT DX,AL
MOV
DX,PC8255
OUT DX,AL
RPT: MOV AL,47H
MOV
DX,PA8255
OUT DX,AL
MOV
10
R17Autonomous III B. TechIISemester MPMCLabManual
DX,PB8255
OUT DX,AL
MOV
DX,PC8255
OUT DX,AL
JMP RPT
10
R17Autonomous III B. TechIISemester MPMCLabManual
PROGRAM: FOR DATA OUT KIT
#INCLUDE
"TKUP86.DEF ORG
0FFFF0H
JMPF
0F000H,0F000H
ORG 0FF000H
MOV AL,090H
MOV
DX,CMD8255
OUT DX,AL
MOV AL,00H
MOV
DX,PA8255
OUT DX,AL
MOV
DX,PB8255
OUT DX,AL
MOV
DX,PC8255
OUT DX,AL
RPT: MOV
DX,PA8255
IN AL,DX
MOV
[0200H],AL
MOV
DX,PB8255
OUT DX,AL
MOV
DX,PC8255
OUT DX,AL
` JMP RPT
RESULT:
Exercise Questions:
1) Write an assembly language program to transfer MRCET string in between two 8255 kits.
Viva Questions:
10
R17Autonomous III B. TechIISemester MPMCLabManual
1) What is the function of IN Instruction?
2) What is the function of OUT Instruction?
3) What is the size of the ports of 8255?
4) What is the function of the control word register of 8255?
OBSERVATION:
11
R17Autonomous III B. TechIISemester MPMCLabManual
11
R17Autonomous III B. TechIISemester MPMCLabManual
11
R17Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 9
PROGRAM FOR INTERFACING STEPPER TO 8086
ORG 0FFFF0H
JMPF 0F000H,0F000H ; the basic reset
jump ORG 0FF000H
START MOV SP,STKPTR ; load stack
pointer CALL INIT8255 ; initialize
8255
LP1 MOV AL,01H ; use num1 for led count
value MOV DX,PA8255
OUT DX,AL ;
CALL DELAY ; call delay
MOV AL,02H ; use num1 for led count
value MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
MOV AL,04H ; use num1 for led count
value MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
MOV AL,08H ; use num1 for led count
value MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
JMP START ; restart again
;******* Delay
module DELAY NOP
MOV CX,03500H ; load Delay count =
0x3500 NOP ;
DLY1 NOP ;
LOOP DLY1 ;
RET ; end of delay
11
R17Autonomous III B. TechIISemester MPMCLabManual
INIT8255
MOV AL,080H ; make all ports
output MOV DX, CMD8255
OUT DX,AL ; write to command register
MOV AL,00H ; clear all
ports MOV DX,PA8255
OUT DX,AL ;
MOV DX,PB8255
OUT DX,AL ;
MOV DX,PC8255
OUT DX,AL ;
RET ;
ORG 0FFFF0H
JMPF 0F000H,0F000H ; the basic reset jump
ORG 0FF000H
START MOV SP,STKPTR ; load stack
pointer CALL INIT8255 ; initialize
8255
LP1 MOV AL,08H ; use num1 for led count
value MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
MOV AL,04H ; use num1 for led count
value MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
MOV AL,02H ; use num1 for led count
value MOV DX,PA8255 ;
OUT DX,AL
CALL DELAY ; call delay
MOV AL,01H ; use num1 for led count
value MOV DX,PA8255
OUT DX,AL
CALL DELAY ; call delay
JMP START ; restart again
;******* Delay
module DELAY NOP
11
R17Autonomous III B. TechIISemester MPMCLabManual
MOV CX,03500H ; load Delay count =
0x3500 NOP
DLY1 NOP
LOOP DLY1
RET ; end of delay
V
D
X
,
P
B
8
2
5
5
O
RESULT: INPUT: U
T
OUTPUT:
D
;
X
*
,
*
A
*
L
*
*
M
*
O
*
V
MOV D
AL,080H X
output MOV ,
DX, P
CMD8255 C
OUT DX,AL ; write to 8
command register 2
MO 5
V 5
AL,0
0H O
MO U
V T
DX,P
A82 D
55 X
OUT DX,AL ,
M A
O L
11
R17Autonomous III B. TechIISemester MPMCLabManual
RET
Exercise Questions:
Viva Questions:
11
R17Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
11
R17Autonomous III B. TechIISemester MPMCLabManual
11
R17Autonomous III B. TechIISemester MPMCLabManual
11
R17Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 10
ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF
8051
AIM: Write an ALP for Arithmetic, logical and bit manipulation operations in 8051
TOOLS:
i. UXASM
ii. TKUP
iii. TKUP86 KIT
iv. FRC CABLE
#INCLUDE
"TKUP52.DEF
" ORG 0000H
START: LJMP MAIN
ORG
0150H MAIN
MOV SP,#50H
MOV
R0,#20H
MOV
R1,#07H
MOV A,R0
ADD A,R1
MOV P1,A
LCALL
DELAY
MOV A,R0
SUBB A,R1
MOV P1,A
LCALL
DELAY
12
R17Autonomous III B. TechIISemester MPMCLabManual
MOV A,R0
MOV
0F0H,R1
MUL AB
MOV P1,A
12
R17Autonomous III B. TechIISemester MPMCLabManual
LCALL
DELAY
MOV
P1,0F0H
LCALL
DELAY
MOV A,R0
MOV
0F0H,R1
DIV AB
MOV P1,A
LCALL
DELAY
MOV
P1,0F0H
LCALL
DELAY
LJMP
MAIN
DELAY NOP
MOV
R4,#020H DLY3
MOV R3,#0FFH
DLY2 MOV
R2,#0FFH
NOP
DLY1
N
O
P
N
O
12
R17Autonomous III B. TechIISemester MPMCLabManual
P
N
O
P
DJNZ
R2,DLY1
DJNZ
R3,DLY2
DJNZ
R4,DLY3
RET
B) PROGRAM: FOR LOGICAL INSTRUCTIONS OF 8051
i) ;Connect P1 to CNLED1
#INCLUDE
"TKUP52.DEF" ORG
0000H
START: LJMP MAIN
ORG
0150H MAIN
MOV SP,#50H
12
R17Autonomous III B. TechIISemester MPMCLabManual
MOV
A,#35H
ANL
A,#0FH
MOV
P1,A
ACALL
DLY MOV
A,#04H
ORL
A,#30H
MOV
P1,A
ACALL
DLY MOV
A,#54H
XRL
A,#78H
MOV
P1,A
ACALL
DLY MOV
A,#55H
CPL A
MOV
P1,A
ACALL
DLY
DLY
N
O
P
12
R17Autonomous III B. TechIISemester MPMCLabManual
N
O
P
MOV
R4,#020H DLY3
MOV R3,#0FFH
DLY2 MOV
R2,#0FFH
NOP
DLY1
N
O
P
N
O
P
N
O
P
N
O
P
DJNZ
R2,DLY1
DJNZ
R3,DLY2
DJNZ
R4,DLY3
RET
12
R17Autonomous III B. TechIISemester MPMCLabManual
ii) ;Connect P1 to CNLED1
12
R17Autonomous III B. TechIISemester MPMCLabManual
#INCLUDE "TKUP52.DEF"
ORG 0000H
START: LJMP
MAIN
ORG
0150H
MAIN: MOV
SP,#060H
MOV
A,#0A5H
MOV P1,A
LCALL
SFTDL RR
A
MOV
P1,A
LCALL
SFTDL
SWAP A
MOV
P1,A
LCALL
SFTDL
RL A
MOV
P1,A
LCALL
SFTDL
SETB C
RLC A
MOV
P1,A
12
R17Autonomous III B. TechIISemester MPMCLabManual
LCALL
SFTDL
RRC A
MOV
P1,A
LCALL
SFTDL
LJMP
MAIN
SFTDL MOV R4,#50H
DL3 MOV R5,#0FFH
DL2 MOV R6,#0FFH
DL1 DJNZ
R6,DL1
DJNZ
R5,DL2
12
R17Autonomous III B. TechIISemester MPMCLabManual
DJNZ
R4,DL3
RET
C) PROGRAM: FOR BIT MANIPULATION INSTRUCTIONS OF 8051
; Connect P1 to CNLED1
#INCLUDE
"TKUP52.DEF
" ORG 0000H
START: LJMP MAIN
ORG
0150H MAIN
MOV SP,#50H
MOV
P1,#00H
MOV
C,00H
SETB C
MOV
P1_7,C
LCALL
SFTDL
CLR C
ANL
C,00H
MOV
P1_7,C
LCALL
SFTDL
CPL C
MOV
P1_3,C
LCALL
SFTDL
12
R17Autonomous III B. TechIISemester MPMCLabManual
ORL
C,00H
MOV
P1_7,C
LCALL
SFTDL
LJMP
MAIN
SFTDL MOV
R4,#50H DL3
MOV
R5,#0FFH DL2
MOV
R6,#0FFH DL1
DJNZ
R6,DL1
DJNZ R5,DL2
13
R17Autonomous III B. TechIISemester MPMCLabManual
DJNZ
R4,DL3
RET
RESULT:
INPU
T:
OUTP
UT:
Exercise Questions:
1) Write an assembly language program for the addition of 012H and 376H in 8051?
Viva Questions:
13
R17Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
13
R17Autonomous III B. TechIISemester MPMCLabManual
13
R17Autonomous III B. TechIISemester MPMCLabManual
13
R17Autonomous III B. TechIISemester MPMCLabManual
13
R17Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 11
TIMER/COUNTERS IN 8051
TOOLS: i) UXASM
Ii) TKUP
Iii) TKUP86 KIT
IV) FRC CABLE
PROGRAM:
; Connect P1 to CNLED1
#INCLUDE "TKUP52.DEF"
ORG 0000H
START: LJMP
MAIN
ORG
0150H
MAIN: MOV
SP,#060H
MOV
TMOD,#01H
BACK: MOV
TL0,#075H
MOV
TH0,#0B8H
MOV
P1,#0AAH
LCALL SFTDL
ACALL DELAY
MOV
TL0,#00H
MOV
TH0,#00H
MOV
13
R17Autonomous III B. TechIISemester MPMCLabManual
P1,#055H
ACALL DELAY
LCALL SFTDL
SJMP BACK
ORG 300H
DELAY: SETB TCON4
AGAIN: JNB TCON5,AGAIN
13
R17Autonomous III B. TechIISemester MPMCLabManual
CLR
TCON4
CLR
TCON5
RET
SFTDL MOV R4,#10H
DL3 MOV R5,#0FFH
DL2 MOV R6,#0FFH
DL1 DJNZ
R6,DL1
DJNZ
R5,DL2
DJNZ
R4,DL3
RET
RESULT:
INPU
T:
OUTP
UT:
Exercise Questions:
1) Write a assembly language program for counting number of 1’s and 0’s in 34H?
Viva Questions:
13
R17Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
13
R17Autonomous III B. TechIISemester MPMCLabManual
14
R17Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 12
INTERRUPT HANDLING IN
8051
TOOLS i) UXASM
ii)TKUP
iii)TKUP86
KIT iv)FRC
CABLE
PROGRAM:
#INCLUDE "TKUP52.DEF"
ORG
0000H START:
LJMP MAIN
ORG 0150H
MAIN MOV
SP,#50H
MOV
IE,#85H
HERE MOV
P1,#7EH
SJMP HERE
ORG 0003H ; INT0 ISR
MOV
P1,#0AAH
LCALL DELAY
LCALL DELAY
LCALL DELAY
RETI
ORG 0013H ; INT1 ISR
MOV
P1,#0A5H
LCALL DELAY
14
R17Autonomous III B. TechIISemester MPMCLabManual
LCALL DELAY
RETI
DELAY NOP
14
R17Autonomous III B. TechIISemester MPMCLabManual
MOV R4,#020H
DLY3 MOV R3,#0FFH
DLY2 MOV R2,#0FFH
DLY1
N
O
P
N
O
P
DJNZ
R2,DLY1
DJNZ
R3,DLY2
DJNZ
R4,DLY3
RET
RESULT:
INPU
T:
OUTP
UT:
Exercise Questions:
Viva Questions:
14
R17Autonomous III B. TechIISemester MPMCLabManual
2) What is the Priority among 8051 interrupts?
3) What are the interrupt registers of 8051?
4) What is the size of the interrupt registers of 8051?
14
R17Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
14
R17Autonomous III B. TechIISemester MPMCLabManual
14
R17Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 13
UART OPERATION IN
8051
TOOLS: i) UXASM
ii) TKUP
iii) TKUP86 KIT
iv) FRC CABLE
PROGRAM:
#INCLUDE "TKUP52.DEF"
ORG
0000H START:
LJMP MAIN
ORG
0150H MAIN:
MOV
SP,#060H
MOV IE,#85H
MOV
TMOD,#20H
MOV
TH1,#0FAH
MOV
SCON,#50H
SETB TCON6
RPT: MOV
SBUF,#'Y' HERE: JNB
SCON1,HERE
14
R17Autonomous III B. TechIISemester MPMCLabManual
CLR
SCON1
MOV
A,#'A'
MOV
P1,A
SJMP
RPT
RESULT: INPUT:
OUTPUT:
14
R17Autonomous III B. TechIISemester MPMCLabManual
Exercise Questions:
Viva Questions:
14
R17Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
15
R17Autonomous III B. TechIISemester MPMCLabManual
15
R17Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 14
INTERFACING LCD TO
8051
TOOLS:
I) UXASM
II) TKUP
III) TKUP86 KIT
IV) FRC CABLE
PROGRAM:
#INCLUDE
"TKUP52.DEF"
ORG 0000H
START: LJMP
MAIN
ORG 0150H
MAIN MOV
SP,#060H LCALL
INIT8255
LOOP MOV
DPTR,#CMDTBL
LCALL INIT_LCD
MOV
DPTR,#STRTBL
LP1 MOV A,#0
MOVC
A,@A+DPTR
CJNE A,#00,LP2
LCALL DELAY
15
R17Autonomous III B. TechIISemester MPMCLabManual
LCALL DELAY
LCALL DELAY
LJMP
MAIN LP2 LCALL
WR_DAT
15
R17Autonomous III B. TechIISemester MPMCLabManual
INC DPTR
LCALL
SDELAY
LJMP LP1
;*******LCD init
module INIT_LCD
MOV A,#0
MOVC
A,@A+DPTR
CJNE A,#00,IL2
RET
IL2 LCALL
WR_CMD
INC DPTR
LJMP INIT_LCD
;******* LCD Write CMD
module WR_CMDPUSH DPH
PUSH DPL
MOV
DPTR,#PB8255
LCALL WRPORT
LCALL SDELAY
MOV A,#04
MOV
DPTR,#PA8255
LCALL WRPORT
LCALL SDELAY
MOV A, #00
MOV
DPTR,#PA8255
LCALL WRPORT
LCALL SDELAY
POP
15
R17Autonomous III B. TechIISemester MPMCLabManual
DPL
POP
DPH
RET
;******* LCD Write Data
module WR_DAT PUSH DPH
15
R17Autonomous III B. TechIISemester MPMCLabManual
PUSH DPL
MOV
DPTR,#PB8255
LCALL WRPORT
LCALL SDELAY
MOV A,#05H
MOV
DPTR,#PA8255
LCALL WRPORT
LCALL SDELAY
MOV A,#01H
MOV
DPTR,#PA8255
LCALL WRPORT
LCALL SDELAY
POP
DPL
POP
DPH
RET
;******Write Port
WRPORT CLR
P1_7
MOVX
@DPTR,A
SETB P1_7
RET
;****** Read
Port RDPORT CLR P1_7
MOVX
A,@DPTR
SETB P1_7
15
R17Autonomous III B. TechIISemester MPMCLabManual
RET
;******* Delay
module SDELAY NOP
MOV
R0,#0FFH
MOV
R1,#01H
LJMP DLY1
15
R17Autonomous III B. TechIISemester MPMCLabManual
N
OP
DELAY
NOP
MOV
R0,#0FFH
MOV
R1,#055H
NOP
DLY1 DJNZ R0,DLY1
MOV
R0,#0FFH
DJNZ
R1,DLY1
RET
;******* initialize
8255 INIT8255
MOV A,#080H
MOV
DPTR,#CMD8255
LCALL WRPORT
RET
ORG 0500H
;******* initialize seven segment
table CMDTBL HEX 38,0E,02,01,00
STRTBL ASCII "HELLO ADM -
TKUP" ENDTBL HEX
00,00
RESULT:
INPU
T:
OUTP
UT :
15
R17Autonomous III B. TechIISemester MPMCLabManual
Viva Questions:
15
R17Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
16
R17Autonomous III B. TechIISemester MPMCLabManual
16
R17Autonomous III B. TechIISemester MPMCLabManual
16
R17Autonomous III B. TechIISemester MPMCLabManual
EXPERIMENT NO: 15
INTERFACING MATRIX/KEYBOARD TO
8051
TOOLS: i) UXASM
ii) TKUP
iii) TKUP86
KIT iv)FRC
CABLE
PROGRAM:
;******* 8255_KBD
******* INCLUDE DEFINATION FILES NOW
; 1. Connect 8255 PA0-7 to CNMUX of L1C peripheral board
; 2. Connect 8255 PC0-7 to CNKEY of L1C peripheral board
; 3. Connect 8255 PB0-7 to CNSEG of L1C peripheral board
; 4. Motor one segment showing 0000->0001->....->000F->0000 (key press)
#INCLUDE "TKUP52.DEF"
ORG
0000H START:
LJMP MAIN
ORG
0150H MAIN
MOV SP,#060H
LCALL INIT8255
MOV
DPTR,#NUM1
LCALL CLRMEM
MOV
DPTR,#NUM2
LCALL CLRMEM
16
R17Autonomous III B. TechIISemester MPMCLabManual
MOV
DPTR,#NUM3
LCALL CLRMEM
NOP
16
R17Autonomous III B. TechIISemester MPMCLabManual
LOOP LCALL SCANKBD
MOV
DPTR,#NUM3
MOVX A,@DPTR
MOV
DPTR,#SEGTBL
MOVC
A,@A+DPTR
MOV
DPTR,#PB8255
LCALL WRPORT
MOV A,#070H
MOV
DPTR,#PA8255
LCALL WRPORT
LJMP LOOP
16
R17Autonomous III B. TechIISemester MPMCLabManual
LCALL WRPORT
MOV
DPTR,#PC8255
LCALL RDPORT
ANL A,#0FH
CJNE
A,#0FH,SKL2
MOV
DPTR,#NUM1
MOVX
A,@DPTR
16
R17Autonomous III B. TechIISemester MPMCLabManual
INC A
LJMP
SKLOOP SKL2
LJMP
GETKEY
;******* GETKEY
module GETKEY MOV
DPTR,#NUM2
MOVX @DPTR,A
MOV
DPTR,#RETTBL
MOVC
A,@A+DPTR
MOV R0,A
MOV
DPTR,#NUM1
MOVX A,@DPTR
MOV
DPTR,#ROWTBL
MOVC
A,@A+DPTR ADD
A,R0
MOV
DPTR,#NUM3
MOVX
@DPTR,A RET
;****** Clear memory
location CLRMEM MOV A,#0
MOVX
@DPTR,A
RET
WRPORT CLR P1_7
MOVX
16
R17Autonomous III B. TechIISemester MPMCLabManual
@DPTR,A
SETB P1_7
RET
;****** Read
Port RDPORT CLR P1_7
MOVX
A,@DPTR
SETB P1_7
RET
16
R17Autonomous III B. TechIISemester MPMCLabManual
;******* Delay
module SDELAY NOP
MOV
R0,#0FFH
MOV
R1,#01H
LJMP DLY1
NOP
DELAY NOP
MOV R0,#0FFH ; load lsb of delay=0x34FF
MOV R1,#055H ; load
msb NOP
DLY1 DJNZ R0,DLY1
MOV R0,#0FFH ; decrement msb
count DJNZ R1,DLY1
RET ; end of delay
;******* initialize
8255 INIT8255
MOV A,#081H ; make all ports output
MOV DPTR,#CMD8255 ; write to command
register LCALL WRPORT
RET
ORG 0500H
;******* initialize seven segment table
SEGTBL HEX
3F,06,5B,4F,66,6D,7D,07,7F,6F,77,7C,39,5E,79,71,00
KBDTBL HEX E0,D0,B0,70,00
RETTBLHEX 00,00,00,00,00,00,00,03,00,00,00,02,00,01,00,00,00
ROWTBL HEX 00, 04, 08, 0C, 00
RESULT:
16
R17Autonomous III B. TechIISemester MPMCLabManual
INPU
T:
OUTP
UT:
17
R17Autonomous III B. TechIISemester MPMCLabManual
Exercise Question:
1) Write an assembly language program for the display of MRCET string on LCDby using 8051
Viva Questions:
17
R17Autonomous III B. TechIISemester MPMCLabManual
OBSERVATION:
17
R17Autonomous III B. TechIISemester MPMCLabManual
17
R17Autonomous III B. TechIISemester MPMCLabManual
17
R17Autonomous III B. TechIISemester MPMCLabManual
17