Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 94

VELAMMAL ENGINEERING COLLEGE

DEPARTMENT OF INFORMATION TECHNOLOGY

EC8681 MICROPROCESSORS AND MICROCONTROLLERS

LABORATORY REGISTRATION NUMBER :

NAME :

SEMESTER : V

ACADEMIC YEAR : 2020-21

EXPT NO DATE EXPERIMENT NAME PAGE NO

1 22-07-20 16-bit data addition using 8086 1


2 24-07-20 Multi-byte Addition using 8086 4
3 06-08-20 16-bit data multiplication using 8086 7
4 06-08-20 16-bit data division using 8086 9
5 06-08-20 BCD Addition using 8086 12
6 14-08-20 1’s complement and 2’s complement 18
number using 8086
7 14-08-20 16-bit logical operations using 8086 20
8 21-08-20 Data block movement using 8086 26
9a 28-08-20 Code Conversion using 8086 32
9b 28-08-20 Code Conversion of hexadecimal nibble 34
to ASCII number using 8086
9c 04-09-20 Code Conversion of 8-bit hexadecimal 37
number to BCD number using 8086
9d 04-09-20 Code Conversion of 8-bit BCD number 39
to hexadecimal number using 8086
10a 11-09-20 Addition/Subtraction of two nxn 41
matrices using 8086
10b 11-09-20 String Manipulations using 8086 47
11 18-09-20 Data Arrangement in ascending/ 52
descending order using 8086
12 18-09-20 Search for data in an array using 8086 57
13 09-10-20 Password Checking using 8086 60
14 09-10-20 Time Delay using 8086 63
15 09-10-20 Digital clock using 8086 66
16 09-10-20 Printer Status 69
17 12-10-20 Interfacing of stepper motor with 8086 71
18 12-10-20 Interfacing of Traffic Light controller 75
with 8086
19 12-10-20 Arithmetic Operations using 8051 78
20 15-10-20 Logical Operations using 8051 86
21 15-10-20 Cube of the number using 8051 90
22 15-10-20 Unpacked BCD to ASCII using 8051 92
Ex.No : 1 16-bit Data Addition using 8086
DATE : 22-07-2020

AIM:
To add two 16-bit immediate values to perform with and without carry operation.
APPARATUS REQUIRED: emu8086 emulator.
ALGORITHM:
1. Load the first data in AX register.
2. Load the second data in BX register.
3. Clear CL register.
4. Add the two data and get the sum in AX register.
5. Store the sum in source index register.
6. Check for carry, if carry flag is set then go to next step, otherwise go to step-8.
7. Increment CL register.
8. Store the carry high order byte of the data register (DH).
9. Stop.

PROGRAM:

a. Addition with carry

MOV AX, 9999H


MOV BX, 9999H
MOV CL, 00H
ADD AX, BX
JNC loop-1
INC CL
loop-1: MOV [SI], AX
MOV DH, CL
HLT

1
OUTPUT:

SI: 3332H

DH: 01H

b. Addition without carry

MOV AX, 1234H


MOV BX, 1234H
MOV CL, 00H
ADD AX, BX
JNC loop-1
INC CL
loop-1: MOV [SI], AX
MOV DH, CL
HLT
OUTPUT:

SI: 2468H

DH: 00H

RESULT:

Thus the two 16-bit numbers are added and the results are observed for
both with and without carry operations at different registers.
Ex.No : 2 Multi-byte Addition using 8086

DATE : 24-07-2020

AIM:
To perform addition operation among two multi-byte data.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:
1. Load the starting address of 1st data in SI register.
2. Load the starting address of 2nd data in DI register.
3. Load the starting address of result in BX register.
4. Load the byte count in CL register.
5. Load a byte of 1st data in AL register.
6. Add the corresponding byte of 2nd data in memory to AL
register along with previous carry.
7. Store the sum in memory.
8. Increment the byte pointer (BX) and result pointer (BP).
9. Decrement the byte count (CL).
10. If byte count (CL) is zero go to next step, otherwise go to step-8.
11. Store final carry in memory.
12. Stop.

PROGRAM:

MOV SI, 2000H


MOV DI, 3000H
MOV BX, 2008H
MOV CL, 04
UP: MOV AL, [SI]
ADD AL, [BX]
MOV [DI], AL
INC SI
INC BX
INC DI
DEC CL
JNZ UP
HLT
Input Output
Memory Data Memory Data Memory Data
Location Location Location

2000 01 2008 23 3000 24

2001 02 2009 27 3001 29

2002 07 200A 10 3002 17

2003 08 200B 14 3003 1C

RESULT:

Thus the addition of multi-byte numbers have been performed and results are observed at
different locations of the memory.
Ex.No : 3 16-bit Data Multiplication using 8086

DATE : 06-08-2020

AIM:
To multiply two 16-bit values and to view the result in memory locations.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Initialize the source index register to 1100H.


2. Load the first data in AX register.
3. Load the second data in BX register.
4. Multiply the two data and store the product term in AX register.
5. Store the lower 16-bit at memory address [1104].
6. Store the higher 16-bit at memory location [1106].
7. Terminate the program.

PROGRAM:

MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
MUL BX
MOV [SI+4], AX
MOV AX, DX
MOV [SI+6], AX
HLT

INPUT:
1100: 43
1101: 43
1102: 11
1103: 11

OUTPUT:
1104: 73
1105: EA
1106: 7B
1107: 04
RESULT:

Thus the two 16-bit numbers are multiplied and the results are observed at
different locations of the memory.
Ex.No : 4 16-bit Data Division using 8086

DATE : 06-08-2020

AIM:
To divide a 16-bit value by a 8-bit number and to view the result in memory locations.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Initialize the source index register to 1100H.


2. Load the dividend in AX register.
3. Load the divisor in BX register.
4. Divide the two data and store the quotient in AX register .
5. Store the quotient at memory address [1104].
6. Store the remainder at memory location [1106].
7. Terminate the program.

PROGRAM:

MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
DIV BX
MOV [SI+4], AX
MOV AX, DX
MOV [SI+6], AX
HLT

INPUT:

1100: 24 1100: 23
1101: 24 1101: 11
1102: 02 1102: 02
1103: 00 1103: 00

OUTPUT:

1104: 12 1104: 91
1105: 12 1105: 08
1106: 00 1106: 01
1107: 00 1107: 00
RESULT:

Thus the a 16-bit number is divided by a 8 bit number and the results are
observed at different locations of the memory.
Ex.No : 5 BCD Addition using 8086

DATE : 06-08-2020

AIM:
To perform BCD addition among
I. Two 8-bit values and to store the results in different location of memory.
II. Two 16-bit values and to store the results in different location of memory.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Initialize the source index register to 1100H.


2. Load the first data in AL/AX register.
3. Load the second data in BL/BX register.
4. Add the two data.
5. Apply DAA instruction to perform decimal adjust.
6. Store the result in memory address [1102]/ [1104].
7. Store the carry at memory location [1103]/ [1106].
8. Terminate the program.

PROGRAM:

A. 8-BIT BCD ADDITION

MOV SI, 1100H


MOV AL, [SI]
MOV BL, [SI+1]
ADD AL, BL
DAA
MOV [SI+2], AL
MOV AL, 00
ADC AL, AL
MOV [SI+3], AL
HLT

INPUT: OUTPUT:

1100: 11 1102: 22
1101: 11 1103: 00

INPUT: OUTPUT:

1100: 11 1102: 10
1101: 99 1103: 01
B. 16-BIT BCD ADDITION

MOV SI, 1100H


MOV AX, [SI]
MOV BX, [SI+2]
ADD AX, BX
DAA
MOV [SI+4], AX
MOV AX, 00
ADC AX, AX
MOV [SI+6], AX
HLT

INPUT: OUTPUT:

1100: 11 1104: 22
1101: 11 1105: 22
1102: 11 1106: 00
1103: 11 1107: 00

INPUT: OUTPUT:

1100: 11 1104: 10
1101: 11 1105: AA
1102: 99 1106: 01
1103: 99 1107: 00
RESULT:

Thus the BCD addition of 8-bit and 16-bit numbers are performed and the results are
observed for both with and without borrow operations at different location of memory.
Ex.No : 6 1’s complement and 2’s complement number using 8086

DATE : 14-08-2020

AIM:
To perform 1’s and 2’s complement of a16-bit data.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Get the input number in the memory location 1100.


2. Move that number in AX register.
3. Find I’s Complement of an given number .
4. Store the result in [1102]
5. ADD I with LSB
6. Store the 2’S Compliment in [1104]
7. Stop the program.

PROGRAM:

MOV SI, 1100H


MOV AX, [SI]
NOT AX
MOV [SI+2], AX
INC AX
MOV [SI+4], AX
HLT

Input Output
Memory Data
1100 11 1102: EE 1104: EF

1101 23 1103: DC 1105: DC


RESULT:

Thus 1’s and 2’s complement of a 16-bit data are performed and the results are noted.
Ex.No : 7 16-bit Logical Operations using 8086

DATE : 14-08-2020

AIM:
To perform logical operations such as AND, OR,XOR, and NOT among two 16-bit
data.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

16-bit AND operation


1. Load the first data in AX register.
2. Load the second data in BX register.
3. The contents of BX is AND with AX register and store the result in AX.
4. Store the sum in source index register.
5. Stop.

16- bit OR operation


1. Load the first data in AX register.
2. Load the second data in BX register.
3. The contents of BX is OR with AX register and store the result in AX.
4. Store the difference in source index register.
5. Stop.

16- bit XOR operation


1. Load the first data in AX register.
2. Load the second data in BX register.
3. The contents of BX is XOR with AX register and store the result in AX.
4. Store the values in source index register.
5. Stop

16- bit NOT operation


1. Load the first data in AX register.
2. The contents of AX is NOT.
3. Store the values in corresponding registers.
4. Stop.
PROGRAM:

a. 16-bit AND operation

MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
AND AX, BX
MOV [SI+4], AX
HLT

b. 16-bit OR operation

MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
OR AX, BX
MOV [SI+4], AX
HLT

c. 16-bit XOR operation

MOV SI,1100H
MOV AX, [SI]
MOV BX, [SI+2]
XOR AX, BX
MOV [SI+4], AX
HLT

d. 16-bit NOT operation

MOV SI,1100H
MOV AX, [SI]
NOT AX
MOV [SI+2], AX
HLT

Input Output
AND OR XOR
Memory Data
1100 11 1104: 00 1104: 11 1104: 11
1101 23
1102 00 1105: 23 1105: 23 1105: 00
1103 23
NOT gate

Input: Output:
1100: 11 1102: EE
1101: 23 1103: DC

AND gate
OR gate
XOR gate
NOT gate

RESULT:

Thus the logical operations such as AND, OR, XOR and NOT among two 16-bit data
are performed and the results are noted.
Ex.No : 8 Data Block Movement using

8086 DATE : 21-08-2020

AIM:
To perform data block movement without overlap.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Load the starting address of 1st data in SI register.


2. Load the starting address of 2nd data in DI register.
3. Load the byte count in CL register.
4. Load a byte of 1st data in AL register.
5. Store the sum in memory.
6. Increment the byte pointer (BX) and result pointer (BP).
7. Decrement the byte count (CL).
8. If byte count (CL) is zero go to next step, otherwise go to step-8.
9. Store final carry in memory.
10. Stop.

PROGRAM:
MOV SI, 2000H
MOV DI, 3000H
MOV CX,0004
REP
MOVSW
HLT

ALGORITHM:

1. Load the starting address of 1st data in SI register.


2. Load the starting address of 2nd data in DI register.
3. Load the byte count in CX register.
4. MOVSW implies the string is to be moved as words from SI to DI and store the
sum in memory.
5. Repeat step 4 until CX becomes 0
6. HLT

PROGRAM:
MOV SI, 2000H
MOV DI, 3000H
MOV CX,0004
REP
MOVSW
HLT
Input Output

Method-1 Method-2
2000: 1A 3000: 1A 3000: 1A
2001: 1B 3001: 1B 3001: 1B
2002: 1C 3002: 1C 3002: 1C
2003: 1D 3003: 1D 3003: 1D

Method-1
Method-2
16 - BIT BLOCK TRANSFER

ALGORITHM:

Step 1: Initialize CL register to number of data in an array (05H).


Step 2: Initialize SI register to starting address of first array (1100H).
Step 3: Initialize DI register to starting address of second array (1200H).
Step 4: Get the data from the first array to AX register.
Step 5: Copy the data from the AX register to second array.
Step 6: Increment SI and DI registers by 2.
Step 7: Decrement the CL register by 1 and If ZF=0, then go to step – 4.
Step 8: Stop the program.

PROGRAM:

MOV CL, 05H


MOV SI, 1100H
MOV DI, 1200H
loop-1: MOV AX, [SI]
MOV [DI], AX
INC SI
INC SI
INC DI
INC DI
DEC CX
JNZ loop-1
HLT
Input Output
1100: 1A 1200: 1A
1101: 2A 1201: 2A
1102: 1B 1202: 1B
1103: 2B 1203: 2B
1104: 1C 1204: 1C
1105: 2C 1205: 2C
1106: 1D 1206: 1D
1107: 2D 1207: 2D
1108: 1E 1208: 1E
1109: 2E 1209: 2E
RESULT:

Thus the operation of data block movement have been performed and results are
observed at different locations of the memory.
Ex.No : 9a Code Conversion using 8086

DATE : 28-08-2020

AIM:
To perform code conversion operation

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Load the first data in SI.


2. Allocate memory to DI to save the data.
3. Perform AND operation between AL and OF.
4. Store the result in DI.
5. Stop.

PROGRAM:

MOV SI, 2000H


MOV DI,2500H
MOV AL, [SI]
AND AL,0FH
MOV [DI], AL
HLT
INPUT DATA OUTPUT DATA

2000: 37 2500: 07

RESULT:

Thus code conversion operation is performed.


Ex.No : 9b Code Conversion of Hexadecimal nibble to ASCII number
using 8086

DATE : 28-08-2020

AIM:
To convert a hexadecimal nibble to ASCII number.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Set SI as pointer for hexagonal nibble.


2. Set DI as pointer for ASCII array.
3. Get a byte of hexagonal nibble in AL registers.
4. Compare AL with 09H.
5. If it is equal go to step L1, otherwise go to step 8.
6. Check carry flag, if carry flag is set, go to step 8.
7. Add 07H from AL register.
8. Add 30H from AL register.
9. Load the binary array in AL to DI.
10.Stop the program.

PROGRAM:

MOV SI, 2000H


MOV DI, 3000H
MOV AL, [SI]
CMP AL, 09H
JE L1
JC L1
ADD AL, 07H
L1: ADD AL, 30H
MOV [DI], AL
HLT
Input Data: Output Data:
2000 – 0A 3000 – 41
2000 - 0F 3000 – 46

RESULT:

Thus hexadecimal nibble to ASCII number is converted.


Ex.No : 9c Code Conversion of 8-bit Hexadecimal number to BCD
number using 8086

DATE : 04-09-2020

AIM:
To convert an 8-bit hexadecimal number to BCD number.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Load the address of data in BX register.


2. Get the binary data in AL register.
3. Clear DX register for storing hundreds and tens.
4. Compare AL with 64 (100 ).
H 10

5. Checks carry flag. If carry flag is set then go to step-9, otherwise go to next step.
6. Subtract 64 (100 ) from AL register.
H 10

7. Increments hundreds register (DL).


8. Go to step-4.
9. Compare AL with 0A (10 ).
H 10

10. Checks carry flag. If carry flag is set then go to step-14, otherwise go to next step.
11. Subtract 0A (10 ) from AL register.
H 10

12. Increments tens register (DH).


13. Go to step-9.
14. Move the count value 04H for rotation in CL register.
15. Rotate the content of DH four times.
16. Add DH to AL to combine tens and units as 2-digit BCD.
17. Save AL and DL in memory.
18. Stop.

PROGRAM:
MOV BX, 1100H
MOV AL, [BX]
MOV DX, 0000H
HUN: CMP AL, 64H
JC TEN
SUB AL, 64H
INC DL
JMP HUN
TEN: CMP AL, 0AH
JC UNIT
SUB AL, 0AH
INC DH
JMP TEN
UNIT: MOV CL, 04
ROL DH, CL
ADD AL, DH
MOV [BX+1], AL
MOV [BX+2], DL
HLT

Input Data: Output Data:


1100 – 39 1101 – 57
1102 – 00
RESULT:
Thus 8-bit hexadecimal number to BCD number is converted.
Ex.No : 9d Code Conversion of 8-bit BCD number to Hexadecimal
number using 8086

DATE : 04-09-2020

AIM:
To convert an 8-bit BCD number to hexadecimal number.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Load the address of data in SI and DI register.


2. Move the contents of [SI] to BL.
3. Use AND instruction to perform AND between 0F and contents of BL.
4. Move the contents of [SI] to AL.
5. Use AND instruction to calculate AND between the value 240 and contents of AL.
6. Move 04 in CL.
7. Use ROR instruction on AL.
8. Move 0A in DL.
9. Use MUL instruction to multiply AL with DL.
10. Use ADD instruction to add AL with BL.
11. Move the contents of AL in [DI].
12. Halt the program.

PROGRAM:

MOV SI, 500H


MOV DI, 600H
MOV BL, [SI]
AND BL, 0FH
MOV AL, [SI]
AND AL, 240
MOV CL, 04H
ROR AL, CL
MOV DL, 0AH
MUL DL
ADD AL, BL
MOV [DI], AL
HLT
Input Data: Output Data:

500 – 18 600 – 12

RESULT:

Thus 8-bit BCD number to hexadecimal number is converted.


Ex.No : 10a Addition/Subtraction of two nxn matrices using

8086 DATE : 11-09-2020

AIM:
To perform addition and subtraction operation among two 4x4 matrices.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Load the starting address of 1st data in SI register.


2. Load the starting address of 2nd data in DI register.
3. Set the Count Value as 04.
4. Move Contents of SI register to AL.
5. Move contents of DI register to BL.
6. Add/Subtract the contents of AL and BL.
7. Move the result from AL register to Memory.
8. Increment SI and DI register.
9. Decrement Count Value.
10. If Count Value becomes zero, stop the program.

PROGRAM:

Matrix Addition

MOV SI,2000H
MOV DI,3000H
MOV CL,04H
L1: MOV AL, [SI]
MOV BL, [DI]
ADD AL, BL
MOV [DI], AL
INC DI
INC SI
DEC CL
JNZ L1
MOV AH, 4CH
HLT
Matrix Subtraction

MOV SI,2000H
MOV DI,3000H
MOV CL,04H
L1: MOV AL, [SI]
MOV BL, [DI]
SUB AL, BL
MOV [DI], AL
INC DI
INC SI
DEC CL
JNZ L1
MOV AH, 4CH
HLT
OUTCOME:
Matrix Addition:
Input Output
Memory Location Data Memory Location Data Memory Location Data

2000 01 3000 04 3000 05

2001 05 3001 07 3001 0C

2002 04 3002 07 3002 0B

2003 03 3003 07 3003 0A


OUTCOME:
Matrix Subtraction:

Input Output
Memory Location Data Memory Location Data Memory Location Data

2000 04 3000 01 3000 03

2001 07 3001 05 3001 02

2002 09 3002 03 3002 06

2003 08 3003 02 3003 06

RESULT:

Thus the addition and subtraction of two 4x4 matrices have been performed and results
are observed at different locations of the memory.
Ex.No : 10b String Manipulations using 8086

DATE : 11-09-2020

AIM:
i.To perform string of data copy operation using 8086.
ii.To reverse the string of input data.

APPARATUS REQUIRED: emu8086 emulator.

i. ALGORITHM:

1. Set SI as pointer for input array of data’s.


2. Set DI as pointer for output array of data’s.
3. Set CX as counter.
4. Clear direction flag (DF) for auto increment of pointers.
5. Move the string of data’s up to the counter value.

PROGRAM:

String Copy

MOV SI, 2000H


MOV DI, 2100H
MOV CX, 04H
CLD
NEXT: MOVSB
LOOP NEXT
HLT

ii. ALGORITHM:

1. Set SI as pointer for input array of data’s.


2. Set DI as pointer for output array of data’s.
3. Set CX as Counter
4. Add counter of SI with 07
5. Move contents of SI address to AL and from AL TO DL address.
6. Decrement SI and DI to reverse.
7. Decrement CX and report loop if DL to 0
8. Stop the Program.
PROGRAM:

String Reversal

MOV SI, 2000H


MOV DI, 3000H
MOV CX, 0008H
ADD SI, 07
L1: MOV AL, [SI]
MOV [DI], AL
DEC SI
INC DI
DEC CX
JNZ L1
HLT

String Copy
String Reversal
OUTCOME:

String Copy:

Input Output
Memory Location Data Memory Location Data

2000 01 2100 01

2001 05 2101 05

2002 04 2102 04

2003 03 2103 03
String Reversal:

Input Output
Memory Location Data Memory Location Data

2000 08 3000 01

2001 07 3001 02

2002 06 3002 03

2003 05 3003 04

2004 04 3004 05

2005 03 3005 06

2006 02 3006 07

2007 01 3007 08

RESULT:

Thus the string manipulation operations such as copying string of data and reversal
have been performed and results are observed at different locations of the memory.
Ex.No : 11 Data Arrangement in ascending/ descending order
using 8086

DATE : 18-09-2020

AIM:

To sort an array of numbers in ascending and descending order and to view the
result in memory locations.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Set SI register as pointer for array.


2. Set CL register as count for N – 1 repetition.
3. Initialize array pointer.
4. Set CH as count for N – 1 Comparisons.
5. Increment the array pointer.
6. Compare the next element of the array with AL.
7. Check the carry flag. If carry flag is set then go to step-12, otherwise go to
next step.
8. Exchange the content of memory pointed by SI and the content
of previous memory location
9. Decrement the count for comparisons (CH register).
10. Check zero flag. If zero flag is reset then go to step-6,
otherwise go to next step.
11. Decrement the count for repetitions (CL register).
12. Check zero flag. If zero flag is reset then go to step-3,
otherwise go to next step.
13. Stop.

PROGRAM:

Ascending Order:

START: MOV SI, 1100H


MOV CL, [SI]
DEC CL

REPEAT: MOV SI, 1100H


MOV CH, [SI]
DEC CH
INC SI
REM:MOV AL, [SI]
INC SI
CMP AL, [SI]

JC LOOP
XCHG AL, [SI]
XCHG AL, [SI - 1]

LOOP: DEC CH
JNZ REM
DEC CL
JNZ REPEAT
HLT

Descending Order:

START: MOV SI, 1100H


MOV CL, [SI]
DEC CL

REPEAT: MOV SI, 1100H


MOV CH, [SI]
DEC CH
INC SI

REM:MOV AL, [SI]


INC SI
CMP AL, [SI]

JNC LOOP
XCHG AL, [SI]
XCHG AL, [SI - 1]

LOOP: DEC CH
JNZ REM
DEC CL
JNZ REPEAT
HLT
Ascending Order:
Descending Order:
ASCENDING ORDER:

INPUT:
1100: 04
1101: 03
1102: 06
1103: 05
1104: 02

OUTPUT:
1101: 02
1102: 03
1103: 05
1104: 06

DESCENDING ORDER:

INPUT:
1100: 04
1101: 06
1102: 03
1103: 05
1104: 07

OUTPUT:
1101: 07
1102: 06
1103: 05
1104: 03

RESULT:

Thus sorting an array of numbers in ascending and descending order have been
done and the results are observed at different locations of the memory.
Ex.No : 12 Search for data in an array using

8086 DATE : 18-09-2020

AIM:
To search a given data in an array and also to determine the position and address of
the data in the array.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Set SI register as pointer for the array.


2. Set DI register as pointer for given data and result.
3. Get the data to search in DL register.
4. Let BL register keep track of position. Initialize the position count as one.
5. Get an element of array in AL.
6. Compare an element of array (AL) with given data (DL).
7. Check for Zero flag. If zero flag is set then go to step-14, otherwise go
to next step.
8. Increment the array pointer (SI) and position count (BL).
9. Get next element of array in AL register.
10. Compare AL with end marker (20H).
11. Check zero flag. If zero flag is not set, then go to step-6,
12. Otherwise go to next step.
13. Clear CX register and store CX register in four
14. Consecutive locations in memory after the given data.
15. Jump to end (Step-17).
16. Move FFH to BH register and store it in memory.
17. Store the position count (BL) in memory.
18. Store the address (SI) in memory.
19. Stop.

PROGRAM:

START: MOV SI, 1100H


MOV DI, 1200H
MOV DL, [DI]
MOV BL, 01H
MOV AL, [SI]
AGAIN: CMP AL, DL
JZ AVAIL
INC SI
INC BL
MOV AL, [SI]
CMP AL, 20H
JNZ AGAIN
MOV CX, 0000H
MOV [DI+1], CX
MOV [DI+3], CX
JMP OVER
AVAIL: MOV BH, 0FFH
MOV [DI+1], BH
MOV [DI+2], BL
MOV [DI+3], SI
OVER: HLT
DATA SEARCH:

Input Data: Output Data:


1100 – 01 1200 – 02[Data to Search] 1201 – FF [Data Availability, FF
if data avail, else 00]
1101 – 02 1202 – 02 [Position]
1102 – 09 1203 – 01 [LSB of Address]
1103 – 45 1204 – 11 [MSB of Address]
1104 – 3A

1105 – 20 [End of Array]

RESULT:

Thus data search in an array done and the results such as its availability, position and
address are observed.
Ex.No : 13 Password Checking using

8086 DATE : 09-10-2020

AIM:
To check whether the password is correct or not.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:

1. Display message enter password condition dx=message,ah-09,int -21h


2.Intialize the password.
3. Count.

4. Read a character ,ah-08,int 21h

5. Compare the read character in al with one character of

password. 6.If both are not equal display invalid password.


7.If all characters are equal display password is correct.

PROGRAM:
DATA SEGMENT
PASSWORD DB 'MPMC1234'
LEN EQU ($-PASSWORD)
MSG1 DB 10,13,'ENTER YOUR PASSWORD: $' //10-ascill character in new
line,13carriage return
MSG2 DB 10,13,'WELCOME TO ELECTRONICS WORLD!!$'
MSG3 DB 10,13,'INCORRECT PASSWORD!$'
NEW DB 10,13,'$'
INST DB 10 DUP(0) // 10-equilaent hexa value of 16, dup(0)- bytes, avoid garbage
DATA ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1 //load effective address
MOV AH,09H // dos interrupt ,display string on screen first message will be displayed
INT 21H
MOV SI,00
UP1:
MOV AH,08H // keyboard input without any echo
INT 21H // CALLS Interrupt handler
CMP AL,0DH
JE DOWN
MOV [INST+SI],AL
MOV DL,'*'
MOV AH,02H // request single display chatracter
INT 21H //software interrupt
INC SI
JMP UP1
DOWN:
MOV BX,00
MOV CX,LEN
CHECK:
MOV AL,[INST+BX]
MOV DL,[PASSWORD+BX]
CMP AL,DL
JNE FAIL //jne-jump if nit equal
INC BX
LOOP CHECK
LEA DX,MSG2
MOV AH,09H // request display
INT 21H
JMP FINISH
FAIL:
LEA DX,MSG3
MOV AH,009H
INT 21H
FINISH:
INT 3
CODE ENDS
END START
END
RESULT:

Thus password checking is verified.


Ex.No : 14 Time Delay using 8086

DATE : 09-10-2020

AIM:
To read create customized time delay to print the string.

APPARATUS REQUIRED: emu8086 emulator.

PROGRAM:

.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, 30
MOV DL, AL
MOV AX, BX
MOV CL, 0AH
MUL CL
MOV BX, AX
AND DX, 00FFH
ADD BX, DX
MOV DELAYTIME, BX
LOOP IN1
NXT:
MOV CX, DELAYTIME
MOV DL, 10
MOV AH, 02H
INT 21H
LEA SI, MSG1
LP:PUSH DX
MOV DL,[SI]
CMP DL,'$'
JE NXT2
MOV AH, 02H
INT 21H
ADD SI, 1
POP DX
MOV DI, DELAYTIME
MOV AH, 0
INT 1Ah
MOV BX, DX
Delay:
MOV AH, 0
INT 1Ah
SUB DX, BX
CMP DI, DX
JA Delay
LOOP LP
NXT2:
MOV AH, 4CH
INT 21H
END

Note:
i.model is the part of program which tells assembler which model we need to use for
our program. In this program we are using SMALL, but there are many like TINY,
SMALL and LARGE

.MODEL SMALL

ii.After setting up DATA SEGMENT, CODE SEGMENT starts, which tells assembler
that our program has been started. We define CODE SEGMENT same as we defined
DATA SEGMENT.

.CODE
OUTPUT:

Time delay :2 ms
This is Microprocessor

RESULT:

Thus the time delay of a string has been created and verified using the simulator.
EX NO: 15 Digital clock using 8086
DATE: 09-10-2020

AIM:
To write an ALP to display Digital clock using 8086

APPARATUAS REQUIRED: 8086 emulator

PROGRAM:

.MODEL SMALL

.STACK 100H

.DATA

PROMPT  DB 'Current System Time is : $'     

TIME DB '00:00:00$'        

.CODE

   MAIN PROC

     MOV AX, @DATA             

     MOV DS, AX

     LEA BX, TIME                 

     CALL GET_TIME                

     LEA DX, PROMPT              

     MOV AH, 09H                  

     INT 21H                      

     LEA DX, TIME                

     MOV AH, 09H                  

     INT 21H                      

     MOV AH, 4CH                  

     INT 21H
   MAIN ENDP

GET_TIME PROC    

    PUSH AX                       

    PUSH CX                       

    MOV AH, 2CH                   

    INT 21H                       

    MOV AL, CH                    

    CALL CONVERT                  

    MOV [BX], AX                  

    MOV AL, CL                    

    CALL CONVERT                  

    MOV [BX + 3], AX                                                          

    MOV AL, DH                    

    CALL CONVERT                  

    MOV [BX + 6], AX                                                                     

    POP CX                        

    POP AX                        

    RET                           

GET_TIME ENDP                   

   CONVERT PROC     

    PUSH DX                       

    MOV AH, 0                     

    MOV DL, 10                   

    DIV DL                        

    OR AX, 3030H                  

    POP DX                        
    RET                           

   CONVERT ENDP                   

 END MAIN

OUTPUT:
Current system Time is: 11:06:46
RESULT:
Thus the Digital Clock is displayed using 8086.

EX NO: 16 Printer Status


DATE: 09-10-2020

AIM:
To check the Status of Printer using 8086.

APPARATUAS REQUIRED: 8086 Emulator.

PROGRAM:
name "charchar"
org 100h
print_new_line macro
mov dl, 13
mov ah, 2
int 21h
mov dl, 10
mov ah, 2
int 21h
endm
mov dx, offset msg1
mov ah, 9
int 21h
; input the string:
mov dx, offset s1
mov ah, 0ah
int 21h
; get actual string size:
xor cx, cx
mov cl, s1[1]
print_new_line
mov bx, offset s1[2]
print_char:
mov dl, [bx]
mov ah, 2
int 21h
print_new_line
inc bx
loop print_char
; wait for any key...
mov ax, 0
int 16h
ret
msg1 db "ENTER THE STRING: $"
s1 db 100,?, 100 dup(' ')
end

OUTPUT:
ENTER THE STRING: PADMA
P
A
D
M
A
RESULT:

Thus the status of printer is checked using 8086.

EX NO: 17 INTERFACING OF STEPPER MOTOR WITH 8086


DATE: 12-10-2020

AIM:
To control stepper motor in clock wise and counter clock wise direction using 8086.

APPARATUS REQUIRED: emu8086 emulator.

PROCEDURE:
1. Load the program
2. Click on emulator
3. Click on run option to see the stepper motor rotation

ALGORITHM:
1. The virtual port 7 is configured.
2. The port connected to the stepper motor does the rotation based on the value specified in the table.

PROGRAM:
name "stepper"

steps_before_direction_change = 20h ; 32 (decimal)

jmp start

; ========= data ===============

; bin data for clock-wise


; half-step rotation:
datcw db 0000_0110b
db 0000_0100b
db 0000_0011b
db 0000_0010b

; bin data for counter-clock-wise


; half-step rotation:
datccw db 0000_0011b
db 0000_0001b
db 0000_0110b
db 0000_0010b

; bin data for clock-wise


; full-step rotation:
datcw_fs db 0000_0001b
db 0000_0011b
db 0000_0110b
db 0000_0000b

; bin data for counter-clock-wise


; full-step rotation:
datccw_fs db 0000_0100b
db 0000_0110b
db 0000_0011b
db 0000_0000b

start:
mov bx, offset datcw ; start from clock-wise half-step.
mov si, 0
mov cx, 0 ; step counter

next_step:
; motor sets top bit when it's ready to accept new command
wait: in al, 7
test al, 10000000b
jz wait

mov al, [bx][si]


out 7, al

inc si

cmp si, 4
jb next_step
mov si, 0

inc cx
cmp cx, steps_before_direction_change
jb next_step

mov cx, 0
add bx, 4 ; next bin data

cmp bx, offset datccw_fs


jbe next_step
mov bx, offset datcw ; return to clock-wise half-step.
jmp next_step

OUTPUT:
RESULT:

Thus the rotation of stepper motor have been observed in both clock wise and counter
clockwise direction for specific time interval.
EX NO: 18 Interfacing of Traffic Light controller with 8086
DATE: 12-10-2020

AIM:
To interface the traffic light using 8086.

APPARATUS REQUIRED: emu8086 emulator.

PROCEDURE:
1.Load the program
2.Click on emulator
3.Open traffic.exe from virtual devices tab
4.Click on run to see the traffic light control

ALGORITHM:
1.Move the contents to AX register.
2.Initialize traffic lights.
3.Load SI register with offset values.
4.Set AX with SI register values.
5.Change the light status after a certain period of time.
6.Send the command from the array table to the port.
7.Stop the program.

PROGRAM:

name "traffic"
mov ax, all_red
out 4, ax ; traffic lights
mov si, offset situation
next:
mov ax, [si]
out 4, ax

; wait 5 seconds (5 million microseconds)


mov cx, 4Ch ; 004C4B40h = 5,000,000
mov dx, 4B40h
mov ah, 86h
int 15h
add si, 2 ; next situation
cmp si, sit_end
jb next
mov si, offset situation
jmp next

; FEDC_BA98_7654_3210
situation dw 0000_0011_0000_1100b
s1 dw 0000_0110_1001_1010b
s2 dw 0000_1000_0110_0001b
s3 dw 0000_1000_0110_0001b
s4 dw 0000_0100_1101_0011b
sit_end = $

all_red equ 0000_0010_0100_1001b

OUTPUT:
RESULT:

Thus the traffic lights been adjusted for specific time interval and the results are
observed.
Ex.No : 19 Arithmetic Operations using 8051

DATE: 12-10-2020

AIM:
To perform the arithmetic operations of 8051.

APPARATUS REQUIRED: edsim51 emulator.

PROGRAM:

a) 8 BIT ADDITION

MOV A, #33H
MOV R1, #22H
ADD A, R1
MOV DPTR, #4500H
MOVX @DPTR, A
END
OUTPUT:

4500 – 55

b) 8 BIT SUBTRACTION

MOV A, #33H
MOV R7, #22H
SUBB A, R7
END
OUTPUT

A - 11

c) MULTIPLICATION

MOV A, #0FFH
MOV B, #02H
MUL AB
END
OUTPUT

A - FE
B – 01

d) DIVISION

MOV A, #0BH
MOV B, #02H
DIV AB
END
OUTPUT
A - 05
B – 01

e) Adding data from RAM memory and storing result in RAM memory
(using direct addressing method)

MOV 30h, #05H


MOV A, #07H
ADD A, 30H
MOV 31H, A
END
OUTPUT
31 - 0C

f) Adding data from RAM memory and storing result in RAM


memory (uisng indirect addressing method)

MOV R1, #33H


MOV R0, #30H
MOV A, #07H
ADD A, @R0
MOV @R1, A
MOV P1, A
END
OUTPUT

p1 – 07

PROGRAM

MOV R0, #03H


MOV PSW, #18H
MOV R0, #05H
END
RESULT:

Thus the operations of 8051 is verified using the simulator.


Ex.No : 20 Logical Operations using 8051

DATE: 15-10-2020

AIM:
To perform logical operations such as AND, OR,XOR, and NOT among two 8-bit data.

APPARATUS REQUIRED: emu8086 emulator.

ALGORITHM:
8-bit AND operation
3. Load the first data in A register.
4. The contents of Ais AND with 8 BIT DATA register and store the result in B register
5. Stop.

8-bit OR operation
1. Load the first data in A register.
2. The contents of Ais ORED with 8 BIT DATA register and store the result in B register
3. Stop.

8-bit XOR operation


1. Load the first data in A register.
2. The contents of Ais XORED with 8 BIT DATA register and store the result in B register
3. Stop.

8-bit NOT operation

1. 1. Load the first data in A register.


2. The contents of Ais XORED with 8 BIT DATA register and store the result in B register
3.Stop

PROGRAM:
a. 8-bit AND operation

MOV A,#0CH
ANL A,#09H
MOV B,A
END

b. 8-bit OR operation

MOV A,#0CH
ORL A,#09H
MOV B,A
END
c. 8-bit XOR operation

MOV A,#0CH
XRL A,#09H
MOV B,A
END

d. 8-bit NOT operation

MOV A,#4CH
CPL A
MOV B,A
END

 AND

OUTPUT:
    B - 08

OR
OUTPUT:

B - 0D

XOR

OUTPUT:
B – 05
 NOT
OUTPUT:

B - B3

RESULT:

Thus the logical operations such as AND, OR,XOR, and NOT among two 8-bit data are performed
and the results are noted.

EX.NO: 21 Cube of the Number using 8051


DATE: 15-10-2020

AIM:
To find cube of a number using 8051.

APPARATUS REQUIRED: edsim51 emulator.

PROGRAM:
org 0000h
mov a, #n //assign value 'n' in decimal to A

mov b, #n //assign value 'n' in decimal to B


mov r0, #n //assign value 'n' in decimal to R0
mul ab
mov 40h, a

mov 41h, b

mov r1, a
mov a, b
mov b, r0
mul ab
mov b, a
mov r2, b

mov a, r1

mov b, r0

mul ab
mov 50h, a
mov r3, b
mov a, r2
add a, r3
mov b, a
mov 51h, b
end
INPUT: OUTPUT:
a – 02 50 –08
b – 02 51 –00
r0 – 02

RESULT:
Thus a cube program is done in 8051 microcontroller.

EX NO: 22 Unpacked BCD to ASCII using 8051


DATE: 15-10-2020

AIM:
To write an ALP to perform the code conversion of BCD to ASCII.

ALGORITHM:
1.Get a number
2.Add the number with 30 H
3. Move the content to any register .
4.Store the result.
5.Stop the program

PROGRAM:
MOV A,#02H
ORL A,# 30H
MOV B,A
END

INPUT OUTPUT TABLE:


Input Output
02H 32H

RESULT:

Thus an Unpacked BCD number is converted to ASCII using 8051.

You might also like