MPMCL Lab
MPMCL Lab
MPMCL Lab
LABORATORY MANUAL
B.TECH
(III YEAR – II SEM)
(2018-19)
Prepared by:
Mr. K Murali Krishna, Associate Professor
Mr. K.D.K. Ajay, Assistant 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
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
PROGRAMME EDUCATIONAL OBJECTIVES (PEOs)
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
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
PROGRAM OUTCOMES (POs)
Engineering Graduates will be able to:
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
3. Design / development of solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal,
and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data,
and synthesis of the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of,
and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend
and write effective reports and design documentation, make effective presentations,
and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in multi disciplinary
environments.
12. Life- long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
3
R15 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.
4
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
INDEX
PART-A
1. Introduction to MASM 6
PART-B
5
R15 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
6
R15 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/TLIN7K
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:
7
R15 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
8
R15 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
9
R15 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
10
R15 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
INITIALIZATION OF DATA
& EXTRA SEGMENT
AXOPR1
AXAX+OPR2
SUMAX
STOP
11
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
PROGRAM:
(A) 16-bit addition using different addressing modes
ASSUME CS: CODE, DS: DATA, ES: EXTRA
DATA SEGMENT
OPR1 DW 5169H
OPR2 DW 1000H
DATA ENDS
EXTRA SEGMENT
SUM DW ?
EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX ; REGISTER ADDRESING MODE
MOV AX,EXTRA
MOV ES,AX
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:
12
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
Step VII : Stop.
FLOW CHART:
START
INITIALIZATION OF DATA
SEGMENT
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
13
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
CODE ENDS
END START
END
(C)16-bit Multiplication using different addressing modes
ALGORITHM:
Step I : Initialize the data & extra segment memory.
Step II : Load the first number into AX register.
Step III : Load the second number into BX register.
Step IV : Multiply AX with BX.
Step V : store lower word in accumulator into extra segment.
Step VI : Store Upper word in DX register into extra segment
Step VII : Verify the result.
Step VIII : Stop.
FLOW CHART:
START
INITIALIZATION OF DATA
& EXTRASEGMENT
AXOPR1
BXOPR2
STOP
14
R15 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
PROD 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 PROD, AX ; DIRECT ADDRESSING MODE
MOV PROD+2, DX ; DIRECT ADDRESSING MODE
INT 03H
CODE ENDS
END START
END
15
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
FLOW CHART:
START
DIVISION OF DX:AX BY BX
16
STOP
R15 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
17
R15 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=
PROD=
PROD+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 ?
18
R15 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:
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 goto 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.
19
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
DXCOUNT-1
BACK: CXDX
SIOFFSET
ADDRESS OF LIST
AX[SI]
IF TRUE
AX < [SI+2]
FALSE
EXCHANGE
[SI] &[SI+2]
INCREMENT SI BY 2
FALSE
IF
CX=0
TRUE
DECREMENT DX
FALSE
IF
DX=0
TRUE
20
STOP
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
PROGRAM:
ASCENDING ORDER
21
R15 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.
22
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
DXCOUNT-1
BACK : CXDX
SIOFFSET ADDRESS
OF LIST
AGAIN: AX[SI]
IF TRUE
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
23
R15 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
24
R15 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 five 16
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?
25
R15 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:
Step I : Initialize the Data segment (DS) & Extra segment(ES)
Step II : Load the offset address of the string into SI .
Step III : Load the number of elements in the string into CX register
Step IV : Move the character to be searched into the AL register
Step V : Scan for the character in ES. If the character is not found go to step VII else go
to next step.
Step VI : Display the message that character found and go to step VIII
Step VII : Display the message that character not found
Step VII : Stop.& Terminate the program
26
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
INITIALIZATION OF DATA
&EXTRA SEGMENT
ALCHARACTER CXCOUNT,
SI, OFFSET LIST
NO
SEARCH FOR
CHARACTER
YES
TERMINATE THE
PROGRAM
STOP
27
R15 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, SLEN
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: INT 03H
CODE ENDS
END START
END
28
R15 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?
29
R15 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 end
30
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
FLOW CHART:
START
STOP
PROGRAM:
RESULT:
32
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
B) REVERSE STRING
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 (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:
STOP
33
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
PROGRAM:
OUTPUT: ‘ROSSECORPORCIM’
34
R15 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
NO
ZF=0?
YES
Decrement CL
STOP
35
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
Program:
OUTPUT:
36
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
D) STRING COMPARISON
AIM: Write an ALP to 8086 to compare the given strings.
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.
37
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
FLOW CHART:
START
NO
ZF=0
?
YES
y
The strings are equal
START
38
R15 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: INT 03H
CODE ENDS
END START
RESULT: INPUT: OUTPUT:
39
R15 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
40
R15 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
STOP
41
R15 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 03H
42
R15 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'
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?
44
R15 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”
45
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
3. Go to file and select “open source” and browse the source file(.ASM file)
46
R15 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”
47
R15 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
48
R15 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
49
R15 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:
50
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
Procedure for TKµP
1. Go to start and select TKµP
3. The following window will be displayed and go to window, select tile to avoid the overlap of
windows
51
R15 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
52
R15 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
53
R15 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
54
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
MOV DX,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 CX
POP BX
POP AX
RET
;******* initialize 8255
INIT8255
MOV AL,080H
MOV DX, CMD8255
OUT DX,AL
MOV AL,00H
55
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
MOV DX,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:
1) What is the use of IN and OUT instructions?
2) What is meant by procedure?
3) What is meant by PPI?
4) What are the modes of 8255?
56
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
OUT DX, AL
57
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
JMPF 0F000H,0F000H
58
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
NOP
59
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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:
1) What is the function of INC Instruction?
2) What is the function of NOP Instruction?
3) What is the size of the ports of 8255?
4) What is the function of the control word register of 8255?
60
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
61
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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:
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?
62
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
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 NOP
64
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
MOV CX,03500H ; load Delay count = 0x3500
NOP
DLY1 NOP
LOOP DLY1
RET ; end of delay
OUTPUT:
Exercise Questions:
1) Write an assembly language program to rotate a stepper motor for 20 steps in clockwise
direction?
Viva Questions:
1. Explain the principle of stepper motor.
2. How to calculate step angle?
3. What are the applications of stepper motor
65
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
66
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
67
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
68
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
#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 R5,DL2
69
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
DJNZ R5,DL2
70
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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:
1) What are the ports of 8051?
2) What is the use of DJNZ instruction?
3) What are the bit manipulation instructions of 8051?
4) What are the flags of 8051?
71
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
72
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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:
1) What are timer/counter registers in 8051?
2) What is the size of timer/Counter?
3) When timer overflow occurs?
4) What are special functions registers of 8051?
73
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
MOV R4,#020H
DLY3 MOV R3,#0FFH
74
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
DLY2 MOV R2,#0FFH
DLY1 NOP
NOP
DJNZ R2,DLY1
DJNZ R3,DLY2
DJNZ R4,DLY3
RET
RESULT: INPUT:
OUTPUT:
Exercise Questions:
1) Write the program for interrupt handing of 8051 using PORT 0?
Viva Questions:
1) What are the interrupts of 8051?
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?
75
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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:
76
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
OUTPUT:
Exercise Questions:
Viva Questions:
1) What is the full form of UART?
2) What is meant by Synchronous and Asynchronous communication?
3) What is the serial communication registers in 8051?
4) Which data communication method is supported by 8051?
77
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
LJMP MAIN
LP2 LCALL WR_DAT
78
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
79
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
LJMP DLY1
80
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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?
81
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
LCALL CLRMEM
NOP
LOOP LCALL SCANKBD
82
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
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
RESULT: INPUT:
OUTPUT:
85
R15 Autonomous III B. Tech II Semester MPMC Lab Manual
Exercise Question:
1) Write an assembly language program for the display of MRCET string on LCD by using 8051
Viva Questions:
1) What are the special function register of 8051?
2) What is the function of accumulator register?
3) How many no. of pins available for 8051?
4) What is the function of SP register
86