GCET Dept of ECE
Geethanjali College of Engineering and Technology
Cheeryal (v), Keesara (M), Ranga Reddy District.
MICROPROCESSOR AND MICROCONTROLLERSLABORATORY MASTER MANUAL
for III ECE- II SEM
DEPARTMENT OFELECTRONICS & COMMUNICATOIN ENGINEERING
2014-2015
INCHARGE HOD
(M.Laxmi) (Dr.C.V.Narasimhulu)
1 | P a g eMPMC LAB MANUAL
DEPT OF ECE
Geethanjali College of Engineering and TechnologyCheeryal (v), Keesara (M), Ranga Reddy District.
…striving toward perfection
LABORATORY MANUALFOR
MICROPROCESSOR AND MICROCONTROLLERS
Prepared by: Checked by: (M.Laxmi)
D.Venkat Rami Reddy
Approved by:Dr.C.Venkata Narasimhulu,HOD
Dept., of ECE
Revision No: 3 Date: 20/12/2014
MPMC LAB 2 | P a g e
DEPT OF ECE
GEETHANJALI COLLEGE OF ENGINEERING AND TECHNOLOGYDEPARTMENT OF Electronics and Communication Engineering
(Name of the Subject ) : Microprocessors and Microcontrollers Course file(JNTU CODE - 55030 Programme : UG
Branch: ECE Version No : 3Year: III Document No. GCETSemester: II No. of pages :
MPMC LAB 3 | P a g e
DEPT OF ECE
Classification status (Unrestricted / Restricted ) : UnrestrictedDistribution List : Dept. Library, Dept Office, Concerned Faculty
Prepared by Updated by: 1) Name : M.Laxmi 1 ) Name : 2) Sign : 2) Sign : 3) Desg : Assoc. Professor. 3) Desg : 4) Date : 10-12--2013 4) Date :
Verified by : 1) Name :D.Venkat Rami Reddy 2) Sign : 3) Desg : Assoc. Professor 4) Date :
* For Q.C Only.1) Name :2) Sign : 3) Desg:4) Date :
Approved by : (HOD ) 1) Name :DrC.V.Narasimhulu 2) Sign : 3) Date :
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
III year B.Tech. ECE- I ISEM L 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)
MPMC LAB 4 | P a g e
DEPT OF ECE
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.
The Mission of the institute
Our mission is to become a high quality premier educational institution, to create technocrats, by ensuring excellence, through enriched knowledge, creativity and self development.
The Vision of the institute
Geethanjali visualizes dissemination of knowledge and skills to students, who would eventually contribute to the well being of the people of the nation and global community.
Vision of the Department
MPMC LAB 5 | P a g e
DEPT OF ECE
To impart quality technical education in Electronics and Communication Engineering
emphasizing analysis, design/synthesis and evaluation of hardware/embedded
software using various Electronic Design Automation (EDA) tools with accent on
creativity, innovation and research thereby producing competent engineers who can
meet global challenges with societal commitment.
Mission of the Department
i. To impart quality education in fundamentals of basic sciences, mathematics,
electronics and communication engineering through innovative teaching-learning
processes.
ii. To facilitate Graduates define, design, and solve engineering problems in the
field of Electronics and Communication Engineering using various Electronic
Design Automation (EDA) tools.
iii. To encourage research culture among faculty and students thereby facilitating
them to be creative and innovative through constant interaction with R & D
organizations and Industry.
iv. To inculcate teamwork, imbibe leadership qualities, professional ethics and social responsibilities in students and faculty.
Program Educational Objectives of B. Tech (ECE) Program :
I. To prepare students with excellent comprehension of basic sciences,
mathematics and engineering subjects facilitating them to gain employment or
pursue postgraduate studies with an appreciation for lifelong learning.
II. To train students with problem solving capabilities such as analysis and
design with adequate practical skills wherein they demonstrate creativity and
innovation that would enable them to develop state of the art equipment and
technologies of multidisciplinary nature for societal development.
III. To inculcate positive attitude, professional ethics, effective communication
and interpersonal skills which would facilitate them to succeed in the chosen
profession exhibiting creativity and innovation through research and
development both as team member and as well as leader.
MPMC LAB 6 | P a g e
DEPT OF ECE
Program Outcomes of B.Tech ECE Program: 1. An ability to apply knowledge of Mathematics, Science, and Engineering to
solve complex engineering problems of Electronics and Communication
Engineering systems.
2. An ability to model, simulate and design Electronics and Communication
Engineering systems, conduct experiments, as well as analyze and interpret
data and prepare a report with conclusions.
3. An ability to design an Electronics and Communication Engineering system,
component, or process to meet desired needs within the realistic constraints
such as economic, environmental, social, political, ethical, health and safety,
manufacturability and sustainability.
4. An ability to function on multidisciplinary teams involving interpersonal skills.
5. An ability to identify, formulate and solve engineering problems of
multidisciplinary nature.
6. An understanding of professional and ethical responsibilities involved in the
practice of Electronics and Communication Engineering profession.
7. An ability to communicate effectively with a range of audience on complex
engineering problems of multidisciplinary nature both in oral and written form.
8. The broad education necessary to understand the impact of engineering
solutions in a global, economic, environmental and societal context.
9. A recognition of the need for, and an ability to engage in life-long learning and
acquire the capability for the same.
10.A knowledge of contemporary issues involved in the practice of Electronics
and Communication Engineering profession
11.An ability to use the techniques, skills and modern engineering tools
necessary for engineering practice.
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 7 | P a g e
DEPT OF ECE
INSTRUCTIONS TO THE STUDENTS:
1. Students are required to attend all labs.
2. Students will work in a group of two in hardware laboratories and individually in computer laboratories.
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.
MPMC LAB 8 | P a g e
DEPT OF ECE
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.
INSTRUCTIONS TO LABORATORY TEACHERS:
1. Observation book and lab records submitted for the lab work are to be
checked and signed before the next lab session.
2. Students should be instructed to switch ON the power supply after the
connections are checked by the lab assistant / teacher.
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.
MPMC LAB 9 | P a g e
DEPT OF ECE
MICROPROCESSORS AND MICROCONTROLLERS LAB
LIST OF EXPERIMENTS
CYCLE-I (MICROPROCESSOR PROGRAMS)
1. Study of TASM
2 16-bit arithmetic Operations
3. Sorting an Array
4. Searching for Character in a String
5. Sting Manipulations
6. Digital Clock Design
MPMC LAB 10 | P a g e
DEPT OF ECE
7. Interfacing DAC
8. Interfacing ADC
CYCLE-II (MICROCONTROLLER PROGRAMS)
9. Arithmetic, Logical and Bit Manipulation operations
10. Timer/Counters operations
11. Interrupt Handling
12. UART Operation
13. LCD Interfacing
14. Interfacing Matrix keyboard
CYCLE-III (ADDITIONAL EXPERIMENTS USING KEIL)
15 Serial Transmission from PC to 8051uc
16. Port Programming of 8051
CYCLE-IV (DESIGN & OPEN EXPERIMENTS)MICROPROCESSORS AND MICROCONTROLLERS LAB
INDEX
SL.No. NAME OF THE EXPERIMENT PAGE No.
CYCLE -I0 Study of TASM/MASM 12
1 16-bit arithmetic Operations 22
2 Sorting an Array 55
3 Searching for Character in a String 61
MPMC LAB 11 | P a g e
DEPT OF ECE
4 Sting Manipulations 65
5 Digital Clock Design 72
6 Interfacing DAC 75
7 Interfacing ADC 79
8 Serial communication between two 8086 microprocessors 83
9 Interfacing stepper motor 93
CYCLE-II
Introduction to 8051 99
10 Arithmetic, Logical and Bit Manipulation operations 108
11 Timers and Counters 114
12 Interrupt Handling 116
CYCLE-3 (ADDITIONAL EXPERIMENTS USING KEIL)119
Introduction to KEIL µ vision 120
13 Timer operation of 8051 in different modes to produce square wave.
107
14 Reading & writing data from/to 8051 ports 112
CYCLE-4 (DESIGN & OPEN EXPERIMENTS)
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:
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
MPMC LAB 13 | P a g e
DEPT OF ECE
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 doesn’t 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.
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
MPMC LAB 14 | P a g e
DEPT OF ECE
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 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
MPMC LAB 15 | P a g e
DEPT OF ECE
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
COMMAND FILE NAME
1 Edit, any editor will do 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:
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:
MPMC LAB 16 | P a g e
DEPT OF ECE
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
If there are any errors in the program assembler reports all of them at the command prompt with line no’s, 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
MPMC LAB 17 | P a g e
DEPT OF ECE
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, it’ll 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 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).
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
8086 ARCHITECTURE:
MPMC LAB 18 | P a g e
DEPT OF ECE
PIN DIAGRAM:
MPMC LAB 19 | P a g e
DEPT OF ECE
8086 INSTRUCTION SET SUMMARY:The following is a brief summary of the 8086 instruction set:Data Transfer InstructionsMOV : Move byte or word to register or memoryIN, OUT : Input byte or word from port, output word to portLEA : Load effective addressLDS, LES : Load pointer using data segment, extra segmentPUSH, POP : Push word onto stack, pop word off stackXCHG : Exchange byte or wordXLAT : Translate byte using look-up tableLogical InstructionsNOT : Logical NOT of byte or word (one's complement)AND : Logical AND of byte or word
MPMC LAB 20 | P a g e
DEPT OF ECE
OR : Logical OR of byte or wordXOR : Logical exclusive-OR of byte or wordTEST : Test byte or word (AND without storing)
Shift and Rotate InstructionsSHL, SHR : Logical shift left, right byte or word by 1 or CLSAL, SAR : Arithmetic shift left, right byte or word by 1 or CLROL, ROR : Rotate left, right byte or word by 1 or CLRCL, RCR : Rotate left, right through carry byte or word by 1 or CL
Arithmetic InstructionsADD, SUB : Add, subtract byte or wordADC, SBB : Add, subtract byte or word and carry (borrow)INC, DEC : Increment, decrement byte or wordNEG : Negate byte or word (two's complement)CMP : Compare byte or word (subtract without storing)MUL, DIV : Multiply, divide byte or word (unsigned)IMUL, IDIV : Integer multiply or divide byte or word (signed)CBW, CWD : Convert byte to word, word to double word (useful before
multiply/divide)AAA, AAS, AAM, AAD: ASCII adjust for addition, subtraction, multiplication,
division (ASCII codes 30-39)DAA, DAS : Decimal adjust for addition, subtraction (binary coded
decimal numbers)
Transfer InstructionsJMP : Unconditional jumpJA (JNBE) : Jump if above (not below or equal)JAE (JNB) : Jump if above or equal (not below)JB (JNAE) : Jump if below (not above or equal)JBE (JNA) : Jump if below or equal (not above)JE (JZ) : Jump if equal (zero)JG (JNLE) : Jump if greater (not less or equal)JGE (JNL) : Jump if greater or equal (not less)JL (JNGE) : Jump if less (not greater nor equal)JLE (JNG) : Jump if less or equal (not greater)JC, JNC : Jump if carry set, carry not setJO, JNO : Jump if overflow, no overflowJS, JNS : Jump if sign, no signJNP (JPO) : Jump if no parity (parity odd)
MPMC LAB 21 | P a g e
DEPT OF ECE
JP (JPE) : Jump if parity (parity even)LOOP : Loop unconditional, count in CXLOOPE (LOOPZ) : Loop if equal (zero), count in CXLOOPNE (LOOPNZ) : Loop if not equal (not zero), count in CXJCXZ : Jump if CX equals zero
Subroutine and Interrupt InstructionsCALL, RET : Call, return from procedureINT, INTO : Software interrupt, interrupt if overflowIRET : Return from interrupt
String InstructionsMOVS : Move byte or word stringMOVSB, MOVSW : Move byte, word stringCMPS : Compare byte or word stringSCAS : Scan byte or word stringLODS, STOS : Load, store byte or word stringREP : RepeatREPE, REPZ : Repeat while equal, zeroREPNE, REPNZ : Repeat while not equal (zero)
Processor Control InstructionsSTC, CLC, CMC : Set, clear, complement carry flagSTD, CLD : Set, clear direction flagSTI, CLI : Set, clear interrupt enable flagLAHF, SAHF : Load AH from flags, store AH into flagsPUSHF, POPF : Push flags onto stack, pop flags off stackESC : Escape to external processor interfaceLOCK : Lock bus during next instructionNOP : No operation (do nothing)WAIT : Wait for signal on TEST inputHLT : Halt processor
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. Go to Start.2. Click on Run. 3. Then Type on CMD and click “ok”.4. Press f and [shift]+: and ↵5. Type “cd tasm” and ↵ 6. 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 filename9. For Turbo linking
Tlink filename10.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:DATACODE SEGMENTMOV AX, DATAMOV DS, AXMOV AX,OPR1ADD AX,OPR2MOV RES,AXHLTCODE ENDSDATA SEGMENTOPR1 DW 4269HOPR2 DW 1000HRES DW ?DATA ENDSEND
MPMC LAB 25 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88E4E MOV AX,4E8E INITIALIZATION OF DATA SEGMENT0003 8ED8 MOV DS,AX
0005 A10000 MOV AX,[0000]THE VALUE IN [0000] IS
MOVED TO AX
0008 03060200 ADD AX,[0002]THE VALUE IN [0002] IS
ADDED TO AX
000C A30400 MOV [0004],AXTHE VALUE IN AX IS
MOVED TO [0004]
000F F4 HLT END OF PROGRAM
FLOW CHART:
MPMC LAB 26 | P a g e
START
INITIALIZATION OF DATA SEGMENT
AXOPR1
AXAX+OPR2RESAX
STOP
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 NUMBERSFLAGS: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
II.SUBTRACTION OF TWO 16-BIT NUMBERS
OBJECTIVE: To write an assembly language program to perform subtraction of two 16-bit signed and unsigned numbers.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER.
PROGRAM: ASSUME CS:CODE,DS:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AX,OPR1MOV BX,OPR2SUB AX,BXMOV RES,AXHLTCODE ENDSDATA SEGMENTOPR1 DW 4269HOPR2 DW 1000HRES DW ?DATA ENDSENDOPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88E4E MOV AX,4E8E INITIALIZATION OF DATA SEGMENT0003 8ED8 MOV DS,AX
0005 A10000 MOV AX,[0000]THE VALUE IN [0000] IS
MOVED TO AX
0008 2B060200 SUB AX,[0002]THE VALUE IN [0002] IS SUBTRACTED FROM AX
000C A30400 MOV [0004],AXTHE VALUE IN AX IS
MOVED TO [0004]
000F F4 HLT END OF PROGRAM
MPMC LAB 28 | P a g e
DEPT OF ECE
FLOW CHART:
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 NUMBERSFLAGS: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
START
INITIALIZATION OF DATA SEGMENT
AXOPR1
AXAX-OPR2RESAX
STOP
DEPT OF ECE
III.MULTIPLICATION OF TWO 16-BIT UNSIGNED NUMBERS
OBJECTIVE: To write an assembly language program to perform multiplication of two 16-bit unsigned numbers.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER.
PROGRAM: ASSUME CS:CODE,DS:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AX,OPR1MUL OPR2MOV RESLW,AXMOV RESHW,DXHLTCODE ENDSDATA SEGMENTOPR1 DW 2000HOPR2 DW 4000HRESLW DW ?RESHW DW ?DATA ENDSEND
MPMC LAB 30 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88E4E MOV AX,4E8EINITIALIZATION OF DATA
SEGMENT0003 8ED8 MOV DS,AX
0005 A10000 MOV AX,[0000]THE VALUE IN [0000] IS MOVED
TO AX
0008F726020
0MUL WORD PTR
[0002]THE VALUE IN [0002] IS
MULTIPLIED BY AX
000C A30400 MOV [0004],AXTHE VALUE IN AX IS MOVED
TO [0004]
000F 89160600 MOV [0006],DXTHE VALUE IN DX IS MOVED
TO [0006]
0013 F4 HLT END OF PROGRAM
MPMC LAB 31 | P a g e
DEPT OF ECE
FLOW CHART:
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
OUTPUT: RESLW = 0000H (AX) RESHW = 0800H (DX)
OUTCOME:This program helps to find the multiplication of two 16-bit numbers
MPMC LAB 32 | P a g e
START
INITIALIZATION OF DATA SEGMENT
AXOPR1
AXAX*OPR2RESLWAXRESHWDX
STOP
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:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AX,OPR1IMUL OPR2MOV RESLW,AXMOV RESHW,DXHLTCODE ENDSDATA SEGMENTOPR1 DW 7593HOPR2 DW 6845HRESLW DW ?RESHW DW ?DATA ENDSEND
MPMC LAB 33 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88F4E MOV AX,4E8FINITIALIZATION OF DATA
SEGMENT0003 8ED8 MOV DS,AX
0005 A10000 MOV AX,[0000]THE VALUE IN [0000] IS MOVED
TO AX
0008 F72E0200IMULWORD PTR
[0002]THE VALUE IN [0002] IS ADDED
TO AX
000C A30400 MOV [0004],AXTHE VALUE IN AX IS MOVED
TO [0004]
000F 89160600 MOV [0006],DXTHE VALUE IN DX IS MOVED
TO [0006]
0013 F4 HLT END OF PROGRAM
MPMC LAB 34 | P a g e
DEPT OF ECE
FLOW CHART:
MPMC LAB 35 | P a g e
START
INITIALIZATION OF DATA SEGMENT
SIGNED MULTIPICATION OF
AX & OPR1
AXAX*OPR2RESLWAXRESHWDX
STOP
DEPT OF ECE
RESULT:
CASE I: Two positive numbersFLAGS: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 numberFLAGS: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 = 8A6DH 2’s Complement of (-7593H) OPR2 = 6845H
OUTPUT: RESLW = 9761H (AX) 2’s Complement RESHW = D01CH (DX) of (- 2FE3689FH)
CASE III: two negative numbersFLAGS: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 = 8A6DH 2’s Complement of (-7593H) OPR2 = 97BBH 2’s Complement of (-6845H)
OUTPUT: RESLW = 689FH (AX) RESHW = 2FE3H (DX)
OUTCOME:This program helps to find the multiplication of two 16-bit signed numbers
MPMC LAB 36 | P a g e
DEPT OF ECE
V.DIVISION OF UNSIGNED NUMBERS
OBJECTIVE: To write an assembly language program to perform division of 16-bit unsigned number by 8-bit unsigned number.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM: ASSUME CS:CODE,DS:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AX,OPR1DIV OPR2MOV RESQ,ALMOV RESR,AHHLTCODE ENDSDATA SEGMENTOPR1 DW 2C58HOPR2 DB 56HRESQ DB ?RESR DB ?DATA ENDSEND
MPMC LAB 37 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88F4E MOV AX,4E8FINITIALIZATION OF DATA
SEGMENT0003 8ED8 MOV DS,AX
0005 A10000 MOV AX,[0000]THE VALUE IN [0000] IS MOVED
TO AX
0008F636020
0DIV BYTE PTR
[0002]THE VALUE IN [0002] IS ADDED
TO AX
000C A20300 MOV [0003],ALTHE VALUE IN AL IS MOVED TO
[0003]
000F 88260400 MOV [0004],AHTHE VALUE IN AH IS MOVED
TO [0004]
0013 F4 HLT END OF PROGRAM
MPMC LAB 38 | P a g e
DEPT OF ECE
FLOW CHART:
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: OPR1 = 2C58H (DIVIDEND) OPR2 = 56H (DIVISOR)
OUTPUT: RESQ = 84H (AL) RESR = 00H (AH)
OUTCOME:This program helps to find the division of two 16-bit unsigned numbers
MPMC LAB 39 | P a g e
START
INITIALIZATION OF DATA SEGMENT
DIVISION OF AX BY OPR2
AXAX/OPR2RESQALRESRAH
STOP
DEPT OF ECE
VI. DIVISION OF SIGNED NUMBERS
OBJECTIVE: To write an assembly language program to perform division of 16-bit signed number by 8-bit signed number.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS: CODE,DS:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AX,OPR1IDIV OPR2MOV RESQ,ALMOV RESR,AHHLTCODE ENDSDATA SEGMENTOPR1 DW 26F8HOPR2 DB 0AAHRESQ DW ?RESR DW ?DATA ENDSEND
MPMC LAB 40 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88F4E MOV AX,4E8FINITIALIZATION OF DATA
SEGMENT0003 8ED8 MOV DS,AX
0005 A10000 MOV AX,[0000]THE VALUE IN [0000] IS MOVED
TO AX
0008 F63E0200IDIV BYTE PTR
[0002]THE VALUE IN [0002] IS ADDED
TO AX
000C A20300 MOV [0003],ALTHE VALUE IN AL IS MOVED
TO [0003]
000F 88260400 MOV [0004],AHTHE VALUE IN AH IS MOVED
TO [0004]
0013 F4 HLT END OF PROGRAM
MPMC LAB 41 | P a g e
DEPT OF ECE
FLOW CHART:
MPMC LAB 42 | P a g e
START
INITIALIZATION OF DATA SEGMENT
SIGNED DIVISION OF AX BY OPR1
AXAX/OPR2RESQALRESRAH
STOP
DEPT OF ECE
RESULT:
CASE I: two positive numbersFLAGS: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 (DIVIDEND) OPR2 = 56H (DIVISOR)
OUTPUT: RESQ = 74H (AL) RESR = 00H (AH)
CASE II: one positive number & one negative numberFLAGS: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 = D908H 2’s Complement of (-26F8H) OPR2 = 56H
OUTPUT: RESQ = 8CH (AL) 2’s Complement of (- 74H) RESR = 00H (AH)
CASE III: 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=0, s=0, z=0, o=0, p=0, a=1, i=1, d=0.
INPUT: OPR1 = 26F8H OPR2 = AAH 2’s Complement of (-56H)
OUTPUT: RESQ = 8CH (AL) 2’s 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
OBJECTIVE: To write an ALP to perform the addition of two ASCII bytes.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM: ASSUME CS: CODE,DS:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AH,00HMOV AL,CHARADD AL,CHAR1AAAMOV RES,AXHLTCODE ENDSDATA SEGMENTCHAR DB '8'CHAR1 DB '6'RES DW ?DATA ENDSEND
MPMC LAB 44 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88F4E MOV AX,4E8FINITIALIZATION OF DATA
SEGMENT0003 8ED8 MOV DS,AX
0005 B400 MOV AH,00 00H IS STORED IN AH
0007 A00000 MOV AL,[0000]THE VALUE IN [0000] IS
MOVED TO AL
000A 02060100 ADD AL,[0001]THE VALUE IN [0001] IS
ADDED TO AL
000E 37 AAAASCII ADJUST AFTER
ADDITION
000F A30200 MOV [0002],AXTHE VALUE IN AX IS
MOVED TO [0002]
0012 F4 HLT END OF PROGRAM
MPMC LAB 45 | P a g e
DEPT OF ECE
FLOW CHART:
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’
OUTPUT: RES = 0104 (AX) unpacked BCD of 14
OUTCOME: This program helps to perform the addition of two ASCII bytes.
MPMC LAB 46 | P a g e
START
INITIALIZATION OF DATA SEGMENT
AH00AlCHAR
ALAL+CHAR1 ASCII adjust for addition
RESAX
STOP
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:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AH,00HMOV AL,CHARSUB AL,CHAR1AASMOV RES,AXHLTCODE ENDSDATA SEGMENTCHAR DB '9'CHAR1 DB '5'RES DW ?DATA ENDSEND
MPMC LAB 47 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88F4E MOV AX,4E8FINITIALIZATION OF DATA
SEGMENT0003 8ED8 MOV DS,AX
0005 B400 MOV AH,00 00H IS STORED IN AH
0007 A00000 MOV AL,[0000]THE VALUE IN [0000] IS
MOVED TO AL
000A 2A060100 SUB AL,[0001]THE VALUE IN [0001] IS SUBTRACTED FROM AL
000E 3F AASASCII ADJUST AFTER
SUBTRACTION
000F A30200 MOV [0002],AXTHE VALUE IN AX IS
MOVED TO [0002]
0012 F4 HLT END OF PROGRAM
MPMC LAB 48 | P a g e
DEPT OF ECE
FLOW CHART:
MPMC LAB 49 | P a g e
START
INITIALIZATION OF DATA SEGMENT
AH00ALCHAR
ALAL-CHAR1 ASCII adjust for subtraction
RESAX
STOP
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) 2’s 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:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AH,00MOV AL,NUM1MUL NUM2AAMMOV RES,AXHLTCODE ENDSDATA SEGMENTNUM1 DB 09NUM2 DB 05RES DW ?DATA ENDSEND
MPMC LAB 51 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88F4E MOV AX,4E8FINITIALIZATION OF DATA
SEGMENT0003 8ED8 MOV DS,AX
0005 B400 MOV AH,00 00H IS STORED IN AH
0007 A00000 MOV AL,[0000]THE VALUE IN [0000] IS
MOVED TO AL
000A F6260100MUL BYTE PTR
[0001]THE VALUE IN [0001] IS
MULTIPLIED BY AL
000E D40A AAMASCII ADJUST AFTER
MULTIPLCATION
000F A30200 MOV [0002],AXTHE VALUE IN AX IS
MOVED TO [0002]
0012 F4 HLT END OF PROGRAM
MPMC LAB 52 | P a g e
DEPT OF ECE
FLOW CHART:
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
START
INITIALIZATION OF DATA SEGMENT
AH00ALNUM1
ALAL*NUM2ASCII adjust for multiplication
RESAX
STOP
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: DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AX,DIVIDENDAADMOV CH,DIVISORDIV CHMOV RESQ,ALMOV RESR,AHHLTCODE ENDSDATA SEGMENTDIVIDEND DW 0607HDIVISOR DB 09HRESQ DB ?RESR DB ?DATA ENDSEND
MPMC LAB 54 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS OPCODE OPERATION COMMENTS
0000 B88F4E MOV AX,4E8FINITIALIZATION OF DATA
SEGMENT0003 8ED8 MOV DS,AX
0005 A10000 MOV AX,[0000]THE VALUE IN [0000] IS
MOVED TO AX
0008 D50A AADASCII ADJUST FOR
DIVIDION
000A 8A2E0200 MOV CH,[0002]THE VALUE IN [0002] IS
MOVED TO CH
000E F6F5 DIV CH AX IS DIVIDED BY CH
0010 A20300 MOV [0003],ALTHE VALUE IN AL IS
MOVED TO [0003]
0013 88260400 MOV [0002],AHTHE VALYE IN AH IS
MOVED TO [0004]
0017 F4 HLT END OF PROGRAM
MPMC LAB 55 | P a g e
DEPT OF ECE
FLOW CHART:
MPMC LAB 56 | P a g e
START
INITIALIZATION OF DATA SEGMENT
AXDIVIDEND ASCII Adjust for Division
CHDIVISOR
AXAX/CHRESQAL, RESRAH
STOP
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: DIVIDEND = 0607H unpacked BCD of 67 DIVISOR = 09H
OUTPUT: RESQ = 07 (AL) RESR = 04 (AH)
VIVA QUESTIONS :
1) How many bit 8086 microprocessor is?
2) What is the size of data bus of 8086?
3) What is the size of address bus of 8086?
4) What is the max memory addressing capacity of 8086?
5) Which are the basic parts of 8086?
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:DATACODE SEGMENT
MOV AX,DATAMOV DS,AXMOV DX,COUNT-1
BACK:MOV CX,DXMOV SI,OFFSET LIST
AGAIN:MOV AX,[SI]CMP AX,[SI+2]JC GOXCHG AX,[SI+2]XCHG AX,[SI]
GO:INC SIINC SILOOP AGAINDEC DXJNZ BACKHLT
CODE ENDSDATA SEGMENT
LIST DW 05H,04H,01H,03H,02HCOUNT EQU 05H
DATA ENDSEND
MPMC LAB 58 | P a g e
DEPT OF ECE
FLOW CHART:
MPMC LAB 59 | P a g e
START
INITIALIZATION OF DATA SEGMENT
DXCOUNT-1
BACK : CXDX
SIOFFSET ADDRESS OF LIST
IF AX < [SI+2]
AGAIN: AX[SI]
TRUE
EXCHANGE [SI] &[SI+2]
INCREMENT SI BY 2
DECREMENT DX
IF CX=0
IF DX=0
STOP
FALSE
TRUE
TRUE
FALSE
FALSE
DEPT OF ECE
RESULT:
INPUT: LIST (DS: 0000H) = 05H,04H,01H,03H,02H
OUTPUT: LIST (DS: 0000H) = 01H,02H,03H,04H,05H
OUTCOME: This program helps to arrange the given numbers in ascending order.
MPMC LAB 60 | P a g e
DEPT OF ECE
II. DESCENDING ORDEROBJECTIVE: To write an assembly language program to arrange the given numbers in descending order.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM: ASSUME CS:CODE,DS:DATACODE SEGMENT
MOV AX,DATAMOV DS,AXMOV DX,COUNT-1
BACK:MOV CX,DXMOV SI,OFFSET LIST
AGAIN:MOV AX,[SI]CMP AX,[SI+2]JNC GOXCHG AX,[SI+2]XCHG AX,[SI]
GO:INC SIINC SILOOP AGAINDEC DXJNZ BACK
HLTCODE ENDSDATA SEGMENT
LIST DW 03H,04H,01H,05H,02HCOUNT EQU 05H
DATA ENDSEND
MPMC LAB 61 | P a g e
DEPT OF ECE
FLOW CHART:
MPMC LAB 62 | P a g e
START
INITIALIZATION OF DATA SEGMENT
DXCOUNT-1
BACK : CXDX
SIOFFSET ADDRESS OF LIST
IF AX > [SI+2]
AGAIN: AX[SI]
TRUE
EXCHANGE [SI] &[SI+2]
INCREMENT SI BY 2
DECREMENT DX
IF CX=0
IF DX=0
STOP
FALSE
TRUE
TRUE
FALSE
FALSE
DEPT OF ECE
RESULT:
INPUT: LIST (DS: 0000H) = 03H, 04H,01H,05H,02H
OUTPUT: LIST (DS: 0000H) = 05H, 04H, 03H,02H,01H
VIVA QUESTIONS:
1) What are the functions of BIU?
2) What are the functions of EU?
3) How many pin IC 8086 is?
4) What IC8086 is?
5) What is the size of instruction queue in 8086?
OUTCOME: This program helps to arrange the given numbers in descending order
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:DATACODE SEGMENTMOV AX,DATAMOV DS,AXLEA SI,LISTXOR BL,BLMOV CL,COUNTMOV AL,BYTBACK:CMP AL,[SI]JZ SKIPINC BXINC SILOOP BACKSKIP:HLTCODE ENDS DATA SEGMENTLIST DB 19H,99H,45H,46H,34HCOUNT DB 05HBYT DB 45HDATA ENDSEND
MPMC LAB 64 | P a g e
DEPT OF ECE
OPCODE:
ADDRESS
OPPCODE OPERATIONS COMMENTS
0000 B8974E MOV AX,4E97 INITIALIZATION OF DATA
SEGMENT0003 8ED8 MOV DS,AX
0005 BE0000 MOV SI,[0000]THE VALUE
[0000] IS MOVED TO SI
0008 32DB XOR BL,BLTHE REGISTER BL IS CLEARED
000A 8A0E0500 MOV CL,[0005]THE VALUE
[0005] IS MOVED TO CL
000E A00600MOV AL,[0006]
THE VALUE [0006] IS MOVED
TO AL
0011 3A04CMP AL,SI
COMPARE THE VALUE OF SI
WITHAL0013 7404 JE 0019 JUMP TO 0019
0015 43 INC BXINCREMENT BX
BY ONE
0016 46 INC SIINCREMENT SI
BY ONE
0017 E2F8 LOOP 0011LOOP BACK TO
0011
0019 F4 HLTEND OF THE PROGRAM
MPMC LAB 65 | P a g e
DEPT OF ECE
YES
NO
NO
YES
MPMC LAB 66 | P a g e
IfCL=0
AL,00H CL,00HSI, OFFSET STR
Increment CL Increment SI
IF AL<[SI]
LENGTHCL
START
INITIALIZATION OF DATA SEGMENT
IfCL=0
ALBYTE CLCOUNT, BX=00SI, OFFSET LIST
Increment BX Increment SI
Decrement CL
STOP
IF AL=[SI]
NOP
DEPT OF ECE
RESULT:
GIVEN DATA:N=19H,99H,45H,46H,34HBYTE= 45H
FLAGS:INITIALLY: C=0,Z=0,S=0,O=0,P=0,A=0,I=1,D=0AFTER EXECUTION: C=0,Z=1,S=0,O=0,P=1,A=0,I=1,D=0
OUTPUT: RES: 45HADDRESS: 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:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AL,’$’MOV CX,00HMOV SI,OFFSET STR1BACK:CMP AL,[SI]JE GOINC CLINC SIJMP BACKGO:MOV LENGTH,CLHLTCODE ENDSDATA SEGMENTSTR1 DB ‘GEETHANJALI COLLEGE OF ENGINEERING AND TECHNOLOGY$’LENGTH DB ?DATA ENDS END
MPMC LAB 68 | P a g e
DEPT OF ECE
FLOW CHART:
MPMC LAB 69 | P a g e
START
INITIALIZATION OF DATA SEGMENT
Unconditional Jump
AL24H CL00HSI OFFSET ADDRESS OF STR1
Increment CL Increment SI
STOP
AL=[SI]
LENGTHCL
FALSE
TRUE
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
II. DISPLAY THE STRING
OBJECTIVE: To write an assembly language program to display the given string.(DOS PROGRAMMING)
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM: ASSUME CS:CODE,DS:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV AH,09HMOV DX,OFFSET MSGINT 21HMOV AH,4CHINT 21HCODE ENDSDATA SEGMENTMSG DB 0DH,0AH,"WELCOME TO MICROPROCESSORS LAB",0DH,0AH,"$" DATA ENDSEND
Output: WELCOME TO MICROPROCESSORS LAB
Learning outcomes: This program helps to display the given string.
MPMC LAB 71 | P a g e
DEPT OF ECE
III.REVERSE THE STRING
OBJECTIVE: To write an assembly language program to reverse the given string.
SOFTWARE REQUIRED: TASM TURBO ASSEMBLER
PROGRAM:
ASSUME CS:CODE,DS:DATACODE SEGMENTMOV AX,DATAMOV DS,AXMOV CL,COUNTMOV SI,OFFSET STR1MOV DI,COUNT-1BACK:MOV AL,[SI]XCHG [DI],ALMOV [SI],ALINC SIDEC DIDEC CLJNZ BACKHLTCODE ENDSDATA SEGMENTSTR1 DB ‘MPMC$’COUNT EQU 04HSTR2 DB DUP (0)DATA ENDS END
MPMC LAB 72 | P a g e
DEPT OF ECE
FLOW CHART:
MPMC LAB 73 | P a g e
INC SI DEC DI DEC CL
IfCL=0
START
INITIALIZATION OF DATA SEGMENT
CLCOUNTSIoffset address of STR1DICOUNT-1
[DI]=[SI]
STOP
FALSE
TRUE
DEPT OF ECE
RESULT:
INPUT: STR1 (DS:0000H) = OUTPUT: STR1 (DS:0004H) =
VIVA QUESTIOS:
1) What do you mean by assembler directives?
2) What .model small stands for?
3) What is the supply requirement of 8086?
4) What is the relation between 8086 processor frequency & crystal Frequency?
5) Functions of Accumulator or AX register?
OUTCOME: To write an assembly language program to reverse the given string.(DOS PROGRAMMING)
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
INTERFACING DAC TO 8086I.DIGITAL TO ANALOG CONVERTER
GENERATION OF WAVE FORMS:
Objective: Program to generate following wave formsa. Ramp waveformb. Square waveformc. Step waveformd. Triangle waveform
Apparatus: 1.ADS-SDA-86-STA kit 2.8255 Study card 3. Adapter, Keyboard, Cables, CRO 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. Connect the CRO probe to JP3 of 8255 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-5000(on system keyboard), we can observe the output on 8086 kit and CRO.
Program:
Ramp Wave Form Generation
.OUTPUT 2500ADCONTROL EQU FFC6H ;control port address for 8255PORTA EQU FFC0H ;porta address for 8255PORTB EQU FFC2H ;portb address for 8255PORTC EQU FFC4H ;portc address for 8255
MPMC LAB 78 | P a g e
DEPT OF ECE
DSEG SEGMENTORG 0000:4000HMSG DB ' Dac mode ',0h
MSG1 DB 'Ramp wave output',0hDSEG ENDS
CSEG SEGMENTORG 0000:5000HASSUME CS:CSEG,DS:DSEG
START:
MOV DX,CONTROLMOV AL,80H ;initialise all ports as outputOUT DX,AL ;ports
;displaying message on LCDCall far f800:4bb1h ;clear displayMov di,80h ;display in upper lineMOV SI,offset MSGCALL FAR f800:4FC0h ;display output routineMOV DI,C0H ;display in lower lineMOV SI,OFFSET MSG1CALL FAR F800:4FC0H ;display output routine
;ramp wave form generationMOV BL,00H
RAMP: MOV DX,PORTBMOV AL,BL ;increment the digital codeOUT DX,AL ;and output it on to PORTBINC BL
;check to see if a NMI-INTRJNZ RAMP
MOV BL,00HJMP RAMP
CSEG ENDS
MPMC LAB 79 | P a g e
DEPT OF ECE
END SQUARE WAVEFORM:
;step waveform generation;-----------------------------
DA00: MOV DX,PORTBMOV AL,00H ;outport 00 for 0V levelCALL OUTPUTMOV AL,0FFHCALL OUTPUTJMP DA00
;routine to output digital valueOUTPUT: OUT DX,AL
CALL DELAYRET
DELAY: MOV CX,0FFH ;to vary the frequency alter the delay countLUP1: LOOP LUP1
RET
STEP WAVEFORM:
DA00: MOV DX,PORTBMOV AL,00H ;outport 00 for 0V levelCALL OUTPUTMOV AL,7FH ;outport 7F for 2.5V levelCALL OUTPUTMOV AL,FFH ;outport FF for 5V levelCALL OUTPUT
;look for NMI-INTR if userJMP DA00 ;switch to ramp w/f generation
;routine to output digital value
OUTPUT: OUT DX,ALMOV CX,FFH
DELAY: LOOP DELAYRET
MPMC LAB 80 | P a g e
DEPT OF ECE
TRIANGULAR WAVEFORM:;step waveform generation
DA00: MOV DX,PORTBMOV AL,00H ;outport 00 for 0V level
UP: CALL OUTPUTINC ALCMP AL,00HJNZ UP
MOV AL,0FFH ;to change amplitude change countUP1: CALL OUTPUT
DEC ALCMP AL,0FFHJNZ UP1
JMP DA00;routine to output digital valueOUTPUT: OUT DX,AL
CALL DELAYRET
DELAY: MOV CX,07H ;to vary the frequency alter the delay countLUP1: 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
INTERFACING ADC TO 80861.ANALOG TO DIGITAL CONVERTER
Objective: Write a program in ALP to establish Communication between two processors using 8251.
Apparatus: 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 2500ADCONTROL EQU FFC6H ;control port address for 8255PORTA EQU FFC0H ;porta address for 8255PORTB EQU FFC2H ;portb address for 8255PORTC EQU FFC4H ;portc address for 8255KWAD EQU F800:4EEDHDBDTA EQUF800:4F1FH
MPMC LAB 82 | P a g e
DEPT OF ECE
DSEG SEGMENTORG 0000:4000H
MSG DB 'Enter channel No',0hDSEG ENDS
CSEG SEGMENTASSUME CS:CSEG,DS:DSEGORG 0000:5000H
;displaying message on LCDCallfar f800:4bb1h ;clear displaymovdi, 80h ;display in upper lineMOV SI,offset MSG ;CALLFAR f800:4FC0h ;display output routine
MOV AX,0000HMOV DS,AX
;AD00: CALL FAR KWAD ;get key for channel selectionMOV CX,SI
MOV AL,90H ;control word for PPIMOV DX,CONTROLOUT DX,AL ;portA->i/p port,portB->o/p port
;portC->o/p port.
AD00: MOV AL,CL ;output channel numberMOV DX,PORTCOUT DX,AL;start conversion
MOV AL,0FH ;PC7 (START/ALE) setMOV DX,CONTROLOUT DX,AL
PUSH CXMOV CX,3FFFH
DEL1: LOOP DEL1POP CX
MPMC LAB 83 | P a g e
DEPT OF ECE
MOV AL,0EH ;PC7 resetMOV DX,CONTROLOUT DX,AL
;look for EOC
MOV AL,0CH ;reset PC6 to read EOCOUT DX,AL
AD01: MOV DX,PORTAIN AL,DX ;poll the EOC line whichAND AL,80H ;is connected to PA7 lineCMP AL,80HJNZ AD01;if EOC (PA7) is high read the digital value otherwise;again check for EOC (PA7) lineMOV AL,0DH ;set OE (PC6) to read valueMOV DX,CONTROLOUT DX,AL;before reading data from ADC set PC6 line
MOV DX,PORTAIN AL,DX ;read digital valueMOV AH,00HMOV SI,AX
PUSH CXCALL FAR DBDTA ;display digital valuePOP CX
JMP AD00CSEG 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?
Outcome: Analog to Digital Conversion using 8255 is studied is Studied
EXPERIMENT NO.8
MPMC LAB 85 | P a g e
DEPT OF ECE
SERIAL COMMMUNICATION BETWEEN TWO MICROPROCESSORS USING 8251
Objective: Write a program in ALP to establish Communication between two processors using 8251.
Apparatus: 1.ADS-SDA-86-STA kit 2.8251 Study card 3. Adapter, Keyboard, Cables, Etc . . .
PROCEDURE :
Transmission1. 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
RECEIVEING1. 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 000AHCNT_BAUD_4000_MODE01 EQU 0140HCNT_BAUD_2400_MODE16 EQU 0028HCNT_BAUD_1200_MODE64 EQU 0014HCNT_BAUD_0300_MODE64 EQU 0050H
MODE_WORD16 EQU CEHMODE_WORD1 EQU CDHMODE_WORD64 EQU CFH
DSEG SEGMENT
MPMC LAB 87 | P a g e
DEPT OF ECE
ORG 0:3000HMSG DB 'TESTING 8251 IN ASYNCHRONOUS MODE',0DH,0AH,1BHDSEG 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 BX,OFFSET MSG MOV SI,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 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 MOV BX,OFFSET MSG MOV SI,EXT_RAM_LC JMP SRVC1AHEAD: MOV DX,DATA_8251 OUT DX,AL MOV CL,AL MOV AX,00H MOV DS,AX MOV AL,CL MOV [SI],AL ADD SI,01H STI IRET.
MPMC LAB 90 | P a g e
DEPT OF ECE
CSEG ENDSEND
;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 000AHCNT_BAUD_4000_MODE01 EQU 0140HCNT_BAUD_2400_MODE16 EQU 0028HCNT_BAUD_1200_MODE64 EQU 0014HCNT_BAUD_0300_MODE64 EQU 0050H
MODE_WORD16 EQU CEHMODE_WORD1 EQU CDHMODE_WORD64 EQU CFH
;************************************;PROGRAM TO TEST 8251 RECEIVING PART.;************************************
DSEG SEGMENT ORG 0000:3000HDSEG 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 ;ICW1 MOV AL,13H OUT DX,AL
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 ADDRESSCTL_PORT .EQUAL FFC6H ;CONTROL PORT ADDRESS
MPMC LAB 96 | P a g e
DEPT OF ECE
CTL_BYTE .EQUAL 80H ;CONTROL BYTE FOR C PORT = ON PHASE_A .EQUAL 0cH ;BYTE TO SWTICH ON A PHASEPHASE_B .EQUAL 06H ;BYTE TO SWTICH ON B PHASEPHASE_C .EQUAL 03H ;BYTE TO SWTICH ON C PHASEPHASE_D .EQUAL 0DH ;BYTE TO SWTICH ON D PHASE
DSEG SEGMENT org 0000:3000H
DELAY_COUNT DW 0DSEG ENDSCSEG SEGMENT
ASSUME CS:CSEG,DS:DSEGORG 0000:4000H
;Start of Test ProgramMOV AL,CTL_BYTE ;8255 INITIALISATIONMOV DX,CTL_PORTOUT DX,AL ;
START: MOV AL,PHASE_A ;PHASE A OF BOTH MOTORS ON
MOV DX,PORT_COUT 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 subroutineDELAY1: MOV CX, OFFSET DELAY_COUNTDL1: LOOP DL1 RETCSEG 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
II.TO ROTATE STEPPER MOTOR IN ANTICLOCKWISE DIRECTION
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 Motor4. 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 file8. 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; EQUATESPORT_C .EQUAL FFC4H; PORT C ADDRESSCTL_PORT .EQUAL FFC6H; CONTROL PORT ADDRESSCTL_BYTE .EQUAL 80H ; CONTROL BYTE FOR C PORT = ON
PHASE_A .EQUAL 0CH ; BYTE TO SWTICH ON A PHASEPHASE_B .EQUAL 06H ; BYTE TO SWTICH ON B PHASEPHASE_C .EQUAL 03H ; BYTE TO SWTICH ON C PHASE
MPMC LAB 99 | P a g e
DEPT OF ECE
PHASE_D .EQUAL 0DH ;BYTE TO SWTICH ON D PHASE
DSEG SEGMENT org 0000:3000H
DELAY_COUNT DW 0DSEG 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 ONMOV DX, PORT_COUT DX, AL CALL DELAY1 ; DELAY BET. SWITCHING OF PHASES MOV AL,BBH ;PHASE_BMOV DX,PORT_C OUT DX,AL ;PHASE B OF BOTH MOTORS ONCALL DELAY ;DELAY BET. SWTICHING OF PHASES MOV AL,DDH ;PHASE_CMOV DX,PORT_C OUT DX,AL ;PHASE C OF BOTH MOTORS ON CALL DELAY1 ;DELAY BET. SWTICHING OF PHASES MOV AL,EEH ;PHASE_AMOV 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 subroutineDELAY1:
MPMC LAB 100 | P a g e
DEPT OF ECE
MOV CX,OFFSET DELAY_COUNTDL1: LOOP DL1 RET
CSEG ENDS.END
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?
Outcome: This program helps to interface stepper-motor to 8086 and can be rotated in anti-clockwise direction
MPMC LAB 101 | P a g e
DEPT OF ECE
INTRODUCTION TO 8051
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:
8-bit ALU, Accumulator and Registers;
8-bit data bus - It can access 8 bits of data in one operation
16-bit address bus - It can access 216 memory locations - 64 kB ( 65536
locations ) each of RAM and ROM
On-chip RAM - 128 bytes ("Data Memory")
On-chip ROM - 4 kB ("Program Memory")
Four byte bi-directional input/output port
UART (serial port)
Two 16-bit Counter/timers
Two-level interrupt priority
Power saving mode
8051 have 128 user defined flags
It consist of 16 bit address bus
It also consist of 3 internal and two external interrupt
Less power usage in 8051 with respect to other micro-controller
It consist of 16-bit program counter and data pointer
8051 can process 1 million one-cycle instructions per second
It also consist of 32 general purpose registers each of 8 bits
Rom on 8051 is 4 Kbytes in size
MPMC LAB 102 | P a g e
DEPT OF ECE
Pin Diagram of 8051
MPMC LAB 103 | P a g e
DEPT OF ECE
Timer/Counter (Timer 0 & Timer 1)
4K byte Program Memory (ROM)
128 bytes Data Memory (RAM)
I/O ports Serial Port 64 K Bus Expansion Control
8051 CPU
Oscillator &Timing
P3 P2 P1 P0 (Address/data)
TxD RxD ALE /PSEN From Crystal Oscillator or RC network
/INT0 /INT1
Other interrupts
T0 T1
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 104 | P a g e
DEPT OF ECE
Mnemonic Description
ADD A,Rn Adds the register to the accumulator
ADD A,direct Adds the direct byte to the accumulator
ADD A,@Ri Adds the indirect RAM to the accumulator
ADD A,#data Adds the immediate data to the accumulator
ADDC A,Rn Adds the register to the accumulator with a carry flag
ADDC A,direct Adds the direct byte to the accumulator with a carry flag
ADDC A,@Ri Adds the indirect RAM to the accumulator with a carry flag
ADDC A,#data Adds the immediate data to the accumulator with a carry flag
SUBB A,Rn Subtracts the register from the accumulator with a borrow
SUBB A,direct Subtracts the direct byte from the accumulator with a borrow
SUBB A,@Ri Subtracts the indirect RAM from the accumulator with a borrow
SUBB A,#data Subtracts the immediate data from the accumulator with a borrow
INC A Increments the accumulator by 1
INC Rn Increments the register by 1
INC Rx Increments the direct byte by 1
INC @Ri Increments the indirect RAM by 1
DEC A Decrements the accumulator by 1
DEC Rn Decrements the register by 1
DEC Rx Decrements the direct byte by 1
DEC @Ri Decrements the indirect RAM by 1
INC DPTR Increments the Data Pointer by 1
MUL AB Multiplies A and B
DIV AB Divides A by B
DA A 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.
MPMC LAB 105 | P a g e
DEPT OF ECE
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 Description
ACALL addr11 Absolute subroutine call
LCALL addr16 Long subroutine call
RET Returns from subroutine
RETI Returns from interrupt subroutine
AJMP addr11 Absolute jump
LJMP addr16 Long jump
SJMP relShort jump (from –128 to +127 locations relative to the following instruction)
JC rel Jump if carry flag is set. Short jump.
JNC rel Jump if carry flag is not set. Short jump.
JB bit,rel Jump if direct bit is set. Short jump.
JBC bit,rel Jump if direct bit is set and clears bit. Short jump.
JMP @A+DPTR Jump indirect relative to the DPTR
JZ rel Jump if the accumulator is zero. Short jump.
JNZ rel Jump if the accumulator is not zero. Short jump.
CJNE A,direct,relCompares direct byte to the accumulator and jumps if not equal. Short jump.
CJNE A,#data,relCompares immediate data to the accumulator and jumps if not equal. Short jump.
CJNE Rn,#data,relCompares immediate data to the register and jumps if not equal. Short jump.
CJNE @Ri,#data,rel
Compares immediate data to indirect register and jumps if not equal. Short jump.
DJNZ Rn,rel Decrements register and jumps if not 0. Short jump.
DJNZ Rx,rel Decrements direct byte and jump if not 0. Short jump.
NOP No operation
Data Transfer Instructions:
Data transfer instructions move the content of one register to another. The register the
content of which is moved remains unchanged. If they have the suffix “X” (MOVX), the data
is exchanged with external memory.
MPMC LAB 106 | P a g e
DEPT OF ECE
Mnemonic Description
MOV A,Rn Moves the register to the accumulator
MOV A,direct Moves the direct byte to the accumulator
MOV A,@Ri Moves the indirect RAM to the accumulator
MOV A,#data Moves the immediate data to the accumulator
MOV Rn,A Moves the accumulator to the register
MOV Rn,direct Moves the direct byte to the register
MOV Rn,#data Moves the immediate data to the register
MOV direct,A Moves the accumulator to the direct byte
MOV direct,Rn Moves the register to the direct byte
MOV direct,direct Moves the direct byte to the direct byte
MOV direct,@Ri Moves the indirect RAM to the direct byte
MOV direct,#data Moves the immediate data to the direct byte
MOV @Ri,A Moves the accumulator to the indirect RAM
MOV @Ri,direct Moves the direct byte to the indirect RAM
MOV @Ri,#data Moves the immediate data to the indirect RAM
MOV DPTR,#data Moves a 16-bit data to the data pointer
MOVC A,@A+DPTR
Moves the code byte relative to the DPTR to the accumulator (address=A+DPTR)
MOVC A,@A+PCMoves the code byte relative to the PC to the accumulator (address=A+PC)
MOVX A,@Ri Moves the external RAM (8-bit address) to the accumulator
MOVX A,@DPTR Moves the external RAM (16-bit address) to the accumulator
MOVX @Ri,A Moves the accumulator to the external RAM (8-bit address)
MOVX @DPTR,A Moves the accumulator to the external RAM (16-bit address)
PUSH direct Pushes the direct byte onto the stack
POP direct Pops the direct byte from the stack/td>
XCH A,Rn Exchanges the register with the accumulator
XCH A,direct Exchanges the direct byte with the accumulator
XCH A,@Ri Exchanges the indirect RAM with the accumulator
XCHD A,@RiExchanges the low-order nibble indirect RAM with the accumulator
Logic Instructions:
Logic instructions perform logic operations upon corresponding bits of two registers.
After execution, the result is stored in the first operand.
MPMC LAB 107 | P a g e
DEPT OF ECE
Mnemonic Description
ANL A,Rn AND register to accumulator
ANL A,direct AND direct byte to accumulator
ANL A,@Ri AND indirect RAM to accumulator
ANL A,#data AND immediate data to accumulator
ANL direct,A AND accumulator to direct byte
ANL direct,#data AND immediate data to direct register
ORL A,Rn OR register to accumulator
ORL A,direct OR direct byte to accumulator
ORL A,@Ri OR indirect RAM to accumulator
ORL direct,A OR accumulator to direct byte
ORL direct,#data OR immediate data to direct byte
XRL A,Rn Exclusive OR register to accumulator
XRL A,direct Exclusive OR direct byte to accumulator
XRL A,@Ri Exclusive OR indirect RAM to accumulator
XRL A,#data Exclusive OR immediate data to accumulator
XRL direct,A Exclusive OR accumulator to direct byte
XORL direct,#data Exclusive OR immediate data to direct byte
CLR A Clears the accumulator
CPL A Complements the accumulator (1=0, 0=1)
SWAP A Swaps nibbles within the accumulator
RL A Rotates bits in the accumulator left
RLC A Rotates bits in the accumulator left through carry
RR A Rotates bits in the accumulator right
RRC A Rotates bits in the accumulator right through carry
Bit-oriented Instructions
Similar to logic instructions, bit-oriented instructions perform logic operations. The
difference is that these are performed upon single bits.
Mnemonic Description
CLR C Clears the carry flag
CLR bit Clears the direct bit
SETB C Sets the carry flag
SETB bit Sets the direct bit
CPL C Complements the carry flag
MPMC LAB 108 | P a g e
DEPT OF ECE
CPL bit Complements the direct bit
ANL C,bit AND direct bit to the carry flag
ANL C,/bit AND complements of direct bit to the carry flag
ORL C,bit OR direct bit to the carry flag
ORL C,/bit OR complements of direct bit to the carry flag
MOV C,bit Moves the direct bit to the carry flag
MOV bit,C Moves the carry flag to the direct bit
Description of all 8051 instructions:
Here is a list of the operands and their meanings:
A - accumulator;
Rn - is one of working registers (R0-R7) in the currently active RAM memory
bank;
Direct - is any 8-bit address register of RAM. It can be any general-purpose
register or a SFR (I/O port, control register etc.);
@Ri - is indirect internal or external RAM location addressed by register R0 or
R1;
#data - is an 8-bit constant included in instruction (0-255);
#data16 - is a 16-bit constant included as bytes 2 and 3 in instruction (0-
65535);
addr16 - is a 16-bit address. May be anywhere within 64KB of program
memory;
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;
bit - is any bit-addressable I/O pin, control or status bit; and
C - is carry flag of the status register (register PSW).
MPMC LAB 109 | P a g e
DEPT OF ECE
EXPERIMENT NO. 10
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT MANIPULATION INSTRUCTIONS OF 8051
Objective: To write ALP for performing Arithmetic , Logical , Bit manipulation operations in 8051
Apparatus: 1.ADS-SDA-51-STA kit 2. Microprocessor Power Supply 3. RS 232 Cable 5. Adapter, Keyboard, Cables, Connecting Wires Etc . . .
Procedure:
MPMC LAB 110 | P a g e
DEPT OF ECE
For generating HEX File.
1. Check for Driver folder (if driver is in D drive)2. Go to Command Prompt3. Type d: and Press enter (if driver is in D drive)4. Type cd Driver and Press enter5. Type cd x8051 and Press enter6. Edit filename.asm Enter7. Now a window appears in which you need to write the program and save it .8. Go to file→Exit. You will return to command prompt9. To check errors and generate .obj file Type x8051 and Press enter in the command prompt.A. Select the option D and enterB.Select the option Y to generate cross-reference and enterC.Enter Input file name as: filename.asmD.Enter output filename as: filename.obj10. Now the .obj file is generated and errors will be displayed11. To link the file now type link and Press enterA.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 timesD.Enter offset address as: 0000E.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 note down the starting and ending address.
To Observe the OUTPUT:
1. Connect the 8051 kit to the processor of desktop with Rs232 cable and power
supply to the 8051 Kit.
2. Open the TALK icon which is on desktop now Talk window appears.
3. In that window go to options → Target Board → 8051 → ok.
4. Go to options →Connect.
5. 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.
MPMC LAB 111 | P a g e
DEPT OF ECE
6. 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.
I.ARITHEMATIC OPERATIONSProgram:
org 9000h;addition without carry
mov a,#06hmov b,#09hadd a,bmov r0,a
;Subtraction with carrymov a,#08hsubbc a,#03hmov r1,a
; multiplicationmov a,#03h
MPMC LAB 112 | P a g e
DEPT OF ECE
mov b,#06hmul abmov r2,a
;divisionmov a,#08hmov b,#03hdiv abmov r3,amov r4,b
;increment operationmov a,#03hinc amov r5,a
;decrement operationmov r6,#07hdec r6lcall 0003hend
II.LOGICAL OPERATIONS
Program1:
org 8000hmov r0,#0fhmov r1,#fohmov r2,#66h
; And operationmov a,#ffhanl a,r0mov r3,a
; Or operationmov a,#ffhorl a,r1mov r4,a
MPMC LAB 113 | P a g e
DEPT OF ECE
; Xor operationmov a,03hmov a,#ffhxrl a,r2mov r5,alcall 0003hend
Program2:
org 9000h; clear register A
mov a,#0fhclr amov r0,a
; swap nibbles of register Amov a,#56hswap amov r1,a
; Complement the bit of register Amov a,#66hcpl amov r2,a
; Rotate the register contents towards right
MPMC LAB 114 | P a g e
DEPT OF ECE
mov a,#63hrr axrl a,rmov r3,a
; Rotate the register contents towards left mov a,#43hrl axrl a,rmov r4,alcall 0003hend
III. BIT MANIPULATION OPERATIONS
Program:
org 9000hmov a,#ffhclr c ;clear the carry flaganl c,acc.7mov r0,asetb c ;set the carry flagmov a,#00horl c,acc.5mov r1,amov a,#ffhcpl acc,3
MPMC LAB 115 | P a g e
DEPT OF ECE
mov r2,alcall 0003hend
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?
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.
MPMC LAB 116 | P a g e
DEPT OF ECE
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 → Nifc26→Nifc26. 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
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 a,tmodorl a,#05hmov tmod,a
setb tr0 ;to start counting
lcall 68eah ;cldis
loop_a: mov dptr,#0194hmov a,tl0movx @dptr,ainc dptrmov a,th0
MPMC LAB 117 | P a g e
DEPT OF ECE
movx @dptr,alcall 6748h ;upd_add
go1: sjmp loop_alcall 03hend
Outcome:
Timer0 as counter in mode 0 is programmed and verified.
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.
MPMC LAB 118 | P a g e
DEPT OF ECE
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 → Nifc26→Nifc26. 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
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 a,tmodorl tmod,#10h ;timer 1, mode 1-16 bit timermov th1,#00h ;timer register loaded with 00ffhmov tl1,#ffhsetb it1 ;intr. 1 edge triggered,should be cleared for
;level triggersetb et1 ;enable timer 0 interruptsetb ex1 ;enable external interrupt 1setb tr1 ;timer 0 run enablesetb px1 ;priority set for external interruptmov r6,#26h ;values which is complemented in timer0 isrsetb ea ;enable global interrupt
MPMC LAB 119 | P a g e
DEPT OF ECE
here: ajmp here
org 8028h ;timer 1 isr
ljmp 8500h
org 8500h
mov r7,#10hcompl: mov a,r6
swap amov r6,alcall upddt ;displayes r6 content in data fieldlcall deldjnz r7,complmov th1,#00hmov tl1,#ffhsetb tr1reti
org 8010h ;external interrupt 1 isr
setb rs0 ;change bankmov r5,#3hljmp 8600h
org 8600h
lcall 68eah ;cldis
mov r6,#00hmov r7,#00h
loop_b: lcall 675fh ;upd_add ;66c1hlcall del ;6794hdjnz r5,increclr rs0reti
incre: inc r6
MPMC LAB 120 | P a g e
DEPT OF ECE
sjmp loop_b
del: mov r0,#ffhmov r1,#ffhlcall del1ret
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?
5) Whether micro reduces memory requirements?
Outcome:This program demonstrates the usage of priority bit and external internal type
bit to handle the interrupt.
MPMC LAB 121 | P a g e
DEPT OF ECE
ADDITIONAL EXPERIMENTS
EXPERIMENT NO.13KEIL µ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 122 | P a g e
DEPT OF ECE
Step 2: To create new project, go to project, select new µvision project.
Step 3: Select a drive where you would like to create your project.
Step 4: Create a new folder and name it with your project name.
Step 5: Open that project folder and give a name of your project executable file and
save it.
Step 6: After saving, it will show some window there select your microcontroller
company i.e. Atmel.
Step 7: Select your chip as AT89C51.
MPMC LAB 123 | P a g e
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.
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.
MPMC LAB 124 | P a g e
DEPT OF ECE
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.Step 17: Now give a right click on target in the project window and select “Options for Target”.
MPMC LAB 125 | P a g e
DEPT OF ECE
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.
Experiment No: 14
SERIAL TRANSMISSION FROM PC TO 8051µC
MPMC LAB 126 | P a g e
DEPT OF ECE
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:
Experiment No: 115
PORT PROGRAMMING OF 8051
MPMC LAB 127 | P a g e
DEPT OF ECE
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 128 | P a g e