MPMC Lab Manual
MPMC Lab Manual
MPMC Lab Manual
Dept of ECE
Geethanjali College of Engineering and Technology
Cheeryal (v), Keesara (M), Ranga Reddy District.
DEPARTMENT OF
ELECTRONICS & COMMUNICATOIN ENGINEERING
2014-2015
INCHARGE
(M.Laxmi)
HOD
(Dr.C.V.Narasimhulu)
1|Page
MPMC LAB MANUAL
DEPT OF ECE
LABORATORY MANUAL
FOR
MICROPROCESSOR AND MICROCONTROLLERS
Prepared by:
(M.Laxmi)
Checked by:
D.Venkat Rami Reddy
Approved by:
Dr.C.Venkata Narasimhulu,HOD
Dept., of ECE
Revision No: 3
MPMC LAB
Date: 20/12/2014
2|Page
DEPT OF ECE
MPMC LAB
3|Page
DEPT OF ECE
GEETHANJALI COLLEGE OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF Electronics and Communication Engineering
(Name of the Subject ) : Microprocessors and Microcontrollers
Course
file
(JNTU CODE - 55030
Programme : UG
Branch: ECE
Year:
III
Semester: II
Version No : 3
Document No. GCET
No. of pages :
Prepared by
1) Name : M.Laxmi
2) Sign
:
3) Desg : Assoc. Professor.
4) Date : 10-12--2013
Verified by : 1) Name :D.Venkat Rami Reddy
2) Sign
:
3) Desg : Assoc. Professor
4) Date :
Approved by : (HOD )
Updated by:
1 ) Name :
2) Sign :
3) Desg :
4) Date :
* For Q.C Only.
1) Name :
2) Sign
:
3) Desg:
4) Date :
1) Name :DrC.V.Narasimhulu
2) Sign :
3) Date :
4|Page
DEPT OF ECE
III year B.Tech. ECE- I ISEM
T/P/D C
0 -/3/2
(56606)MICROPROCESSORS AND MICROCONTROLLERS LAB
List of Experiments
The following programs/experiments are written for assembler and execute the
same with8086 and 8051 kits
1. Programs for 16 bit arithmetic operations for 8086 (using various addressing
modes)
2. Program for sorting an array for 8086
3. Program for searching for a number or character in a string for 8086
4. Program for String manipulations for 8086
5. Program for digital clock design using 8086.
6. Interfacing ADC and DAC to 8086.
7. Parallel communication between two microprocessors using 8255.
8. Serial communication between two microprocessor kits using 8251.
9. Interfacing to 8086 and programming to control stepper motor.
10. Programming using arithmetic, logical and bit manipulation instructions of 8051
11. Program and verify Timer/Counter in 8051.
12. Program and verify interrupt handling in 8051.
13. UART operation in 8051.
14. Communication between 8051 kit and PC.
15. Interfacing LCD to 8051.
16. Interfacing matrix or keyboard to 8051.
17. Data transfer from peripheral to memory through DMA controller 8237/8257
Note: Minimum of 12 experiments to be conducted.
MPMC LAB
5|Page
DEPT OF ECE
Our mission is to become a high quality premier educational institution, to
create technocrats, by ensuring excellence, through enriched knowledge,
creativity and self development.
MPMC LAB
6|Page
DEPT OF ECE
II.
III.
7|Page
DEPT OF ECE
12. An ability to use modern Electronic Design Automation (EDA) tools, software
and electronic equipment to analyze, synthesize and evaluate Electronics and
Communication Engineering systems for multidisciplinary tasks.
13. Apply engineering and project management principles to one's own work and
also to manage projects of multidisciplinary nature.
MPMC LAB
8|Page
DEPT OF ECE
3. While coming to the lab bring the lab manual cum observation book,
record etc.
4. Take only the lab manual, calculator (if needed) and a pen or pencil to
the work area.
5. Before coming to the lab, prepare the prelab questions. Read through
the lab experiment to familiarize yourself with the components and
assembly sequence.
6. Utilize 3 hours time properly to perform the experiment and noting
down the readings. Do the calculations, draw the graph and take
signature from the instructor.
7. If the experiment is not completed in the prescribed time, the pending
work has to be done in the leisure hour or extended hours.
8. You will be expected to submit the completed record book according to
the deadlines set up by your instructor.
9. For practical subjects there shall be a continuous evaluation during the
semester for 25 sessional marks and 50 end examination marks.
10. Of the 25 marks for internal, 15 marks shall be awarded for day-to-day
work and 10 marks to be awarded by conducting an internal laboratory
test.
9|Page
DEPT OF ECE
3. The promptness of submission should be strictly insisted by awarding the
marks accordingly.
4. Ask viva questions at the end of the experiment.
5. Do not allow students who come late to the lab class.
6. Encourage the students to do the experiments innovatively.
1. Study of TASM
MPMC LAB
10 | P a g e
DEPT OF ECE
2
3. Sorting an Array
4.
5. Sting Manipulations
6.
7.
Interfacing DAC
8.
Interfacing ADC
9.
10.
Timer/Counters operations
11.
Interrupt Handling
12.
UART Operation
13.
LCD Interfacing
14.
15
16.
PAGE
No.
CYCLE -I
MPMC LAB
11 | P a g e
DEPT OF ECE
0
Study of TASM/MASM
12
22
Sorting an Array
55
61
Sting Manipulations
65
72
Interfacing DAC
75
Interfacing ADC
79
83
93
CYCLE-II
Introduction to 8051
99
10
108
11
114
12
Interrupt Handling
116
119
120
13
107
14
112
MPMC LAB
12 | P a g e
DEPT OF ECE
STUDY OF MASM
Introduction:
The aim of this laboratory is to introduce the student to assembly language programming and
tools that she will need throughout the lab experiments.
Objectives:
MPMC LAB
13 | P a g e
DEPT OF ECE
1. Introduction to Microsoft Macro Assembler (MASM)
2. General structure of an assembly language program
3. Use of the Dos Debugger program
Overview:
In general, programming of microprocessor usually takes several iterations before the right
sequence of machine code instruction is written. The process, however is facilitated using a
special program called an Assembler. The Assembler allows the user to write alphanumeric
instructions. The Assembler, in turn, generates the desired machine instructions from the
assembly language instructions.
Assembly language programming consists of following steps:
STEP PRODUCES
1 Editing Source file
2 Assembling Object file
3 Linking Executable file
4 Executing Results
Assembling the program:
The assembler is used to convert the assembly language instructions to machine code. It is
used immediately after writing the Assembly language program. The assembler starts
checking the syntax or validity of the structure of each instruction in the source file .if any
errors are found, the assembler displays a report on these errors along with brief explanation
of their nature. However If the program doesnt contain any errors, the assembler produces
an object file that has the same name as the original file but with the .obj extension.
Linking the program:
The Linker is used convert the object file to an executable file. The executable file is the final
set of machine code instructions that can directly be executed by the microprocessor. It is the
different than the object file in the sense that it is self-contained and re-locatable. An object
file may represent one segment of a long program. This segment cannot operate by itself, and
must be integrated with other object files representing the rest of the program, in order to
produce the final self-contained executable file In addition to the executable file; the linker
can also generate a special file called the map file this file contains information about the
start, end, length of the stack, code, and data segments it also lists the entry point of the
program.
Executing the program
The executable file contains the machine language code .it can be loaded in the RAM and
executed by the microprocessor simply by typing, from the DOS prompt ,the name of the file
followed by the carriage Return Key (Enter Key). If the program produces an output on the
screen or sequence of control signals to control a piece of hard ware, the effect should be
noticed almost immediately. However, if the program manipulates data in memory, nothing
would seem to have happened as a result of executing the program.
MPMC LAB
14 | P a g e
DEPT OF ECE
Debugging the program
The debugger can also be used to find logical errors in the program. Even if a program does
not contain syntax errors it may not produce the desired results after execution. Logical
errors may be found by tracing the action of the program. once found, the source file should
be rewrite to fix the problem, then the re-assembled and re-linked. A special program called
the debugger is designed for that purpose. The debugger allows the user to trace the action of
the program, by single stepping through the program or executing the program up to a
desired point, called break point. It also allows the user to inspect or change the contents of
the microprocessor internal registers or the contents of any memory location.
The DOS -Debugger:
The DOS Debug program is an example of simple debugger that comes with MS-DOS.
Hence it is available on any PC .it was initially designed to give the user the capability to
trace logical errors in executable file. It allows the user to take an existing executable file and
unassembled it, i.e. convert it to assembly language. Also, it allows the user to write
assembly language instructions directly, and then convert them to machine language. The
program is simple and easy to use, but offers limited capabilities, which make it unsuitable
for serious assembly language programming. Below, are the summarized basic DOS Debugger commands.
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
Move
M range address
Name
N[pathname][argument list]
Output
O port byte
Proceed
P [=address][number]
Quit
Register
R[register]
Search
S range list
Trace
T [=address][value]
MPMC LAB
15 | P a g e
DEPT OF ECE
Unassembled
u [range]
Write
W [address}[drive][first sector][number]
MS-MASM:
Microsofts 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 programmers 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
COMMAND
FILE NAME
Name.asm
2 Masm Filename
Name.obj
3 Filename
A.1 The Assembly Language Process Using the Command line
The following section explains how to assemble and link a file using the command line from
a DOS window. The steps are:
1. Create or edit the source code (.asm file) using any ASCII text editor. Warning the file
must be saved in an ASCII format - some editors like 'winword', or 'word' store the file by
default in a binary format. To save as an ASCII format in some of the Microsoft editors,
select output type as *.TXT but specify the full file name as
myfile.asm
(the .asm extension should be used for assembly language files).
2. Invoke the masm program to assemble the file and produce a .obj file and optionally, a .lst
file.
3. Invoke the link program to produce a .exe program (or a .com program via a command line
argument).
Assume we have an assembly language file called test.asm that has been saved in ASCII
format.
Open a DOS window. To assemble the file, change to the directory where the file is via the
'cd'
command, and type:
C:\> masm test
If assembly is successful, this will produce a file called test.obj. If errors are present,the
syntax errors with line numbers will be displayed. You can also produce a listing file (.lst)
which shows opcodes for all instructions via:
C:\> masm test,test, test
It is a good idea to always create a .lst file output. A .exe file must be created from the .obj
file via the link program. Type:
MPMC LAB
16 | P a g e
DEPT OF ECE
C:\> link test
You will be prompted for file names for the Run file, List file, libraries, and Definitions file.
Just hitting <enter> for each choice will use the defaults. This will produce a test.exe file
which can then be executed. You can also produce the .exe file with no prompting from the
link program via:
C:\> link test,,,,,
Use 5 commas after filename (test) to provide defaults for all other choices.
Using the command line for masm/link is probably the easiest thing to do, if you are only
assembling/linking one source file. Most of your labs will only consist of one source file.
MICROPROCESSOR LAB EXECUTION PROCEDURE
STEP1: Opening DOS prompt
Click on start menu button and click on Run and then type Cmd at command prompt DOS
window will be appeared
STEP2: checking the masm installation
To know MASM is installed or not simply type masm at the command prompt Upon that it
replies masm version vendor (Microsoft), etc... If u get any error there is no masm in that PC
STEP3: directory changing (create a folder with your branch and not in C drive) Change the
current directory to your own 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
Ex. D cd eee10
Now we are in folder eee10
STEP4: writing the program
At the command prompt type the edit program name.asm
Ex. Edit add.asm
Immediately editor window will be opened. Type the program in that window. After
completion, save the program. To save the program, go to file opt in the menu bar and select
save opt now your code is ready to assemble.
STEP5: assembling, linking and executing the program
Go to file opt & click exit opt. Now DOS prompt will be displayed ,to assemble the program
type the following commands at the DOS prompt masm program name, program name,
program name hit the enter
Ex. Masm add,add,add enter
MPMC LAB
17 | P a g e
DEPT OF ECE
If there are any errors in the program assembler reports all of them at the command prompt
with line nos, if there are no bugs you are ready to link the program. To link the program
type the following line at command prompt
Link programname,,,,, (5 commas)
Ex. Link add,,,,,
After linking to execute the program type the following command
Debug programname.exe hit the enter
Ex. Debug add.exe
To execute the program, instruction by instruction (debugging) first of all press the r
key(register) hit the enter key, itll displays all the registers and their initial values in
HEXADECIMAL 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 itll 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).
STEP6: copying list file (common for all programs):
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,
Program name.lst
(ex. Add.lst) you should copy this to your lab observation
Opening a list file
Edit program name.lst
Ex. Edit add.lst
MPMC LAB
18 | P a g e
DEPT OF ECE
8086 ARCHITECTURE:
MPMC LAB
19 | P a g e
DEPT OF ECE
PIN DIAGRAM:
20 | P a g e
DEPT OF ECE
Logical Instructions
NOT
:
AND
:
OR
:
XOR
:
TEST
:
Transfer Instructions
JMP
:
JA (JNBE)
:
JAE (JNB)
:
JB (JNAE)
:
JBE (JNA)
:
JE (JZ)
:
JG (JNLE)
:
JGE (JNL)
:
JL (JNGE)
:
JLE (JNG)
:
JC, JNC
:
MPMC LAB
Unconditional jump
Jump if above (not below or equal)
Jump if above or equal (not below)
Jump if below (not above or equal)
Jump if below or equal (not above)
Jump if equal (zero)
Jump if greater (not less or equal)
Jump if greater or equal (not less)
Jump if less (not greater nor equal)
Jump if less or equal (not greater)
Jump if carry set, carry not set
21 | P a g e
DEPT OF ECE
JO, JNO
JS, JNS
JNP (JPO)
JP (JPE)
LOOP
LOOPE (LOOPZ)
LOOPNE (LOOPNZ)
JCXZ
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
MPMC LAB
22 | P a g e
DEPT OF ECE
CYCLE-I
MPMC LAB
23 | P a g e
DEPT OF ECE
PROCEDURE FOR SOFTWARE PROGRAMMING
1.
2.
3.
4.
5.
6.
Go to Start.
Click on Run.
Then Type on CMD and click ok.
Press f and [shift]+: and
Type cd tasm and
To write a new program type
NE filename.asm
Then write the program.
7. To save the program, press F3 + E.
8. To check errors
TASM filename
9. For Turbo linking
Tlink filename
10. For Turbo Debugging
Td filename
It shows a message i.e. program has no symbol table and press ok.
11. For step by step execution press F7 upto HLT.
12. To see the result go to View and then to Dump.
13. To exit the file click on File and then on Quit. (or alt + x)
MPMC LAB
24 | P a g e
DEPT OF ECE
EXPERIMENT NO.1
ARITHMETIC OPERATIONS IN 8086
I.ADDITION OF TWO 16-BIT NUMBERS
OBJECTIVE: To write an assembly language program for performing addition of
two 16-bit signed and unsigned numbers.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER.
PROGRAM:
ASSUME CS: CODE,DS:DATA
CODE SEGMENT
MOV AX, DATA
MOV DS, AX
MOV AX,OPR1
ADD AX,OPR2
MOV RES,AX
HLT
CODE ENDS
DATA SEGMENT
OPR1 DW 4269H
OPR2 DW 1000H
RES DW ?
DATA ENDS
END
MPMC LAB
25 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE
OPERATION
COMMENTS
INITIALIZATION OF DATA
SEGMENT
0000
B88E4E
MOV AX,4E8E
0003
8ED8
MOV DS,AX
0005
A10000
MOV AX,[0000]
0008
03060200
ADD AX,[0002]
000C
A30400
MOV [0004],AX
000F
F4
HLT
FLOW CHART:
START
INITIALIZATION OF DATA
SEGMENT
AXOPR1
AXAX+OPR2
RESAX
STOP
MPMC LAB
26 | P a g e
DEPT OF ECE
RESULT:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
INPUT:
OPR1 = 4269H
OPR2 = 1000H
OUTPUT: RES = 5269H
SIGNED NUMBERS
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
INPUT:
OPR1 = 9763H
OPR2 = A973H
OUTPUT: RES = 40D6H
OUTCOME:
This program helps to find the addition of two 16-bit numbers.
UNSIGNED NUMBERS
MPMC LAB
27 | P a g e
DEPT OF ECE
OPCODE
OPERATION
COMMENTS
0000
B88E4E
MOV AX,4E8E
0003
8ED8
MOV DS,AX
INITIALIZATION OF DATA
SEGMENT
0005
A10000
MOV AX,[0000]
0008
2B060200
SUB AX,[0002]
000C
A30400
MOV [0004],AX
000F
F4
HLT
MPMC LAB
28 | P a g e
DEPT OF ECE
START
FLOW CHART:
INITIALIZATION OF DATA
SEGMENT
AXOPR1
AXAX-OPR2
RESAX
STOP
RESULT:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
INPUT:
OPR1 = 4269H
OPR2 = 1000H
OUTPUT: RES = 3269H
SIGNED NUMBERS
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
INPUT:
OPR1 = 9763H
OPR2 = 8973H
OUTPUT: RES = 0DF0H
OUTCOME:
This program helps to find the subtraction of two 16-bit numbers
UNSIGNED NUMBERS
MPMC LAB
29 | P a g e
DEPT OF ECE
III.MULTIPLICATION OF TWO 16-BIT UNSIGNED NUMBERS
PROGRAM:
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV AX,OPR1
MUL OPR2
MOV RESLW,AX
MOV RESHW,DX
HLT
CODE ENDS
DATA SEGMENT
OPR1 DW 2000H
OPR2 DW 4000H
RESLW DW ?
RESHW DW ?
DATA ENDS
END
MPMC LAB
30 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
OPCODE
OPERATION
0000
B88E4E
MOV AX,4E8E
0003
8ED8
MOV DS,AX
0005
A10000
MOV AX,[0000]
0008
F726020
0
000C
A30400
MOV [0004],AX
000F
89160600
MOV [0006],DX
0013
F4
HLT
END OF PROGRAM
MPMC LAB
COMMENTS
INITIALIZATION OF DATA
SEGMENT
31 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
AXOPR1
AXAX*OPR2
RESLWAX
RESHWDX
STOP
RESULT:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
INPUT:
OPR1 = 2000H
OPR2 = 4000H
MPMC LAB
32 | P a g e
DEPT OF ECE
IV.MULTIPLICATION OF TWO 16-BIT SIGNED NUMBERS
OBJECTIVE: To write an assembly language program to perform multiplication of
two 16-bit signed numbers.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV AX,OPR1
IMUL OPR2
MOV RESLW,AX
MOV RESHW,DX
HLT
CODE ENDS
DATA SEGMENT
OPR1 DW 7593H
OPR2 DW 6845H
RESLW DW ?
RESHW DW ?
DATA ENDS
END
MPMC LAB
33 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
OPCODE
OPERATION
0000
B88F4E
MOV AX,4E8F
0003
8ED8
MOV DS,AX
0005
A10000
MOV AX,[0000]
0008
F72E0200
IMULWORD PTR
[0002]
000C
A30400
MOV [0004],AX
000F
89160600
MOV [0006],DX
0013
F4
HLT
END OF PROGRAM
MPMC LAB
COMMENTS
INITIALIZATION OF DATA
SEGMENT
34 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
SIGNED
MULTIPICATION OF
AX & OPR1
AXAX*OPR2
RESLWAX
RESHWDX
STOP
MPMC LAB
35 | P a g e
DEPT OF ECE
RESULT:
CASE I: Two positive numbers
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
INPUT:
OPR1 = 7593H
OPR2 = 6845H
OUTPUT: RESLW = 689FH (AX)
RESHW = 2FE3H (DX)
CASE II: one positive number & one negative number
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
INPUT:
MPMC LAB
36 | P a g e
DEPT OF ECE
MPMC LAB
37 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
OPCODE
OPERATION
0000
B88F4E
MOV AX,4E8F
0003
8ED8
MOV DS,AX
0005
A10000
MOV AX,[0000]
0008
F636020
0
000C
A20300
MOV [0003],AL
000F
88260400
MOV [0004],AH
0013
F4
HLT
END OF PROGRAM
MPMC LAB
COMMENTS
INITIALIZATION OF DATA
SEGMENT
38 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION
OF DATA
SEGMENT
DIVISION OF AX
BY OPR2
AXAX/OPR2
RESQAL
RESRAH
STOP
RESULT:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=0, a=1, i=1, d=0.
INPUT:
MPMC LAB
39 | P a g e
DEPT OF ECE
VI. DIVISION OF SIGNED NUMBERS
MPMC LAB
40 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
OPCODE
OPERATION
0000
B88F4E
MOV AX,4E8F
0003
8ED8
MOV DS,AX
0005
A10000
MOV AX,[0000]
0008
F63E0200
000C
A20300
MOV [0003],AL
000F
88260400
MOV [0004],AH
0013
F4
HLT
END OF PROGRAM
MPMC LAB
COMMENTS
INITIALIZATION OF DATA
SEGMENT
41 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
SIGNED DIVISION OF
AX BY OPR1
AXAX/OPR2
RESQAL
RESRAH
STOP
MPMC LAB
42 | P a g e
DEPT OF ECE
RESULT:
CASE I: two positive numbers
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=0, a=1, i=1, d=0.
INPUT:
OPR1 = 26F8H
OPR2 = AAH 2s Complement of (-56H)
OUTPUT: RESQ = 8CH (AL) 2s Complement of (- 74H)
RESR = 00H (AH)
OUTCOME:
This program helps to find the division of two 16-bit unsigned numbers
MPMC LAB
43 | P a g e
DEPT OF ECE
VII.ASCII ADDITION
MPMC LAB
44 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
OPCODE
OPERATION
0000
B88F4E
MOV AX,4E8F
0003
8ED8
MOV DS,AX
0005
B400
MOV AH,00
00H IS STORED IN AH
0007
A00000
MOV AL,[0000]
000A
02060100
ADD AL,[0001]
000E
37
AAA
000F
A30200
MOV [0002],AX
THE VALUE IN AX IS
MOVED TO [0002]
0012
F4
HLT
END OF PROGRAM
MPMC LAB
COMMENTS
INITIALIZATION OF DATA
SEGMENT
45 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
AH00
AlCHAR
ALAL+CHAR1
ASCII adjust for addition
RESAX
STOP
RESULT:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=1, s=0, z=0, o=0, p=1, a=1, i=1, d=0.
INPUT:
CHAR = 8
CHAR1 = 6
OUTCOME: This program helps to perform the addition of two ASCII bytes.
MPMC LAB
46 | P a g e
DEPT OF ECE
VIII. ASCII SUBTRACTION
OBJECTIVE: To write an ALP to perform the subtraction of two ASCII bytes.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV AH,00H
MOV AL,CHAR
SUB AL,CHAR1
AAS
MOV RES,AX
HLT
CODE ENDS
DATA SEGMENT
CHAR DB '9'
CHAR1 DB '5'
RES DW ?
DATA ENDS
END
MPMC LAB
47 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
OPCODE
OPERATION
0000
B88F4E
MOV AX,4E8F
0003
8ED8
MOV DS,AX
0005
B400
MOV AH,00
00H IS STORED IN AH
0007
A00000
MOV AL,[0000]
000A
2A060100
SUB AL,[0001]
000E
3F
AAS
000F
A30200
MOV [0002],AX
THE VALUE IN AX IS
MOVED TO [0002]
0012
F4
HLT
END OF PROGRAM
MPMC LAB
COMMENTS
INITIALIZATION OF DATA
SEGMENT
48 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
AH00
ALCHAR
ALAL-CHAR1
ASCII adjust for subtraction
RESAX
STOP
MPMC LAB
49 | P a g e
DEPT OF ECE
RESULT:
CASE I:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
INPUT:
CHAR = 9
CHAR1 = 5
OUTPUT: RES = 0004 (AX)
CASE II:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=1, s=1, z=0, o=0, p=1, a=1, i=1, d=0.
INPUT:
CHAR = 5
CHAR1 = 9
OUTPUT: RES = FF06 (AX) 2s Complement of (-4)
OUTCOME: This program helps to perform the subtraction of two ASCII bytes.
MPMC LAB
50 | P a g e
DEPT OF ECE
IX. ASCII MULTIPLICATION
OBJECTIVE: To write an ALP to perform the multiplication of two ASCII bytes.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS: CODE,DS:DATA
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV AH,00
MOV AL,NUM1
MUL NUM2
AAM
MOV RES,AX
HLT
CODE ENDS
DATA SEGMENT
NUM1 DB 09
NUM2 DB 05
RES DW ?
DATA ENDS
END
MPMC LAB
51 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
OPCODE
OPERATION
0000
B88F4E
MOV AX,4E8F
0003
8ED8
MOV DS,AX
0005
B400
MOV AH,00
00H IS STORED IN AH
0007
A00000
MOV AL,[0000]
000A
F6260100
000E
D40A
AAM
000F
A30200
MOV [0002],AX
THE VALUE IN AX IS
MOVED TO [0002]
0012
F4
HLT
END OF PROGRAM
MPMC LAB
COMMENTS
INITIALIZATION OF DATA
SEGMENT
52 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
AH00
ALNUM1
ALAL*NUM2
ASCII adjust for multiplication
RESAX
STOP
RESULT:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
INPUT:
NUM1 = 09
NUM2 = 05
OUTPUT: RES = 0405 (AX) unpacked BCD of 45.
OUTCOME: This program helps to perform the multiplication of two ASCII
bytes.
MPMC LAB
53 | P a g e
DEPT OF ECE
X.ASCII DIVISION
OBJECTIVE: To write an ALP to perform the division of two ASCII numbers.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS: CODE, DS: DATA
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV AX,DIVIDEND
AAD
MOV CH,DIVISOR
DIV CH
MOV RESQ,AL
MOV RESR,AH
HLT
CODE ENDS
DATA SEGMENT
DIVIDEND DW 0607H
DIVISOR DB 09H
RESQ DB ?
RESR DB ?
DATA ENDS
END
MPMC LAB
54 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
OPCODE
OPERATION
0000
B88F4E
MOV AX,4E8F
0003
8ED8
MOV DS,AX
0005
A10000
MOV AX,[0000]
0008
D50A
AAD
000A
8A2E0200
MOV CH,[0002]
000E
F6F5
DIV CH
AX IS DIVIDED BY CH
0010
A20300
MOV [0003],AL
THE VALUE IN AL IS
MOVED TO [0003]
0013
88260400
MOV [0002],AH
THE VALYE IN AH IS
MOVED TO [0004]
0017
F4
HLT
END OF PROGRAM
MPMC LAB
COMMENTS
INITIALIZATION OF DATA
SEGMENT
55 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
AXDIVIDEND
ASCII Adjust for Division
CHDIVISOR
AXAX/CH
RESQAL, RESRAH
STOP
MPMC LAB
56 | P a g e
DEPT OF ECE
RESULT:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
INPUT:
OUTCOME: This program helps to perform the division of two ASCII bytes.
MPMC LAB
57 | P a g e
DEPT OF ECE
EXPERIMENT NO.2
PROGRAM FOR SORTING AN ARRAY FOR 8086
I.ASCENDING ORDER
OBJECTIVE: To write an assembly language program to arrange the given numbers
in ascending order.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
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]
JC GO
XCHG AX,[SI+2]
XCHG AX,[SI]
GO:INC SI
INC SI
LOOP AGAIN
DEC DX
JNZ BACK
HLT
CODE ENDS
DATA SEGMENT
LIST DW 05H,04H,01H,03H,02H
COUNT EQU 05H
DATA ENDS
END
MPMC LAB
58 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
DXCOUNT-1
BACK : CXDX
SIOFFSET
ADDRESS OF LIST
AGAIN: AX[SI]
IF
AX <
[SI+2]
TRUE
FALSE
EXCHANGE
[SI] &[SI+2]
INCREMENT SI BY 2
FALSE
IF
CX=
0
TRUE
DECREMENT DX
FALSE
IF
DX=
0
TRUE
STOP
MPMC LAB
59 | P a g e
DEPT OF ECE
RESULT:
INPUT:
MPMC LAB
60 | P a g e
DEPT OF ECE
II. DESCENDING ORDER
OBJECTIVE: To write an assembly language program to arrange the given numbers
in descending order.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
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]
JNC GO
XCHG AX,[SI+2]
XCHG AX,[SI]
GO:INC SI
INC SI
LOOP AGAIN
DEC DX
JNZ BACK
HLT
CODE ENDS
DATA SEGMENT
LIST DW 03H,04H,01H,05H,02H
COUNT EQU 05H
DATA ENDS
END
MPMC LAB
61 | P a g e
DEPT OF ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
DXCOUNT-1
BACK : CXDX
SIOFFSET
ADDRESS OF LIST
AGAIN: 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
MPMC LAB
62 | P a g e
DEPT OF ECE
RESULT:
INPUT:
MPMC LAB
63 | P a g e
DEPT OF ECE
EXPERIMENT NO.3
PROGRAM FOR SEARCHING FOR A NUMBER/CHARACTER IN A STRING FOR
8086
SEARCHING FOR A NUMBER
OBJECTIVE: To find whether the given byte is in given string or not & find its relative
address
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
LEA SI,LIST
XOR BL,BL
MOV CL,COUNT
MOV AL,BYT
BACK:CMP AL,[SI]
JZ SKIP
INC BX
INC SI
LOOP BACK
SKIP:HLT
CODE ENDS
DATA SEGMENT
LIST DB 19H,99H,45H,46H,34H
COUNT DB 05H
BYT DB 45H
DATA ENDS
END
MPMC LAB
64 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
0000
OPPCODE
B8974E
OPERATIONS
MOV AX,4E97
0003
8ED8
MOV DS,AX
0005
BE0000
MOV SI,[0000]
0008
32DB
XOR BL,BL
000A
8A0E0500
MOV CL,[0005]
000E
A00600
0011
3A04
0013
7404
JE 0019
0015
43
INC BX
0016
46
INC SI
0017
E2F8
LOOP 0011
0019
F4
HLT
MPMC LAB
MOV AL,[0006]
CMP AL,SI
COMMENTS
INITIALIZATION
OF DATA
SEGMENT
THE VALUE
[0000] IS MOVED
TO SI
THE REGISTER
BL IS CLEARED
THE VALUE
[0005] IS MOVED
TO CL
THE VALUE
[0006] IS MOVED
TO AL
COMPARE THE
VALUE OF SI
WITHAL
JUMP TO 0019
INCREMENT BX
BY ONE
INCREMENT SI
BY ONE
LOOP BACK TO
0011
END OF THE
PROGRAM
65 | P a g e
DEPT OF ECE
START
INITIALIZATION OF
DATA SEGMENT
ALBYTE
CLCOUNT,
BX=00
AL,00H
CL,00H
SI, OFFSET LIST
STR
IF
AL=[SI]
IF
AL<[SI]
YES
Increment BX
Increment SI NO
Decrement CL
Increment CL
Increment SI
If
CL=0
NO
If
CL=0
NOP
YES
STOP
LENGTHCL
MPMC LAB
66 | P a g e
DEPT OF ECE
RESULT:
GIVEN DATA:
N=19H,99H,45H,46H,34H
BYTE= 45H
FLAGS:
INITIALLY: C=0,Z=0,S=0,O=0,P=0,A=0,I=1,D=0
AFTER EXECUTION: C=0,Z=1,S=0,O=0,P=1,A=0,I=1,D=0
OUTPUT:
RES: 45H
ADDRESS: BX----0002
VIVA QUESTIONS:
1) What is the size of instruction queue in 8086?
2) Which are the registers present in 8086?
3) What do you mean by pipelining in 8086?
4) How many 16 bit registers are available in 8086?
5) Specify addressing modes for any instruction?
OUTCOME: This program helps find whether the given byte is in given string
or not with its relative address
MPMC LAB
67 | P a g e
DEPT OF ECE
EXPERIMENT NO.4
PROGRAM FOR STRING MANIPULATIONS FOR 8086
I. LENGTH OF THE STRING
OBJECTIVE: To write an assembly language program to find the length of the given
string.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV AL,$
MOV CX,00H
MOV SI,OFFSET STR1
BACK:CMP AL,[SI]
JE GO
INC CL
INC SI
JMP BACK
GO:MOV LENGTH,CL
HLT
CODE ENDS
DATA SEGMENT
STR1 DB GEETHANJALI COLLEGE OF ENGINEERING AND TECHNOLOGY$
LENGTH DB ?
DATA ENDS
END
MPMC LAB
68 | P a g e
DEPT OF ECE
START
FLOW CHART:
INITIALIZATION OF
DATA SEGMENT
AL24H CL00H
SI OFFSET ADDRESS
OF STR1
TRUE
AL=[SI]
FALSE
Increment CL
Increment SI
Unco
nditio
nal
Jump
LENGTHCL
STOP
MPMC LAB
69 | P a g e
DEPT OF ECE
RESULT:
INPUT:
STR (DS:0000H) = GEETHANJALI COLLEGE OF ENGINEERING AND
TECHNOLOGY
OUTPUT: LENGTH =
OUTCOME: This program helps to find the length of the given string.
MPMC LAB
70 | P a g e
DEPT OF ECE
OBJECTIVE: To write an assembly language program to display the given string.
(DOS PROGRAMMING)
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
MOV AX,DATA
MOV DS,AX
MOV AH,09H
MOV DX,OFFSET MSG
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
DATA SEGMENT
MSG DB 0DH,0AH,"WELCOME TO MICROPROCESSORS LAB",0DH,0AH,"$"
DATA ENDS
END
Output:
WELCOME TO MICROPROCESSORS LAB
Learning outcomes:
This program helps to display the given string.
71 | P a g e
DEPT OF ECE
FLOW CHART:
MPMC LAB
72 | P a g e
DEPT OF ECE
START
INITIALIZATION OF
DATA SEGMENT
CLCOUNT
SIoffset address of STR1
DICOUNT-1
[DI]=[SI]
INC SI
DEC DI
DEC CL
FALSE
If
CL=0
TRUE
STOP
MPMC LAB
73 | P a g e
DEPT OF ECE
RESULT:
INPUT:
STR1 (DS:0000H) =
MPMC LAB
74 | P a g e
DEPT OF ECE
EXPERIMENT NO.5
PROGRAM FOR DIGITAL CLOCK DESIGN USING 8086
PROGRAM TO DISPLAY CURRENT SYSTEM TIME
OBJECTIVE: To write an assembly language program to display current system
time.(DOS PROGRAMMING)
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'Current System Time is : $'
TIME DB '00:00:00$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
LEA BX, TIME
CALL GET_TIME
LEA DX, PROMPT
MOV AH, 09H
INT 21H
LEA DX, TIME
MOV AH, 09H
INT 21H
MOV AH, 4CH
INT 21H
MAIN ENDP
GET_TIME PRO
MPMC LAB
75 | P a g e
DEPT OF ECE
PUSH AX
PUSH CX
MOV AH, 2CH
INT 21H
MOV AL, CH
CALL CONVERT
MOV [BX], AX
MOV AL, CL
CALL CONVERT
MOV [BX+3], AX
MOV AL, DH
CALL CONVERT
MOV [BX+6], AX
POP CX
POP AX
RET
GET_TIME ENDP
CONVERT PROC
PUSH DX
MOV AH, 0
MOV DL, 10
DIV DL
OR AX, 3030H
POP DX
RET
CONVERT ENDP
END MAIN
MPMC LAB
76 | P a g e
DEPT OF ECE
VIVA QUESTIONS:
1) Functions of BX register?
2) Functions of CX register?
3) Functions of DX register?
4) How Physical address is generated?
5) Which are pointers present in this 8086?
OUTCOME:
This program helps to display current system time. (DOS PROGRAMMING)
EXPERIMENT NO.6
MPMC LAB
77 | P a g e
DEPT OF ECE
FFC6H
FFC0H
FFC2H
FFC4H
DEPT OF ECE
DSEG
CSEG
SEGMENT
ORG 0000:4000H
MSG
DB '
MSG1
DSEG
Dac mode
',0h
SEGMENT
ORG 0000:5000H
ASSUME CS:CSEG,DS:DSEG
START:
MOV
MOV
OUT
DX,CONTROL
AL,80H
DX,AL
;clear display
;display in upper line
;display output routine
;display in lower line
;display output routine
CSEG
MPMC LAB
JNZ
RAMP
MOV
JMP
BL,00H
RAMP
ENDS
79 | P a g e
DEPT OF ECE
END
SQUARE WAVEFORM:
;step waveform generation
;----------------------------DA00:
MOV
DX,PORTB
MOV
AL,00H
CALL OUTPUT
MOV
AL,0FFH
CALL OUTPUT
JMP
DA00
MOV
MOV
CALL
MOV
CALL
MOV
CALL
JMP
DX,PORTB
AL,00H
OUTPUT
AL,7FH
OUTPUT
AL,FFH
OUTPUT
DA00
MPMC LAB
OUT
DX,AL
MOV CX,FFH
LOOP DELAY
RET
80 | P a g e
DEPT OF ECE
TRIANGULAR WAVEFORM:
;step waveform generation
DA00:
UP:
UP1:
MOV
MOV
CALL
INC
CMP
JNZ
DX,PORTB
AL,00H
OUTPUT
AL
AL,00H
UP
MOV
CALL
DEC
CMP
JNZ
AL,0FFH
OUTPUT
AL
AL,0FFH
UP1
JMP
DA00
;routine to output digital value
OUTPUT:
OUT DX,AL
CALL DELAY
RET
DELAY:
MOV CX,07H
LUP1:
LOOP LUP1
RET
Outcome: The waveforms are generated by interfacing PPI to 8086 kit and can
be observed on CRO.
EXPERIMENT NO.7
MPMC LAB
81 | P a g e
DEPT OF ECE
1.ADS-SDA-86-STA kit
2.8255 Study card
3. Adapter, Keyboard, Cables, Connecting Wires Etc . . .
PROCEDURE
1. Connect 8086 kit PC using RS232 cable.
2. Connect Power supply to 8086 kit and 8255 interfacing kit(only blue(+5v) and
black(0v) lines Power cable to power supply)
3. Connect 8255 to CN4 of 8086 using 26 pin bus.
4. Keep the DIP switch in 1 & 7 on (8086kit), open TALK, and go to options select
target device as 8086 and Connect.
5. Change dip switch into 1 & 5on, once reset 8086 kit.
6. Go to file Download hex file
7. Keep the DIP switch in 1 & 7 on (8086kit)
8. G-5000(on kit keyboard), ENTER CHANNEL NUMBER displays on LCD display.
9. Type the channel number on kit keyboard and connect the connecting wire the
particular channel and power supplies given to 8255 study card. Now observe the
output on the 8086 kit
Program:
.OUTPUT 2500AD
CONTROL
EQU
FFC6H
PORTA
EQU
FFC0H
PORTB
EQU
FFC2H
PORTC
EQU
FFC4H
KWAD
EQU
F800:4EEDH
DBDTA
EQUF800:4F1FH
MPMC LAB
82 | P a g e
DEPT OF ECE
DSEG
MSG
DSEG
CSEG
SEGMENT
ORG 0000:4000H
DB
'Enter channel No',0h
ENDS
SEGMENT
ASSUME
CS:CSEG,DS:DSEG
ORG 0000:5000H
;AD00:
AD00:
MOV
MOV
CALL
MOV
AX,0000H
DS,AX
FAR KWAD
CX,SI
MOV
MOV
OUT
AL,90H
DX,CONTROL
DX,AL
MOV
AL,CL
MOV
DX,PORTC
OUT
DX,AL
;start conversion
MOV
MOV
OUT
DEL1:
MPMC LAB
PUSH
MOV
LOOP
POP
AL,0FH
DX,CONTROL
DX,AL
;clear display
;display in upper line
;
;display output routine
CX
CX,3FFFH
DEL1
CX
83 | P a g e
DEPT OF ECE
MOV
MOV
OUT
AL,0EH
DX,CONTROL
DX,AL
;PC7 reset
AL,0CH
DX,AL
MOV
DX,PORTA
IN
AL,DX
;poll the EOC line which
AND
AL,80H
;is connected to PA7 line
CMP
AL,80H
JNZ
AD01
;if EOC (PA7) is high read the digital value otherwise
;again check for EOC (PA7) line
MOV
AL,0DH
;set OE (PC6) to read value
MOV
DX,CONTROL
OUT
DX,AL
;before reading data from ADC set PC6 line
MOV
IN
MOV
MOV
DX,PORTA
AL,DX
AH,00H
SI,AX
PUSH
CALL
POP
CX
FAR DBDTA
CX
JMP
CSEG
AD00
ENDS
END
.
MPMC LAB
84 | P a g e
DEPT OF ECE
VIVA QUESTIONS:
1) Which is by default pointer for CS/ES?
2) How many segments present in it?
3) What is the size of each segment?
4) Basic difference between 8085 and 8086?
5) Which operations are not available in 8085?
EXPERIMENT NO.8
MPMC LAB
85 | P a g e
DEPT OF ECE
1.ADS-SDA-86-STA kit
2.8251 Study card
3. Adapter, Keyboard, Cables, Etc . . .
PROCEDURE :
Transmission
1. Connect 8086 kit PC using RS232 cable.
2. Connect Power supply to 8086 kit and 8251 interfacing kit(only blue(+5v) and
black(0v) lines Power cable to power supply)
3. Connect 8251 to 8086 using 50pin and 26pin bus.
4. Short 5 & 6 pins of JP9 in 8251 kit
5. Keep the DIP switch in 1 & 7 on (8086kit), open TALK, and go to options select
target device as 8086 and Connect.
6. Change dip switch into 1 & 5on, once reset 8086 kit.
7. Go to file Download hex file
8. G-4000(on system keyboard), we can observe the output on 8251 kit.
9. Remove RS232 cable from 8086kit and connect it to 8251, transmitted data
displayed on PC Monitor
RECEIVEING
1. Connect 8086 kit PC using RS232 cable.
2. Connect Power supply to 8086 kit and 8251 interfacing kit (only blue(+5v) and
black(0v) lines Power cable to power supply)
3. Connect 8251 to 8086 using 50pin and 26pin bus.
4. Short 1 & 2 pins of JP9 in 8251 kit
MPMC LAB
86 | P a g e
DEPT OF ECE
5. Keep the DIP switch in 1 & 7 on (8086kit), open TALK, and go to options select
target device as 8086 and Connect.
6. Change dip switch into 1 & 5on, once reset 8086 kit.
7. Go to file Download hex file
8. Change the DIP switch into 1 & 7 on, once reset.
9. Remove RS232 cable from 8086 kit and connect it to 8251.
10. G-4000 (on 8086 kit keyboard) .enter
11. Give some input from system keyboard (Example press A, B, C, D enter),once
reset 8086 kit That data will be received at 8086 kit at location FF00 (press E, enter
address FF00 and press Comma you will get the ASCII values of A, B, C,D).
PROGRAM:
;PROGRAM TO TEST 8251 TRANSMISSION
.OUTPUT 2500AD
CLOCK_FREQ EQU 1536000
CTL_8251 EQU 3402H
DATA_8251 EQU 3400H
TMR1_8253 EQU 3002H
CTL_8253 EQU 3006H
EXT_RAM_LC EQU 0000:FF00H
DBDT
EQU F800:4F1FH
CNT_BAUD_9600_MODE16 EQU 000AH
CNT_BAUD_4000_MODE01 EQU 0140H
CNT_BAUD_2400_MODE16 EQU 0028H
CNT_BAUD_1200_MODE64 EQU 0014H
CNT_BAUD_0300_MODE64 EQU 0050H
MODE_WORD16 EQU CEH
MODE_WORD1 EQU CDH
MODE_WORD64 EQU CFH
DSEG SEGMENT
MPMC LAB
87 | P a g e
DEPT OF ECE
ORG 0:3000H
MSG DB 'TESTING 8251 IN ASYNCHRONOUS MODE',0DH,0AH,1BH
DSEG ENDS
CSEG SEGMENT
ORG 0000:4000H
ASSUME CS:CSEG,DS:DSEG
START:
MOV AX,00H
MOV SS,AX
MOV SP,2000H
MOV AX,00H
MOV DS,AX
CLI
CLD
MOV BX,0202H
PUSH CS
POP AX
MOV [BX],AX
MOV BX,0200H
LEA AX,CS:SRVC1
MOV [BX],AX
MOV DX,FFD8H
MOV AL,13H
OUT DX,AL
MOV DX,FFDAH
MOV AL,80H
OUT DX,AL
MOV AL,0FH
OUT DX,AL
MOV AL,0FEH
MPMC LAB
88 | P a g e
DEPT OF ECE
OUT DX,AL
MOV DX,CTL_8253
MOV AL,76H
OUT DX,AL
MOV DX,TMR1_8253
MOV AL,<CNT_BAUD_9600_MODE16
OUT DX,AL
MOV AL,>CNT_BAUD_9600_MODE16
OUT DX,AL
STI
MOV DX,CTL_8251
MOV AL,00H
OUT DX,AL
NOP
NOP
NOP
NOP
OUT DX,AL
NOP
NOP
NOP
NOP
OUT DX,AL
MOV DX,CTL_8251
MOV AL,40H
OUT DX,AL
NOP
NOP
NOP
NOP
MPMC LAB
89 | P a g e
DEPT OF ECE
MOV DX,CTL_8251
MOV AL,MODE_WORD16
OUT DX,AL
NOP
NOP
MOV DX,CTL_8251
MOV AL,33H
OUT DX,AL
NOP
NOP
BACK: NOP
JMP BACK
SRVC1:
MOV AX,0000H
MOV DS,AX
MOV AL,[BX]
ADD BX,01H
CMP AL,1BH
JNZ AHEAD
90 | P a g e
DEPT OF ECE
CSEG ENDS
END
;PROGRAM TO TEST 8251 RECEIVING PART
.OUTPUT 2500AD
CLOCK_FREQ EQU 1536000
CTL_8251 EQU 3402H
DATA_8251 EQU 3400H
TMR1_8253 EQU 3002H
CTL_8253 EQU 3006H
EXT_RAM_LC EQU 0:FF00H
DBDT
EQU F800:4F1FH
CNT_BAUD_9600_MODE16 EQU 000AH
CNT_BAUD_4000_MODE01 EQU 0140H
CNT_BAUD_2400_MODE16 EQU 0028H
CNT_BAUD_1200_MODE64 EQU 0014H
CNT_BAUD_0300_MODE64 EQU 0050H
MODE_WORD16 EQU CEH
MODE_WORD1 EQU CDH
MODE_WORD64 EQU CFH
;************************************
;PROGRAM TO TEST 8251 RECEIVING PART.
;************************************
DSEG SEGMENT
ORG 0000:3000H
DSEG ENDS
CSEG SEGMENT
ORG 0000:4000H
ASSUME CS:CSEG,DS:DSEG
START:
MPMC LAB
91 | P a g e
DEPT OF ECE
MOV AX,00H
MOV SS,AX
MOV SP,2000H
MOV DS,AX
CLI
CLD
MOV BX,0202H
PUSH CS
POP AX
MOV [BX],AX
MOV BX,200H
LEA AX,CS:SRVC2
MOV [BX],AX
MOV DX,FFD8H
MOV AL,13H
OUT DX,AL
;ICW1
MOV DX,FFDAH
MOV AL,80H
OUT DX,AL
MOV AL,0FH
OUT DX,AL
MOV AL,0FEH
OUT DX,AL
MOV BX,EXT_RAM_LC
MOV DX,CTL_8253
MOV AL,76H
OUT DX,AL
MOV DX,TMR1_8253
MOV AL,<CNT_BAUD_9600_MODE16
OUT DX,AL
MPMC LAB
92 | P a g e
DEPT OF ECE
MOV AL,>CNT_BAUD_9600_MODE16
OUT DX,AL
STI
MOV DX,CTL_8251
MOV AL,00H
OUT DX,AL
NOP
NOP
NOP
NOP
OUT DX,AL
NOP
NOP
NOP
NOP
OUT DX,AL
MOV DX,CTL_8251
MOV AL,40H
OUT DX,AL
NOP
NOP
NOP
NOP
MOV DX,CTL_8251
MOV AL,MODE_WORD16
OUT DX,AL
NOP
NOP
NOP
NOP
MOV DX,CTL_8251
MOV AL,36H
OUT DX,AL
MPMC LAB
93 | P a g e
DEPT OF ECE
BACK1: NOP
JMP BACK1
SRVC2:
MOV DX,DATA_8251
IN AL,DX
IN AL,DX
NOP
NOP
NOP
NOP
CMP AL,0DH
JNZ AHEAD2
MOV AH,00
MOV SI,AX
CALL FAR DBDT
MOV BX,EXT_RAM_LC
JMP TERM
AHEAD2:MOV [BX],AL
INC BX
TERM: STI
IRET
CSEG ENDS
END
OUTCOME: This program helps to establish Communication between two
processors using 8251.
MPMC LAB
94 | P a g e
DEPT OF ECE
Fig1.8251 CONNECTIONS
MPMC LAB
95 | P a g e
DEPT OF ECE
EXPERIMENT NO.9
INTERFACING TO 8086 AND PROGRAMMING TO CONTROL STEPPER
MOTOR.
I.TO ROTATE STEPPER MOTOR IN CLOCKWISE DIRECTION
Objective: Write a program in ALP to interface stepper motor to 8086 and rotate it in
clockwise direction.
Apparatus:
1.ADS-SDA-86-STA kit
2. Stepper motor interface card
3. 1 Amp Power Supply.
4. Stepper Motor
5. Adapter, Keyboard, Cables, Connecting Wires Etc . . .
PROCEDURE
1. Connect 8086 kit PC using RS232 cable.
2. Connect Power supply to 8086 kit
3. Connect 1Amp Power Supply to the Stepper Motor
4. Connect 8255 to CN4 of 8086 using 26 pin bus.
5. Keep the DIP switch in 1 & 7 on (8086kit), open TALK, and go to options select
target device as 8086 and Connect.
6. Change dip switch into 1 & 5on, once reset 8086 kit.
7. Go to file Download hex file
8. Keep the DIP switch in 1 & 7 on (8086kit)
9. G-4000(on kit keyboard), now the stepper motor will be rotating in clockwise
direction
Program:
.OUTPUT 2500AD
;EQUATES
PORT_C .EQUAL FFC4H ;PORT C ADDRESS
CTL_PORT .EQUAL FFC6H ;CONTROL PORT ADDRESS
MPMC LAB
96 | P a g e
DEPT OF ECE
CTL_BYTE
PHASE_A
PHASE_B
PHASE_C
PHASE_D
.EQUAL
.EQUAL
.EQUAL
.EQUAL
.EQUAL
80H
0cH
06H
03H
0DH
DSEG
SEGMENT
org 0000:3000H
DELAY_COUNT DW 0
DSEG ENDS
CSEG
SEGMENT
ASSUME CS:CSEG,DS:DSEG
ORG 0000:4000H
;Start of Test Program
MOV AL,CTL_BYTE
;8255 INITIALISATION
MOV DX,CTL_PORT
OUT DX,AL ;
START:
MOV AL,PHASE_A
;PHASE A OF BOTH MOTORS ON
MOV DX,PORT_C
OUT DX,AL
CALL DELAY1
;DELAY BET. SWITCHING OF PHASES
MOV AL,PHASE_C
MOV DX,PORT_C
OUT DX,AL
;PHASE B OF BOTH MOTORS
ON
CALL DELAY1
;DELAY BET. SWTICHING OF
PHASES
MOV AL,PHASE_B
MOV DX,PORT_C
OUT DX,AL
;PHASE C OF BOTH MOTORS
ON
CALL DELAY1
;DELAY BET. SWTICHING OF PHASES
MOV AL,PHASE_D
MOV DX,PORT_C
OUT DX,AL
;PHASE D OF BOTH MOTORS
ON
CALL DELAY1
;DELAY BET. SWTCHING OF PHASES
JMP START ;PROGRAMS LOOPS FROM HERE
MPMC LAB
97 | P a g e
DEPT OF ECE
;Delay subroutine
DELAY1: MOV CX, OFFSET DELAY_COUNT
DL1:
LOOP DL1
RET
CSEG
ENDS
.END
Outcome: This program helps to interface stepper-motor to 8086 and can be
rotated in clockwise direction.
MPMC LAB
98 | P a g e
DEPT OF ECE
Objective: Write a program in ALP to interface stepper motor to 8086 and rotate it in
anti-clockwise direction.
Apparatus:
1.ADS-SDA-86-STA kit
2. Stepper motor interface card
3. 1 Amp Power Supply.
4. Stepper Motor
5. Adapter, Keyboard, Cables, Connecting Wires Etc . . .
PROCEDURE
1. Connect 8086 kit PC using RS232 cable.
2. Connect Power supply to 8086 kit
3. Connect 1Amp Power Supply to the Stepper Motor
4. Connect 8255 to CN4 of 8086 using 26 pin bus.
5. Keep the DIP switch in 1 & 7 on (8086kit), open TALK, and go to options select
target device as 8086 and Connect.
6. Change dip switch into 1 & 5on, once reset 8086 kit.
7. Go to file Download hex file
8. Keep the DIP switch in 1 & 7 on (8086kit)
9. G-4000(on kit keyboard), now the stepper motor will be rotating in clockwise
direction
Program:
.OUTPUT 2500AD
; EQUATES
PORT_C .EQUAL FFC4H; PORT C ADDRESS
CTL_PORT .EQUAL FFC6H; CONTROL PORT ADDRESS
CTL_BYTE .EQUAL 80H ; CONTROL BYTE FOR C PORT = ON
PHASE_A
PHASE_B
PHASE_C
PHASE_D
MPMC LAB
.EQUAL 0CH
.EQUAL 06H
.EQUAL 03H
.EQUAL 0DH
DEPT OF ECE
DSEG
SEGMENT
org 0000:3000H
DELAY_COUNT DW 0
DSEG ENDS
; In a one-phase on scheme (anti clockwise) half step
CSEG SEGMENT
ASSUME CS:CSEG,DS:DSEG
ORG 0000:4000H
;Start of Test Program
MOV AL,CTL_BYTE
;8255 INITIALISATION
MOV DX,CTL_PORT
OUT
DX,AL
START:
MOV
AL, 77H
;PHASE_D
;PHASE A OF BOTH MOTORS
ON
MOV
DX, PORT_C
OUT
DX, AL
CALL
DELAY1 ; DELAY BET. SWITCHING OF PHASES
MOV
AL,BBH
;PHASE_B
MOV
DX,PORT_C
OUT
DX,AL
;PHASE B OF BOTH MOTORS
ON
CALL
DELAY
;DELAY BET. SWTICHING OF PHASES
MOV
AL,DDH
;PHASE_C
MOV
DX,PORT_C
OUT
DX,AL
;PHASE C OF BOTH MOTORS
ON
CALL
DELAY1 ;DELAY BET. SWTICHING OF PHASES
MOV
AL,EEH
;PHASE_A
MOV
DX,PORT_C
OUT
DX,AL
;PHASE D OF BOTH MOTORS
ON
CALL
DELAY1
;DELAY BET. SWTCHING OF PHASES
JMP
STAR
;PROGRAMS LOOPS FROM HERE
;Delay subroutine
DELAY1:
MOV CX,OFFSET DELAY_COUNT
MPMC LAB
Page
100 |
DEPT OF ECE
DL1:
LOOP
RET
CSEG
ENDS
.END
DL1
VIVA QUESTIONS:
1) What is the difference between min mode and max mode of 8086?
2) What is the difference between near and far procedure?
3) What is the difference between Macro and procedure?
4) What is the difference between instructions RET & IRET?
5) What is the difference between instructions MUL & IMUL?
INTRODUCTION TO 8051
MPMC LAB
Page
101 |
DEPT OF ECE
The Intel 8051 is Harvard architecture, single chip microcontroller (C) which was
developed by Intel in 1980 for use in embedded systems. 8051 is an 8-bit micro
controller. The Important features of 8085 Architecture:
MPMC LAB
Page
102 |
DEPT OF ECE
MPMC LAB
Page
103 |
DEPT OF ECE
T0
/INT0 /INT1
T1
Other
interrupts
128 bytes
Data Memory
(RAM)
4K byte Program
Memory (ROM)
Timer/Counter
(Timer 0 &
Timer 1)
8051 CPU
Oscillator
&Timing
64 K Bus
Expansion Control
From Crystal
Oscillator or RC
network
ALE
/PSEN
I/O ports
P3 P2 P1 P0
(Address/data)
Serial Port
TxD
RxD
Architecture of 8051
Types of instructions:
Depending on operation they perform, all instructions are divided in several groups:
Arithmetic Instructions
Branch Instructions
Data Transfer Instructions
Logic Instructions
Bit-oriented Instructions
Arithmetic instructions:
Arithmetic instructions perform several basic operations such as addition,
subtraction, division, multiplication etc. After execution, the result is stored in the first
operand. For example:
ADD A,R1 - The result of addition (A+R1) will be stored in the accumulator.
MPMC LAB
Page
104 |
DEPT OF ECE
Mnemonic
ADD A,Rn
ADD A,direct
ADD A,@Ri
ADD A,#data
ADDC A,Rn
ADDC A,direct
ADDC A,@Ri
ADDC A,#data
SUBB A,Rn
SUBB A,direct
SUBB A,@Ri
SUBB A,#data
INC A
INC Rn
INC Rx
INC @Ri
DEC A
DEC Rn
DEC Rx
DEC @Ri
INC DPTR
MUL AB
DIV AB
DA A
Description
Adds the register to the accumulator
Adds the direct byte to the accumulator
Adds the indirect RAM to the accumulator
Adds the immediate data to the accumulator
Adds the register to the accumulator with a carry flag
Adds the direct byte to the accumulator with a carry flag
Adds the indirect RAM to the accumulator with a carry flag
Adds the immediate data to the accumulator with a carry flag
Subtracts the register from the accumulator with a borrow
Subtracts the direct byte from the accumulator with a borrow
Subtracts the indirect RAM from the accumulator with a borrow
Subtracts the immediate data from the accumulator with a borrow
Increments the accumulator by 1
Increments the register by 1
Increments the direct byte by 1
Increments the indirect RAM by 1
Decrements the accumulator by 1
Decrements the register by 1
Decrements the direct byte by 1
Decrements the indirect RAM by 1
Increments the Data Pointer by 1
Multiplies A and B
Divides A by B
Decimal adjustment of the accumulator according to BCD code
Branch Instructions:
There are two kinds of branch instructions:
Unconditional jump instructions: upon their execution a jump to a new location from
where the program continues execution is executed.
Conditional jump instructions: a jump to a new program location is executed only if a
specified condition is met. Otherwise, the program normally proceeds with the next
instruction.
Mnemonic
MPMC LAB
Page
Description
105 |
DEPT OF ECE
ACALL addr11
LCALL addr16
RET
RETI
AJMP addr11
LJMP addr16
Description
Moves the register to the accumulator
Moves the direct byte to the accumulator
Moves the indirect RAM to the accumulator
Moves the immediate data to the accumulator
Moves the accumulator to the register
Moves the direct byte to the register
Moves the immediate data to the register
106 |
DEPT OF ECE
MOV direct,A
MOV direct,Rn
MOV direct,direct
MOV direct,@Ri
MOV direct,#data
MOV @Ri,A
MOV @Ri,direct
MOV @Ri,#data
MOV DPTR,#data
MOVC
A,@A+DPTR
Description
AND register to accumulator
AND direct byte to accumulator
AND indirect RAM to accumulator
AND immediate data to accumulator
AND accumulator to direct byte
AND immediate data to direct register
OR register to accumulator
OR direct byte to accumulator
OR indirect RAM to accumulator
OR accumulator to direct byte
107 |
DEPT OF ECE
ORL direct,#data
XRL A,Rn
XRL A,direct
XRL A,@Ri
XRL A,#data
XRL direct,A
XORL direct,#data
CLR A
CPL A
SWAP A
RL A
RLC A
RR A
RRC A
Bit-oriented Instructions
Similar to logic instructions, bit-oriented instructions perform logic operations.
The difference is that these are performed upon single bits.
Mnemonic
CLR C
CLR bit
SETB C
SETB bit
CPL C
CPL bit
ANL C,bit
ANL C,/bit
ORL C,bit
ORL C,/bit
MOV C,bit
MOV bit,C
Description
Clears the carry flag
Clears the direct bit
Sets the carry flag
Sets the direct bit
Complements the carry flag
Complements the direct bit
AND direct bit to the carry flag
AND complements of direct bit to the carry flag
OR direct bit to the carry flag
OR complements of direct bit to the carry flag
Moves the direct bit to the carry flag
Moves the carry flag to the direct bit
A - accumulator;
Rn - is one of working registers (R0-R7) in the currently active RAM memory
bank;
MPMC LAB
Page
108 |
DEPT OF ECE
addr11 - is an 11-bit address. May be within the same 2KB page of program
memory as the first byte of the following instruction;
Rel - is the address of a close memory location (from -128 to +127 relative to
the first byte of the following instruction). On the basis of it, assembler
computes the value to add or subtract from the number currently stored in the
program counter;
MPMC LAB
Page
109 |
DEPT OF ECE
EXPERIMENT NO. 10
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION
INSTRUCTIONS OF 8051
1.ADS-SDA-51-STA kit
2. Microprocessor Power Supply
3. RS 232 Cable
5. Adapter, Keyboard, Cables, Connecting Wires Etc . . .
Procedure:
For generating HEX File.
1. Check for Driver folder (if driver is in D drive)
2. Go to Command Prompt
3. Type d: and Press enter (if driver is in D drive)
4. Type cd Driver and Press enter
5. Type cd x8051 and Press enter
6. Edit filename.asm Enter
7. Now a window appears in which you need to write the program and save it .
8. Go to fileExit. You will return to command prompt
9. To check errors and generate .obj file Type x8051 and Press enter in the
command prompt.
A. Select the option D and enter
B.Select the option Y to generate cross-reference and enter
C.Enter Input file name as: filename.asm
D.Enter output filename as: filename.obj
10. Now the .obj file is generated and errors will be displayed
MPMC LAB
Page
110 |
DEPT OF ECE
11. To link the file now type link and Press enter
A.Enter input filename as: filename.obj
B.To skip the entry of input, output and library files which are already
c.added press enter 3 times
D.Enter offset address as: 0000
E.Select the option H to generate .hex file
12. Hex file is generated and the length and memory address of hex file will be
displayed. Now
Go to file Download Hex file. Select the HEX file which is generated by
following the path D drive driver X8051 filename.hex. Now I appears on Talk
window to indicate that file is downloaded.
7. Type G and Starting address of HEX file and press enter.
8. Now program gets executed and register status will be displayed.
9. To generate opcode Press Z starting address of hex file and enter.
MPMC LAB
Page
111 |
DEPT OF ECE
I.ARITHEMATIC OPERATIONS
Program:
org 9000h
;addition without carry
mov a,#06h
mov b,#09h
add a,b
mov r0,a
;Subtraction with carry
mov a,#08h
subbc a,#03h
mov r1,a
; multiplication
mov a,#03h
mov b,#06h
mul ab
mov r2,a
;division
mov a,#08h
mov b,#03h
div ab
mov r3,a
mov r4,b
;increment operation
mov a,#03h
inc a
mov r5,a
;decrement operation
mov r6,#07h
dec r6
lcall 0003h
MPMC LAB
Page
112 |
DEPT OF ECE
end
II.LOGICAL OPERATIONS
Program1:
org 8000h
mov r0,#0fh
mov r1,#foh
mov r2,#66h
; And operation
mov a,#ffh
anl a,r0
mov r3,a
; Or operation
mov a,#ffh
orl a,r1
mov r4,a
; Xor operation
mov a,03h
mov a,#ffh
xrl a,r2
mov r5,a
lcall 0003h
end
MPMC LAB
Page
113 |
DEPT OF ECE
Program2:
org 9000h
; clear register A
mov a,#0fh
clr a
mov r0,a
; swap nibbles of register A
mov a,#56h
swap a
mov r1,a
; Complement the bit of register A
mov a,#66h
cpl a
mov r2,a
; Rotate the register contents towards right
mov a,#63h
rr a
xrl a,r
mov r3,a
; Rotate the register contents towards left
mov a,#43h
rl a
xrl a,r
mov r4,a
lcall 0003h
end
MPMC LAB
Page
114 |
DEPT OF ECE
VIVA QUESTIONS:
1) What is the function of 01h of Int 21h?
2) What is the function of 02h of Int 21h?
3) What is the function of 09h of Int 21h?
4) What is the function of 0Ah of Int 21h?
5) What is the function of 4ch of Int 21h?
MPMC LAB
Page
115 |
DEPT OF ECE
Outcome: Arithmetic , Logical , Bit manipulation operations in 8051 were performed
and opcode and register contents were noted.
EXPERIMENT NO.11
PROGRAM AND VERIFY TIMER/COUNTER IN 8051
Objective: To program and verify Timer/counter in 8051(Timer 0 mode 2 counter).
Apparatus:
1.ADS-SDA-51-STA kit
2. Microprocessor Power Supply
3. RS 232 Cable
4. NIFC-26 study card
5. Adapter, Keyboard, Cables, Connecting Wires Etc . . .
Procedure:
1. Connect the 8051 kit to the processor of desktop with Rs232 cable and power
supply to the 8051 Kit.
2.Short 1 & 2 pins of JP1 of Study card.
3.Connect NIFC 26 study card to the 8051 using 50 line bus (P2 of 8051 kit to study
card) and 10 line bus (JP12 of 8051 kit to JP3 of Study card).
4.Now switch on the power supply.
5. Open the TALK icon which is on desktop now Talk window appears.
6. In that window go to options Target Board 8051 ok.
7. Go to options Connect.
8. Press E on kit keyboard to activate serial port of the kit. Now SERIAL PORT
displays on the kit and ALS 8051 STA displays on talk window.
9. Go to file Download Hexfile. Select the HEX file by following the path E drive
Talk MC COMM Nifc26Nifc26. Now I appears on TALk window to indicate
that file is downloaded.
10. Type G 9200 (Starting address) and press enter.
11. Now program gets executed
MPMC LAB
Page
116 |
DEPT OF ECE
12. Now data location displays on the LCD display of Kit and by pressing SW1 of
study card we can observe the increment in the data field displayed.
Program:
org9200h
mov
orl
mov
setb
lcall
loop_a:
mov
mov
movx
inc
mov
movx
lcall
go1:
sjmp
lcall
end
a,tmod
a,#05h
tmod,a
tr0
68eah
;cldis
dptr,#0194h
a,tl0
@dptr,a
dptr
a,th0
@dptr,a
6748h
;upd_add
loop_a
03h
Outcome:
Timer0 as counter in mode 0 is programmed and verified.
MPMC LAB
Page
117 |
DEPT OF ECE
EXPERIMENT NO.12
PROGRAM AND VERIFY INTERRUPT HANDLING IN 8051
Objective: To program and verify interrupt handling in 8051
Apparatus:
1.ADS-SDA-51-STA kit
2. Microprocessor Power Supply
3. RS 232 Cable
4.NIFC-26 study card
5. Adapter, Keyboard, Cables, Connecting Wires Etc . . .
Procedure:
1. Connect the 8051 kit to the processor of desktop with Rs232 cable and power
supply to the 8051 Kit.
2.Short 1 & 2 pins of JP5 and JP6 of Study card.
3.Connect NIFC 26 study card to the 8051 using 50 line bus (P2 of 8051 kit to study
card) and 10 line bus (JP12 of 8051 kit to JP3 of Study card).
4.Now switch on the power supply.
5. Open the TALK icon which is on desktop now Talk window appears.
6. In that window go to options Target Board 8051 ok.
7. Go to options Connect.
8. Press E on kit keyboard to activate serial port of the kit. Now SERIAL PORT
displays on the kit and ALS 8051 STA displays on talk window.
9. Go to file Download Hexfile. Select the HEX file by following the path E drive
Talk MC COMM Nifc26Nifc26. Now I appears on TALk window to indicate
that file is downloaded.
10. Type G 9700 (Starting address) and press enter.
11. Now program gets executed
MPMC LAB
Page
118 |
DEPT OF ECE
12. Now data location displays on the LCD display of Kit (continues swapping of bits
26)
13. Give an external interrupt by pressing sw3 on study card now you can observe
that data field counts from 0 to 2 and continues swapping of bits 26
Program:
org 9700h
mov
orl
mov
mov
setb
setb
setb
setb
setb
mov
setb
here: ajmp
a,tmod
tmod,#10h
th1,#00h
tl1,#ffh
it1
et1
ex1
tr1
px1
r6,#26h
ea
here
org
8028h
ljmp
8500h
org
8500h
mov
compl: mov
swap
mov
lcall
lcall
djnz
mov
mov
MPMC LAB
Page
r7,#10h
a,r6
a
r6,a
upddt
del
r7,compl
th1,#00h
tl1,#ffh
;timer 1 isr
119 |
DEPT OF ECE
setb
reti
tr1
org
8010h
setb
mov
ljmp
rs0
r5,#3h
8600h
org
8600h
lcall
68eah
mov
mov
loop_b: lcall
lcall del
djnz
clr
reti
incre: inc
r6,#00h
r7,#00h
675fh
sjmp
loop_b
del: mov
mov
lcall
ret
r0,#ffh
r1,#ffh
del1
;cldis
;upd_add
;6794h
;66c1h
r5,incre
rs0
r6
VIVA QUESTIONS:
1) Can we use SP as offset address holder with CS?
2) Which is the base registers in 8086?
3) Which is the index registers in 8086?
4) What do you mean by segment override prefix?
MPMC LAB
Page
120 |
DEPT OF ECE
ADDITIONAL EXPERIMENTS
MPMC LAB
Page
121 |
DEPT OF ECE
EXPERIMENT NO.13
KEIL VISION3 TOOL
Procedure to create a new vision project:
Step 1: Give a double click on vision3 icon on the desktop, it will generate a
window as shown below:
MPMC LAB
Page
122 |
DEPT OF ECE
Step 8: After selecting chip click on OK then it will display some window asking to
add STARTUP file. Select YES.
Step 9: A target is created and startup file is added to your project target and is
shown below.
Step 10: To write your project code select a new file from FILE menu bar.
Step 11: It will display some text editor, to save that file select SAVE option from
FILE menu bar.
MPMC LAB
Page
123 |
DEPT OF ECE
Step 12: Save file name with .c extension.
Step 13: Write the code of your project and save it.
Step 14: To add c file to target, give a right click on Source Group, choose ADD
files to Group option.
Step 15:It will displays some window there select the file you have to add and
click on ADD option.
Step 16: The file will be added to target and it is shown in the project window.
MPMC LAB
Page
124 |
DEPT OF ECE
Step 17: Now give a right click on target in the project window and select Options
for Target.
Step 18: It will show some window, in that go to output option and choose Create
Hex file option by selecting that box.
Step 19: In the same window go to Linker option and choose use memory layout
from target dialog by selecting the box, and Click OK.
Step 20: Now to compile your project Select build target option or press F7.
Step 21: In the build OUTPUT window, you can see the errors and warnings of the
code. Project HEX file will be created.
MPMC LAB
Page
125 |
DEPT OF ECE
Experiment No: 14
SERIAL TRANSMISSION FROM PC TO 8051C
Aim: To transmit characters from PC to 8051uc serially and to see the output on
terminal window.
Tools: PC installed with KEIL vision3
Program:
#include<reg51.h>
void serTx(unsigned char);
void main(void)
{
TMOD=0x20;
TH1=0xfd;
SCON=0x50;
TR1=1;
while(1)
{
serTx('M');
serTx('R');
serTx('E');
serTx('C');
serTx('W');
}
}
void serTx(unsigned char x)
{
SBUF=x;
while(TI==0);
TI=0;
}
Result:
MPMC LAB
Page
126 |
DEPT OF ECE
Experiment No: 115
PORT PROGRAMMING OF 8051
Aim: Aim: To write 8051 C program to toggle all the bits of P0 and P2 continuously
with some delay.
Tools: PC installed with KEIL vision3.
Program:
#include <unsigned int>
Void MSDelay(unsigned int):
Void main(void)
{
While(1)
{
P0=0X55;
P2=0X55;
MSDelay(250);
P0=0XAA;
P2=0X55;
MSDelay(250);
}
}
Void MSDelay(unsigned int itime)
{
Unsigned int I, j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
Result:
MPMC LAB
Page
127 |