MPMC Lab Manual
MPMC Lab Manual
MICROCONTROLLERS LAB
MICROPROCESSORS & MICROCONTROLLERS
LAB MANUAL
B.TECH
(III YEAR – II SEM)
(2022-23)
Prepared by:
Mr. KDK Ajay, Asst. Professor
VISION
MISSION
To provide high quality academic programmes, training activities, research facilities and
opportunities supported by continuous industry institute interaction aimed at employability,
entrepreneurship, leadership and research aptitude among students.
QUALITY POLICY
1
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
PROGRAM OUTCOMES (POs)
Engineering Graduates will be able to:
3
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
The student will learn the internal organization of popular
8086/8051 microprocessors/microcontrollers.
The student will learn hardware and software interaction and integration.
To apply the concepts in the design of microprocessor/microcontroller based systems in
real time applications
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
INDEX
PART-A
1. Introduction to MASM 7
PART-B
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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:
8
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
FLOW CHART:
START
AXOPR1
AXAX-OPR2 DIFFAX
PROGRAM:
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
(C) 16-bit Multiplication using different addressing modes
ALGORITHM:
START
AXOPR1 BXOPR2
STOP
1
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
(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.
Step V : store the Quotient in AX register into extra segment.
Step VI : Store the reminder in DX register into extra segment.
Step VII : Verify the result.
Step VIII : Stop.
FLOW CHART:
START
DIVISION OF DX:AX BY BX
STOP
1
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
END
1
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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 ?
1
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
OBSERVATION:
2
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
2
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
2
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
2
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
2
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
2
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
PROGRAM:
ASCENDING ORDER
2
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
Result:
DESCENDING ORDER
ALGORITHM:
Step I: Initialize the data segment memory.
Step II : Initialize the number of elements counter
Step III : Initialize the comparisons counter..
Step IV: Load the numbers into respective registers
Step V: Compare the elements. If first element > second element go to step VII
Else go to next step.
Step VI: Swap the numbers in the memory.
Step VII: Increment memory pointer & Decrement the comparison counter.
Step VIII: Is count = 0? If yes go to next step else go to step IV.
Step IX: decrement the element counter.
Step X: Is count not 0? go Step III else go to next step Step IX: Stop & terminate the program.
2
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
JNZ BACK
INT 03H
CODE ENDS
END START
END
3
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
OBSERVATION:
3
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
3
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
3
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
3
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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:
3
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
NO
SEARCH FOR CHARACTER
YES
STOP
3
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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, 09H
INT 21H
GOTOEND: MOV AH, 4CH
INT 21H
CODE ENDS
END START
3
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
END
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
OBSERVATION:
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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 mode
Step V : move the character by character from source to destination till the
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
FLOW CHART:
START
Load the offset address of source and destination the string into SI and DI.
LLLoooaaaddd ttthhheee oooffffffssseeettt
aaaddrddrddreeessssss
ooofff
STOP
PROGRAM:
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
CLD
REP MOVSB
INT 03H
CODE ENDS
END START
END
RESULT:
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
4
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
PROGRAM:
5
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
OUTPUT: ‘ROSSECORPORCIM’
5
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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 CL
NO
ZF=0?
YES
Decrement CL
STOP
5
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
Program:
LAB OUTPUT:
5
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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 ch
NO
ZF=0
YES
START
5
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
EXITP: MOV AH, 4CH
5
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
INT 03H
CODE ENDS
END START
RESULT: INPUT: OUTPUT:
5
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
(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 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
5
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
5
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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, 15
REP MOVSB
INT 3H
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
CODE ENDS
END START
RESULT:
INPUT: STRING1: 'MICROPROCESSOR INTERFACING LAB'
STRING2:‘AND ’
OUTPUT: STRING3: ‘MICROPROCESSOR AND INTERFACING LAB'
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
ADD SI, 19
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
MOV CX, 15
REP MOVSB
INT 03H
CODE ENDS
END START
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
OBSERVATION:
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
6
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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”
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
3. Go to file and select “open source” and browse the source file(.ASM file)
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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”
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
7. Observe the following window and double click on path of the File to view the program
7
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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:
8
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
Procedure for TKµP
3. The following window will be displayed and go to window, select tile to avoid the overlap
of windows
8
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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
R20 Autonomous III B. Tech II Semester MPMC Lab Manual
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 ; load stack pointer
CALL INIT8255 ; initialize 8255
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
8
R17 Autonomous III B. Tech II MPMC Lab
Semester
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 CX
POP BX
POP AX
RET
;******* initialize 8255
INIT8255
MOV AL,080H
MOV DX,
CMD8255 OUT
DX,AL
8
R17 Autonomous III B. Tech II MPMC Lab
Semester
MOV AL,00H
8
R17 Autonomous III B. Tech II MPMC Lab
Semester
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:
8
R17 Autonomous III B. Tech II MPMC Lab
OBSERVATION:
89
R17 Autonomous III B. Tech II MPMC Lab
90
R17 Autonomous III B. Tech II MPMC Lab
91
R17 Autonomous III B. Tech II MPMC Lab
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
OUT DX, AL
MOV AL, 01H
92
R17 Autonomous III B. Tech II MPMC Lab
OUT DX, AL
93
R17 Autonomous III B. Tech II MPMC Lab
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 :
TOOLS:
i. UXASM
ii. TKUP
iii. TKUP86 KIT
iv. FRC CABLE
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"
ORG 0FFFF0H
94
R17 Autonomous III B. Tech II MPMC Lab
JMPF 0F000H,0F000H
95
R17 Autonomous III B. Tech II MPMC Lab
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
JNE AGAIN
JMP RPT
DELAY: MOV CX,
0FF00H NXT2: MOV BX,
1234H NXT: NOP
NOP
NOP
NOP
96
R17 Autonomous III B. Tech II MPMC Lab
NOP
97
R17 Autonomous III B. Tech II MPMC Lab
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:
98
R17 Autonomous III B. Tech II MPMC Lab
OBSERVATION:
99
R17 Autonomous III B. Tech II MPMC Lab
10
R17 Autonomous III B. Tech II MPMC Lab
10
R17 Autonomous III B. Tech II MPMC Lab
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 DX,PB8255
OUT DX,AL
MOV DX,PC8255
OUT DX,AL
JMP RPT
10
R17 Autonomous III B. Tech II MPMC Lab
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:
OBSERVATION:
10
R17 Autonomous III B. Tech II MPMC Lab
10
R17 Autonomous III B. Tech II MPMC Lab
10
R17 Autonomous III B. Tech II MPMC Lab
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 NOP ;
MOV CX,03500H ; load Delay count =
0x3500 NOP ;
DLY1 NOP ;
LOOP DLY1 ;
RET ; end of delay
10
R17 Autonomous III B. Tech II MPMC Lab
;******* initialize 8255
10
R17 Autonomous III B. Tech II MPMC Lab
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
10
R17 Autonomous III B. Tech II MPMC Lab
DELAY NOP
10
R17 Autonomous III B. Tech II MPMC Lab
MOV CX,03500H ; load Delay count =
0x3500 NOP
DLY1 NOP
LOOP DLY1
RET ; end of delay
;******* initialize
8255 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
RESULT: INPUT:
OUTPUT:
Exercise Questions:
Viva Questions:
11
R17 Autonomous III B. Tech II MPMC Lab
OBSERVATION:
11
R17 Autonomous III B. Tech II MPMC Lab
11
R17 Autonomous III B. Tech II MPMC Lab
11
R17 Autonomous III B. Tech II MPMC Lab
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
MOV A,R0
MOV 0F0H,R1
MUL AB
MOV P1,A
11
R17 Autonomous III B. Tech II MPMC Lab
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 NOP
NOP
NOP
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
11
R17 Autonomous III B. Tech II MPMC Lab
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 NOP
NOP
MOV R4,#020H
DLY3 MOV R3,#0FFH
DLY2 MOV R2,#0FFH
NOP
DLY1 NOP
NOP
NOP
NOP
DJNZ R2,DLY1
DJNZ R3,DLY2
DJNZ R4,DLY3
RET
ii) ;Connect P1 to CNLED1
11
R17 Autonomous III B. Tech II MPMC Lab
#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
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
11
R17 Autonomous III B. Tech II MPMC Lab
R5,DL2
11
R17 Autonomous III B. Tech II MPMC Lab
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
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
11
R17 Autonomous III B. Tech II MPMC Lab
DJNZ R5,DL2
12
R17 Autonomous III B. Tech II MPMC Lab
DJNZ R4,DL3
RET
RESULT: INPUT:
OUTPUT:
Exercise Questions:
1) Write an assembly language program for the addition of 012H and 376H in 8051?
Viva Questions:
12
R17 Autonomous III B. Tech II MPMC Lab
OBSERVATION:
12
R17 Autonomous III B. Tech II MPMC Lab
12
R17 Autonomous III B. Tech II MPMC Lab
12
R17 Autonomous III B. Tech II MPMC Lab
12
R17 Autonomous III B. Tech II MPMC Lab
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 P1,#055H
ACALL DELAY
LCALL SFTDL
SJMP BACK
ORG 300H
DELAY: SETB TCON4
AGAIN: JNB TCON5,AGAIN
12
R17 Autonomous III B. Tech II MPMC Lab
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: INPUT:
OUTPUT:
Exercise Questions:
1) Write a assembly language program for counting number of 1’s and 0’s in 34H?
Viva Questions:
12
R17 Autonomous III B. Tech II MPMC Lab
OBSERVATION:
12
R17 Autonomous III B. Tech II MPMC Lab
12
R17 Autonomous III B. Tech II MPMC Lab
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
LCALL DELAY
RETI
DELAY NOP
13
R17 Autonomous III B. Tech II MPMC Lab
MOV R4,#020H
DLY3 MOV R3,#0FFH
DLY2 MOV R2,#0FFH
DLY1 NOP
NOP
DJNZ R2,DLY1
DJNZ R3,DLY2
DJNZ R4,DLY3
RET
RESULT: INPUT:
OUTPUT:
Exercise Questions:
Viva Questions:
13
R17 Autonomous III B. Tech II MPMC Lab
OBSERVATION:
13
R17 Autonomous III B. Tech II MPMC Lab
13
R17 Autonomous III B. Tech II MPMC Lab
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
CLR SCON1
MOV A,#'A'
MOV P1,A
SJMP RPT
RESULT: INPUT:
13
R17 Autonomous III B. Tech II MPMC Lab
OUTPUT:
13
R17 Autonomous III B. Tech II MPMC Lab
Exercise Questions:
Viva Questions:
13
R17 Autonomous III B. Tech II MPMC Lab
OBSERVATION:
13
R17 Autonomous III B. Tech II MPMC Lab
13
R17 Autonomous III B. Tech II MPMC Lab
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
LCALL DELAY
LCALL DELAY
13
R17 Autonomous III B. Tech II MPMC Lab
LJMP MAIN
LP2 LCALL WR_DAT
14
R17 Autonomous III B. Tech II MPMC Lab
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 DPL
POP DPH
RET
;******* LCD Write Data
module WR_DAT PUSH DPH
14
R17 Autonomous III B. Tech II MPMC Lab
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
RET
;******* Delay module
SDELAY NOP
MOV R0,#0FFH
MOV R1,#01H
14
R17 Autonomous III B. Tech II MPMC Lab
LJMP DLY1
14
R17 Autonomous III B. Tech II MPMC Lab
NOP
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: INPUT :
OUTPUT
:
Viva Questions:
1) What are the special function register of 8051?
2) What is the function of accumulator register?
3) What is the function of CJNE instruction?
4) What is the function of MOVX instruction?
14
R17 Autonomous III B. Tech II MPMC Lab
OBSERVATION:
14
R17 Autonomous III B. Tech II MPMC Lab
14
R17 Autonomous III B. Tech II MPMC Lab
14
R17 Autonomous III B. Tech II MPMC Lab
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
MOV DPTR,#NUM3
14
R17 Autonomous III B. Tech II MPMC Lab
LCALL CLRMEM
NOP
14
R17 Autonomous III B. Tech II MPMC Lab
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
15
R17 Autonomous III B. Tech II MPMC Lab
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 @DPTR,A
SETB P1_7
RET
;****** Read Port
RDPORT CLR P1_7
MOVX A,@DPTR
SETB P1_7
RET
15
R17 Autonomous III B. Tech II MPMC Lab
;******* 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: INPUT:
OUTPUT:
15
R17 Autonomous III B. Tech II MPMC Lab
Exercise Question:
1) Write an assembly language program for the display of MRCET string on LCDby using 8051
Viva Questions:
15
R17 Autonomous III B. Tech II MPMC Lab
OBSERVATION:
15
R17 Autonomous III B. Tech II MPMC Lab
15
R17 Autonomous III B. Tech II MPMC Lab
15
R17 Autonomous III B. Tech II MPMC Lab
15