0% found this document useful (0 votes)
29 views

MPMC Lab Manual - Reference

The document contains an assembly language program to perform basic arithmetic operations like addition, subtraction, multiplication and division on a 8086 microprocessor. It loads two 16-bit operands into registers, performs the arithmetic operation and stores the result in memory. It provides the assembly code using MASM assembler and also the machine code for implementing the programs on a 8086 microprocessor kit. The programs demonstrate performing 16-bit addition, subtraction and multiplication and 32-bit by 16-bit division operations on the 8086 microprocessor.

Uploaded by

sham kevin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

MPMC Lab Manual - Reference

The document contains an assembly language program to perform basic arithmetic operations like addition, subtraction, multiplication and division on a 8086 microprocessor. It loads two 16-bit operands into registers, performs the arithmetic operation and stores the result in memory. It provides the assembly code using MASM assembler and also the machine code for implementing the programs on a 8086 microprocessor kit. The programs demonstrate performing 16-bit addition, subtraction and multiplication and 32-bit by 16-bit division operations on the 8086 microprocessor.

Uploaded by

sham kevin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 77

Dr.N.G.P.

INSTITUTE OF TECHNOLOGY
(Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai)

Recognized by UGC & Accredited by NAAC and NBA

Coimbatore, Tamil Nadu

EC8681 - MICROPROCESSORS AND


MICROCONTROLLERS LABORATORY

DEPARTMENT OF ELECTRICAL AND


ELECTRONICS ENGINEERING
Dr.N.G.P. INSTITUTE OF TECHNOLOGY
Dr.N.G.P.-Kalapatti Road, Coimbatore – 641048. Tamil Nadu.Ph:0422 – 2369105

BONAFIDE CERTIFICATE
Department of Electrical and Electronics Engineering
certified that this is a bonafide record of work done by
Mr. / Ms. ……………………………………………… of the ………………………………… B.E. / B.Tech. /
M.E. / M.Tech. in the year EC8681 – MICROPROCESSORS AND MICROCONTROLLERS
Laboratory conducted in this institution, as prescribed by Anna University – Chennai, for
the ............. semester, during the academic year 2019 / 2020.

Faculty In – Charge HoD / EEE

Date:

Anna University Register No. : …………………………………

Submitted for the Anna University Examination held on

…………………………………………………………………………………

Internal Examiner External Examiner


SYLLABUS
EC8681 MICROPROCESSOR AND MICROCONTROLLER LABORATORY L T P C
0 042
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 MASM


1.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 EXPERIMENTS


7. 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 MASM


14. Basic arithmetic and Logical operations
15. Square and Cube program, Find 2’s complement of a number
16. Unpacked BCD to ASCII
TOTAL: 60 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

1
Ex. No: 1a BASIC 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 ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1

16-BIT ADDITION:

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 data


1004 C7,C3,34,12 MOV BX,1234H Load BX-register with 2nd data
1008 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 OUTPUT
Register Data Address Data
AX 1234H 1200H 68
BX 1234H 1201H 24

2
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 data


1004 C7,C3,EE,EE MOV BX,EEEEH Load BX-register with 2nd
data
1008 29,D8 SUB AX,BX Subtract the contents of BX
from AX-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 OUTPUT
Register Data Address Data
AX FFFFH 1200H 11
BX 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.

3
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 data
1004 C7, C3, 4444 MOV BX,4444H Load BX-register with 2nd data
1008 F7, E3 MUL BX Multiply the contents of AX with
BX-register
100a C7, C6, MOV SI,1200H Assign SI-reg to 1200H
00,12
100e 89, 14 MOV [SI],DX Store the result

1010 C7, C6, MOV SI,1202H Assign SI-reg to 1202H


02,12
1014 89,04 MOV [SI],AX Store the result

1016 F4 HLT Stop the program

OUTPUT:

INPUT OUTPUT
Register Data Address Data
AX 4444H 1200H 34
BX 4444H 1201H 12
1202H 10
1203H 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.

4
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-register


100E C7, C6,00,12 MOV SI,1200H Assign SI-reg to 1200H
1012 89, 04 MOV [SI],AX Store the Quotient
1014 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 OUTPUT
Register 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.

5
Ex. No: 1B LOGICAL OPERATION

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 ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1

LOGICAL OR OPERATION

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 SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
OR AL, BL
INT 3H
CODE ENDS
END START

ii) By using 8086 kit:


ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C6,C0,85 MOV AL,85H Load AL-register with 1st Data
1003 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 OUTPUT
Register Data Address Data
AL 85H 1200H 9D
BL 95H

6
LOGICAL AND OPERATION

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 SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
AND AL, BL
INT 3H
CODE ENDS
END START

ii) By using 8086 kit:


ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 Org 1000h Starting address of the program
1000 C6,C0,85 MOV AL,85H Load AL-register with 1st Data
1003 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 OUTPUT
Register Data Address Data
AL 85H 1200H 81H
BL 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

7
PROGRAM:
i) By using MASM:
CODE SEGMENT
ASSUME CS: CODE
START: MOV AL, 85H
MOV BL, 99H
ADD AL, BL
NOT AL
INT 3H
CODE ENDS
END START

ii) By using 8086 kit:


ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C6,C0,85 MOV AL,85H Load AL-register with 1st Data
1003 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 OUTPUT
Register Data Address Data
AL 85H 1200H 7EH
BL 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.

8
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 ----1
3. Keyboard ----1
4. 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 program
1000 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.

9
100C 88,25 Move content of AH to DI-
MOV [DI], AH
register.
100F FC REPEAT: CLD Clear the direction flag.
1010 A4 MOVSB Move the string byte.
1011 E2,F3 Unconditional loop to address
LOOP: REPEAT
specified by the label REPEAT.
1013 F4 HLT Stop the program

OUTPUT:

INPUT OUTPUT
Address Data Address Data
1200 55 1300 55
1201 65 1301 65
1202 75 1302 75
1203 85 1303 85
1204 95 1304 95
1205 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.

10
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 ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1

ALGORITHM:
1. Load the address of BCD data in SI-register.
2. Copy the BCD data to BL-register
3. 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 SEGMENT
ASSUME CS: CODE, DS: CODE
MOV BL, 75
MOV AL, BL
MOV DL, AL
AND DL, 0FH
AND AL, 0F0H
MOV CL, 4
ROR AL, CL
MOV DH, 0AH
MUL DH
ADD AL, DL
MOV [BX+1], AL
MOV SI, 1200H
MOV [SI], BX
MOV AH, 4CH
INT 21H
CODE ENDS
END

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.
1005 88 C2 MOV DL, AL Copy the input data to DX-reg.

11
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 OUTPUT
Register 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 SEGMENT
ASSUME CS: CODE, DS: CODE
MOV AX, 45h

12
MOV AH, AL
MOV CL, 4h
SHR AH, CL
AND AX, 0F0FH
MOV SI, 1200H
MOV [SI], AX
INT 3H
CODE ENDS
END

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 OUTPUT
Register Data Address Data
AX 45H 1200 05
1201 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.

13
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 ----1
3. Keyboard ----1
4. 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 SEGMENT
ASSUME 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 program
1000 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.

14
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 MOV SI, 1400H Load Si-reg with address 1400.


14
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-digits
1015 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-F
1021 76 03 JBE L4 If byte jump to label L4
1023 80 C2 07 ADD DL, 07 If letter add 37H
1026 80 C2 30 L4: ADD DL, 30H Else only add 30H
1029 FE CD DEC CH Decrement Count
102B 75 EA JNZ L2 If count is not zero then goto label
L2
102D F4 HLT Stop the program

OUTPUT:

INPUT OUTPUT
Register Data Address Data
AL 09 1400 11
BL 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 SEGMENT
ASSUME CS: CODE
MOV AL, 32H
MOV BL, 17H

15
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 MOV SI, 1400H Load Si-reg with address 1400.


14
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-digits
1015 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-F
1021 76 03 JBE L4 If byte jump to label L4
1023 80 C2 07 ADD DL, 07 If letter add 37H
1026 80 C2 30 L4: ADD DL, 30H Else only add 30H
1029 FE CD DEC CH Decrement Count

16
102B 75 EA JNZ L2 If count is not zero then goto label
L2
102D F4 HLT Stop the program

OUTPUT:

INPUT OUTPUT
Register Data Address Data
AL 32 1400 15
BL 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 SEGMENT
ASSUME 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 program
1000 C6 C0 32 MOV AL, 06H Load AL-reg with data 04h.

17
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 MOV SI, 1400H Load Si-reg with address 1400.


14
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-digits
1016 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-F
1022 76 03 JBE L4 If byte jump to label L4
1024 80 C2 07 ADD DL, 07 If letter add 37H
1027 80 C2 30 L4: ADD DL, 30H Else only add 30H
102A FE CD DEC CH Decrement Count
102C 75 EA JNZ L2 If count is not zero then goto label
L2
102E F4 HLT Stop the program

OUTPUT:

INPUT OUTPUT
Register Data Address Data
AL 04 1400 04
BL 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 SEGMENT
ASSUME CS: CODE
MOVAL, 000FH

18
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-digits
101a 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

19
1026 76,03 JBE L4 If byte jump to label L4
1028 80,C2,07 ADD DL, 07 If letter add 37H
102b 80,C2,30 L4: ADD DL, 30H Else only add 30H
102e FE,CD DEC CH Decrement Count
1030 75,EA JNZ L2 If count is not zero then goto label
L2
1032 F4 HLT Stop the program
OUTPUT:

INPUT OUTPUT
Register 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.

20
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 ----1
3. Keyboard ----1
4. 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

21
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 OUTPUT
ADDRESS DATA ADDRESS DATA Address Data
1300 00H 1400 00H 1501 00
1301 01H 1401 05H 1502 06
1302 10H 1402 01H 1503 11
1303 12H 1403 02H 1504 14
1304 02H 1404 50H 1505 52
1305 03H 1405 90H 1506 93
1306 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 BCD
7. 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.

22
Ex. No: 4A 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 ----1
3. Keyboard ----1
4. 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: DATA


DATA SEGMENT
STRING1 DB 'MICROPROCESSOR AND INTERFACING LAB$'
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
SUB CL, CL
MOV SI, OFFSET STRING1
BACK: LODSB
INC CL
CMP AL,'$'
JNZ BACK
MOV BL, CL
MOV SI, 1200H
MOV [SI], BL
INT 03H
CODE ENDS
END START

ii) By using 8086 kit:


ADDRESS OPCODE LABEL MNEMONICS COMMENTS

1000 C7,C6,00,12 MOV SI,1200H SI 1200


1004 C7,C7,FF,FF MOV DX, FFFFH DXFFFF

1008 C6,C4,FF MOV AH, FFH AH FF, check FF


100B 42 NOEND: INC DX Increment the DX reg by 1

23
100C 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 E3
1201 F4
1202 54
1203 66
1204 88
1205 99
1206 10
1207 FF

OUTPUT:

ADDRESS (Hex) String length Hex)


1100 07

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 SMALL
DATA 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
MOV ES, AX

24
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.
Initialize the destination
1003 C7,C7,00,21 MOV DI,2100H
address.
Initialize count value to the
1007 C7,C1,06,00 MOV CX,0006 H
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.
Unconditional loop to
1010 E2,FB LOOP:REPEAT address specified by the
label REPEAT.
1013 F4 HLT Stop the program.

OUTPUT:

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
2000 55 2100 55
2001 55 2101 55
2002 55 2102 55
2003 55 2103 55
2004 55 2104 55
2005 55 2105 55

RESULT:

Thus an assembly language program for copying, finding the length of a string was
implemented and its output was verified.

25
Ex. No: 4B 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 ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1

ALGORITHM:

SORTING IN ASCENDING ORDER:


1. Start
2. 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. Start
2. 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]

26
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
1000 MOV SI, 2000 Initialize the memory pointer.
C7,C6,00,20
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

27
pointer
1014 Compare the content of AL
3A,04 CMP AL,[SI] and content of address hold
by SI.
1016 If carry occur jump to the
72,05 JC :AHEAD address specify by the label
AHEAD.
1018 Exchange the content of AL
86,04 XCHG AL,[SI] and the content hold by the
address specify in SI.
101a Exchange the content of AL
86,44,FF XCHG AL,[SI-1] 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,F0 In the count value not reach
JNZ :RECMP to zero jumps to address
specify by RECMP.
1021 FE,C9 DEC CL Decrement the content of CL.
1023 75,E3 In the count value not reach
JNZ: REPEAT to zero jump to address
specify by REPEAT.
1025 F4 HLT Stop the program

OUTPUT:

INPUT OUTPUT
Address Data Address Data
2000 05 2001 01
2001 05 2002 02
2002 04 2003 03
2003 03 2004 04
2004 02 2005 05
2005 01

DESCENDING ORDER:
iv) By using 8086 kit:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 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

28
SI.
1016 If carry occur jump to the
73,05 JNC :AHEAD address specify by the label
AHEAD.
1018 Exchange the content of AL
86,04 XCHG AL,[SI] and the content hold by the
address specify in SI.
101a Exchange the content of AL
86,44,FF XCHG AL,[SI-1] 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,F0 In the count value not reach to
JNZ :RECMP zero jumps to address specify
by RECMP.
1021 FE,C9 DEC CL Decrement the content of CL.
1023 75,E3 In the count value not reach to
JNZ: REPEAT zero jump to address specify
by REPEAT.
1025 F4 HLT Stop the program

OUTPUT:

INPUT OUTPUT
Address Data Address Data
2000 05 2001 05
2001 05 2002 04
2002 04 2003 03
2003 03 2004 02
2004 02 2005 01
2005 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.

29
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 ----1
3. Keyboard ----1
4. 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 ENDS
CODE 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

30
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-register
100B 8A,04 MOV AL,[SI] Set first data as largest
100D FE,C9 DEC CL Decrement the count
100F 46 AGAIN: INC SI Increment the SI-register to
point to next data in array
1010 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 count
101A 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 OUTPUT
Address Data Address Data
2000 05 (COUNT) 2100 19
2001 15
2002 19
2003 02
2004 01
2005 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

31
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-register
100B 8A,04 MOV AL,[SI] Set first data as largest
100D FE,C9 DEC CL Decrement the count
100F 46 AGAIN: INC SI Increment the SI-register to
point to next data in array
1010 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 count
101A 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.

32
OUTPUT:

INPUT OUTPUT
Address Data Address Data
2000 05 (COUNT) 2100 01
2001 15
2002 19
2003 02
2004 01
2005 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.

33
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 ----1
3. Keyboard ----1
4. 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

34
(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 Cursor
0006 8C, C8 MOV AX,CS Initialize DS To Code Segment
0008 8E, D8 MOV DS,AX Copy The Content Of AX To
DS-Register
000A B4, 09 MOV AH,09H Load The Function Code IN
AH-register
000C BA, 04,50 MOV DX,450H Load address of string to display
in DX-register
000F CD, 21 INT 21H Call DOS service for display
0011 BE, 04,00 MOV SI,400H Initialize the pointer
0014 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 return
001D 74,0C JE CHECK If equal go to CHECK
001F 88,04 MOV [SI],AL Store the keyboard character in
memory
0021 B4,02 MOV AH,02H Load the function code in AH.
0023 B2, 2A MOV DL, ‘*’ Load the ASCII value of ‘*’ in
DL
0025 CD,21 INT 21H Call DOS service for display
0027 46 INC SI Increment Pointer
0028 41 INC CX Increment the count
0029 EB,EC JMP L1 Jump to L1 to get next character
002B 83,F9,07 CHECK: CMP CX,0007H Compare count with 07H
002E 75,20 JNE REPEAT If count not equal to 07H then
goto repeat
0030 BE,04,00 MOV SI, 400H Initialize the pointers
0033 BF,05,00 MOV DI,500H Copy the value 500H to DI-reg
0036 8A,04 L2: MOV AL, [SI] Get a character of entered
password in AL-register
0038 3A,05 CMP AL,[DI] Compare entered character with
corresponding character of
stored password
003A 75,14 JNE REPEAT If not equal jump to repeat
003C 46 INC SI Increment the pointer
003D 47 INC DI Increment the DI-register
003E E2,F6 LOOP L2 Repeat comparison until counter
expires
0040 E8,00,79 CALL CLRS Clear the screen
0043 E8,00,6F CALL POS Position the cursor
0046 B4,09 MOV AX,09H Load the function code in AH-
register
004A BA,06,00 MOV DX,600H Load the address of String to
display in DX-register
004B CD,21 INT 21H Call DOS service for display
004D E9,06,0F JMP EXIT GO to EXIT.

35
0050 E8,00,79 REPEAT CALL CLRS Clear the screen
0053 E8,00,6F CALL POS Position the cursor
0056 B4,09 MOV AH,09H Load the function code in AH
0058 BA,05,50 MOV DX,550H Load the address of string to
display in DX-register
005B CD,21 INT 21H Call DOS service for display
005D B4,09 MOV AH,09H Load the function code in AH
005F BA,05,80 MOV DX,580H Load address of string to display
in DX
0062 CD,21 INT 21H Call DOS service for display
0064 B4,00 MOV AH,00H Load the function code in AH
0066 CD,16 INT 16H Call Bios service to get
keyboard
0068 3C,1B CMP AL,1BH Check for Esc key
006A 75,94 JNE AGAIN If key pressed is not esc, then go
to again
006C E9,06,0F JMP EXIT If key pressed is not esc, then go
to exit
006F B4,02 MOV AH,02H Load the function code in AH
0071 B7,00 MOV BH,00H Load the video page in BH
0073 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
positioning
0078 C3 RET Return to main program
0079 POS ENDP End of procedure to position the
cursor
0079 CLRS PROC NEAR Start of procedure to clear the
screen.
0079 B4,07 MOV AH,07H Load the function code in AH
007B B0,00 MOV AL,00H Load number of lines to scroll
down in AL
007D B7 07 MOV BH,07H Load the blanked area attribute
in BL
007F B9 0000 MOV CX, 0000H Load the X and Y coordinates of
upper left corner in CL and CH
0082 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 program
0088 CLRS ENDP End of procedure to clear the
screen.
0450 ORG 450H
0450 45 4E 54 45 DB ‘ENTER THE
52 20 54 48 PASSWORD : ‘,’$’
45 20 50 41
53 53 57 4F
52 44 20
3A 20 24
0500 ORG 500H
0500 57 45 4C 43 DB ‘WELCOME’,’$’
4F 4D 45
24

36
0500 ORG 550H
0550 49 4E 43 4F DB ‘INCORRECT
52 52 45 43 PASSWORD. ‘,’$.
54 20 50 41
53 53 57 4F
52 44 2E 20
20 24
0580 ORG 580H
0580 50 52 45 53 DB ‘ PRESS ANY KEY
53 20 41 4E TO TRY AGAIN OR
59 20 4B 45 PRESS ESC TO EXIT
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
0600 ORG 600H
0600 45 4E 54 52 DB ‘ENTRY
59 20 41 43 ACCEPTED’ ,’$’.
43 45 50 54
45 44 24
060F B4 4C EXIT MOV AH,4CH Load the function in AH
0611 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: WELCOME


INCORRECT PASSWORD
PRESS ANY KEY TO TRY AGAIN OR PRESS ESC TO EXIT
ENTRY ACCEPTED

RESULT:

Thus an assembly language program for password checking using 8086 was implemented
and its output was verified.

37
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 ----1
3. Keyboard ----1
4. 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, AX
JNZ BACK1
MOV AH, 02H
DISP: POP DX
ADD 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.

38
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 ----1
3. Keyboard ----1
4. 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 Part
MONTH: 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

39
; 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 conversion
1003 CALL DISPLAY Call subroutine for Display
1006 DELAY: MOV AL,0B0H Copy the data 0B0H to AL-reg
1009 OUT 16H,AL Configure output port
100B MOV CL,07H Copy the data 07H to AL-reg
100E S2: MOV AL,88H Copy 88H to AL-register
1011 OUT 14H,AL Configure output port
1013 MOV AL,80H Copy the data 80H to AL-reg
1016 OUT 14H,AL Configure output port
1018 S1: NOP No operation
1019 NOP No operation
101A NOP No operation
101B NOP No operation
101C IN AL,14H Copy 14H to AL-reg
101E MOV DL,AL Copy the Content of AL reg to
DL-reg.
1020 IN AL,14H Copy 14H to AL-reg
1022 OR AL,DL OR the contents of AL with DL
1024 JNZ S1 Jump on no zero to S1
1026 DEC CL Decrement CL-register
1028 JNZ S2 Jump on no zero to S2
102A MOV SI,1500H Copy SI-reg with data 1500H
102E MOV AL,[SI] Copy the content of SI-reg to AL
1030 INC AL Increment AL-register
1032 MOV [SI],AL Copy the content of AL reg to SI-
reg
1034 CMP AL,3CH Compare AL with 3CH
1037 JNZ START Jump on no zero to start
1039 MOV AL,00H Copy AL with data 00H
103C MOV [SI],AL Copy the content of Al to SI-reg
103E INC SI Increment SI-register
103F MOV AL,[SI] Copy the content of SI-reg to AL
1041 INC AL Increment AL-register
1043 MOV [SI],AL Copy the content of AL reg to SI-

40
reg
1045 CMP AL,3CH Compare AL with 3CH
1048 JNZ START Jump on no zero to start
104A MOV AL,0 Copy AL with data 00H
104D MOV [SI],AL Copy the content of AL reg to SI-
reg
104F INC SI Increment SI-register
1050 MOV AL,[SI] Copy the content of SI-reg to AL
1052 INC AL Increment AL-register
1054 MOV [SI],AL Copy the content of AL reg to SI-
reg
1056 CMP AL,18H Compare AL with 18H
1059 JNZ START Jump on no zero to start
105B MOV AL,0 Copy AL with data 00H
105E MOV [SI],AL Copy the content of AL reg to SI-
reg
1060 JMP START Jump to start
1063 DISPLAY: MOV AH,06H Copy 06H to AH-register
1066 MOV DX,1600H Copy 1600H to DX-register
106A MOV CH,01H Copy 01H to CH-register
106D MOV CL,0H Copy 00H to CL-register
1070 INT 5 Call Interrupt
1072 RET Return from subroutine
1073 CONVERT: MOV SI,1500H Copy 1500H to SI-register
1077 MOV BX,1608H Copy 1608H to BX-register
107B MOV AL,24H Copy 24H to AL-register
107E MOV [BX],AL Copy the content of AL-reg to BX
1080 MOV AL,[SI] Copy the content of SI-reg to AL
1082 MOV AH,0 Copy AL with data 00H
1085 MOV DH,0AH Copy the data 0AH to DH-register
1088 DIV DH Divide DH-reg by AH reg
108A ADD AH,30H Add the data 30H with AH-reg
108D DEC BX Decrement BX-register
108E MOV [BX],AH Copy the data from AH to DH-
reg
1090 DEC BX Decrement BX-register
1091 ADD AL,30H Add the data 30H with AL-reg
1094 MOV [BX],AL Copy the data from AL to BX-reg
1096 DEC BX Decrement BX-register
1097 MOV AL,3AH Copy the 3AH to AL-reg
109A MOV [BX],AL Copy the data from AL to BX-reg
109C DEC BX Decrement BX-register
109D INC SI Increment SI-register
109E MOV AL,[SI] Copy the content of SI-reg to AL
10A0 MOV AH,0 Copy the data 0 to AH-reg
10A3 MOV DH,0AH Copy the data 0AH to DH-register
10A6 DIV DH Divide DH-reg by AH reg
10A8 ADD AH,30H Add the data 30H with AH-reg

41
10AB MOV [BX],AH Copy the data from AH to BX-
reg
10AD DEC BX Decrement BX-register
10AE ADD AL,30H Add the data 30H with AL-reg
10B1 MOV [BX],AL Copy the data from AL to BX-reg
10B3 DEC BX Decrement BX-register
10B4 MOV AL,3AH Copy the 3AH to AL-reg
10B7 MOV [BX],AL Copy the data from AL to BX-reg
10B9 DEC BX Decrement BX-register
10BA INC SI Increment SI-register
10BB MOV AL,[SI] Copy the content of SI-reg to AL
10BD MOV AH,0 Copy the data 0 to AH-reg
10C0 MOV DH,0AH Copy the data 0AH to DH-register
10C3 DIV DH Divide DH-reg by AH reg
10C5 ADD AH,30H Add the data 30H with AH-reg
10C8 MOV [BX],AH Copy the data from AH to BX-
reg
10CA DEC BX Decrement BX-register
10CB ADD AL,30H Add the data 30H with AL-reg
10CE MOV [BX],AL Copy the data from AL to BX-reg
10D0 RET Return from subroutine
10D1 GETC: IN AL,02H Copy 02H to AL-reg
10D3 AND AL,0FFH AND data AL with 0FFH
10D6 CMP AL,0F0H Compare AL with 0F0H
10D9 JNE GETC If no zero jump to getc

OUTPUT:
1500- 99 YEAR
1501- 09 MONTH
1502- 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 explain
8. What does EU and BIU do?
9. Describe about LOOP instructions
10. Explain about DAA instruction.

RESULT:

Thus an assembly language program for reading system date using 8086 was implemented
and its output was verified.

42
Ex. No:6 COUNTERS AND TIME DELAY

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 ----1
3. Keyboard ----1
4. 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

43
MOV BX, DX
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 COMMENTS


1000 ORG 1000H Starting address
1000 C6,C0,36 MOV AL,36 Move 36 to AL-register
1003 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-register
1008 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-register
100D E6,C8 OUT C8,AL The content of AL-reg is
copied to Port.
100F F4 HLT Stop the program.

OUTPUT:

WAVEFORM GENERATION
WAVEFORMS 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.

44
INTERFACING EXPERIMENTS

45
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 ----1
4. 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-register
1002 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-register
1007 BE 77 10 MOV SI, LABEL Copy the direction of rotation
value to SI-reg.
100A E8 32 00 CALL OUT Call to OUT port
100D 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
100F E6 20 OUT PORTA, AL Move the AL-reg value to
PORTA
1011 E8 4A 00 CALL DELAY1 Call Delay program
1014 46 INC SI Increment SI-register
1015 43 INC BX Increment BX-register
1016 E8 26 00 CALL OUT Call to OUT port
1019 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
101B E6 22 OUT PORTB, AL Move the AL-reg value to
PORTB
101D E8 3E 00 CALL DELAY1 Call Delay program
1020 46 INC SI Increment SI-register
1021 43 INC BX Increment BX-register
1022 E8 1A 00 CALL OUT Call to OUT port
1025 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
1027 E6 24 OUT PORTC, AL Move the AL-reg value to
PORTC
1029 E8 32 00 CALL DELAY1 Call Delay program
102C 46 INC SI Increment SI-register
102D 43 INC BX Increment BX-register
102E E8 0E 00 CALL OUT Call to OUT port
1031 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
1033 E6 24 OUT PORTC, AL Move the AL-reg value to
PORTC
1035 46 INC SI Increment SI-register
1036 8A 04 MOV AL, [SI] Copy the contents of SI-reg
to Al-register
1038 E6 20 OUT PORTC, AL Move the AL-reg value to

46
PORTC
103A E8 21 00 CALL DELAY1 Call Delay program
103D EB C5 JMP REPEAT Jump to label REPEAT
103F 8A 07 OUT: MOV AL, [BX] Copy the content of BX to
AL-register
1041 E6 24 OUT PORTC, AL Move the AL-reg value to
PORTC
1043 43 INC BX Increment BX-register
1044 8A 07 MOV AL, [BX] Copy the content of BX to
AL-register
1046 E6 22 OUT PORTB, AL Move the AL-reg value to
PORTB
1048 43 INC BX Increment BX-register
1049 8A 07 MOV AL, [BX] Copy the content of BX to
AL-register
104B E6 20 OUT PORTA, AL Move the AL-reg value to
PORTA
104D E8 01 00 CALL DELAY Call Delay program
1050 C3 RET Return from subroutine
1051 BF 40 00 DELAY: MOV DI, 00040H Move 40h to DI-register
1054 BA FF FF A: MOV DX, 0FFFFH Move 0FFFFh to DX-register
1057 4A A1: DEC DX Decrement DX-register
1058 75 FD JNZ A1 Jump on no zero to A1.
105A 4F DEC D1 Decrement D1-register
105B 75 F6 JNZ A Jump on no zero to A
105D C3 RET
105E BF 15 00 DELAY1: MOV DI, 00015H Move 15h to DI-register
1061 BA FF FF B: MOV DX, 0FFFH Move 0FFFh to DX-register
1064 4A B1: DEC DX Decrement DX-register
1065 75 FD JNZ B1 Jump on no zero to B1
1067 4F DEC D1 Decrement D1-register
1068 75 F6 JNZ B Jump on no zero to B
106A C3 RET
106B 12 27 44 10 LOOKUP: DB 12H,27H,44H,10H
106F 2B 92 109D 2BH,92H,10H,9DH
1073 84 48 2E 84 84H,48H,2EH,84H
1077 48 4B 20 49 LABEL: DB 48H,4BH,20H,49H
107B 04 04H For traffic light control.
107C END
VIVA 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
implemented in 8086 kit.

47
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 ----1
3. Stepper Motor Interface board ----1
4. Power card ----1
5. Keyboard ----1
6. 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-reg
100F 4A loop DEC DX Decrement DX-register
1010 75,FD JNZ loop Jump on no zero to loop
1012 47 INC DI Increment DI-register
1013 E2,F2 LOOP loop1 Loop to label loop1
1015 E9,E8, FF JMP Ahead Jump to ahead
1018 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 program


100A FE CB DEC BL Decrement BL-register
100C 75 F5 JNZ 1003 Jump on no zero to label 1003
100E E8 2A 00 CALL 103B Call subroutine program
1011 C6 C3 20 MOV BL, 20 Copy the data 20 to BL-register
1014 C7 C7 43 MOV DI, 1043 Copy the data 1043 to DI-reg
10

48
1018 E8 0A 00 CALL 1025 Call subroutine program
101B FE CB DEC BL Decrement BL-register
101D 75 75 JNZ 1014 Jump on no zero to 1014
101F E8 19 00 CALL 103B Call subroutine program
1022 E9 DB FF JMP 1000 Jump to label 1000
1025 C6 C1 04 MOV CL, 04 Copy the data 04 to CL-register
1028 8A 05 MOV AL, [DI] Copy the content of DI to AL-
register
102A E6 C0 OUT C0, AL Assign the content of AL to
Output
102C C7 C2 10 MOV DX, 1010 Copy the content 1010 to Dx-
10 register
1030 4A DEC DX Decrement DX-register
1031 75 FD JNZ 1030 Jump on no zero to label 1030
1033 47 INC DI Increment DI-register
1034 E2 F2 LOOP 1028 Loop to label 1028
1036 C3 RET Return from subroutine
1037 C7,C2,FF,FF MOV DX, 0FFFF Copy FFFF in DX-register
103B 4A DEC DX Decrement DX-register
103C 75 FD JNZ 103B Jump on no zero 103B
103E C3 RET Return from subroutine
103F 09,05,06,0A FORWARD DATA To rotate in forward direction
1043 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.

49
Ex. No: 9 DIGITAL CLOCK

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 ----1
4. Keyboard ----1
5. PC with Intel/AMD Processor----1

PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 CALL CONVERT Call subroutine for conversion
1003 CALL DISPLAY Call subroutine for Display
1006 DELAY: MOV AL,0B0H Copy the data 0B0H to AL-reg
1009 OUT 16H,AL Configure output port
100B MOV CL,07H Copy the data 07H to AL-reg
100E S2: MOV AL,88H Copy 88H to AL-register
1011 OUT 14H,AL Configure output port
1013 MOV AL,80H Copy the data 80H to AL-reg
1016 OUT 14H,AL Configure output port
1018 S1: NOP No operation
1019 NOP No operation
101A NOP No operation
101B NOP No operation
101C IN AL,14H Copy 14H to AL-reg
101E MOV DL,AL Copy the Content of AL reg to
DL-reg.
1020 IN AL,14H Copy 14H to AL-reg
1022 OR AL,DL OR the contents of AL with DL
1024 JNZ S1 Jump on no zero to S1
1026 DEC CL Decrement CL-register
1028 JNZ S2 Jump on no zero to S2
102A MOV SI,1500H Copy SI-reg with data 1500H
102E MOV AL,[SI] Copy the content of SI-reg to AL
1030 INC AL Increment AL-register
1032 MOV [SI],AL Copy the content of AL reg to SI-
reg
1034 CMP AL,3CH Compare AL with 3CH
1037 JNZ START Jump on no zero to start
1039 MOV AL,00H Copy AL with data 00H
103C MOV [SI],AL Copy the content of Al to SI-reg
103E INC SI Increment SI-register
103F MOV AL,[SI] Copy the content of SI-reg to AL
1041 INC AL Increment AL-register
1043 MOV [SI],AL Copy the content of AL reg to SI-
reg
1045 CMP AL,3CH Compare AL with 3CH

50
1048 JNZ START Jump on no zero to start
104A MOV AL,0 Copy AL with data 00H
104D MOV [SI],AL Copy the content of AL reg to SI-
reg
104F INC SI Increment SI-register
1050 MOV AL,[SI] Copy the content of SI-reg to AL
1052 INC AL Increment AL-register
1054 MOV [SI],AL Copy the content of AL reg to SI-
reg
1056 CMP AL,18H Compare AL with 18H
1059 JNZ START Jump on no zero to start
105B MOV AL,0 Copy AL with data 00H
105E MOV [SI],AL Copy the content of AL reg to SI-
reg
1060 JMP START Jump to start
1063 DISPLAY: MOV AH,06H Copy 06H to AH-register
1066 MOV DX,1600H Copy 1600H to DX-register
106A MOV CH,01H Copy 01H to CH-register
106D MOV CL,0H Copy 00H to CL-register
1070 INT 5 Call Interrupt
1072 RET Return from subroutine
1073 CONVERT: MOV SI,1500H Copy 1500H to SI-register
1077 MOV BX,1608H Copy 1608H to BX-register
107B MOV AL,24H Copy 24H to AL-register
107E MOV [BX],AL Copy the content of AL-reg to BX
1080 MOV AL,[SI] Copy the content of SI-reg to AL
1082 MOV AH,0 Copy AL with data 00H
1085 MOV DH,0AH Copy the data 0AH to DH-register
1088 DIV DH Divide DH-reg by AH reg
108A ADD AH,30H Add the data 30H with AH-reg
108D DEC BX Decrement BX-register
108E MOV [BX],AH Copy the data from AH to DH-
reg
1090 DEC BX Decrement BX-register
1091 ADD AL,30H Add the data 30H with AL-reg
1094 MOV [BX],AL Copy the data from AL to BX-reg
1096 DEC BX Decrement BX-register
1097 MOV AL,3AH Copy the 3AH to AL-reg
109A MOV [BX],AL Copy the data from AL to BX-reg
109C DEC BX Decrement BX-register
109D INC SI Increment SI-register
109E MOV AL,[SI] Copy the content of SI-reg to AL
10A0 MOV AH,0 Copy the data 0 to AH-reg
10A3 MOV DH,0AH Copy the data 0AH to DH-register
10A6 DIV DH Divide DH-reg by AH reg
10A8 ADD AH,30H Add the data 30H with AH-reg
10AB MOV [BX],AH Copy the data from AH to BX-
reg

51
10AD DEC BX Decrement BX-register
10AE ADD AL,30H Add the data 30H with AL-reg
10B1 MOV [BX],AL Copy the data from AL to BX-reg
10B3 DEC BX Decrement BX-register
10B4 MOV AL,3AH Copy the 3AH to AL-reg
10B7 MOV [BX],AL Copy the data from AL to BX-reg
10B9 DEC BX Decrement BX-register
10BA INC SI Increment SI-register
10BB MOV AL,[SI] Copy the content of SI-reg to AL
10BD MOV AH,0 Copy the data 0 to AH-reg
10C0 MOV DH,0AH Copy the data 0AH to DH-register
10C3 DIV DH Divide DH-reg by AH reg
10C5 ADD AH,30H Add the data 30H with AH-reg
10C8 MOV [BX],AH Copy the data from AH to BX-
reg
10CA DEC BX Decrement BX-register
10CB ADD AL,30H Add the data 30H with AL-reg
10CE MOV [BX],AL Copy the data from AL to BX-reg
10D0 RET Return from subroutine
10D1 GETC: IN AL,02H Copy 02H to AL-reg
10D3 AND AL,0FFH AND data AL with 0FFH
10D6 CMP AL,0F0H Compare AL with 0F0H
10D9 JNE GETC If no zero jump to getc

OUTPUT:
1500- 00 SECONDS
1501- 00 MINUTES
1502- 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.

52
Ex. No:10 KEYBOARD AND DISPLAY

AIM:
To 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 ----1
5. Keyboard ----1
6. PC with Intel/AMD Processor----1

ALGORITHM:
Display of rolling message “HELP US “
1. Initialize the counter
2. Set 8279 for 8 digit character display, right entry
3. Set 8279 for clearing the display
4. Write the command to display
5. Load the character into accumulator and display it
6. Introduce the delay
7. Repeat from step 1.

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 program
PROGRAM:

53
LOOK-UP TABLE:

1200 98 68 7C C8

1204 FF 1C 29 FF

OUTPUT:

MEMORY 7-SEGMENT LED FORMAT HEX DATA


LOCATION d c b a dp e g f
1200H 1 0 0 1 1 0 0 0 98
1201H 0 1 1 0 1 0 0 0 68
1202H 0 1 1 1 1 1 0 0 7C
1203H 1 1 0 0 1 0 0 0 C8
1204H 1 1 1 1 1 1 1 1 FF
1205H 0 0 0 0 1 1 0 0 1C
1206H 0 0 1 0 1 0 0 1 29
1207H 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.

54
Ex. No:11 PRINTER INTERFACE

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 ----1
5. PC with Intel/AMD Processor----1

PROGRAM:
00C8 DATA EQU 00C8H
00D0 CONTL EQU 00D0H
00C0 STUS EQU 00C0H

ADDRESS OPCODE LABEL MNEMONICS COMMENTS

1000 Org 1000h Starting address of the program


1000 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 processor
10. 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.

55
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 ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1

ALGORITHM:
1. Initialize 8253 and 8251 to check the transmission and reception of a character
2. 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, MOV SI,1500H Initialize Si-register with address 1500H
15
1004 C6,C0,36 MOV AL,36H Copy 36H data to AL-register
1007 E6,16 OUT 16H,AL Configure output port
1009 C6,C0,40 MOV AL,40H Copy the data 40H to AL-register
100C E6,10 OUT 10H,AL Configure output port
100E C6,C0,01 MOV AL,01H Copy 01H data to AL-register
1011 E6,10 OUT 10H,AL Configure output port
1013 C6,C1,05 RELOAD: MOV CL,05H Count value for number of data’s
1016 E4,0A CHECK: IN AL,0AH Configure input port to transmit data
1018 80,E0,04 AND AL,04H AND the contents of AL-reg with 04H
101B 74,F9 JZ CHECK If zero Jump to Label Check
101D E4,08 MOV AL,[SI] Copy the content of SI-reg to AL-register
101F 88,04 OUT 08H,AL Configure output port
1021 46 INC SI Increment SI-register
1022 80,F8,3F CMP AL,3FH Compare AL-reg with 3FH data
1025 75,EC JNZ RELOAD If no zero jump to label reload
1027 FE,C9 DEC CL Decrement CL-register
1029 75,EB JNZ CHECK If CL not zero jump to label Check
102B CD,02 INT 02 Call interrupt routine

56
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
1000 C7,C6,00,1 MOV SI,1500H Initialize Si-register with address 1500H
5
1004 C6,C0,36 MOV AL,36H Copy 36H data to AL-register
1007 E6,16 OUT 16H,AL Configure output port
1009 C6,C0,40 MOV AL,40H Copy the data 40H to AL-register
100C E6,10 OUT 10H,AL Configure output port
100E C6,C0,01 MOV AL,01H Copy 01H data to AL-register
1011 E6,10 OUT 10H,AL Configure output port
1013 C6,C1,05 RELOAD: MOV CL,05H Count value for number of data’s
1016 E4,0A CHECK: IN AL,0AH Configure input port to transmit data
1018 80,E0,02 AND AL,02H AND the contents of AL-reg with 02H
101B 74,F9 JZ CHECK If zero Jump to Label Check
101D E4,08 MOV AL,[SI] Copy the content of SI-reg to AL-register
101F 88,04 OUT 08H,AL Configure output port
1021 46 INC SI Increment SI-register
1022 80,F8,3F CMP AL,3FH Compare AL-reg with 3FH data
1025 75,EC JNZ RELOAD If no zero jump to label reload
1027 FE,C9 DEC CL Decrement CL-register
1029 75,EB JNZ CHECK If CL not zero jump to label Check
102B CD,02 INT 02 Call interrupt routine

RECEIVER END:

OUTPUT:

INPUT(Transmitter end) OUTPUT (Receiver end)


Address Data Address Data
1500 11 1500 11
1501 22 1501 22
1502 33 1502 33
1503 44 1503 44
1504 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.

57
Ex. 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 ----1
3. Keyboard ----1
4. PC with Intel/AMD Processor----1

ALGORITHM:
1. Initialize accumulator to hold control word
2. store control word in control word register
3. Read data port A.
4. Store data from port A in memory
5. Place contents in port B
PROGRAM:

TRANSMITTER:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 C6, C0,82 MOV AL,82H Copy 82H to AL-register
1003 E6,26 OUT 26H,AL Configure output port
1005 C6,C0,3F MOV AL,3FH Copy 3F to AL-register
1008 E6,20 OUT 20H,AL Configure output port
100a E4,22 Loop: IN AL,22H Configure AL-register
100c 80,E8,3f SUB AL,3FH Subtract 3F from AL-register
100f 75,F9 JNZ LOOP Jump on no zero to loop
1011 C6,C0,24 MOV AL,24H Copy 24H to AL-register
1014 E6,20 OUT 20H,AL Configure output port
1016 E8,02,00 CALL DELAY Call delay program
1019 CD,02 INT 02 Call interrupt routine
101b C6,C3,05 Delay: MOV BL,05H Copy 05H to BL-register
101e C6,C2,FF Lion: MOV DL,0FFH Copy FFH to DL-register
1021 FE,CA L2: DEC DL Decrement DL-register
1023 75,F9 JNZ L2 Jump on no zero to Label L2
1025 FE,CB DEC BL Decrement BL-register
1027 75,F5 JNZ LION Jump on no zero to lion
1029 C3 RET Return from subroutine

RECEIVER:
ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 C6 C0 90 MOV AL,90H Copy 90H to AL-register
1003 E6 26 OUT 26H,AL Configure output port

1005 E4 20 CHECK: IN AL,20H Configure AL-register


1007 80 E8 3F SUB AL,3FH Subtract 3F from AL-register

100A 75 F9 JNZ CHECK Jump on no zero to loop

58
100C C6 C0 3F MOV AL,3FH Copy 3FH to AL-register

100F E6 22 OUT 22H,AL Configure output port


1011 C6 C1 08 MOV CL,08H Copy 08H to AL-register

1014 E8 12 00 CALL DELAY Call delay program


1017 C7,C6,00,12 MOV SI,1200H Copy 1200H TO SI-register

101b E4 20 L1: IN AL,20H Configure AL-register


101d 88,04 MOV [SI],AL copy content of AL-register to
SI-register
101F E8 07 00 CALL DELAY Call delay program
1022 46 INC SI Increment SI-register

1023 FE C9 DEC CL Decrement CL-register


1025 75 F4 JNZ L1 Jump on no-zero to L1

1027 CD 02 INT 02 Call interrupt routine


1029 C6 C3 05 DELAY: MOV BL,05H Copy 05H to BL-register

102C C6 C2 FF LION: MOV DL,0FFH Copy FFH to DL-register


102F FE CA L2: DEC DL Decrement DL-register
1031 75 FC JNZ L2 Jump on no zero to L2
1033 FE CB DEC BL Decrement BL-register
1035 75 F5 JNZ LION Jump on no-zero to Lion
1037 C3 RET Return from subroutine
1038 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.

59
Ex. 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 ----1
5. Keyboard ----1
6. 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
100E B0 00 MOV AL,00 Introduce delay
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
1018 24 01 AND AL,01 Read the EOC signal from port &
101A 3C 01 CMP AL,01 check for end of conversion
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

60
1024 F4 HLT Stop

OUTPUT:

ANALOG VOLTAGE DIGITAL DATA ON LED HEX CODE IN MEMORY


DISPLAY LOCATION
5 1111 1111 FF
3.84 0000 0111 07
3.83 1001 0010 92
3.79 0111 0100 74
3.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.

61
Ex. 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 ----1
4. Keyboard ----1
5. 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 WAVE


ADDRESS 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

62
PROGRAM: SAWTOOTH WAVE
ADDRESS 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 WAVE


ADDRESS OPCODE LABEL PROGRAM COMMENTS
1000 B0 00 L3 MOV AL,00H Load 00 in accumulator
1002 E6 C8 L1 OUT C8,AL Send through output port
1004 FE C0 INC AL Increment contents of
accumulator
1006 75 F8 JNZ L1 Send through output port until
it reaches FF
1008 B0 FF MOV AL,0FFH Load FF in accumulator
100A E6 C8 L2 OUT C8,AL Send through output port
100C FE C0 DEC AL Decrement contents of
accumulator
100E 75 F8 JNZ L2 Send through output port until
it reaches 00
1110 EB EA JMP L3 Go to starting location

OUTPUT:

WAVEFORM GENERATION
WAVEFORMS AMPLITUDE TIME PERIOD
Square wave 10v 1ms
Saw-tooth wave 10v 1.4ms
Triangular 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 available
8. 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.

63
8051 MICROCONTROLLER

64
Ex. 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 ----1
3. Keyboard ----1
4. 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 OUTPUT
Register Data Address Data
A-register 02H 4500 06H
B-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.
4102 75,F0,04 MOV B,#data Load data 2 in B-register
4105 95,F0 SUBB A,B Subtract the contents of B-

65
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 Data
A-register 05H 4500 04H
B-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 OUTPUT
REGISTER DATA ADDRESS DATA
A 5 4500 19H
B 5

66
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 OUTPUT
REGISTER DATA ADDRESS DATA
A-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.

67
Ex. 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 ----1
3. Keyboard ----1
4. 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 OUTPUT
REGISTER DATA ADDRESS DATA
R0-Register 14 4500 10
A-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
4100 80, FE STOP: SJMP STOP Stop the program

68
OUTPUT:

INPUT OUTPUT
REGISTER DATA ADDRESS DATA
R0-Register 14 4500 16
A-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 OUTPUT
REGISTER DATA ADDRESS DATA
R0-Register 14 4500 06
A-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:

Thus an assembly language program for logical operations using 8051 was performed and its
output was verified.

69
Ex. 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 ----1
3. Keyboard ----1
4. 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 DATA
4200 FF 4201 01
4202 FE

70
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

71
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 OUTPUT
ADDRESS DATA ADDRESS DATA
4200 56 4201 98
4202 B4
4203 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 DATA
4200 05 4201 0BH

72
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 8051
6. List the modes of Timer in 8051.
7. Draw the format of TCON register of 8051
8. Draw the format of IE register.
9. Draw the format of IP register
10. 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.

73
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 ----1
4. 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.

74
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 OUTPUT
ADDRESS DATA ADDRESS DATA
4200 29 4201 39
4202 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.

75

You might also like