View
986
Download
4
Category
Tags:
Preview:
DESCRIPTION
Microprocessor lab manual for regulation 2013
Citation preview
MICROPROCESSOR & MICROCONTROLLER
LAB MANUAL
For Second Year B.E-CSE Students
UNITED INSTITUTE OF TECHNOLOGY
COIMBATORE-20
Prepared by,
Mr.S.KEERTHI M.E.,
1
UNITED INSTITUTE OF TECHNOLOGY
PERIYANAICKENPALAYAM-641020
Department of Computer & Science Engineering
RECORD NOTE
CS 6412 - MICROPROCESSOR AND MICROCONTROLLERLABORATORY
STUDENT NAME :
REGISTER NO :
SEMESTER :
YEAR :
STAFF INCHARGE HOD/DEAN
2
First Edition : Dec 2014
© All Rights reserved by the publisher/author
PREFACE
3
Printed & Published by: United Institute of Technology, G.Koundampalayam, Periyanaickenpalayam, Coimbatore – 641 020
PrefaceThis workbook is prepared with an object of giving a firsthand
experience to the students in translating and experiencing theories of
Microprocessors & Microcontrollers thorough experimental
applications. The topic includes all relevant experiments as
prescribed by Anna University, Chennai. Enough care and efforts
have been taken to clarify every aspect of the theory involved in each
experiment.
The authors however prescribe the students to find analogies for
these theories and also to lookout for practical applications of each
proof of the theory explained.
.
4
Acknowledgement
I place my sincere thanks to the management, especially to the
Chairman, Shri. R.Shanmugam of United Institute of Technology for
having provided a scope for designing and formulating a laboratory
workbook on Microprocessors and Microcontrollers Laboratory.
I thank the principal, Dr.P.Prakasam, for all his encouragement
and inputs. I place my special thank to Dr.S.Natarajan Dean-ES and
Mrs. D Gokila Head of the department (ECE) for their valuable
inputs and editorial suggestions. Last but not the least I thank all the
other colleagues of United Institute of Technology for their support.
5
INSTRUCTIONS: Wear shoes compulsorily.
Shirts should be tucked in.
Women students should protect their hairs.
Do not allow chains to hang.
Do not lean over rotating machinery.
Energize the circuit only after getting approval from the faculty in charge.
Supply to your test table should be obtained only through the lab technician.
Return the apparatus to stores and get permission from faculty in charge before
leaving the laboratory.
PREPARATION FOR LABORATORY RECORDS:
Each experiment should begin on a new page.
The name of the experiments should be written in capital letters on the top of the
page.
Experiment number and date should be written at the top left corner.
Each record should contain the following
Aim of the Experiment
Apparatus Required
Procedure
Model Calculation
Results / Discussions.
All the above should be written on the right page of the record.
Neat Circuit Diagram
Name Plate Details / Specifications / Design Details
Tabulations
Graph
The above should be written / drawn on the left page of the record using
pencil.
Graphs / figures drawn on sheets should be firmly pasted to the record.
Before writing the record, the student should get the corresponding observations
approved by the faculty in - charge and carry over the marks obtained to the record.
The record be completed in all respects and submitted in the next class.
6
SYLLABUS
CS6412 MICROPROCESSOR AND MICROCONTROLLER LABORATORY L T P C0 0 3 2
OBJECTIVES:The student should be made to:
Introduce ALP concepts and features Write ALP for arithmetic and logical operations in 8086 and 8051 Differentiate Serial and Parallel Interface Interface different I/Os with Microprocessors Be familiar with MASM
8086 PROGRAMS USING KITS AND MASM1.Basic arithmetic and Logical operations 2.Move a data block without overlap 3.Code conversion, decimal arithmetic and Matrix operations. 4.Floating point operations, string manipulations, sorting and searching 5.Password checking, Print RAM size and system date 6.Counters and Time Delay
PERIPHERALS AND INTERFACING EXPERIMENTS7. Traffic light control 8. Stepper motor control 9. Digital clock 10. Key board and Display 11. Printer status 12. Serial interface and Parallel interface 13. A/D and D/A interface and Waveform Generation
8051 EXPERIMENTS USING KITS AND MASM14. Basic arithmetic and Logical operations 15. Square and Cube program, Find 2’s complement of a number 16. Unpacked BCD to ASCII
TOTAL: 45 PERIODS
OUTCOMES:At the end of the course, the student should be able to:
Write ALP Programs for fixed and Floating Point and Arithmetic Interface different I/Os with processor Generate waveforms using Microprocessors Execute Programs in 8051 Explain the difference between simulator and Emulator
7
INDEX
Exp.No Experiment Name Page No
Marks Signature
16 – BIT MICROPROCESSOR (8086)1. Arithmetic Operations & Logical operations using 80862. Move a Data Block without Overlap3. Code Conversions4. Decimal Arithmetic & Matrix Operations4.a Floating point operations4.b String Copy, String Length4.c Sorting(Ascending &Descending order)4.d Searching 5.a Password Checking5.b Print RAM Size5.c System Date6 Counters and Time delay
PERIPHERALS AND INTERFACING EXPERIMENTS7. Traffic light control8 Stepper motor control9 Digital clock10 Key board and Display
11 Printer status12.a Serial interface and Parallel interface12.b Parallel Interface
13.a A/D Interface
13.b D/A interface and Waveform Generation8051 Experiments using kits and ASM
14.a Arithmetic Operations14.b Logical Operations
15 Square, Cube and 2’s complement of a Number 16 Unpacked BCD to ASCII Total Marks
8
8086 MICROPROCESOR
9
INTRODUCTION TO MASM
EDITOR:
An editor is a program, which allows you to create a file containing the assembly language statements for your program. As you type in your program, the editor stores the ASCII codes for the letters and numbers in successive RAM locations. When you have typed in all of your programs, you then save the file on a floppy of hard disk. This file is called source file. The next step is to process the source file with an assembler. In the MASM /TASM assembler, you should give your source file name the extension, .ASM
ASSEMBLER:
An assembler program is used to translate the assembly language mnemonics for instructions to the corresponding binary codes. When you run the assembler, it reads the source file of your program the disk, where you saved it after editing on the first pass through the source program the assembler determines the displacement of named data items, the offset of labels and pails this information in a symbol table. On the second pass through the source program, the assembler produces the binary code for each instruction and inserts the offset etc that is calculated during the first pass. The assembler generates two files on floppy or hard disk. The first file called the object file is given the extension.OBJ. The object file contains the binary codes for the instructions and information about the addresses of the instructions. The second file generated by the assembler is called assembler list file. The list file contains your assembly language statements, the binary codes for each instructions and the offset for each instruction. In MASM/TASM assembler, MASM/TASM source file name ASM is used to assemble the file. Edit source file name LST is used to view the list file, which is generated, when you assemble the file.
LINKER:
A linker is a program used to join several object files into one large object file and convert to an exe file. The linker produces a link file, which contains the binary codes for all the combined modules. The linker however doesn’t assign absolute addresses to the program, it assigns is said to be reloadable because it can be put anywhere in memory to be run. In MASM/TASM, LINK/TLINK source filename is used to link the file.
DEBUGGER:
A debugger is a program which allows you to load your object code program into system memory, execute the program and troubleshoot are debug it the debugger allows you to look at the contents of registers and memory locations after your program runs. It allows you to change the contents of register and memory locations after your program runs. It allows you to change the contents of register and memory locations and return the program. A debugger also allows you to set a break point at any point in the program. If you inset a breakpoint the debugger will run the program upto the instruction where the breakpoint is set and stop execution. You can then examine register and memory contents to see whether the results are correct at that point. In MASM/TASM, td filename is issued to debug the file.
DEBUGGER FUNCTIONS:
1. Debugger allows looking at the contents of registers and memory locations.2. We can extend 8-bit register to 16-bit register which the help of extended register option. 3. Debugger allows setting breakpoints at any point with the program.
10
4. The debugger will run the program upto the instruction where the breakpoint is set and then stop execution of program. At this point, we can examine registry and memory contents at that point. 5. With the help of dump we can view register contents. 6. We can trace the program step by step with the help of F7. 7. We can execute the program completely at a time using F8 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.
Below, are summarized the 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]
11
MS-MASM:
Microsoft’s Macro Assembler (MASM) is an integrated software package Written by Microsoft Corporation for professional software developers. It consists of an editor, an assembler, a linker and a debugger (Code View). The programmer’s workbench combines these four parts into a user-friendly programming environment with built in on line help. The following are the steps used if you are to run MASM from DOS.
PC PROGRAMMING WITH ASSEMBLY LANGUAGE USING MASM
Procedure:
1. Open command window (click: start->run->type cmd )
2. Paste the 8086 or MASM software in any drive.3. In that window change the directory [Where you paste the masm software]
12
4. In the command window type the directory name after that change the directory to 8086(masm) after that type edit
5. After changing directory type edit then you get one window in that window you can write a program
6. After writing a program click: file->save->exit [again we enter the command window]
13
7. Type : masm filename,,;[This will display the error report]
8. Type: link filename,,; [This will create a list file you can see this inside the masm(8086)software]
Note: Here we no need to use stack segment so no need to worry about stack error
14
9. Type: debug filename.exe [to create exe file]
10. Type: n filename.bin [to create a bin file]
15
11. Type: WCS: 1000 [writing code segment]
12. Type: g =1000 [to execute a program]
16
13. Type: u 1000 [to see opcode]
14. Type: e 1200 [see output in corresponding address] use space bar to see next output value
17
15. Type: q [terminate a line]
16. Downloading procedure
Note: don’t use these command while down loading
Mov ah, 4ch [These commands are used to see the results system itself]
Int 21h
(Bin file is used to downloading) Type: dc then you can get the following window
18
17. Press f1 key and set the port settings
18. Press esc key to abort
19. Now in micro 86 kit select receiving mode (i.e.) type Si 1000(starting address) then press enter key. Then the kit is ready to receive data and press any in the host to start transmission. During transmission the message display as, transmission progress.
Press esc to abort.
Now binary files are downloaded to kit.
19
Ex. No: 1 ARITHMETIC OPERATIONS
AIM: To write and execute an assembly language program for add, subtract, multiply and divide two 16 bit unsigned numbers in 8086 kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1
2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Load the First Data in AX-register. 2. Load the First Data in BX-register.2. Add the two data and get the sum in AX-register. 3. Store the sum in memory location.4. Stop the program.
PROGRAM: i) By Using Masm:
CODE SEGMENT ASSUME CS: CODE, DS: CODE ORG 1000H MOV AX, 1234H MOV BX, 1234H ADD AX, BX MOV SI, 1200H MOV [SI], AX MOV AH, 4CH INT 21H CODE ENDS END
ii) By using 8086 kit:
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
1000 C7,C0,34,12 MOV AX,1234H Load AX-register with 1st data1004 C7,C3,34,12 MOV BX,1234H Load BX-register with 2nd data1008 01,D8 ADD AX,BX Add the contents of AX with BX
100A C7,C6,00,12 MOV SI,1200H Assign SI-reg to 1200H
100E 89,04 MOV [SI],AX Store the sum
1010 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AX 1234H 1200H 68BX 1234H 1201H 24
20
16-BIT SUBTRACTION:
ALGORITHM:1. Load the First Data in AX-register. 2. Load the First Data in BX-register.3. Subtract the content of BX-reg from AX-register. 4. Store the result in memory location.5. Stop the program.
PROGRAM:
i) BY USING MASM: CODE SEGMENT
ASSUME CS: CODE, DS: CODE ORG 1000H MOV AX, 0FFFFH MOV BX, 0EEEEH SUB AX, BX MOV SI, 1200H MOV [SI], AX MOV AH, 4CH INT 21H CODE ENDS END
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONIC COMMENTS
1000 C7,C0,FF,FF MOV AX,FFFFH Load AX-register with 1st data1004 C7,C3,EE,EE MOV BX,EEEEH Load BX-register with 2nd
data1008 29,D8 SUB AX,BX Subtract the contents of BX
from AX-register100A C7,C6,00,12 MOV SI,1200H Assign SI-reg to 1200H
100E 89,04 MOV [SI],AX Store the result
1010 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AX FFFFH 1200H 11BX EEEEH 1201H 11
16-BIT MULTIPLICATION
ALGORITHM:
1. Load the First Data in AX-register. 2. Load the First Data in BX-register.3. Subtract the content of BX-reg from AX-register.
21
4. Store the result in memory location.5. Stop the program.
PROGRAM:i) By using MASM:
CODE SEGMENT ASSUME CS: CODE, DS: CODE ORG 1000H MOV AX, 4444H MOV BX, 4444H MUL BX
MOV SI, 1200H MOV [SI], DX MOV SI, 1202H
MOV [SI], AX MOV AH, 4CH INT 21H CODE ENDS END
ii) By using 8086 kit:
ADDRESS OPCODE LABEL MNEMONIC COMMENTS
1000 C7,C0, 4444 MOV AX,4444H Load AX-register with 1st data1004 C7, C3, 4444 MOV BX,4444H Load BX-register with 2nd data1008 F7, E3 MUL BX Multiply the contents of AX with
BX-register100a C7, C6,
00,12MOV SI,1200H Assign SI-reg to 1200H
100e 89, 14 MOV [SI],DX Store the result
1010 C7, C6, 02,12
MOV SI,1202H Assign SI-reg to 1202H
1014 89,04 MOV [SI],AX Store the result
1016 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AX 4444H 1200H 34BX 4444H 1201H 12
1202H 101203H 32
32-BIT BY 16-BIT DIVISION
ALGORITHM: 1. Load the First Data in AX-register. 2. Load the First Data in BX-register.3. Subtract the content of BX-reg from AX-register. 4. Store the result in memory location.5. Stop the program.
22
PROGRAM:i) By using MASM:
CODE SEGMENT ASSUME CS: CODE, DS: CODE ORG 1000H MOV DX, 0000H MOV AX, 8888H MOV CX, 4444H DIV CX MOV SI, 1200H MOV [SI], AX MOV SI, 1202H MOV [SI], DX MOV AH, 4CH INT 21H CODE ENDS END
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7, C2,00,00 MOV DX,0000H Initialize DX-register with Lsb of Dividend
1004 C7, C0,88,88 MOV AX,8888H Load AX-register with Msb of Dividend
1008 C7, C1,44,44 MOV CX, 4444H Load CX-register with Divisor
100C F7, F1 DIV CX Divide AX by CX-register100E C7, C6,00,12 MOV SI,1200H Assign SI-reg to 1200H 1012 89, 04 MOV [SI],AX Store the Quotient1014 C7, C6,02,12 MOV SI,1202H Assign SI-reg to 1202H
1018 89, 14 MOV [SI],DX Store the Remainder
101A F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
DX 0000H 1200H 00(quotient)AX 8888H 1202H 02(quotient)CX 4444H 1203H 00(remainder)
1204H 00(remainder)
RESULT:
Thus an assembly language program for add, subtract, multiply and divide two 16 bit unsigned numbers was executed using MASM and 8086 kit.
Ex. No: 1B LOGICAL OPERATION
23
AIM: To write and execute an assembly language program for performing logical OR, AND,
NAND operation in 8086 kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Load the First Data in AL-register. 2. Load the Second Data in BL-register.3. Logically OR the content of AL with BL-register. 4. Store the result in memory location.5. Stop the program
PROGRAM:i) By using MASM:
CODE SEGMENTASSUME CS: CODESTART: MOV AL, 85HMOV BL, 99HOR AL, BLINT 3HCODE ENDSEND START
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C6,C0,85 MOV AL,85H Load AL-register with 1st Data1003 C6,C3,99 MOV BL,99H Load BX-register with 2nd Data
1006 08,D8 OR AL, BL OR the contents of AL with BL-register
1008 C7,C6,00,12 MOV SI,1200H Assign SI-reg to 1200H
100C 89,04 MOV [SI],AX Store the Result
100E F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AL 85H 1200H 9DBL 95H
LOGICAL AND OPERATION
24
ALGORITHM:1. Load the First Data in AL-register. 2. Load the Second Data in BL-register.3. Logically AND the content of AL with BL-register. 4. Store the result in memory location.5. Stop the program
PROGRAM:i) By using MASM:
CODE SEGMENTASSUME CS: CODESTART: MOV AL, 85HMOV BL, 99HAND AL, BLINT 3HCODE ENDSEND START
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 Org 1000h Starting address of the program1000 C6,C0,85 MOV AL,85H Load AL-register with 1st Data1003 C6,C3,99 MOV BL,99H Load BX-register with 2nd Data
1006 20,D8 AND AL, BL AND the contents of AL with BL-register
1008 C7,C6,00,12 MOV SI,1200H Assign SI-reg to 1200H
100C 89,04 MOV [SI],AX Store the Result
100E F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AL 85H 1200H 81HBL 95H
LOGICAL NAND OPERATION
ALGORITHM:1. Load the First Data in AL-register. 2. Load the Second Data in BX-register.3. Logically AND the content of AX with BX-register. 4. Logically the content of AX register is complemented.5. Store the result in memory location.6. Stop the program
PROGRAM:i) By using MASM:
CODE SEGMENTASSUME CS: CODE
25
START: MOV AL, 85HMOV BL, 99HADD AL, BLNOT ALINT 3HCODE ENDSEND START
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C6,C0,85 MOV AL,85H Load AL-register with 1st Data1003 C6,C3,99 MOV BL,99H Load BX-register with 2nd Data
1006 20,D8 AND AL, BL AND the contents of AL with BL-register
1008 F6,D0 NOT AL Complement the contents of AL-register
100A C7,C6,00,12 MOV SI,1200H Assign SI-reg to 1200H
100E 89,04 MOV [SI],AX Store the Result
1010 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AL 85H 1200H 7EHBL 95H
VIVA QUESTIONS:
1. What is a Microprocessor? 2. What is the need for timing diagram?3. Define mnemonics.4. What is the difference between min mode and max mode of 8086?5. What is flag?
6. What is stack?7. What is interrupt?8. What are the various interrupts in 8086?9. What is the difference between compiler and assembler?
10. Which interrupts are generally used for critical events?
RESULT:
Thus an assembly language program for performing logical OR, AND, NAND operation was executed using MASM and 8086 kit.
26
Ex. No: 2 MOVE A DATA BLOCK WITHOUT OVERLAP
AIM:
To write and execute an assembly language program for transferring data from one block to another block without overlapping using 8086 kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Initialize counter.2. Initialize source block pointer.3. Initialize destination block pointer.4. Get the byte from source block.5. Store the byte in destination block.6. Increment source, destination pointers and decrement counter.7. Repeat steps 4, 5 and 6 until counter equal to zero.8. Stop.
PROGRAM:i) By using MASM:
DATA SEGMENT ARRAY1 DW 1111H,2222H,3333H,4444H,5555H ARRAY2 DW 5 DUP (0) COUNT DW 0005H
CODE SEGMENT MOV AX,@DATA
MOV DS, AX LEA SI, ARRAY1 LEA DI, ARRAY2
MOV CX, COUNT NEXT: MOV AX,[SI] MOV DI, 1200H MOV [DI], AX INC SI INC SI
INC DI INC DI LOOP NEXT
MOV AH, 4Ch INT 21h END
i) By using 8086 kit: ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 Org 1000h Starting address of the program1000 C7 C6 0012 MOV SI, 1200H Initialize the source address.1004 C7 C7 0013 MOV DI,1300H Initialize the destination
address.1008 C7 C1 0600 MOV CX,0006 H Initialize count value to the
count register.
27
100C 88,25MOV [DI], AH
Move content of AH to DI-
register.
100F FC REPEAT: CLD Clear the direction flag.
1010 A4 MOVSB Move the string byte.
1011 E2,F3LOOP: REPEAT
Unconditional loop to address
specified by the label REPEAT.
1013 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTAddress Data Address Data
1200 55 1300 551201 65 1301 651202 75 1302 751203 85 1303 851204 95 1304 951205 A5 1305 A5
VIVA QUESTIONS:
1. What is the fabrication technology used for 8086?2. What are the functional units available in 8086 architecture?3. Write the flags of 8086.4. What are control bits?5. What are the flag manipulation instructions of 8086?6. What is Macro?7. Which bus controller used in maximum mode of 8086?8. What is the size of data bus and address bus in 8086?9. What are the various segment registers in 8086?
10. What is the maximum memory addressing capability of 8086?
RESULT:
Thus an assembly language program for transferring data from one block to another block without overlapping was executed using 8086 kit and MASM.
28
Ex. No: 3A CODE CONVERSION
AIM:
To write and execute an assembly language program for converting BCD to Binary data, packed to unpacked BCD code using 8086 kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Load the address of BCD data in SI-register.2. Copy the BCD data to BL-register3. Get the BCD data in AL-register.4. Copy the BCD data in DL-register from AL-register.5. Logically AND DL with 0Fh to mask upper nibble and get unit’s digit in DL-reg.6. Move the count value for rotation in CL-register.7. Rotate the content of AL to move the upper nibble to lower nibble position.8. Move 0Ah to DH-register.9. Multiply AL with DH-register. The product will be in AL-register.10. Add the unit’s digit in DL-register to product in AL-register.11. Save the binary data (AL) in memory.12. Stop.
PROGRAM:i) By using MASM:
CODE SEGMENTASSUME CS: CODE, DS: CODEMOV BL, 75MOV AL, BLMOV DL, ALAND DL, 0FHAND AL, 0F0HMOV CL, 4ROR AL, CLMOV DH, 0AHMUL DHADD AL, DLMOV [BX+1], ALMOV SI, 1200HMOV [SI], BXMOV AH, 4CHINT 21HCODE ENDSEND
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C6 C3 75 MOV BL, 75 Copy BL-reg with data 7510.
1003 88 D8 MOV AL, BL Copy the contents of BL-reg to the AL-register.
29
1005 88 C2 MOV DL, AL Copy the input data to DX-reg.
1007 80 E2 0F AND DL, 0Fh Logically AND the content of DL-reg with 0Fh and store the resultant data in DL-register.
100A 80 E0 F0 AND AL, 0F0h Logically AND the content of DL-reg with F0h and store the resultant data in AL-register
100D C6 C1 04 MOV CL, 4 Copy the data 4 to CL-reg.
1010 D2 C8 ROR AL, CL Rotate right the contents of AL-register with the number of count’s in CL-register
1012 C6 C6 0A MOV DH, 0Ah Copy the data 0Ah to DH-reg.
1015 F6 E6 MUL DH Multiply AL with DH-register. The product will be in AL-register.
1017 00 D0 ADD AL, DL
Add the unit’s digit in DL-register to product in AL-register.
1019 88 47 01 MOV [BX+1], AL Copy the content of AL-reg to the address pointed by BX-register.
101C C7 C6 00 12 MOV SI, 1200H Initialize SI-reg with address 1200H
10 89 1C MOV [SI], BX Copy the contents of BX-reg to address pointed by SI-reg.
10 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
BL 7410 1200 4Bh
PACKED BCD TO UNPACKED BCD CODE
ALGORITHM: 1. Load number into AL-register with packed BCD data.2. Mask the lower nibble.3. Rotate 4 times to right to make MSB=LSB.4. Display the digit.5. Load number into AL-register with upper nibble.6. Mask upper nibble.7. Display the result in memory location.8. Stop.
PROGRAM:i) By using MASM:
CODE SEGMENTASSUME CS: CODE, DS: CODE
30
MOV AX, 45hMOV AH, ALMOV CL, 4hSHR AH, CLAND AX, 0F0FHMOV SI, 1200HMOV [SI], AXINT 3HCODE ENDSEND
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7 C0 4500 MOV AX, 45h Copy AX-reg with data 45.
1004 88 C4 MOV AH, AL Copy the contents of AL-reg to the AH-register.
1006 C6 C1 04 MOV CL, 4h Copy the data to CL-register.
1009 D2 EC SHR AH, CL Shift right the data of AL-register based on the data on CL-register.
100B 81 E0 0F0F AND AX, 0F0FH Logically AND the content of AX-reg with 0F0Fh and store the resultant data in AX-register
100F C7 C6 0012 MOV SI, 1200H Load Si-reg with address 1200.1013 89 04 MOV [SI], AX Copy the contents of AX-reg to
1200 address.1015 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AX 45H 1200 051201 04
RESULT:
Thus an assembly language program for converting BCD to Binary data, packed to unpacked BCD code using 8086 kit and MASM was implemented and its output was verified.
31
Ex. No: 3B DECIMAL OPERATIONS
AIM: To write and execute an assembly language program to add, subtract, multiply and divide
two 8-bit BCD data using 8086 kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Get the 1st BCD number.2. Get the 2nd BCD number.3. Add two BCD numbers.4. Adjust result to valid BCD numbers.5. Display the result.
PROGRAM:i) By using MASM:
CODE SEGMENTASSUME CS: CODE
MOV AL, 09H MOV BL, 02H ADD AL, BL DAA MOV CH, 02H MOV SI, 1400H MOV [SI], AL MOV CL, 04H MOV BH, AL
L2: ROL BH, CL MOV DL, BH AND DL, 0FH CMP DL, 09 JBE L4 ADD DL, 07
L4: ADD DL, 30H MOV AH, 02 INT 21H DEC CH JNZ L2 MOV AH, 4CH INT 21H CODE ENDS END
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 Org 1000h Starting address of the program1000 C6 C0 09 MOV AL, 09H
Load AL-reg with data 09h.
1003 C6 C3 02 MOV BL, 02H
Load BL-reg with data 02h.
32
1006 00 D8 ADD AL, BL
Add the contents of AL-reg with BL-register and the result will be stored in AL-register.
1008 27 DAA
Adjust result to valid BCD number.
1009 C6 C5 02 MOV CH, 02H
Count of digits to be displayed
100C C7 C6 00 14
MOV SI, 1400H
Load Si-reg with address 1400.
1010 88 04 MOV [SI], AL Copy the contents of AL-reg to address 1400.
1012 C6 C1 04 MOV CL, 04H Count to roll by 4-digits1015 88 C7 MOV BH, AL
Copy the contents of AL-reg to BH-register
1017 D2 CF L2: ROL BH, CL Roll BL-reg so that MSB comes to LSB.
1019 88 FA MOV DL, BH Load DL-reg with data to be displayed.
101B 80 E2 0F AND DL, 0FH Get only LSB data.101E 80 FA 09 CMP DL, 09 check if digit is 0-9 or letter A-F1021 76 03 JBE L4 If byte jump to label L41023 80 C2 07 ADD DL, 07 If letter add 37H 1026 80 C2 30 L4: ADD DL, 30H Else only add 30H1029 FE CD DEC CH Decrement Count102B 75 EA JNZ L2 If count is not zero then goto label
L2102D F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AL 09 1400 11BL 02
BCD SUBTRACTION
ALGORITHM: 1. Get the 1st BCD number.2. Get the 2nd BCD number.3. Subtract two BCD numbers.4. Adjust result to valid BCD numbers.5. Display the result.
PROGRAM:i) By using MASM:
CODE SEGMENTASSUME CS: CODE
MOV AL, 32H MOV BL, 17H
33
SUB AL, BL DAS MOV CH, 02H MOV SI, 1400H MOV [SI], AL MOV CL, 04H MOV BH, AL
L2: ROL BH, CL MOV DL, BH AND DL, 0FH CMP DL, 09 JBE L4 ADD DL, 07
L4: ADD DL, 30H MOV AH, 02 INT 21H DEC CH JNZ L2 MOV AH, 4CH INT 21H CODE ENDS END
iii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C6 C0 32 MOV AL, 32H
Load AL-reg with data 32h.
1003 C6 C3 17 MOV BL, 17H
Load BL-reg with data 17h.
1006 28 D8 SUB AL, BL
Subtract the contents of BL-reg from AL-register and the result will be stored in AL-register.
1008 2F DAS
Adjust result to valid BCD number.
1009 C6 C5 02 MOV CH, 02H
Count of digits to be displayed
100C C7 C6 00 14
MOV SI, 1400H
Load Si-reg with address 1400.
1010 88 04 MOV [SI], AL Copy the contents of AL-reg to address 1400.
1012 C6 C1 04 MOV CL, 04H Count to roll by 4-digits1015 88 C7 MOV BH, AL
Copy the contents of AL-reg to BH-register
1017 D2 C7 L2: ROL BH, CL Roll BL-reg so that MSB comes to LSB.
1019 88 FA MOV DL, BH Load DL-reg with data to be displayed.
101B 80 E2 0F AND DL, 0FH Get only LSB data.101E 80 FA 09 CMP DL, 09 check if digit is 0-9 or letter A-F1021 76 03 JBE L4 If byte jump to label L41023 80 C2 07 ADD DL, 07 If letter add 37H 1026 80 C2 30 L4: ADD DL, 30H Else only add 30H1029 FE CD DEC CH Decrement Count
34
102B 75 EA JNZ L2 If count is not zero then goto label L2
102D F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AL 32 1400 15BL 17
BCD MULTIPLICATION
ALGORITHM:
1. Get the 1st BCD number.2. Get the 2nd BCD number.3. Multiply two BCD numbers.4. Adjust result to valid BCD numbers.5. Display the result.
PROGRAM:ii) By using MASM:
CODE SEGMENTASSUME CS: CODE
MOV AL, 04H MOV BL, 06H MUL BL AAM MOV CH, 04H MOV SI, 1400H MOV [SI], AX MOV CL, 04H MOV BH, AL
L2: ROL BH, CL MOV DL, BH AND DL, 0FH CMP DL, 09 JBE L4 ADD DL, 07
L4: ADD DL, 30H MOV AH, 02 INT 21H DEC CH JNZ L2 MOV AH, 4CH INT 21H CODE ENDS END
iv) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 Org 1000h Starting address of the program1000 C6 C0 32 MOV AL, 06H Load AL-reg with data 04h.
35
1003 C6 C3 04 MOV BL, 04H
Load BL-reg with data 06h.
1006 F6 E3 MUL BL
Multiply the contents of AL-reg with BL-register and the result will be stored in AL-register.
1008 D4 0A AAM
Adjust result to valid BCD number.
100A C6 C5 04 MOV CH, 04H
Count of digits to be displayed
100D C7 C6 00 14
MOV SI, 1400H
Load Si-reg with address 1400.
1011 88 04 MOV [SI], AL Copy the contents of AL-reg to address 1400.
1013 C6 C1 04 MOV CL, 04H Count to roll by 4-digits1016 88 C7 MOV BH, AL
Copy the contents of AL-reg to BH-register
1018 D2 C7 L2: ROL BH, CL Roll BL-reg so that MSB comes to LSB.
101A 88 FA MOV DL, BH Load DL-reg with data to be displayed.
101C 80 E2 0F AND DL, 0FH Get only LSB data.101F 80 FA 09 CMP DL, 09 check if digit is 0-9 or letter A-F1022 76 03 JBE L4 If byte jump to label L41024 80 C2 07 ADD DL, 07 If letter add 37H 1027 80 C2 30 L4: ADD DL, 30H Else only add 30H102A FE CD DEC CH Decrement Count102C 75 EA JNZ L2 If count is not zero then goto label
L2102E F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address Data
AL 04 1400 04BL 06 1401 02
BCD DIVISION
ALGORITHM:1. Get the 1st BCD number.2. Get the 2nd BCD number.3. Multiply two BCD numbers.4. Adjust result to valid BCD numbers.5. Display the result.
PROGRAM: i). By using MASM:
CODE SEGMENTASSUME CS: CODE
MOVAL, 000FH
36
MOV BL, 08H DIV BL MOV CH, 04H MOV SI, 1400H
MOV [SI], AX MOV SI, 1402H
MOV [SI], BL MOV CL, 04H MOV BH, AL L2: ROL BH, CL MOV DL, BH AND DL, 0FH CMP DL, 09 JBE L4 ADD DL, 07 L4: ADD DL, 30H MOV AH, 02 INT 21H DEC CH JNZ L2 MOV AH, 4CH INT 21H CODE ENDS END
iii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C6,C0,0F MOVAL, 000FH Load AL-reg with data 0Fh.
1003 C6,C3,08 MOV BL, 08H Load BL-reg with data 08h.
1006 F6,F3 DIV BL
Divide the contents of AL-reg with BL-register and the result will be stored in AL-register.
1008 C6,C5,04 MOV CH, 04H
Count of digits to be displayed
100b C7,C6,00,14 MOV SI, 1400H
Load SI-reg with address 1400.
100f 89,04 MOV [SI], AX Copy the contents of AL-reg to address 1400.
1011 C7,C6,02,14 MOV SI, 1402H Load SI-reg with address 1402.
1015 88,1C MOV [SI], BL Copy the contents in BL-reg to address 1402.
1017 C6,C1,04 MOV CL, 04H Count to roll by 4-digits101a 88,C7 MOV BH, AL
Copy the contents of AL-reg to BH-register
101c D2,C7 L2: ROL BH, CL Roll BL-reg so that MSB comes to LSB.
101e 88,FA MOV DL, BH Load DL-reg with data to be displayed.
1020 80,E2,0F AND DL, 0FH Get only LSB data.1023 80,FA,09 CMP DL, 09 check if digit is 0-9 or letter A-F
37
1026 76,03 JBE L4 If byte jump to label L41028 80,C2,07 ADD DL, 07 If letter add 37H 102b 80,C2,30 L4: ADD DL, 30H Else only add 30H102e FE,CD DEC CH Decrement Count1030 75,EA JNZ L2 If count is not zero then goto label
L21032 F4 HLT Stop the programOUTPUT:
INPUT OUTPUTRegister Data Address Data
AL F(Dividend) 1400 01(Quotient)BL 08(Divisor) 1401 07(Remainder)
RESULT: Thus an assembly language program for performing addition, subtraction,
multiplication and division of two 8-bit BCD numbers was performed and its output was verified.
38
Ex. No: 3C MATRIX ADDITION
AIM: To write and execute an assembly language program for performing addition of two matrices
using 8086 kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Get the 1st BCD number.2. Get the 2nd BCD number.3. Multiply two BCD numbers.4. Adjust result to valid BCD numbers.5. Display the result.
PROGRAM: i). By using MASM:
.MODEL SMALL
.DATA M1 DB 00H,01H,10H,12H,02H,03H,0F0H,0C0H,04H M2 DB 00H,05H,01H,02H,50H,90H,03H,04H,0AAH.CODE.STARTUP MOV BX, OFFSET M1 MOV BP, OFFSET M2 MOV SI, 0001H MOV CL, 09H REPEAT: MOV AL,[BX+SI] ADD AL, [BP+SI] MOV [DI], AL INC SI INC DI LOOP REPEAT MOV AH, 4CH INT 21H END
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C3,00,13 MOV BX,1300H Load the base address of the 1st input matrix in BX.
1004 C7,C5,00,14 MOV BP,1400H Load the base address of the 2nd
input matrix in BP
1008 C7,C6,00,00 MOV SI,0000H
Initialize pointer for element of matrix.
100C C7,C7,00,15 MOV DI,1500H
Set DI-register as pointer for sum matrix.
1010 C6,C1,09 MOV CL, 09H
Set CL as count for elements in matrix.
1013 8A,00 REPEAT: MOV AL,[BX+SI] Get an element of 1st matrix in
39
AL.1015 02,02 MOV AL,[BP+SI] Add corresponding element of 2nd
matrix to AL.1017 88,05 MOV [DI],AL Store the sum of an element in
memory.1019 46 INC SI
Increment the pointers.
101A 47 L2: INC DI Increment the pointers.101B E2,F6 LOOP REPEAT Repeat addition until count is
zero.101D F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTADDRESS DATA ADDRESS DATA Address Data
1300 00H 1400 00H 1501 001301 01H 1401 05H 1502 061302 10H 1402 01H 1503 111303 12H 1403 02H 1504 141304 02H 1404 50H 1505 521305 03H 1405 90H 1506 931306 0F0H 1406 03H 1507 F3H
1307 0C0H 1407 04H 1508 C4H
1308 04H 1408 0AAH 1509 AEH
VIVA QUESTIONS:
1. What is the fabrication technology used for 8086?2. What are the features of Intel 8086?3. What is Logical Address?4. What is The Effective Address:5. What is Program counter?6. Distinguish between packed BCD and unpacked BCD7. What is 1st / 2nd / 3rd / 4th generation processor?8. Name the processor lines of two major manufacturers?9. What are the different types of Addressing Modes?10. What are the General Data Registers & their uses?
RESULT:
Thus an assembly language program for performing addition of two matrices numbers was performed and its output was verified.
40
Ex. No: 4A FLOATING POINT OPERATIONS
AIM: To write and execute an assembly language program for computing the area of a circle using
8087 instruction using 8086 kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Start2. Initialize the 8087 processor.3. Fetch the Radius from Memory location 1500h.4. To obtain r2 multiply using the instruction ST with ST (0)5. Then π is loaded employing a constant load operation.6. Now perform π*r*r using fmul instruction.7. Now convert the resultant data to packed decimal before storing it in memory location.8. Store the result in memory location 1600H.
9. Stop.
PROGRAM:
(i) BY USING MASM:.MODEL SMALL.DATARADIUS DD 3.4AREA DD ?END
.CODEMOV AX,@DATAMOV DS,AXFINITFLD RADIUSFMUL ST, ST(0)FLDPIFMULFSTP AREAEND
i) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 9B DB E3 FINIT Initialize1003 PB DF 06
0015FILD DS:[1500H] radius
1008 9B D8 C8 FMUL ST, ST(0) St = r*r100B 9B D9 EB FLDPI St (0) = pi100E 9B D8 C9 FMUL ST, ST(1) St (1) = r*r
St = pi*r*r1011 9B DF 36 0016 FBSTP DS: [1600H] Area1016 F4 HLT Stop the program
41
OUTPUT:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
1500 2 1600 12.56
RESULT: Thus an assembly language program for finding the area of a circle using 8087 instruction
was performed and its output was verified.
42
Ex. No: 4B STRING OPERATIONS
AIM: To write and execute an assembly language program to find the length and copying string,
using 8086 kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Load the source and destination index register with starting and the ending address
respectively.2. Load the terminate data value as “FF”.3. Load the content of source index to the AL register.4. Increment SI register and compare with register AH.5. If it is non- zero value, increment the memory location by using the control instruction to
store the data.6. Compare the string byte with FF, if it is not equal, repeat.7. Count the string byte till zero flag is set. If zero flag is set then store the count value to the
memory.8. Terminate the program when FF is matched.9. Stop
PROGRAM:i) By using MASM:
ASSUME CS: CODE, DS: DATADATA SEGMENTSTRING1 DB 'MICROPROCESSOR AND INTERFACING LAB$'DATA ENDSCODE SEGMENT
START: MOV AX, DATAMOV DS, AXSUB CL, CLMOV SI, OFFSET STRING1
BACK: LODSB INC CLCMP AL,'$'JNZ BACKMOV BL, CLMOV SI, 1200HMOV [SI], BLINT 03HCODE ENDSEND START
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C6,00,12 MOV SI,1200H SI 12001004 C7,C7,FF,FF MOV DX, FFFFH DXFFFF
1008 C6,C4,FF MOV AH, FFH AH FF, check FF
43
100B 42 NOEND: INC DX Increment the DX reg by 1100C 8A,04 MOV AL,[SI] AL [SI]100E 46 INC SI Increment the SI reg. by 1
100F 38,C4 CMP AH,AL Compare the content of AH & AL
1011 75,FB JNZ : NOEND If the Compared result is not ‘0’ go to by the address specified label NOEND.
1013 89,16,00,11 MOV [1100],DX [1100] DX ie. store the result
1017 F4 HLT Terminate the program
INPUT:
ADDRESS (Hex) Data (Hex)1200 E31201 F41202 541203 661204 881205 991206 101207 FF
OUTPUT:
STRING COPYING
ALGORITHM:1. Load the source and destination index register with starting and the ending address respectively.2. Initialize the counter with the total number of words to be copied.3. Clear the direction flag for auto incrementing mode of transfer.4. Use the string manipulation instruction MOVSW with the prefix REP to copy a string from source to destination.5. Stop
PROGRAM:
i) By using MASM:.MODEL SMALLDATA SEGMENT SRC DB ‘MICROPROCESSOR’ DB 10 DUP (?) DST DB 20 DUP (0) DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA, ES: DATA START: MOV AX, DATA MOV DS, AX
44
ADDRESS (Hex) String length Hex)1100 07
MOV ES, AX LEA SI, SRC LEA DI, DST MOV CX, 20 CLD REP MOVSB INT 3H CODE ENDS END START
ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C6,00,20 MOV SI,2000H Initialize the source address.
1003 C7,C7,00,21 MOV DI,2100HInitialize the destination
address.
1007 C7,C1,06,00 MOV CX,0006 HInitialize count value to the
count register.
100B C6,C4,55 MOV AH,55H Move 55 to AH register.
100E FC REPEAT: CLD Clear the direction flag.
100F A4 MOVSB Move the string byte.
1010 E2,FB LOOP:REPEAT
Unconditional loop to
address specified by the
label REPEAT.
1013 F4 HLT Stop the program.
OUTPUT:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
2000 55 2100 552001 55 2101 552002 55 2102 552003 55 2103 552004 55 2104 552005 55 2105 55
RESULT:
Thus an assembly language program for copying, finding the length of a string was implemented and its output was verified.
45
Ex. No: 4C SORTING (ASCENDING AND DESCENDING ORDER)
AIM: To write and execute an assembly language program to sort an array of numbers in ascending
and descending order.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:
SORTING IN ASCENDING ORDER:1. Start2. Load the array count in two registers C1 and C2. 3. Get the first two numbers. 4. Compare the numbers and exchange if necessary so that the two numbers are in
ascending order. 5. Decrement C2. 6. Get the third number from the array and repeat the process until C2 is 0. 7. Decrement C1 and repeat the process until C1 is 0.8. Stop
SORTING IN DESCENDING ORDER:1. Start2. Load the array count in two registers C1 and C2. 3. Get the first two numbers. 4. Compare the numbers and exchange if necessary so that the two numbers are in
descending order. 5. Decrement C2. 6. Get the third number from the array and repeat the process until C2 is 0. 7. Decrement C1 and repeat the process until C1 is 0.8. Stop
PROGRAM:i) By using MASM:
.MODEL SMALL
.STACK 100
.DATA NUM DB 12H, 45H, 79H, 66H.CODE
START: MOV AX,@DATA MOV DS, AX MOV BX, 3
LOOP2: MOV CX, BX MOV DI, 0 MOV AL, NUM [DI] MOV DX, DI
LOOP1: INC DI CMP AL, NUM [DI] JNB NEXT MOV AL, NUM [DI] MOV DX, DI
NEXT: LOOP LOOP1 XCHG AL, NUM [DI]
46
MOV SI, DX MOV NUM [SI], AL DEC BX JNZ LOOP2 MOV AH, 4CH INT 21H
END START
DESCENDING ORDER:ii) By using MASM:
.MODEL SMALL
.STACK 100
.DATA NUM DB 12H, 45H, 79H, 66H.CODE
START: MOV AX,@DATA MOV DS, AX MOV BX, 3
LOOP2: MOV CX, BX MOV DI, 0 MOV AL, NUM [DI] MOV DX, DI
LOOP1: INC DI CMP AL, NUM [DI] JB NEXT MOV AL, NUM [DI] MOV DX, DI
NEXT: LOOP LOOP1 XCHG AL, NUM [DI] MOV SI, DX MOV NUM [SI], AL DEC BX JNZ LOOP2 MOV AH, 4CH INT 21H
END START
ASCENDING ORDER:iii) By using 8086 kit:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000C7,C6,00,20
MOV SI, 2000 Initialize the memory pointer.
1004 8A,0C MOV CL,[SI] Move the content SI to CL.
1006 FE,C9 DEC CL Decrement the count value
1008 C7,C6,00,20 REPEAT: MOV SI,2000 Move 2000 to SI.
100c 8A,2C MOV CH,[SI] Move the content of to CH.
100e FE,CD DEC CH Decrement the CH by one.
1010 46 INC SI Increment the memory pointer
1011 8A,04 RECMP: MOV AL,[SI] Move the content of SI to AL.
1013 46 INC SI increment the memory
47
pointer1014
3A,04 CMP AL,[SI]Compare the content of AL and content of address hold by SI.
101672,05 JC :AHEAD
If carry occur jump to the address specify by the label AHEAD.
101886,04 XCHG AL,[SI]
Exchange the content of AL and the content hold by the address specify in SI.
101a
86,44,FF XCHG AL,[SI-1]
Exchange the content of AL and the content hold by the address specify in SI-1.
101d FE,CD AHEAD: DEC CH Decrement the CH register by 1.
101f 75,F0JNZ :RECMP
In the count value not reach to zero jumps to address specify by RECMP.
1021 FE,C9 DEC CL Decrement the content of CL.
1023 75,E3JNZ: REPEAT
In the count value not reach to zero jump to address specify by REPEAT.
1025 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTAddress Data Address Data
2000 05 2001 012001 05 2002 022002 04 2003 032003 03 2004 042004 02 2005 052005 01
DESCENDING ORDER:iv) By using 8086 kit:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS1000 C7,C6,00,20 MOV SI, 2000 Initialize the memory pointer.
1004 8A,0C MOV CL,[SI] Move the content SI to CL.
1006 FE,C9 DEC CL Decrement the count value
1008 C7,C6,00,20 REPEAT: MOV SI,2000 Move 2000 to SI.
100C 8A,2C MOV CH,[SI] Move the content of to CH.
100E FE,CD DEC CH Decrement the CH by one.
1010 46 INC SI Increment the memory pointer
1011 8A,04 RECMP: MOV AL,[SI] Move the content of SI to AL.
1013 46 INC SI increment the memory pointer
1014 3A,04 CMP AL,[SI] Compare the content of AL and content of address hold by
48
SI.1016
73,05 JNC :AHEADIf carry occur jump to the address specify by the label AHEAD.
101886,04 XCHG AL,[SI]
Exchange the content of AL and the content hold by the address specify in SI.
101a
86,44,FF XCHG AL,[SI-1]
Exchange the content of AL and the content hold by the address specify in SI-1.
101d FE,CD AHEAD: DEC CH Decrement the CH register by 1.
101f 75,F0JNZ :RECMP
In the count value not reach to zero jumps to address specify by RECMP.
1021 FE,C9 DEC CL Decrement the content of CL.
1023 75,E3JNZ: REPEAT
In the count value not reach to zero jump to address specify by REPEAT.
1025 F4 HLT Stop the program
OUTPUT:
INPUT OUTPUTAddress Data Address Data2000 05 2001 052001 05 2002 042002 04 2003 032003 03 2004 022004 02 2005 012005 01
RESULT: Thus an assembly language program for sorting an array of number in ascending and
descending order was performed and its output was verified.
49
Ex.No:4C SEARCHING A NUMBER
AIM: To write and execute an assembly language program for searching a number using 8086 kit
and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Get the count in register for number of data.2. Initialize the array address.3. Compare the selected two numbers and check carry.4. If bigger, store the largest value in accumulator. 5. Otherwise interchange the contents with register.6. Decrement the count.7. Continue the same operation till the count becomes zero.8. Store the result in memory locations.
PROGRAM:
LARGEST:(i) By using MASM:
DATA SEGMENT X DW 0060H, 0020H, 0030H, 0040H, 0050H MES DB 10, 13,'LARGEST NUMBER AMONG THE SERIES IS $'
DATA ENDSCODE SEGMENT
ASSUME CS: CODE, DS: DATA START: MOV AX, DATA MOV DS, AX MOV CX, 05H LEA SI, X MOV AX, [SI] DEC CX
UP: CMP AX, [SI+2] JNB CONTINUE MOV AX, [SI+2]
CONTINUE: ADD SI, 2 DEC CX JNZ UP AAM ADD AX, 3030H MOV BX, AX MOV AH, 09H LEA DX, MES INT 21H MOV DL, BH MOV AH, 02H INT 21H MOV DL, BL INT 21H MOV AH, 4CH INT 21H
50
CODE ENDS END START
(ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C6,00,20 MOV SI,2000H Set SI-register as pointer for array.
1004 C7,C7,00,21 MOV DI,2100H Set DI-register as pointer for array.
1008 8A,0C MOV CL,[SI] Set CL-register as count for elements in the array.
100A 46 INC SI Increment the SI-register100B 8A,04 MOV AL,[SI] Set first data as largest100D FE,C9 DEC CL Decrement the count100F 46 AGAIN: INC SI Increment the SI-register to
point to next data in array1010 8A,1C MOV BL,[SI] Get the next data in BL-reg.1012 3A,C3 CMP AL,BL Compare the current largest data
in AL with BL.1014 73,02 JNB AHEAD If carry is not set then AL is
greater than BL, hence proceed to AHEAD
1016 8A,C3 MOV AL,BL If carry is set then make BL as current largest
1018 FE,C9 AHEAD: DEC CL Decrement the count101A 75,F3 JNZ AGAIN If count is not zero repeat
search.101C 88,05 MOV [DI],AL Store the largest data in
memory.101E F4 HLT Stop the program.
OUTPUT:
INPUT OUTPUTAddress Data Address Data
2000 05 (COUNT) 2100 192001 152002 19 2003 02 2004 012005 06
SMALLEST:
iii) By using MASM:DATA SEGMENT X DW 0060H, 0020H, 0030H, 0040H, 0050H MES DB 10, 13,'SMALLEST NUMBER AMONG THE SERIES IS $' DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA START: MOV AX, DATA
51
MOV DS, AX MOV CX, 05H LEA SI, X MOV AX, [SI] DEC CX
UP: CMP AX, [SI+2] JB CONTINUE MOV AX, [SI+2]
CONTINUE: ADD SI, 2 DEC CX JNZ UP AAM ADD AX, 3030H MOV BX, AX MOV AH, 09H LEA DX, MES INT 21H MOV DL, BH MOV AH, 02H INT 21H MOV DL, BL INT 21H MOV AH, 4CH INT 21H CODE ENDS END START
iv) By using 8086:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C6,00,20 MOV SI,2000H Set SI-register as pointer for array.
1004 C7,C7,00,21 MOV DI,2100H Set DI-register as pointer for array.
1008 8A,0C MOV CL,[SI] Set CL-register as count for elements in the array.
100A 46 INC SI Increment the SI-register100B 8A,04 MOV AL,[SI] Set first data as largest100D FE,C9 DEC CL Decrement the count100F 46 AGAIN: INC SI Increment the SI-register to
point to next data in array1010 8A,1C MOV BL,[SI] Get the next data in BL-reg.1012 3A,C3 CMP AL,BL Compare the current largest data
in AL with BL.1014 72,02 JB AHEAD If carry is not set then AL is
greater than BL, hence proceed to AHEAD
1016 8A,C3 MOV AL,BL If carry is set then make BL as current largest
1018 FE,C9 AHEAD: DEC CL Decrement the count101A 75,F3 JNZ AGAIN If count is not zero repeat
search.101C 88,05 MOV [DI],AL Store the largest data in
memory.101E F4 HLT Stop the program.
52
OUTPUT:
INPUT OUTPUTAddress Data Address Data
2000 05 (COUNT) 2100 012001 152002 19 2003 02 2004 012005 06
VIVA QUESTIONS:
1. What are Data Copy/Transfer Instructions?2. What are Machine Control Instructions?3. What are Flag Manipulation Instructions?4. What are String Instructions?5. Explain the difference between a JMP and CALL instruction?6. What is meant by Polling?7. Define Pipelining?8. Explain about "LEA"?9. Define Pipelining?10. What is a bus?
RESULT: Thus an assembly language program for searching a smallest and largest was
performed and its output was verified.
53
Ex.No:5A PASSWORD CHECKING
AIM: To write and execute an assembly language program for password checking using 8086 kit
and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
PROGRAM:i) By using MASM
.MODEL SMALL .DATA NAM DB ’KRISHNA$’ PASS DB 50 DB? DB 10 DUP (?) MSG1 DB 10, 13,"ENTER THE PASSWORD: $", 10, 13 MSG2 DB 10, 13,"PASSWORD VALID: CONGRATS!!!! $", 10, 13 MSG3 DB 10, 13,"PASSWORD INVALID, SORRY TRY AGAIN ## $", 10, 13 PRINT MACRO MSG; MACRO DEFINITION TO PRINT A STRING ON SCREEN LEA DX, MSG MOV AH, 09 INT 21H ENDM .CODE START: MOV AX,@DATA MOV DS, AX MOV ES, AX XOR AX, AX PRINT MSG1 LEA DX, PASS MOV AH, 0AH; READ PASSWORD FROM KEYBOARD INT 21H MOV DI, DX INC DI MOV CL, BYTE PTR [DI]; LENGTH OF THE STRING IN CL REGISTER MOV CH, 00 INC DI LEA SI, NAM CLD BACK: CMPSB JNE XX LOOP BACK PRINT MSG2 JMP XXY XX: PRINT MSG3 XXY: MOV AH, 4CH INT 21H END START
54
(ii) By using 8086 kit:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
0000 E8,00,79 AGAIN: CALL CLRS Assign ASCII value for carriage return
0003 E8,00,6F CALL POS Position The Cursor0006 8C, C8 MOV AX,CS Initialize DS To Code Segment0008 8E, D8 MOV DS,AX Copy The Content Of AX To
DS-Register000A B4, 09 MOV AH,09H Load The Function Code IN
AH-register000C BA, 04,50 MOV DX,450H Load address of string to display
in DX-register000F CD, 21 INT 21H Call DOS service for display0011 BE, 04,00 MOV SI,400H Initialize the pointer0014 B9, 00,00 MOV CX,0000H Initialize count in CX-register as
zero.0017 B4, 00 L1: MOV AH,00H Load the function code in AH.0019 CD, 16 INT 16H Call BIOS to get keyboard
character in AL.001B 3C,0D CMP AL,CR Compare the key code with
carriage return001D 74,0C JE CHECK If equal go to CHECK001F 88,04 MOV [SI],AL Store the keyboard character in
memory0021 B4,02 MOV AH,02H Load the function code in AH.0023 B2, 2A MOV DL, ‘*’ Load the ASCII value of ‘*’ in
DL0025 CD,21 INT 21H Call DOS service for display0027 46 INC SI Increment Pointer0028 41 INC CX Increment the count0029 EB,EC JMP L1 Jump to L1 to get next character002B 83,F9,07 CHECK: CMP CX,0007H Compare count with 07H 002E 75,20 JNE REPEAT If count not equal to 07H then
goto repeat0030 BE,04,00 MOV SI, 400H Initialize the pointers0033 BF,05,00 MOV DI,500H Copy the value 500H to DI-reg0036 8A,04 L2: MOV AL, [SI] Get a character of entered
password in AL-register0038 3A,05 CMP AL,[DI] Compare entered character with
corresponding character of stored password
003A 75,14 JNE REPEAT If not equal jump to repeat003C 46 INC SI Increment the pointer003D 47 INC DI Increment the DI-register003E E2,F6 LOOP L2 Repeat comparison until counter
expires0040 E8,00,79 CALL CLRS Clear the screen0043 E8,00,6F CALL POS Position the cursor0046 B4,09 MOV AX,09H Load the function code in AH-
register004A BA,06,00 MOV DX,600H Load the address of String to
display in DX-register004B CD,21 INT 21H Call DOS service for display
55
004D E9,06,0F JMP EXIT GO to EXIT.0050 E8,00,79 REPEAT CALL CLRS Clear the screen0053 E8,00,6F CALL POS Position the cursor0056 B4,09 MOV AH,09H Load the function code in AH0058 BA,05,50 MOV DX,550H Load the address of string to
display in DX-register005B CD,21 INT 21H Call DOS service for display005D B4,09 MOV AH,09H Load the function code in AH005F BA,05,80 MOV DX,580H Load address of string to display
in DX0062 CD,21 INT 21H Call DOS service for display0064 B4,00 MOV AH,00H Load the function code in AH0066 CD,16 INT 16H Call Bios service to get
keyboard0068 3C,1B CMP AL,1BH Check for Esc key006A 75,94 JNE AGAIN If key pressed is not esc, then go
to again006C E9,06,0F JMP EXIT If key pressed is not esc, then go
to exit006F B4,02 MOV AH,02H Load the function code in AH0071 B7,00 MOV BH,00H Load the video page in BH0073 BA,00,00 MOV DX,0000H Load the X and Y coordinate in
DL and DH.0076 CD ,10 INT 10H Call Bios service for cursor
positioning0078 C3 RET Return to main program0079 POS ENDP End of procedure to position the
cursor0079 CLRS PROC NEAR Start of procedure to clear the
screen.0079 B4,07 MOV AH,07H Load the function code in AH007B B0,00 MOV AL,00H Load number of lines to scroll
down in AL007D B7 07 MOV BH,07H Load the blanked area attribute
in BL007F B9 0000 MOV CX, 0000H Load the X and Y coordinates of
upper left corner in CL and CH0082 BA 184F MOV DX,184FH Load the X and Y coordinates
of lower right corner in DL and DH
0085 CD 10 INT 10H Call BIOS video service for clearing screen.
0087 C3 RET Return to main program0088 CLRS ENDP End of procedure to clear the
screen.0450 ORG 450H0450 45 4E 54 45
52 20 54 48 45 20 50 41 53 53 57 4F 52 44 20 3A 20 24
DB ‘ENTER THE PASSWORD : ‘,’$’
0500 ORG 500H0500 57 45 4C 43
4F 4D 45 DB ‘WELCOME’,’$’
56
240500 ORG 550H0550 49 4E 43 4F
52 52 45 43 54 20 50 41 53 53 57 4F 52 44 2E 20 20 24
DB ‘INCORRECT PASSWORD. ‘,’$.
0580 ORG 580H0580 50 52 45 53
53 20 41 4E 59 20 4B 45 59 20 54 4F 20 54 52 59 20 41 41 41 49 4E 20 4F 52 20 50 52 45 53 53 20 45 53 43 20 54 4F 20 45 58 49 54 20 24
DB ‘ PRESS ANY KEY TO TRY AGAIN OR PRESS ESC TO EXIT ‘,’$’
0600 ORG 600H0600 45 4E 54 52
59 20 41 43 43 45 50 54 45 44 24
DB ‘ENTRY ACCEPTED’ ,’$’.
060F B4 4C EXIT MOV AH,4CH Load the function in AH0611 CD 21 INT 21H Call DOS service to return to
command prompt.0613 CODE ENDS Ends of code segment
END Assembly end
OUTPUT:
ENTER THE PASSWORD: WELCOMEINCORRECT PASSWORDPRESS ANY KEY TO TRY AGAIN OR PRESS ESC TO EXITENTRY ACCEPTED
RESULT:
Thus an assembly language program for password checking using 8086 was implemented and its output was verified.
57
Ex.No:5B PRINT RAM SIZE
AIM: To write and execute an assembly language program to print the size of the file in RAM using
8086kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
PROGRAM:i) By using MASM
PROMPT MACRO MESSAGE PUSH AX MOV AH, 09H LEA DX, MESSAGE INT 21H POP AX ENDM
DATA SEGMENT MES DB 10, 13, 'THE SIZE OF CONVENTIONAL RAM MEMORY IS: $'
MES1 DB 'KBYTES$' DATA ENDS
CODE SEGMENT ASSUME CS: CODE
LEA DX, MES INT 12H CALL D_BCD LEA DX, MES1 MOV AH, 4CH INT 21H
D_BCD PROC NEAR MOV CX, 00H MOV BX, 10H BACK1: MOV DX, 00H DIV BX
PUSH DX INC CX
OR AX, AXJNZ BACK1MOV AH, 02H
DISP: POP DXADD DL, 30H INT 21H LOOP DISP RET ENDP CODE ENDS END
RESULT: Thus an assembly language program to print the size of the file in RAM using 8086 was implemented and its output was verified.
58
Ex.No:5C SYSTEM DATE
AIM: To write and execute an assembly language program for reading system date using 8086kit
and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
PROGRAM:i) By using MASM
.MODEL SMALL .DATA .CODE START: MOV AX,@DATA MOV DS, AX
; Day Part DAY: MOV AH, 2AH ; To get System Date INT 21H MOV AL, DL ; Day is in DL AAM MOV BX, AX CALL DISP MOV DL,'/' MOV AH, 02H ; To Print / in DOS INT 21H
; Month PartMONTH: MOV AH, 2AH ; To get System Date INT 21H MOV AL, DH ; Month is in DH AAM MOV BX, AX CALL DISP MOV DL,'/' ; To Print / in DOS MOV AH, 02H INT 21H
; Year Part YEAR: MOV AH, 2AH ; To get System Date INT 21H ADD CX, 0F830H; To negate the effects of 16bit value, MOV AX, CX ; since AAM is applicable only for AL (YYYY -> YY) AAM MOV BX, AX CALL DISP
; To terminate the Program MOV AH, 4CH ; To Terminate the Program INT 21H
59
; Display Part DISP PROC MOV DL, BH ; since the values are in BX, BH Part ADD DL, 30H ; ASCII Adjustment MOV AH, 02H ; To Print in DOS INT 21H MOV DL, BL ; BL Part ADD DL, 30H ; ASCII Adjustment MOV AH, 02H ; To Print in DOS INT 21H RET DISP ENDP ; End Disp Procedure END START ; End of MAIN
PROGRAM:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 CALL CONVERT Call subroutine for conversion1003 CALL DISPLAY Call subroutine for Display1006 DELAY: MOV AL,0B0H Copy the data 0B0H to AL-reg1009 OUT 16H,AL Configure output port100B MOV CL,07H Copy the data 07H to AL-reg100E S2: MOV AL,88H Copy 88H to AL-register1011 OUT 14H,AL Configure output port1013 MOV AL,80H Copy the data 80H to AL-reg1016 OUT 14H,AL Configure output port1018 S1: NOP No operation1019 NOP No operation101A NOP No operation101B NOP No operation101C IN AL,14H Copy 14H to AL-reg101E MOV DL,AL Copy the Content of AL reg to
DL-reg.1020 IN AL,14H Copy 14H to AL-reg1022 OR AL,DL OR the contents of AL with DL1024 JNZ S1 Jump on no zero to S11026 DEC CL Decrement CL-register1028 JNZ S2 Jump on no zero to S2102A MOV SI,1500H Copy SI-reg with data 1500H102E MOV AL,[SI] Copy the content of SI-reg to AL1030 INC AL Increment AL-register1032 MOV [SI],AL Copy the content of AL reg to SI-
reg 1034 CMP AL,3CH Compare AL with 3CH1037 JNZ START Jump on no zero to start1039 MOV AL,00H Copy AL with data 00H103C MOV [SI],AL Copy the content of Al to SI-reg103E INC SI Increment SI-register103F MOV AL,[SI] Copy the content of SI-reg to AL1041 INC AL Increment AL-register1043 MOV [SI],AL Copy the content of AL reg to SI-
60
reg 1045 CMP AL,3CH Compare AL with 3CH1048 JNZ START Jump on no zero to start104A MOV AL,0 Copy AL with data 00H104D MOV [SI],AL Copy the content of AL reg to SI-
reg104F INC SI Increment SI-register1050 MOV AL,[SI] Copy the content of SI-reg to AL1052 INC AL Increment AL-register1054 MOV [SI],AL Copy the content of AL reg to SI-
reg 1056 CMP AL,18H Compare AL with 18H1059 JNZ START Jump on no zero to start105B MOV AL,0 Copy AL with data 00H105E MOV [SI],AL Copy the content of AL reg to SI-
reg1060 JMP START Jump to start1063 DISPLAY: MOV AH,06H Copy 06H to AH-register1066 MOV DX,1600H Copy 1600H to DX-register106A MOV CH,01H Copy 01H to CH-register106D MOV CL,0H Copy 00H to CL-register1070 INT 5 Call Interrupt1072 RET Return from subroutine1073 CONVERT: MOV SI,1500H Copy 1500H to SI-register1077 MOV BX,1608H Copy 1608H to BX-register107B MOV AL,24H Copy 24H to AL-register107E MOV [BX],AL Copy the content of AL-reg to BX1080 MOV AL,[SI] Copy the content of SI-reg to AL1082 MOV AH,0 Copy AL with data 00H1085 MOV DH,0AH Copy the data 0AH to DH-register1088 DIV DH Divide DH-reg by AH reg108A ADD AH,30H Add the data 30H with AH-reg108D DEC BX Decrement BX-register108E MOV [BX],AH Copy the data from AH to DH-
reg1090 DEC BX Decrement BX-register1091 ADD AL,30H Add the data 30H with AL-reg1094 MOV [BX],AL Copy the data from AL to BX-reg1096 DEC BX Decrement BX-register1097 MOV AL,3AH Copy the 3AH to AL-reg109A MOV [BX],AL Copy the data from AL to BX-reg109C DEC BX Decrement BX-register109D INC SI Increment SI-register109E MOV AL,[SI] Copy the content of SI-reg to AL10A0 MOV AH,0 Copy the data 0 to AH-reg10A3 MOV DH,0AH Copy the data 0AH to DH-register10A6 DIV DH Divide DH-reg by AH reg10A8 ADD AH,30H Add the data 30H with AH-reg
61
10AB MOV [BX],AH Copy the data from AH to BX-reg
10AD DEC BX Decrement BX-register10AE ADD AL,30H Add the data 30H with AL-reg10B1 MOV [BX],AL Copy the data from AL to BX-reg10B3 DEC BX Decrement BX-register10B4 MOV AL,3AH Copy the 3AH to AL-reg10B7 MOV [BX],AL Copy the data from AL to BX-reg10B9 DEC BX Decrement BX-register10BA INC SI Increment SI-register10BB MOV AL,[SI] Copy the content of SI-reg to AL10BD MOV AH,0 Copy the data 0 to AH-reg10C0 MOV DH,0AH Copy the data 0AH to DH-register10C3 DIV DH Divide DH-reg by AH reg10C5 ADD AH,30H Add the data 30H with AH-reg10C8 MOV [BX],AH Copy the data from AH to BX-
reg10CA DEC BX Decrement BX-register10CB ADD AL,30H Add the data 30H with AL-reg10CE MOV [BX],AL Copy the data from AL to BX-reg10D0 RET Return from subroutine10D1 GETC: IN AL,02H Copy 02H to AL-reg10D3 AND AL,0FFH AND data AL with 0FFH10D6 CMP AL,0F0H Compare AL with 0F0H10D9 JNE GETC If no zero jump to getc
OUTPUT:1500- 99 YEAR1501- 09 MONTH1502- 09 DATE
VIVA QUESTIONS:
1. Why data bus is bi-directional?2. Why address bus is unidirectional?3. Define machine cycle.4. What is DMA?5. What is a port?6. What are nibble, byte and word?7. What is PSW? Give its structure and explain8. What does EU and BIU do?9. Describe about LOOP instructions10. Explain about DAA instruction.
RESULT:
Thus an assembly language program for reading system date using 8086 was implemented and its output was verified.
Ex.No:6 COUNTERS AND TIME DELAY
62
AIM:To write and execute an assembly language program for creating time delay using counters in
8086kit and MASM.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
PROGRAM:i) By using MASM
.MODEL SMALL.DATA MSGIN DB 'Enter delay duration (0-50): $' MSG1 DB 'This is Microprocessor!$' DELAYTIME DW 0000H
.CODE MOV DX,@DATA MOV DS, DX LEA DX, MSGIN MOV AH, 09H INT 21H
IN1: MOV AH, 01H INT 21H CMP AL, 0DH ; JE NXT SUB AL, 30H MOV DL, AL MOV AX, BX MOV CL, 0AH MUL CL MOV BX, AX AND DX, 00FFH ADD BX, DX MOV DELAYTIME, BX LOOP IN1
NXT: MOV CX, DELAYTIME MOV DL, 10 MOV AH, 02H INT 21H
LEA SI, MSG1 LP: PUSH DX
MOV DL, [SI] CMP DL,'$' JE NXT2 MOV AH, 02H INT 21H
ADD SI, 1 POP DX MOV DI, DELAYTIME MOV AH, 0 INT 1Ah MOV BX, DX
63
Delay: MOV AH, 0 INT 1Ah
SUB DX, BX CMP DI, DX
JA Delay LOOP LP
NXT2: MOV AH, 4CH INT 21H
END
(iii) By using 8086 kit:
Square wave Generation:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS1000 ORG 1000H Starting address1000 C6,C0,36 MOV AL,36 Move 36 to AL-register1003 E6,CE OUT CE,AL The content of AL-reg is
copied to Port.1005 C6,C0,10 MOV AL,10 Move 10 to AL-register1008 E6,C8 OUT C8,AL The content of AL-reg is
copied to Port.100A C6,C0,00 MOV AL,00 Move 00 to AL-register100D E6,C8 OUT C8,AL The content of AL-reg is
copied to Port.100F F4 HLT Stop the program.
OUTPUT:
WAVEFORM GENERATIONWAVEFORMS AMPLITUDE TIME PERIOD
Square wave 10v 1ms
VIVA QUESTIONS:
1. What are the advantages of modular programming?2. What is the BHE signal? Explain its significance?3. What does MASM stand for and what is its use?4. Which interrupt in the 8086 has the highest priority?5. Where 8086 is mainly used and tell its applications?6. Abbreviation of ASCII.7. Define Signed and Unsigned number?8. What do you mean by assembler directives?9. What is the Maximum clock frequency in 8086?10. What is meant by cross-compiler?
RESULT:
Thus an assembly language program for creating time delay using counters in 8086 was implemented and its output was verified.
64
INTERFACING EXPERIMENTS
65
Ex. No: 7 TRAFFIC LIGHT CONTROL
AIM: To write and execute an assembly language Program for interfacing the Traffic Light
Controller in 8086 kit.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Traffic Light Controller Interface board ----1 3. Power card ----14. Keyboard ----1
5. PC with Intel/AMD Processor----1
PROGRAM:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 B0,80 START: MOV AL,80H Move 80 to AL-register1002 E6,26 OUT CONTROL,AL Copy the AL-reg content to
output port.1004 BB 6B 10 REPEAT: MOV BX, LOOKUP Copy the lookup data value
to BX-register1007 BE 77 10 MOV SI, LABEL Copy the direction of rotation
value to SI-reg.100A E8 32 00 CALL OUT Call to OUT port100D 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register100F E6 20 OUT PORTA, AL Move the AL-reg value to
PORTA1011 E8 4A 00 CALL DELAY1 Call Delay program1014 46 INC SI Increment SI-register1015 43 INC BX Increment BX-register1016 E8 26 00 CALL OUT Call to OUT port1019 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register101B E6 22 OUT PORTB, AL Move the AL-reg value to
PORTB101D E8 3E 00 CALL DELAY1 Call Delay program1020 46 INC SI Increment SI-register1021 43 INC BX Increment BX-register1022 E8 1A 00 CALL OUT Call to OUT port1025 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register1027 E6 24 OUT PORTC, AL Move the AL-reg value to
PORTC1029 E8 32 00 CALL DELAY1 Call Delay program102C 46 INC SI Increment SI-register102D 43 INC BX Increment BX-register102E E8 0E 00 CALL OUT Call to OUT port1031 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register1033 E6 24 OUT PORTC, AL Move the AL-reg value to
PORTC1035 46 INC SI Increment SI-register1036 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
66
1038 E6 20 OUT PORTC, AL Move the AL-reg value to PORTC
103A E8 21 00 CALL DELAY1 Call Delay program103D EB C5 JMP REPEAT Jump to label REPEAT103F 8A 07 OUT: MOV AL, [BX] Copy the content of BX to
AL-register1041 E6 24 OUT PORTC, AL Move the AL-reg value to
PORTC1043 43 INC BX Increment BX-register1044 8A 07 MOV AL, [BX] Copy the content of BX to
AL-register1046 E6 22 OUT PORTB, AL Move the AL-reg value to
PORTB1048 43 INC BX Increment BX-register1049 8A 07 MOV AL, [BX] Copy the content of BX to
AL-register104B E6 20 OUT PORTA, AL Move the AL-reg value to
PORTA104D E8 01 00 CALL DELAY Call Delay program1050 C3 RET Return from subroutine1051 BF 40 00 DELAY: MOV DI, 00040H Move 40h to DI-register1054 BA FF FF A: MOV DX, 0FFFFH Move 0FFFFh to DX-register1057 4A A1: DEC DX Decrement DX-register1058 75 FD JNZ A1 Jump on no zero to A1.105A 4F DEC D1 Decrement D1-register105B 75 F6 JNZ A Jump on no zero to A105D C3 RET 105E BF 15 00 DELAY1: MOV DI, 00015H Move 15h to DI-register1061 BA FF FF B: MOV DX, 0FFFH Move 0FFFh to DX-register1064 4A B1: DEC DX Decrement DX-register1065 75 FD JNZ B1 Jump on no zero to B11067 4F DEC D1 Decrement D1-register1068 75 F6 JNZ B Jump on no zero to B106A C3 RET106B 12 27 44 10 LOOKUP: DB 12H,27H,44H,10H
For traffic light control.
106F 2B 92 109D 2BH,92H,10H,9DH1073 84 48 2E 84 84H,48H,2EH,84H1077 48 4B 20 49 LABEL: DB 48H,4BH,20H,49H 107B 04 04H 107C ENDVIVA QUESTIONS:
1. Which Segment is used to store interrupt and subroutine return address registers?2. What is the difference between instructions RET & IRET?3. What .model small means?4. Difference between small, medium, tiny, huge?5. What is dd, dw, db?6. What is the function of 01h of Int 21h? 7. What is the function of 02h of Int 21h? 8. What is the function of 09h of Int 21h? 9. What is the function of 0Ah of Int 21h?10. What is the function of 4ch of Int 21h?
RESULT: Thus the assembly language program for interfacing the traffic light controller was
67
implemented in 8086 kit.
68
Ex.No:8 STEPPER MOTOR INTERFACING
AIM:To write and execute an assembly language Program to run a stepper motor at different
speed, and to control its speed of direction.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Stepper Motor ----13. Stepper Motor Interface board ----1 4. Power card ----15. Keyboard ----16. PC with Intel/AMD Processor----1
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 Org 1000H Starting address of the program
1000 C7,C7,18,10 Ahead MOV DI, 1018 Copy the data 1018 to DI-reg
1004 C6, C1,04 MOV CL, 04 Copy the value 04 to CL-register
1007 8A, 05 Loop1 MOV AL, [DI] Copy the content of DI-reg to AL-register
1009 E6 , C0 OUT C0, AL The content of AL is moved to Out port
100B C7,C2,10,10 MOV DX, 1010 Copy the data 1010 to DX-reg100F 4A loop DEC DX Decrement DX-register 1010 75,FD JNZ loop Jump on no zero to loop1012 47 INC DI Increment DI-register1013 E2,F2 LOOP loop1 Loop to label loop11015 E9,E8, FF JMP Ahead Jump to ahead1018 09,05,06,0A TABLE 09 05 06 0A
HLT Stop the program.
DIRECTION CONTROL OF STEPPER MOTOR
PROGRAM: ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C6,C3, 20 MOV BL, 20 Copy the data 20h to BL-register.
1003 C7,C7,3F,10 MOV DI, 103F Copy the data 103F to DI-reg
1007 E8 1B 00 CALL 1025 Call subroutine program100A FE CB DEC BL Decrement BL-register100C 75 F5 JNZ 1003 Jump on no zero to label 1003100E E8 2A 00 CALL 103B Call subroutine program1011 C6 C3 20 MOV BL, 20 Copy the data 20 to BL-register1014 C7 C7 43
10MOV DI, 1043 Copy the data 1043 to DI-reg
69
1018 E8 0A 00 CALL 1025 Call subroutine program101B FE CB DEC BL Decrement BL-register101D 75 75 JNZ 1014 Jump on no zero to 1014101F E8 19 00 CALL 103B Call subroutine program1022 E9 DB FF JMP 1000 Jump to label 10001025 C6 C1 04 MOV CL, 04 Copy the data 04 to CL-register1028 8A 05 MOV AL, [DI] Copy the content of DI to AL-
register102A E6 C0 OUT C0, AL Assign the content of AL to
Output 102C C7 C2 10
10MOV DX, 1010 Copy the content 1010 to Dx-
register1030 4A DEC DX Decrement DX-register1031 75 FD JNZ 1030 Jump on no zero to label 10301033 47 INC DI Increment DI-register1034 E2 F2 LOOP 1028 Loop to label 10281036 C3 RET Return from subroutine1037 C7,C2,FF,FF MOV DX, 0FFFF Copy FFFF in DX-register103B 4A DEC DX Decrement DX-register103C 75 FD JNZ 103B Jump on no zero 103B103E C3 RET Return from subroutine103F 09,05,06,0A FORWARD DATA To rotate in forward direction1043 0A,06,05, 09 REVERSE DATA To rotate in Reverse direction
1047 HLT Stop the program.
VIVA QUESTIONS:
1. What MASM is?2. What do u mean by emulator?3. What is SI, DI and their functions?4. What do you mean by IVT in 8086?5. Why we indicate FF as 0FF in program?6. .stack 100 means?7. What do you mean by 20 dup (0)?8. What is 8087? How it is different from 8086?9. What do you mean by debugger?10. When divide overflow error occurs?
RESULT: Thus an assembly language Program to run the stepper motor in both forward and reverse direction with delay was executed and its output was verified.
Ex. No: 9 DIGITAL CLOCK
70
AIM:To write and execute an assembly language Program for digital clock in 8086 kit.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. Traffic Light Controller Interface board ----1 3. Power card ----14. Keyboard ----1
5. PC with Intel/AMD Processor----1
PROGRAM:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 CALL CONVERT Call subroutine for conversion1003 CALL DISPLAY Call subroutine for Display1006 DELAY: MOV AL,0B0H Copy the data 0B0H to AL-reg1009 OUT 16H,AL Configure output port100B MOV CL,07H Copy the data 07H to AL-reg100E S2: MOV AL,88H Copy 88H to AL-register1011 OUT 14H,AL Configure output port1013 MOV AL,80H Copy the data 80H to AL-reg1016 OUT 14H,AL Configure output port1018 S1: NOP No operation1019 NOP No operation101A NOP No operation101B NOP No operation101C IN AL,14H Copy 14H to AL-reg101E MOV DL,AL Copy the Content of AL reg to
DL-reg.1020 IN AL,14H Copy 14H to AL-reg1022 OR AL,DL OR the contents of AL with DL1024 JNZ S1 Jump on no zero to S11026 DEC CL Decrement CL-register1028 JNZ S2 Jump on no zero to S2102A MOV SI,1500H Copy SI-reg with data 1500H102E MOV AL,[SI] Copy the content of SI-reg to AL1030 INC AL Increment AL-register1032 MOV [SI],AL Copy the content of AL reg to SI-
reg 1034 CMP AL,3CH Compare AL with 3CH1037 JNZ START Jump on no zero to start1039 MOV AL,00H Copy AL with data 00H103C MOV [SI],AL Copy the content of Al to SI-reg103E INC SI Increment SI-register103F MOV AL,[SI] Copy the content of SI-reg to AL1041 INC AL Increment AL-register1043 MOV [SI],AL Copy the content of AL reg to SI-
reg 1045 CMP AL,3CH Compare AL with 3CH1048 JNZ START Jump on no zero to start
71
104A MOV AL,0 Copy AL with data 00H104D MOV [SI],AL Copy the content of AL reg to SI-
reg104F INC SI Increment SI-register1050 MOV AL,[SI] Copy the content of SI-reg to AL1052 INC AL Increment AL-register1054 MOV [SI],AL Copy the content of AL reg to SI-
reg 1056 CMP AL,18H Compare AL with 18H1059 JNZ START Jump on no zero to start105B MOV AL,0 Copy AL with data 00H105E MOV [SI],AL Copy the content of AL reg to SI-
reg1060 JMP START Jump to start1063 DISPLAY: MOV AH,06H Copy 06H to AH-register1066 MOV DX,1600H Copy 1600H to DX-register106A MOV CH,01H Copy 01H to CH-register106D MOV CL,0H Copy 00H to CL-register1070 INT 5 Call Interrupt1072 RET Return from subroutine1073 CONVERT: MOV SI,1500H Copy 1500H to SI-register1077 MOV BX,1608H Copy 1608H to BX-register107B MOV AL,24H Copy 24H to AL-register107E MOV [BX],AL Copy the content of AL-reg to BX1080 MOV AL,[SI] Copy the content of SI-reg to AL1082 MOV AH,0 Copy AL with data 00H1085 MOV DH,0AH Copy the data 0AH to DH-register1088 DIV DH Divide DH-reg by AH reg108A ADD AH,30H Add the data 30H with AH-reg108D DEC BX Decrement BX-register108E MOV [BX],AH Copy the data from AH to DH-
reg1090 DEC BX Decrement BX-register1091 ADD AL,30H Add the data 30H with AL-reg1094 MOV [BX],AL Copy the data from AL to BX-reg1096 DEC BX Decrement BX-register1097 MOV AL,3AH Copy the 3AH to AL-reg109A MOV [BX],AL Copy the data from AL to BX-reg109C DEC BX Decrement BX-register109D INC SI Increment SI-register109E MOV AL,[SI] Copy the content of SI-reg to AL10A0 MOV AH,0 Copy the data 0 to AH-reg10A3 MOV DH,0AH Copy the data 0AH to DH-register10A6 DIV DH Divide DH-reg by AH reg10A8 ADD AH,30H Add the data 30H with AH-reg10AB MOV [BX],AH Copy the data from AH to BX-
reg10AD DEC BX Decrement BX-register
72
10AE ADD AL,30H Add the data 30H with AL-reg10B1 MOV [BX],AL Copy the data from AL to BX-reg10B3 DEC BX Decrement BX-register10B4 MOV AL,3AH Copy the 3AH to AL-reg10B7 MOV [BX],AL Copy the data from AL to BX-reg10B9 DEC BX Decrement BX-register10BA INC SI Increment SI-register10BB MOV AL,[SI] Copy the content of SI-reg to AL10BD MOV AH,0 Copy the data 0 to AH-reg10C0 MOV DH,0AH Copy the data 0AH to DH-register10C3 DIV DH Divide DH-reg by AH reg10C5 ADD AH,30H Add the data 30H with AH-reg10C8 MOV [BX],AH Copy the data from AH to BX-
reg10CA DEC BX Decrement BX-register10CB ADD AL,30H Add the data 30H with AL-reg10CE MOV [BX],AL Copy the data from AL to BX-reg10D0 RET Return from subroutine10D1 GETC: IN AL,02H Copy 02H to AL-reg10D3 AND AL,0FFH AND data AL with 0FFH10D6 CMP AL,0F0H Compare AL with 0F0H10D9 JNE GETC If no zero jump to getc
OUTPUT:1500- 00 SECONDS1501- 00 MINUTES1502- 09 HOURS
VIVA QUESTIONS:
1. What is ASCII code?2. What is assembler?3. What is linker?4. What is Loader?5. What is Debugger?6. Difference between Assembly and high level language.7. Name an IC used to display time, date? 8. What is I2C?9. What is Machine language?10. Which is faster? Machine language or high level language.
RESULT:Thus an assembly language Program for digital clock in 8086 kit was written and executed.
Ex.No:10 KEYBOARD AND DISPLAY
73
AIM:ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 BE 00 START MOV SI,1200H Initialize array
1003 B9 0F MOV CX,000FH Initialize array size
1006 B0 10 MOV AL,10 Store the control word for display mode
1008 E6 C2 OUT C2,AL Send through output port
100A B0 CC MOV AL,CC Store the control word to clear display
100C E6 C2 OUT C2,AL Send through output port
100E B0 90 MOV AL,90 Store the control word to write display
1010 E6 C2 OUT C2,AL Send through output port
1012 8A 04 NEXT MOV AL,[SI] Get the first data
1014 E6 C0 OUT C0,AL Send through output port
1016 E8 E7 CALL DELAY Give delay
1019 46 INC SI Go & get next data
101A E2 F6 LOOP NEXT Loop until all the data’s have been taken
101C EB E2 JMP START Go to starting location
1500 BA FF A0 DELAY MOV DX,0A0FFH Store 16bit count value
1503 4A LOOP1 DEC DX Decrement count value
1504 74 FD JNZ LOOP1 Loop until count values becomes zero
1506 C3 RET Return to main programTo write and execute an assembly language Program to display the rolling message “HELP
US “in the display.
APPARATUS: 1. 8086 microprocessor kit/MASM ----1 2. 8279 Interface board ----1 4. Power card ----15. Keyboard ----16. PC with Intel/AMD Processor----1
ALGORITHM:Display of rolling message “HELP US “1. Initialize the counter2. Set 8279 for 8 digit character display, right entry3. Set 8279 for clearing the display 4. Write the command to display5. Load the character into accumulator and display it6. Introduce the delay7. Repeat from step 1.
PROGRAM:
LOOK-UP TABLE:
74
1200 98 68 7C C8
1204 FF 1C 29 FF
OUTPUT:
MEMORY LOCATION
7-SEGMENT LED FORMAT HEX DATAd c b a dp e g f
1200H 1 0 0 1 1 0 0 0 981201H 0 1 1 0 1 0 0 0 681202H 0 1 1 1 1 1 0 0 7C1203H 1 1 0 0 1 0 0 0 C81204H 1 1 1 1 1 1 1 1 FF1205H 0 0 0 0 1 1 0 0 1C1206H 0 0 1 0 1 0 0 1 291207H 1 1 1 1 1 1 1 1 FF
VIVA QUESTIONS:
1. What are the types of interfacing?2. Compare memory interfacing and IO interfacing.3. What is the difference between memory mapped IO and IO mapped IO
interfacing?4. What IC 8279 is?5. What are the tasks involved in keyboard interface?6. What is scanning in keyboard and what is scan time?7. What is the difference between 2-key and n-key rollover?8. What is the control registers available in 8279?9. What is key debouncing?10. What are the command words available in 8279?
RESULT:
Thus the rolling message “HELP US” is displayed using 8279 interface kit.
Ex.No:11 PRINTER INTERFACE
75
AIM: To write and execute an assembly language program for printer interface with
microprocessor 8086 kit and to print a single character “A”.
APPARATUS REQUIRED:
1. 8086 microprocessor kit/MASM ----2 2. Centronics printer interface board ----1 3. Power card ----1
4. Keyboard ----15. PC with Intel/AMD Processor----1
PROGRAM:00C8 DATA EQU 00C8H00D0 CONTL EQU 00D0H 00C0 STUS EQU 00C0H
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 Org 1000h Starting address of the program1000 B0 05 MOV AL,05H Load the AL-reg with value 05H
1002 E6 D0 OUT CONTL,AL Copy the contents of AL-reg to CONTL
1004 E4 C0 IN AL,STUS Load the contents of STUS to AL-register.
1006 24 20 AND AL,20H Logically AND the contents of AL-reg with 20H
1008 3C 20 CMP AL,20H Compare the contents of AL-reg with 20H
100A 75 44 JNZ ERR Jump on no-zero to label ERR
VIVA QUESTIONS:
1. What are the different types of printer interfacing techniques available?2. What type of interface is 8295?3. What are the different types of printers available?4. What is the expansion of LPT?5. What is meant by serial and parallel interface?6. What is g in the output of the program?7. What does u mean by directives?8. What does d mean by directives?9. Whether 8086 is compatible with Pentium processor10. Types of procedure?
RESULT: Thus an assembly language program for printer interface to print a single character “A”
was performed and its output was verified.
76
Ex.No:12A SERIAL INTERFACE
AIM: To write and execute assembly language program to establish serial communication
between two 8086 kits.
APPARATUS REQUIRED: 1. 8086 microprocessor kit/MASM ----2 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Initialize 8253 and 8251 to check the transmission and reception of a character2. Initialize8253 to give an output of 150 KHz at channel 0 which will give a 9600 baud rate of 8251.3. The command word and mode word is written to the 8251 to set up for subsequent operations 4. The status word is read from the 8251 on completion of a serial I/O operation, or when the host CPU is checking the status of the device before starting the next I/O operation
PROGRAM:
TRANSMITTER END:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C6,00,15
MOV SI,1500H Initialize Si-register with address 1500H
1004 C6,C0,36 MOV AL,36H Copy 36H data to AL-register1007 E6,16 OUT 16H,AL Configure output port1009 C6,C0,40 MOV AL,40H Copy the data 40H to AL-register100C E6,10 OUT 10H,AL Configure output port100E C6,C0,01 MOV AL,01H Copy 01H data to AL-register1011 E6,10 OUT 10H,AL Configure output port1013 C6,C1,05 RELOAD: MOV CL,05H Count value for number of data’s1016 E4,0A CHECK: IN AL,0AH Configure input port to transmit data1018 80,E0,04 AND AL,04H AND the contents of AL-reg with 04H101B 74,F9 JZ CHECK If zero Jump to Label Check101D E4,08 MOV AL,[SI] Copy the content of SI-reg to AL-register101F 88,04 OUT 08H,AL Configure output port1021 46 INC SI Increment SI-register1022 80,F8,3F CMP AL,3FH Compare AL-reg with 3FH data1025 75,EC JNZ RELOAD If no zero jump to label reload1027 FE,C9 DEC CL Decrement CL-register1029 75,EB JNZ CHECK If CL not zero jump to label Check102B CD,02 INT 02 Call interrupt routine
77
RECEIVER END:ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C6,00,15
MOV SI,1500H Initialize Si-register with address 1500H
1004 C6,C0,36 MOV AL,36H Copy 36H data to AL-register1007 E6,16 OUT 16H,AL Configure output port1009 C6,C0,40 MOV AL,40H Copy the data 40H to AL-register100C E6,10 OUT 10H,AL Configure output port100E C6,C0,01 MOV AL,01H Copy 01H data to AL-register1011 E6,10 OUT 10H,AL Configure output port1013 C6,C1,05 RELOAD: MOV CL,05H Count value for number of data’s1016 E4,0A CHECK: IN AL,0AH Configure input port to transmit data1018 80,E0,02 AND AL,02H AND the contents of AL-reg with 02H101B 74,F9 JZ CHECK If zero Jump to Label Check101D E4,08 MOV AL,[SI] Copy the content of SI-reg to AL-register101F 88,04 OUT 08H,AL Configure output port1021 46 INC SI Increment SI-register1022 80,F8,3F CMP AL,3FH Compare AL-reg with 3FH data1025 75,EC JNZ RELOAD If no zero jump to label reload1027 FE,C9 DEC CL Decrement CL-register1029 75,EB JNZ CHECK If CL not zero jump to label Check102B CD,02 INT 02 Call interrupt routine
OUTPUT:
INPUT(Transmitter end) OUTPUT (Receiver end)Address Data Address Data
1500 11 1500 111501 22 1501 221502 33 1502 331503 44 1503 441504 3F 1504 3F
RESULT:
Thus an assembly language program to establish a serial communication between two 8086 kits was implemented and its output was verified.
78
EXP. NO: 12B PARALLEL INTERFACE
AIM: To write and execute assembly language program to establish parallel communication
between two 8086 kits.
APPARATUS REQUIRED:1. 8086 microprocessor kit/MASM ----1 2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Initialize accumulator to hold control word2. store control word in control word register3. Read data port A.4. Store data from port A in memory5. Place contents in port B
PROGRAM:
TRANSMITTER:ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 C6, C0,82 MOV AL,82H Copy 82H to AL-register1003 E6,26 OUT 26H,AL Configure output port1005 C6,C0,3F MOV AL,3FH Copy 3F to AL-register1008 E6,20 OUT 20H,AL Configure output port100a E4,22 Loop: IN AL,22H Configure AL-register100c 80,E8,3f SUB AL,3FH Subtract 3F from AL-register100f 75,F9 JNZ LOOP Jump on no zero to loop1011 C6,C0,24 MOV AL,24H Copy 24H to AL-register1014 E6,20 OUT 20H,AL Configure output port1016 E8,02,00 CALL DELAY Call delay program1019 CD,02 INT 02 Call interrupt routine101b C6,C3,05 Delay: MOV BL,05H Copy 05H to BL-register101e C6,C2,FF Lion: MOV DL,0FFH Copy FFH to DL-register1021 FE,CA L2: DEC DL Decrement DL-register1023 75,F9 JNZ L2 Jump on no zero to Label L21025 FE,CB DEC BL Decrement BL-register1027 75,F5 JNZ LION Jump on no zero to lion1029 C3 RET Return from subroutine
RECEIVER:ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 C6 C0 90 MOV AL,90H Copy 90H to AL-register1003 E6 26 OUT 26H,AL Configure output port
1005 E4 20 CHECK: IN AL,20H Configure AL-register1007 80 E8 3F SUB AL,3FH Subtract 3F from AL-register
100A 75 F9 JNZ CHECK Jump on no zero to loop
79
100C C6 C0 3F MOV AL,3FH Copy 3FH to AL-register
100F E6 22 OUT 22H,AL Configure output port1011 C6 C1 08 MOV CL,08H Copy 08H to AL-register
1014 E8 12 00 CALL DELAY Call delay program1017 C7,C6,00,12 MOV SI,1200H Copy 1200H TO SI-register
101b E4 20 L1: IN AL,20H Configure AL-register101d 88,04 MOV [SI],AL copy content of AL-register to
SI-register101F E8 07 00 CALL DELAY Call delay program1022 46 INC SI Increment SI-register
1023 FE C9 DEC CL Decrement CL-register1025 75 F4 JNZ L1 Jump on no-zero to L1
1027 CD 02 INT 02 Call interrupt routine1029 C6 C3 05 DELAY: MOV BL,05H Copy 05H to BL-register
102C C6 C2 FF LION: MOV DL,0FFH Copy FFH to DL-register102F FE CA L2: DEC DL Decrement DL-register1031 75 FC JNZ L2 Jump on no zero to L21033 FE CB DEC BL Decrement BL-register1035 75 F5 JNZ LION Jump on no-zero to Lion1037 C3 RET Return from subroutine1038 C3 RET Return from subroutine
OUTPUT:
INPUT(Transmitter end) OUTPUT (Receiver end)Address Data Address Data
1200 24 1200 24
VIVA QUESTIONS:
1. What is Baud rate?2. What is the difference between synchronous and asynchronous communication?3. What is the expansion of RS?4. What is the expansion of USART?5. What is the role of RS-232?6. What type of interface is 8255?7. What are the different types of modes in 8255?8. What are the features of mode 0 in 8255?9. What are the features of mode 1 in 8255?10. What are the features of mode 2 in 8255?
RESULT:
Thus an assembly language program to establish a parallel communication between two 8086 kits was implemented and its output was verified.
80
EXP. NO: 13A INTERFACING ANALOG TO DIGITAL CONVERTER
AIM: To write and execute an assembly language program to convert an analog signal into a digital
signal using an ADC interfacing.
APPARATUS REQUIRED:1. 8086 microprocessor kit/MASM ----1 2. ADC Interface board ----1 4. Power card ----15. Keyboard ----16. PC with Intel/AMD Processor----1
ALGORITHM:(i) Select the channel and latch the address.(ii) Send the start conversion pulse.(iii) Read EOC signal.(iv) If EOC = 1 continue else go to step (iii)(v) Read the digital output.(vi) Store it in a memory location.
PROGRAM:ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 B0 10 MOV AL,00 Load accumulator with value for ALE high
1002 E6 C8 OUT 0C8H,AL Send through output port
1004 80 18 MOV AL,08 Load accumulator with value for ALE low
1006 E6 C8 OUT 0C8H,AL Send through output port
1008 B0 01 MOV AL,01 Store the value to make SOC high in the accumulator
100A E6 D0 OUT 0D0H,AL Send through output port
100C B0 00 MOV AL,00
Introduce delay100E B0 00 MOV AL,00
1010 B0 00 MOV AL,00
1012 B0 00 MOV AL,00 Store the value to make SOC low the accumulator
1014 E6 D0 OUT 0D0H,AL Send through output port
1016 E4 D8 L1 IN AL, 0D8H
Read the EOC signal from port & check for end of conversion
1018 24 01 AND AL,01
101A 3C 01 CMP AL,01
101C 75 F8 JNZ L1 If the conversion is not yet completed, read EOC signal from port again
101E E4 C0 IN AL,0C0H Read data from port
1020 BB 00 11 MOV BX,1100 Initialize the memory location to store data
1022 88 07 MOV [BX],AL Store the data
81
1024 F4 HLT Stop
OUTPUT:
ANALOG VOLTAGE DIGITAL DATA ON LED DISPLAY
HEX CODE IN MEMORY LOCATION
5 1111 1111 FF3.84 0000 0111 073.83 1001 0010 923.79 0111 0100 743.76 0100 0011 43
0 0000 0000 00
RESULT:Thus the ADC was interfaced with 8086 and the given analog inputs were converted
into its digital equivalent.
82
EXP. NO: 13B INTERFACING DIGITAL TO ANALOG CONVERTER
AIM: To write and execute an assembly language program for digital to analog conversion.
APPARATUS REQUIRED:1. 8086 microprocessor kit/MASM ----1 2. DAC Interface board ----1 3. Power card ----14. Keyboard ----15. PC with Intel/AMD Processor----1
ALGORITHM:Square Waveform:(i) Send low value (00) to the DAC.(ii) Introduce suitable delay.(iii) Send high value to DAC.(iv)Introduce delay.(v) Repeat the above procedure.Saw-tooth waveform:(i) Load low value (00) to accumulator.(ii) Send this value to DAC.(iii) Increment the accumulator.(iv)Repeat step (ii) and (iii) until accumulator value reaches FF.(v) Repeat the above procedure from step 1.Triangular waveform:(i) Load the low value (00) in accumulator.(ii) Send this accumulator content to DAC.(iii) Increment the accumulator.(iv)Repeat step 2 and 3 until the accumulator reaches FF, decrement the
accumulator and send the accumulator contents to DAC.(v) Decrementing and sending the accumulator contents to DAC.(vi)The above procedure is repeated from step (i)
PROGRAM: SQUARE WAVEADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 B0 00 L2 MOV AL,00H Load 00 in accumulator
1002 E6 C8 OUT C8,AL Send through output port
1004 E8 09 00 CALL L1 Give a delay
1007 B0 FF MOV AL,FFH Load FF in accumulator
1009 E6 C8 OUT C8,AL Send through output port
100B E8 02 00 CALL L1 Give a delay
100E EB F0 JMP L2 Go to starting location
1010 B9 FF C5 L1 MOV CX,05FFH Load count value in CX register
1013 E2 FE L3 LOOP L3 Decrement until it reaches zero
1015 C3 RET Return to main program
83
PROGRAM: SAWTOOTH WAVEADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 B0 00 L2 MOV AL,00H Load 00 in accumulator
1002 E6 C0 L1 OUT C0,AL Send through output port
1004 FE C0 INC AL Increment contents of accumulator
1006 75 FA JNZ L1 Send through output port until it reaches FF
1008 EB F6 JMP L2 Go to starting location
PROGRAM: TRIANGULAR WAVEADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 B0 00 L3 MOV AL,00H Load 00 in accumulator1002 E6 C8 L1 OUT C8,AL Send through output port1004 FE C0 INC AL Increment contents of
accumulator1006 75 F8 JNZ L1 Send through output port until
it reaches FF1008 B0 FF MOV AL,0FFH Load FF in accumulator100A E6 C8 L2 OUT C8,AL Send through output port100C FE C0 DEC AL Decrement contents of
accumulator100E 75 F8 JNZ L2 Send through output port until
it reaches 001110 EB EA JMP L3 Go to starting location
OUTPUT:
WAVEFORM GENERATIONWAVEFORMS AMPLITUDE TIME PERIOD
Square wave 10v 1msSaw-tooth wave 10v 1.4msTriangular wave 10v 3.2ms
VIVA QUESTIONS:
1. What are the different types of ADC?2. What is meant by conversion time?3. What are the different types of ADC techniques available?4. Name the ADC IC available using serial interface technique?5. Name the ADC IC available using parallel interface technique?6. What are the different types of DAC techniques available?7. Name the DAC IC available8. What is resolution?9. What is settling time?10. What is range of operation in DAC?
RESULT:
Thus the DAC was interfaced with 8086 and different waveforms have been generated.
84
8051 MICROCONTROLLER
85
EXP. NO: 14A ARITHMETIC OPERATIONS USING 8051
AIM: To write and execute an assembly language program for Add, subtract, multiply and division of two 8-bit numbers using 8051.
APPARATUS: 1. 8051 microcontroller kit ----1
2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM:1. Load the First Data in A-register. 2. Load the Second Data in B-register.3. Add the two data with carry.4. Store the sum in memory location.5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 74,05 MOV A,#data Load data 1 in accumulator.
4102 75,F0,05 MOV B,#data Load data 2 in B-register
4105 35,F0 ADDC A,B Add the contents of accumulator and B-reg with carry.
4107 90,45,00 MOV DPTR,#4500H Initialize DPTR with address 4500H
410A F0 MOVX @ DPTR,A Store the result in 4500H
410B 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUTRegister Data Address DataA-register 02H 4500 06HB-register 04H
SUBTRACTION
ALGORITHM:1. Load the First Data in A-register. 2. Load the Second Data in B-register.3. Subtract the two data with borrow.4. Store the sum in memory location.5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 74,05 MOV A,#data Load data 1 in accumulator.
86
4102 75,F0,04 MOV B,#data Load data 2 in B-register
4105 95,F0 SUBB A,B Subtract the contents of B-reg from accumulator with borrow.
4107 90 45 00 MOV DPTR,#4500H Initialize DPTR with address 4500H
410A F0 MOVX @ DPTR,A Store the result in 4500H
410B 80, FE STOP: SJMP STOP Stop the program
OUTPUT: INPUT OUTPUT
Register Data Address DataA-register 05H 4500 04HB-register 01H
MULTIPLICATION
ALGORITHM:1. Get the multiplier in the accumulator. 2. Get the multiplicand in the B register. 3. Multiply A with B. 4. Store the product in memory location.5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 74,05 MOV A,#data Load data 1 in accumulator.
4102 75,F0,05 MOV B,#data Load data 2 in B-register
4105 A4 MUL AB A*B, Higher byte of result in B and lower byte of result in A.
4106 90,45,00 MOV DPTR,#4500H Initialize DPTR with address 4500H
4109 F0 MOVX @ DPTR,A Store the LSB in 4500H
410A A3 INC DPTR Increment Data pointer
410B E5,F0 MOV A,B Copy the content of B-reg to A-register.
410D F0 MOVX @ DPTR,A Store the MSB in 4501H
410E 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUTREGISTER DATA ADDRESS DATA
A 5 4500 19HB 5
87
DIVISION
ALGORITHM: 1. Get the Dividend in the accumulator. 2. Get the Divisor in the B register. 3. Divide A by B. 4. Store the Quotient and Remainder in memory.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 74,data1 MOV A,#data 1 Load data 1 in accumulator.
4102 75,data2 MOV B,#data 2 Load data 2 in B-register
4104 84 DIV AB Divide. Remainder in A and quotient in B
4105 90,45,00 MOV DPTR,#4500H Initialize DPTR with address 4500H
4108 F0 MOVX @ DPTR,A Store the Remainder in 4500H
4109 A3 INC DPTR Increment Data pointer
410A E5,F0 MOV A,B Copy the content of B-reg to A-register.
410C F0 MOVX @ DPTR,A Store the quotient in 4501H
410D 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUTREGISTER DATA ADDRESS DATAA-Register 05 4500 01(quotient)B-Register 03 4501 02(remainder)
RESULT:
Thus an assembly language program for Division of two 8-bit numbers and 16-bit numbers using 8051 was performed and its output was verified.
88
EXP. NO: 14B LOGICAL OPERATIONS USING 8051
AIM: To write and execute an assembly language program to perform logical operations using 8051.
APPARATUS: 1. 8051 microcontroller kit ----1
2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM: 1. Get the Data 1 in the R0-register. 2. Get the Data 2 in the A register. 3. Logical AND, OR, XOR A with R0. 4. Store the result in memory.
5. Stop the program.
PROGRAM: AND OPERATION
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 78,14 MOV R0,#DATA 1 Load data 1 in R0-reg.
4102 74,12 MOV A,#DATA 2 Load data 2 in A-register
4104 58 ANL A,R0 Logical AND the contents of A-reg with R0-register.
4105 90,45,00 MOV DPTR,#4500H Initialize DPTR with address 4500H
4108 F0 MOVX @ DPTR,A Store the result in 4500H
4100 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUTREGISTER DATA ADDRESS DATAR0-Register 14 4500 10A-Register 12
PROGRAM: OR OPERATION
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 78,14 MOV R0,#DATA 1 Load data 1 in R0-reg.
4102 74,12 MOV A,#DATA 2 Load data 2 in A-register
4104 58 ORL A,R0 Logical OR the contents of A-reg with R0-register.
4105 90,45,00 MOV DPTR,#4500H Initialize DPTR with address 4500H
4108 F0 MOVX @ DPTR,A Store the result in 4500H
89
4100 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUTREGISTER DATA ADDRESS DATAR0-Register 14 4500 16A-Register 12
PROGRAM: XOR OPERATION
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 78,14 MOV R0,#DATA 1 Load data 1 in R0-reg.
4102 74,12 MOV A,#DATA 2 Load data 2 in A-register
4104 68 XRL A,R0 Logical EX-OR the contents of A-reg with R0-register.
4105 90,45,00 MOV DPTR,#4500H Initialize DPTR with address 4500H
4108 F0 MOVX @ DPTR,A Store the result in 4500H
4100 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUTREGISTER DATA ADDRESS DATAR0-Register 14 4500 06A-Register 12
VIVA QUESTIONS:
1. Difference between microprocessor and microcontroller.2. Explain DJNZ instructions of Intel 8051 microcontroller? 3. Why 8051 is called 8 bit microcontroller?4. What is the difference between Harvard and Newman architecture?5. Intel 8051 follows which architecture: Harvard or Newman?6. How much on-chip RAM is available?7. What is special function registers?8. What are the different industrial applications of micro controllers?9. What is the difference between the CISC and RISC processors? 10. List the addressing modes of 8051.
RESULT:
90
Thus an assembly language program for logical operations using 8051 was performed and its output was verified.
91
EXP. NO: 15 SQUARE OF A NUMBER USING 8051
AIM: To write and execute an assembly language program to find the square, cube and 2’s complement of a number using 8051.
APPARATUS: 1. 8051 microcontroller kit ----1
2. Power card ----13. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM: 1. Get the Data in the R0-register. 2. Get the same Data in the B register. 3. Multiply A and B. 4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 90, 45, 00 MOV DPTR,#4200H Initialize data pointer with address 4200H
4103 E0 MOVX A,@DPTR Copy the content of data from address 4200H to accumulator
4104 F8 MOV R0,A Copy the content of data from R0-reg to accumulator
4105 F5,F0 MOV B,A Copy the content of data from A-reg to B-register.
4107 A4 MUL AB Multiply AB
4108 A3 INC DPTR Increment data pointer to store the result
4109 F0 MOVX @DPTR,A Store the result in 4500H
410A E5,F0 MOV A,B Copy the content of data from B-reg to A-register.
410C A3 INC DPTR Increment data pointer to store the result
410D F0 MOVX @ DPTR,A Store the result in 4501H
410E 80, FE STOP: SJMP STOP Stop the program
OUTPUT:INPUT OUTPUT
ADDRESS DATA ADDRESS DATA4200 FF 4201 01
4202 FE
92
CUBE OF A NUMBER USING 8051
ALGORITHM: 1. Get the Data in the R0-register. 2. Get the same Data in the B register. 3. Multiply A and B. 4. Store the result in memory. 5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 90 42 00 MOV DPTR,#4200H Initialize data pointer with address 4200H
4103 E0 MOVX A,@DPTR Copy the content of data from address 4200H to accumulator
4104 F8 MOV R0,A Copy the content of data from A-reg to R0-register.
4105 F5,F0 MOV B,A Copy the content of data from A-reg to B-register.
4107 A4 MUL AB Multiply AB
4108 C0,F0 PUSH B Store the content of B-reg in stack
410A F5,F0 MOV B,A Copy the content of data from A-reg to B-register.
410C E8 MOV A,R0 Copy the content of data from R0-reg to accumulator
410D A4 MUL AB Multiply AB
410E A3 INC DPTR Increment data pointer to store the result
410F F0 MOVX @DPTR,A Copy the content of data from address 4201H to accumulator
4110 AA,F0 MOV R2,B Copy the content of data from R2-reg to B-register
4112 D0,F0 POP B Retrieve the data from stack
4114 E8 MOV A,R0 Copy the content of data from R0-reg to accumulator
4115 A4 MUL AB Multiply AB
4116 2A ADD A,R2 Add the contents of A and R2 register and store the data in A-reg.
4117 A3 INC DPTR Increment data pointer to store the result
4118 F0 MOVX @ DPTR,A Store the result in 4500H
4119 E5,F0 MOV A,B Copy the content of data from B-reg to A-register.
411B A3 INC DPTR Increment data pointer to store the result
93
411C F0 MOVX @DPTR,A Copy the content of data from address 4202H to accumulator
411D 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
4200 56 4201 984202 B44203 09
2’S COMPLEMENT OF A NUMBER USING 8051
ALGORITHM: 1. Get the Data in the R0-register. 2. Get the same Data in the B register. 3. Multiply A and B. 4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 90 42 00 MOV DPTR,#4200H Initialize data pointer with address 4200H
4103 E0 MOVX A,@DPTR Copy the content of data from address 4200H to accumulator
4104 F4 CPL A Complement the contents of Accumulator
4105 24,01 ADD A,#01H Add the contents of Accumulator and 01 data and store the data in A-reg.
4107 A3 INC DPTR Increment data pointer to store the result
4108 F0 MOVX @DPTR,A Copy the content of data from address 4201H to accumulator
4109 80, FE STOP: SJMP STOP Stop the program
OUTPUT:INPUT OUTPUT
ADDRESS DATA ADDRESS DATA4200 05 4201 0BH
94
VIVA QUESTIONS:
1. Give the format of PSW register of 8051.2. What is the use of PCON register?3. Give the interrupt priorities of 8051.4. What is the significance of DPTR?5. Draw the format of TMOD register of 80516. List the modes of Timer in 8051.7. Draw the format of TCON register of 80518. Draw the format of IE register.9. Draw the format of IP register10. Draw the format of SCON register of 8051
RESULT:
Thus an assembly language program to find square, cube and 2’s complement of a number using 8051 was performed and its output was verified.
95
EXP. NO: 16 UNPACKED BCD TO ASCII USING 8051
AIM: To write and execute an assembly language program to convert unpacked BCD to ASCII using 8051.APPARATUS:
1. 8051 microcontroller kit ----1 2. Power card ----1
3. Keyboard ----14. PC with Intel/AMD Processor----1
ALGORITHM: 1. Get the Data in the R0-register. 2. Get the same Data in the B register. 3. Multiply A and B. 4. Store the result in memory.
5. Stop the program.
PROGRAM:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
4100 90 42 00 MOV DPTR,#4200H Initialize data pointer with address 4200H
4103 E0 MOVX A,@DPTR Copy the content of data from address 4200H to accumulator
4104 F5,F0 MOV B,A Copy the content of data from A-reg to B-register.
4106 55,0F ANL A, 0FH AND the contents of A-reg with 0F and store the data in A-register.
4108 44,30 ORL A,#30H Add the contents of Accumulator and 30 data and store the data in A-reg.
410A A3 INC DPTR Increment data pointer to store the result
410B F0 MOVX @DPTR,A Copy the content of data from address 4201H to accumulator
410C E5,F0 MOV A,B Copy the content of data from B-reg to A-register.
410E 55,F0 ANL A,F0H AND the contents of A-reg with F0 and store the data in A-register
4110 03 RR A Rotate right accumulator
4111 03 RR A Rotate right accumulator
4112 03 RR A Rotate right accumulator
4113 03 RR A Rotate right accumulator
4114 44,30 ORL A,#30H Add the contents of Accumulator and 30 data and store the data in A-reg.
96
4116 A3 INC DPTR Increment data pointer to store the result
4117 F0 MOVX @DPTR,A Copy the content of data from address 4201H to accumulator
4118 80, FE STOP: SJMP STOP Stop the program
OUTPUT:
INPUT OUTPUTADDRESS DATA ADDRESS DATA
4200 29 4201 394202 32
VIVA QUESTIONS:
1. How will you configure ports as input and output port?2. What are the flags supported by 8051 controller?3. What is meant by Power-on- Reset in 8051 controller?4. What are the different groups of instructions supported by 8051?5. What is the need of pull up registers in 8051?6. How many bytes of internal RAM and ROM supported by 8051 micro controller?7. What are the alternative functions of port 3 of 8051?8. What are the uses of scratch pad area of internal RAM of 8051?9. Write a program to find the 2’s complement using 8051?10. How to calculate the execution time for instruction in 8051?
RESULT:
Thus an assembly language program for conversion of Unpacked BCD to ASCII number using 8051 was performed and its output was verified.
97
Recommended