Vous êtes sur la page 1sur 39

DEPARTMENT OF INFORMATION

TECHNOLOGY

IT6411 MICROPROCESSORS AND


MICROCONTROLLERS LAB
LAB MANUALS
FOURTH SEMESTER
REGULATION 2013

[Type the abstract of the document here. The abstract is typically a short summary of the contents of the
document. Type the abstract of the document here. The abstract is typically a short summary of the
contents of the document.]

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

ANNA UNIVERSITY
CHENNAI-600 025
DEPARTMENT OF INFORMATION TECHNOLOGY
YEAR / SEM : II YEAR / IV SEM REGULATION : AUC / 2013

IT6411 MICROPROCESSORS AND MICROCONTROLLERS LAB


S. No

Title of Experiments

Page No

8086 programs using kits and MASM


1

Basic arithmetic operations


Logical operations

Move a data block without overlap


8086 Programs using Open source
Code conversion and decimal arithmetic and
matrix operation
Floating point operation
String manipulation
Sorting and searching
Password checking, Print RAM size and system
date
Counters and Time delay

3
4
5
6

2
6
11
13

16

Peripherals and Interfacing Experiments


7
8
9
10
11
12
13

Traffic light control


Stepper motor Control
Digital clock
Keyboard, Display I/F
Printer status
Serial Interface and parallel interface
A/D Interface and D/A Interface and waveform
generation

17
18
20
23
27
29

8051 Experiments using kits and MASM


14
15
16

Basic arithmetic and logical operations


Square and cube of program, Find 2s
complement of a number
Unpacked BCD to ASCII

STAFF-IN-CHARGE

31

HOD/IT

IT Dept/KLNCE

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

EX.NO : 1 A

ARITHMETIC OPERATIONS USING 8086

i.Aim:
To perform arithmetic operations using 8086.
Apparatus:
1.Microprocessor kit
2.Power chord
3.Keyboard.
Two Byte Addition:
Algorithm:
1.Initialize carry register CL with 00.Load AH and AL registers with MSB and LSB
of first data respectively. Load BH and BL registers with MSB and LSB of second
data.
2.Add accumulator register content with base register.
3.Check for carry flag.If carry exixts,increment carry register by one,else go to next
step.
4.Store accumulator content to 1500 and 1501 respectively.
5.Store carry register content to 1502 and stop program.
Program:
Address
Opcode

Operand

Label Mnemonics
Comments
MOV CL,00
MOV
AX,0FFFEH
MOV BX,1010H
ADD AX,BX
JNC L1
INC CL
L1
MOV [1500],AX
MOV [1502],CL
HLT

ii. Multi Byte Addition:


Algorithm:
1. Load SI with address of first byte of first data.
2. Load DI with address of first byte of second data.
3. Clear the carry flag and initialize counter register with no.of data
bytes of data to be added.
4. Add the content of memory pointed by DI with content of memory pointer by
IT Dept/KLNCE

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

DS:SI also with carry bit DI pointer acts as destination.


5. Update SI and DI register accordingly using DI and dec counter.
6. If counter is not equal to zero,go to step 4,else go to next step.
7. Stop program.
Program
Address
Opcode
Operand
Label Mnemonics
Comments
MOV SI,2400
MOV DI,2404
CLC
MOV CL,04
L1
MOV AL,[SI]
ADC[DI],AL
INC SI
INC DI
JN2 L1
HLT
Iii. Two Byte Subtraction:
Algorithm:
1. Move 00 to CL register. Load first and second data to AX and BX.
2. Subtract AX with BXIf carry exists,increase CL count.
3. Store AX register and CL count value to memory location.
4. Stop the program.
Program:
Address
Opcode
Operand
Label
Mnemonic Comments
s
MOV
CL,00
MOV
AX,0FFFF
H
MOV
BX,1010H
SUB
AX,BX
JNC L1
INC CL
L1;
MOV[1500
],AX
MOV[1502
],CL
HLT
IT Dept/KLNCE

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

iv.Multibyte Subtraction:
Algorithm:
1. Load SI and DI with first and second data.
2. Clear the carry flag and initialize CL register with no.of data byte.
3. Subtract content of memory pointer by ES:DI from content of memory pointer
by ES:DI along carry bit with DI pointer acts as destination pointer.
4. Update SI and DI register with carry bit DI pointer acting as decrement
counter.If counter !=0 then go to step 4,otherwise go to next step.
5. Stop the program.
Program:
Address
Opcode
Operand
Label
Mnemonics
Comments
MOV SI,2400
MOV
DI,2404
CLC
MOV CL,04
L1
MOV AL,[SI]
SBB[DI],AL
INC SI
INC DI
DEC CL
JNZ L1
HLT
v.8 Bit Multiplication:
Algorithm:
1. Load accumulator(AL) with 1st data and BL with 2nd data.
2. Multiply and store AX content into memory.
3. Stop the program
Program:
Address
Opcode
Operand
Label
Mnemonics Comments
MOV
AL,0AA
MOV
BL,0BB
MUL BL
MOV[3100],
AX
HLT
vi.16 Bit Multiplication:
Algorithm:
1. Load AX with 1st data and multiply 2nd data with AX content.
2. Move MSB in DX & LSB in AX to memory and stop the program.
IT Dept/KLNCE

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

Program:
Address
Opcode

Operand

Label

Mnemonics
Comments
MOV
AX,0FFFF
MOV
BX,1010
MUL BX
MOV[2902],D
X
MOV[2900],A
X
HLT

Vii.16/8 Bit Division:


Algorithm:
1. Load AX with first 16 bit
2. Get 2nd data in BL register.
3. Divide AX with BL content
4. Store AX content in memory
5. Stop the program
Program:
Address
Opcode
Operand

Label

Mnemonic Comments
s
MOV
AX,0002
MOV
BL,01
DIV BL
MOV[2300
],AX
HLT

Viii.32/16 Bit Division:


Algorithm:
1. Load AX with LSB of 1st data and DX with MSB first data
2. Divide DX & accumulator content with 2nd data
3. Store quotient (AX) into memory
4. Store remainder(DX) into memory
5. Stop the program.
Program:
Address
Opcode
Operand
Label
Mnemonic Comments
s
MOV
AX,6562
IT Dept/KLNCE

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

MOV
DX,1232
MOV
CX,1F20
DIV CX
MOV
[1200],AX
MOV[1202
],DX
HLT
Result:
Thus arithmetic operations using 8086 is done and program is executed and output is
verified.

Ex.NO:1.B

8086 programs using Logical Operations

i. ONE'S COMPLEMENT OF A 16-BIT NUMBER:


AIM:
To find the one's complement of the data in register pair AX and store the
result at 1400.
Apparatus required:
1.8086 Microprocessor kit
2.Power chord
3.Keyboard.
EXAMPLE:
The example given is to find the one's complement of 1234 and store it in
memory location 1400.
Input:
Data:
(AX) = 0001 0010 0011 0100 = 1234
Result:
[1400] = 1110 1101 1100 1011 = EDCB
PROGRAM:
MOV AX,1234 ; word in AX register
NOT AX
MOV [1400],AX ; One's complement in
IT Dept/KLNCE

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

; AX and memory
HLT
OBJECT CODES:
Memory Address

Object Codes

1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A

C7
C0
34
12
F7
D0
89
06
00
14
F4

Mnemonics
MOV AX,1234

NOT AX
MOV [1400],AX

HLT

ii. MASKING OFF BITS SELECTIVELY:


AIM:
To clear 8 selected bits,the 2nd HN and the HN in a 16 bit number.
EXAMPLE:
The 16 bit number is at location 1200 and the result is at location 1400.
Input:
[1200] = FF
[1201] = FF
Result:
[1400] = 0F
[1401] = 0F
PROGRAM:
MOV AX,[1200] ;data in AX
AND AX,0F0F
MOV [1400],AX ;result in 1400
HLT
OBJECT CODES:
Memory Address
1000

Object Codes
8B

Mnemonics
MOV AX,[1200]
IT Dept/KLNCE

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C

06
00
12
81
E0
0F
0F
89
06
00
14
F4

AND AX,0F0F

MOV [1400],AX

HLT

iii. SETTING BITS SELECTIVELY IN A 16-BIT NUMBER:


OBJECTIVE:
To set the LN snd the 2nd LN of a 16-Bit number in AX and store the
result at memory location 1100.
EXAMPLE:
The accumulator AX is initially cleared.
Input:
(AX) = 0000
Result:
[1100] = 0F0F
PROGRAM:
MOV AX,0 ;clear accumulator
OR AX,0F0F
;OR with 0F0F
MOV [1100],AX ;Store result in memory
HLT
OBJECT CODES:
Memory Address

Object Codes

Mnemonics

1000
1001
1002
1003
1004
1005
1006
1007
1008

C7
C0
00
00
81
C8
0F
0F
89

MOV AX,0000

OR AX,0F0F

MOV [1100],AX
IT Dept/KLNCE

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1009
100A
100B
100C

06
00
11
F4

HLT

iv. SUM OF THE NUMBERS IN A WORD ARRAY:


OBJECTIVE:
To obtain the sum of a 16-bit array in memory, using index register SI and store the
result in memory,
EXAMPLE:
Data in array from START =1110
[1110]=0FFF
[1112]=0FFF
[1114]=0FFF
[1116]=0FFF
[1118]=0FFF
PROGRAM:
MOV CX, 5
MOV AX, 0
MOV SI, AX
LOOP1 : ADD AX,START[SI]
ADD SI,2

;number of elements in CX
;initialise SI to start of array
;decrement CX and check
;if Zero

LOOP LOOP1
MOV [SUM],AX
HLT
OBJECT CODES:

Memory Address

Object Codes

Mnemonics

1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C

C7
C1
05
00
C7
C0
00
00
89
C6
03
06
10

MOV CX, 5

MOV AX, 00

MOV SI, AX
LOOP1 : ADD AX,[1100]

IT Dept/KLNCE

10

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

100D
100E
100F
1010
1011
1012
1013
1014
1015
1016
1017
1018

11
81
C6
02
00
E2
F6
89
06
00
12
F4

ADD SI,2

LOOP LOOP1
MOV [1200],AX

HLT

EX.NO 3
STRING MANIPULATION OPERATIONS USING 8086
Aim:
1. To transfer a block of 10 data word from one memory to another in forward &
reverse direction
2. Block transfer in forward direction:
Algorithm
1. Move source index register with necessary offset address
2. Move destination index register with necessary offset address
3. Load the count value in CX register
4. Move string byte from source to destination address through accumulator
5. Increment the SI & DI registers
6. Decrement CX,if it is zero ,go to next step else step 4
7. Stop the program
Program
Address
Opcode
Operand
Label
Mnemonic Comments
s
MOV
SI,1500
MOV
DI,1600
MOV
CX,0005
L1
MOV
AX,[SI]
L1
MOV
[DI],AX
INC SI
INC SI
INC DI
IT Dept/KLNCE

11

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

L2

INC DI
DEC CX
JNZ L1
HLT

Block transfer in reverse direction


Algorithm
1. Move source index register with necessary offset address
2. Move destination index register with necessary offset address
3. Load the count value in CX register
4. Move content of memory pointed by source index reg to accumulator
5. Move the accumulator content to memory pointed by destination index register
6. Increment DI and decrement SI register
7. Decrement CX,if zero go to next step,else go to step 4
8. Stop the program
Program
Address
Opcode
Operand
Label
Mnemonic Comments
s
MOV
SI,1500
MOV
DI,1600
MOV
CX,0005
L1
MOV
AX,[SI]
MOV
[DI],AX
DEC DI
DEC DI
INC SI
INC SI
DEC CX
JNZ L1
HLT
Array addition
Algorithm
1. Load the counter reg CX with the number of data bytes to be added & also
clear AX.
2. Load SI reg with the starting address of the data
3. Initialize the carry reg with zero.Add the numbers in the array pointed by SI
with content of AX along carry
4. Check for carry.If carry exists then increment the carr reg by 1 , then go to next
IT Dept/KLNCE

12

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

step
5. Update the SI content to point to the next data & decrement the CX reg
count.Check for zero flag.If not equal to zero go to next step
6. Move the result in AX and carry reg to memory
7. Stop the program
Program
Address
Opcode
Operand
Label
Mnemonic Comments
s
MOV
CX,0005
MOV
AX,0000
MOV
BX,0000
MOV
SI,1700
CLC
L2
ADC
AX,[SI]
JNZ L1
INC BX
L1
INC SI
INC SI
DEC CX
JNZ L2
MOV[1600
],AX
MOV[1602
],BX
HLT
Even and odd number generation
1. Load count value to CX register
2. Initialize DI register to a address & clear AL reg
3. Load accumulator with 00 for even number generation and 01 for odd number
generation
4. Move the content of accumulator to memory location pointed by DI
5. Add 02 to accumulator . Increment DI register
6. Decrement CX reg . If zero go to next step,else step 4
7. Stop the program
Even number generation
Address
Opcode
Operand
Label
Mnemonic Comments
s
MOV
IT Dept/KLNCE

13

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

L1

Odd number generation:


Address
Opcode
Operand

Label

L1

CX,0005
MOV
DI,1500
MOV
AL,00
MOV
[DI],AL
ADD
AL,02
INC DI
DEC CX
JNZ L1
HLT
Mnemonics Comments
MOV
CX,0005
MOV
DI,1500
MOV
AL,01
MOV
[DI],AL
ADD AL,02
INC DI
DEC CX
JNZ L1
HLT

Arithmetic operations using 8086 simulator(emu Open source)

Aim:
To perform arithmetic operations using 8086.
Apparatus Required:
1.PC with 8086 emulator

Program: 16 bit addition


ORG 1000h
Mov ax,0002h
IT Dept/KLNCE

14

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

Mov bx,0013h
Mov cx,0000h
Add ax,bx
Jnc l1
Inc cx
Mov si,1400h
Mov[si],ax
Add si,0002h
Mov [si],cx
Hlt
SAMPLE DATAS:ADDITION
INPUT
Address/Reg
Ax
Bx
CX

Data
004E
00FF
0000

OUTPUT
Address
Ax
Bx
CX

Data
01 4D
OOFF
OOOO

OUTPUT
Address
Ax
Bx

Data
EFF0
2030

16 bit subtraction
Mov ax,0005h
Mov bx,0003h
Mov cx,0000h
sub ax,bx
Jnc l1
Inc cx
Mov si,1400h
Mov[si],ax
Add si,0002h
Mov [si],cx
Hlt
SAMPLE DATAS:SUBTRACTION
INPUT
Address/Reg
Ax
Bx

Data
1020
20 30

IT Dept/KLNCE

15

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

CX

0000

CX

0001

16 bit Multiplication
Mov ax,1020h
Mov bx,2020h
Mov cx,0000h
Mov si,1400h
Mul bx
Mov [si],ax
Add si,0002h
Mov[si],cx
hlt

SAMPLE DATAS:MULTIPLICATION
INPUT
Address/Reg
Ax
Bx
CX

Data
1020
20 20
0000

OUTPUT
Address
Ax
Bx
CX
DX

Data
0400
2020
0000
0206

16 bit division
Mov ax,1020h
Mov bx,2020h
Mov cx,0000h
Mov si,1400
Div bx
Mov[si],ax
Add si,0002h
Mov[si],cx
hlt
SAMPLE DATAS:DIVISION
INPUT

OUTPUT
IT Dept/KLNCE

16

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

Address/Reg
Ax
Bx
CX

Data
0025
0005
0000

Address
Ax
Bx
CX
DX

Data
0007
2025
0000
0002

SORTING IN 8086:

org 1000h
mov ax,0505h
L3:mov bx,1400h
L2:mov ax,[bx]
cmp ax,0002h[bx]
jc l1
xchg ax,0002[bx]
mov [bx],ax
L1:add bx,0002h
dec di
jnc L2
mov cl,ch
dec ch
jmp L3
hlt
BLOCK TRANSFER [Forward ] :
mov si,1400h
mov di,1500h
mov cx,0005h
L1:mov ax,[si]
mov [di],ax
add si,0002h
add di,0002h
dec cx
jnz l1
mov [si],1500h
mov [si],ax
hlt
IT Dept/KLNCE

17

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

BLOCK TRANSFER [Reverse] :


mov si,1500h
mov di,1400h
mov cx,0005h
L1:mov ax,[si]
mov [di],ax
add di,0002h
add si,0002h
dec cx
jnz l1
mov [si],1400h
mov [si],ax
hlt
Ex.No .7

TRAFFIC LIGHT CONTROLLER

AIM:

To write a Program for Microprocessor based Traffic light system using


8086LCD mnemonics
APPARATUS REQUIRED:
8086 MP kit, 50 core cable,Traffic light controller interface
Procedure:
Enter the program starting from location 1000. Execute the program
The traffc light controller Led glows as per the given control word.
Direction can be varied by entering the data in the look up table in the reverse order.

Memory Address

Object Codes

Mnemonics

1000
1003
1007
100A
100C
100E
1010
1012
1016

C6 C0 80
E6 26
C7 C3 73 10
C7 C6 7F 10
E8 33 00
8A 04
E6 20
E8 4D 00
46

MOV AL,80H
MOV CL,04
MOV AL,[DI]
MOV C0,AL
MOV DX,1010
DEC DX
JNZ 100F
INC DI
LOOP 1007
IT Dept/KLNCE

18

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1017
1019
101A
101C
101F
1020

43
E8 27 00
8A 04
E6 22
E8 41 00
46
43
E8 1B 00

JMP 1000
TABLE 09 05 06 0A

Ex.No:8

Stepper motor Interface with 8086


AIM:
To run a stepper motor at different speed.
APPARATUS REQUIRED:
8086 MP kit, RS 232 cable, Stepper motor interface
Procedure:
Enter the program starting from location 1000. Execute the program
The stepper motor rotates. Speed can be varied by varying the count at dx register pair.
Direction can be varied by entering the data in the look up table in the reverse order.
PROGRAM

Memory Address

Object Codes

Mnemonics

1000
1004
1007
1009
100B
100F
1010
1012
1013
1015
1018

C7 C7 18 10
C6 C1 04
8A 05
E6 C0
C7 C2 1010
4A
75 FD
47
E2 F2
E9 E8 FF
09 05 06 0A

MOV DI,1018
MOV CL,04
MOV AL,[DI]
MOV C0,AL
MOV DX,1010
DEC DX
JNZ 100F
INC DI
LOOP 1007
JMP 1000
TABLE 09 05 06 0A

AIM:To run a stepper motor for required angle within 360 which is equivalent to 256
steps

IT Dept/KLNCE

19

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in


Procedure:
Enter the program and execute it
By converting the requiring steps in decimal to hex and entering the hex data at 1001 the
motor rotates for so much steps and stops.
PROGRAM

Memory Address

Object Codes

Mnemonics

1000
1003
1007
100A
100C
100E
1010
1012
1016
1017
1019
101A
101C
101F
1020

C7 C3 45
C7 C7 20 10
C6 C1 04
8A 05
E6 C0
FE CB
74 OD
C7 C2 10 10
4A
75 FD
47
E2 EE
E9 E4 FF
F4
09 05 06 0A

MOV DI,1018
MOV CL,04
MOV AL,[DI]
MOV C0,AL
MOV DX,1010
DEC DX
JNZ 100F
INC DI
LOOP 1007
JMP 1000
TABLE 09 05 06 0A

AIM:

To run a stepper motor in both forward and reverse direction with delay

APPARATUS REQUIRED:
8086 MP kit, RS 232 cable, Stepper motor interface
Procedure:
Enter the program and execute it after connecting the stepper motor in port1. Execute the
program. Now stepper motor runs in both forward and reverse direction continuously with a
delay
By converting the requiring steps in decimal to hex and entering the hex data at 1001 the
motor rotates for so much steps and stops.

PROGRAM

Memory Address

Object Codes

Mnemonics

IT Dept/KLNCE

20

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1000
1003
1007
100A
100C
100E
1011
1014
1018
101B
101D
101F
1022
1025
1028
102A
102C
1030
1031
1033
1034
1036
1037
103B
103C
103E
103F
1043

C6 C3 20
C7 C7 3F10
E8 1B 00
FE CB
75 F5
E8 2A 00
C6 C3 20
C7 C7 43 10
E8 0A 00
FE CB
75 F5
E8 19 00
E9 DB FF
C6 C1 04
8A 05
E6 C0
C7 C2 10 10
4A 75 FD
47
E2 F2
C3
C7 C2 FF FF
4A
75 FD
C3
09 05 06 0A
0A 06 05 09

MOV BL,20
MOV DI,103F
CALL 1025
DEC BL
JNZ 1003
CALL 103B
MOV BL,20
MOV DI,1043
CALL 1025
DEC BL
JNZ 1014
CALL 103B
JMP 1000
MOV CL,04
MOV AL,[DI]
OUT C0,AL
MOV DX,1010
DEC DX
JNZ 1030
INC DI
LOOP 1028
RET
MOV DX,0FFFF
DEC DX
JNZ 103B
RET
FORWARD DATA
REVERSE DATA

RESULT:
EX.NO:9

DIGITAL CLOCK
Aim
To generate a digital clock in 8086 kit.
Store time value in memory location 1500-SECONDS
1501-MINUTES
1502-HOURS
Address
Opcode
Label
Mnemonics
1000
E8 00 60
START
CALL
CONVERT
1003
E8 00 51
CALL
DISPLAY

Comments

IT Dept/KLNCE

21

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1006

B0 B0

1008
100A
100C
100E
1010
1012
1014
1015
1016
1017
1018
101A
101C
101E
1020
1022
1024
1026

E6 16
B1 07
B0 88
E6 14
B0 80
E6 14
90
90
90
90
E4 14
8A D0
E4 14
0A C2
75 F2
FE C9
75 E6
BE 15 00

1029
102B
102D
102F
1031
1033
1035
1037
1038
103A
103C
103E
1040
1042
1044
1046
1047
1049
104B
104D
104F
1051

8A 04
FE C0
88 04
3C 3C
75 CD
B0 00
88 04
46
8A 04
FE C0
88 04
3C 3C
75 BE
B0 00
88 04
46
8A 04
FE C0
88 04
3C 18
75 AF
B0 00

DELAY:

S2:

S1:

MOV
AL,0B0H
OUT 16H,AL
MOV CL,07H
MOV AL,88H
OUT 14H,AL
MOV A;,80H
OUT 14H,AL
NOP
NOP
NOP
NOP
IN AL,14H
MOV DL,AL
IN AL,14H
OR AL,DL
JNZ S1
DEC CL
JNZ S2
MOV
SI,1500H
MOV AL,[SI]
INC AL
MOV [SI],AL
CMP AL,3CH
JNZ START
MOV AL,00H
MOV [SI],AL
INC SI
MOV AL,[SI]
INC AL
MOV [SI],AL
CMP AL,3CH
JNZ START
MOV AL,0
MOV [SI],AL
INC SI
MOV AL,[SI]
INC AL
MOV [SI],AL
CMP AL,18H
JNZ START
MOV AL,0
IT Dept/KLNCE

22

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1053
1055

88 04
EB A9

1057

B4 06

1059

BA 1600

105C

B5 01

105E
1060
1062

B1 00
CD 05
C3

1063

BE 1500

1066

BB 1608

1069
106B

B0 24
88 07

106D

8A 04

106F
1071

B4 00
B6 0A

1073
1075
1078
1079

F6 F6
80 C4 30
4B
88 27

107B
107C
107E

4B
04 30
88 07

1080
1081

4B
B0 3A

1083

88 07

1085
1086

MOV [SI],AL
JMP START
DISPLAY:

MOV
AH,06H
MOV
DX,1600H
MOV
CH,01H
MOV CL,0H
INT 5
RET

CONVERT:

4B

MOV
SI,1500H
MOV
BX,1608H
MOV AL,24H
MOV
[BX],AL
MOV AL[SI]
;SECONDS
MOV AH,0
MOV
DH,0AH
DIV DH
ADD AH,30H
DEC BX
MOV
[BX],AL
DEC BX
ADD L,30H
MOV
[BX]AL
DEC BX
MOV
AL,3AH
MOV
[BX],AL
DEC BX

46

INC SI
IT Dept/KLNCE

23

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1087
1089
108B

8A 04
B4 00
B6 0A

108D
108F
1092

F6 F6
80 C4 30
88 27

1094
1095
1097

4B
04 30
88 07

1099
109A

4B
B0 3A

109C

88 07

109E

4B

109F

46

10A0
10A2
10A4

8A 04
B4 00
B6 0A

10A6
10A8
10AB

F6 F6
80 C4 30
88 27

10AD
10AE
10B0

4B
04 30
88 07

10B2

C3

10B3
10B5

E4 02
24 FF

10B7

3C F0

10B9

75 F8

;MINUTES
MOV AL,[SI]
MOV AH,0
MOV
DH,0AH
DIV DH
ADD AH,30H
MOV
[BX],AH
DEC BX
ADD AL,30H
MOV
[BX],AL
DEC BX
MOV
AL,3AH
MOV
[BX],AL
DEC BX
INC SI
;HOURS
MOV AL,[SI]
MOV AH,0
MOV
DH,0AH
DIV DH
ADD AH,30H
MOV
[BX],AH
DEC BX
ADD AL,30H
MOV
[BX],AL
RET
GETC:

IN AL,02H
AND
AL,0FFH
CMP
AL,0F0H
JNE GETC
END
IT Dept/KLNCE

24

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

Result:
EX.NO:10

INTERFACING & PROGRAMMING WITH 8279

Aim
A.To display a letter in display interfacing with 8279
B.To roll the display in 8279 using 8086
i)TO DISPLAY A IN THE FIRST DIGIT:
Program
Address
Opcode
Label
Mnemonics
Operand
1000
B0 00
MOV AL,00
1002
E6 C2
OUT C2,AL
1004
B0 CC
MOV
AL,0CC
1006
E6 C2
OUT C2,AL
1008
B0 90
MOV AL,90
100A
E6 C2
OUT C2,AL
100C
B0 88
MOV AL,88
100E
E6 C0
OUT C0,AL
1010
B0 FF
MOV AL,0FF
1012
B9 05 00
MOV
CX,0005
1015
E6 C0
NEXT
OUT C0,AL
1017
E2 FC
LOOP NEXT
1019
F4
HLT
II) ROLLING DISPLAY
PROGRAM:
Address
Opcode
Operand
1000
BE 00 12
1003
B9 0F
1006
1008
100A
100C
100E
1010
1012
1014

B0 10
E6 C2
B0 CC
B0 90
E6 C2
E6 C2
8A 04
E6 C0

Label

Mnemonics

START

MOV SI,1200
MOV
CX,000F
MOV AL,10
OUT C2,AL
MOV AL,CC
OUT C2,AL
MOV AL,90
OUT C2,AL
MOV AL,[SI]
OUT C0,AL

NEXT

Comments

Comments

IT Dept/KLNCE

25

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1016

E8 E7 04

1019
101A
101C

46
E2 F6
EB E2

1500

BA,FF,A0

DELAY

1503
1504
1506

4A
74,FD
C3

LOOP1

1200

FF,FF,FF,FF
FF,FF,FF,FF
98,68,7C,C8
FF,1C,29,FF

Ex.No :12a.

CALL
DELAY
INC SI
LOOP NEXT
JMP START
MOV
DX,A0FF
DEC DX
JNZ LOOP1
RET

Serial Interface (8251) Interface with 8086

AIM:

To send the data serially to another serial port.


APPARATUS REQUIRED:

8086 MP kit, RS 232 cable


Procedure:

Connect the two serial ports with RS232C Cable. First make the receiver ready and
Then execute the program at transmitter end.
EXAMPLE:
Data in Transmitter :41H
Receiver [1500]:41H

OBJECT CODES:TRANSMITTER END

Memory Address

Object Codes

Mnemonics

IT Dept/KLNCE

26

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1000
1002
1004
1006
1008
100A
100C
100E
1010
1012
1014
1016
1018
101A
101C
101E

B0 36
E6 CE
B0 10
E6 C8
B0 00
E6 C8
B0 4E
E6 C2
B0 37
E6 C2
E4 C2
24 04
74 FA
B0 41
E6 C0
CD 02

MOV AL,36
OUT CE,AL
MOV AL,10
OUT C8,AL
MOV AL,00
OUT C8,AL
MOV AL,4E
OUT C2,AL
MOV AL,37
OUT C2,AL
LOOP1: IN AL,C2
AND AL,04
JZ LOOP1
MOV AL,41
OUT C0,AL
INT2

Receiver end
Memory Address

Object Codes

1200
1202
1204
1206
1208
120A
120C
120E
1210
1212
1214
1216
1218
121A
121C

B0 36
E6 CE
B0 10
E6 C8
B0 00
E6 C8
B0 4E
E6 C2
B0 37
E6 C2
E4 C2
24 04
74 FA
B0 41
E6 C0

Mnemonics
MOV AL,36
OUT CE,AL
MOV AL,10
OUT C8,AL
MOV AL,00
OUT C8,AL
MOV AL,4E
OUT C2,AL
MOV AL,37
OUT C2,AL
LOOP 2: IN AL,C2
AND AL,02
JZ LOOP2
IN AL,C0
MOV BX,1500
IT Dept/KLNCE

27

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

121E

CD 02

MOV [BX],AL
INT2

RESULT:

______________________________________
Ex.No:12 b.

Parallel Interface(8255) Interface with 8086


AIM:
To initialize Port A as an input port in mode -0.
APPARATUS REQUIRED:
8086 MP kit, 50 core cable, 8255 kit
Procedure:
1. Connect the 8086 kit with 8255 using core cable.
2. Enter the program starting from user RAM address 1000H set a known data in SPDT switch
3. Type and execute the program in 8086 kit
4. Verify the result at 1500H as data data given through SPDT switch

OBJECT CODES:To initialize PORT A as input port in mode 0.

Memory Address

Object Codes

Mnemonics

IT Dept/KLNCE

28

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1000
1003
1005
1007
1009
100B

BE 00
B0 90
E6 C6
E4 C0
88 04
F4

MOV SI,1500H
MOV AL,90H
OUT C6,AL
IN AL,C0
MOV [SI],AL
HLT

AIM:
To initialize Port A as an input port and port B as output port in mode 0
APPARATUS REQUIRED:
8086 MP kit, 50 core cable, 8255 kit
Procedure:
1. Connect the 8086 kit with 8255 using core cable.
5. Set a known data in SPDT switch
6. Type and execute the program in 8086 kit
7. Verify visually that the data output at the LEDs is same as that set by the SPDT switch
settings

OBJECT CODES:To initialize PORT A as input port and port B as output port in mode-0

Memory Address

Object Codes

Mnemonics

1000
1003
1005
1007
1009
100B

BE 00
B0 90
E6 C6
E4 C0
88 04
F4

ORG 1000H
MOV AL,90H
OUT C6,AL
IN AL,C0
OUT C2,AL
HLT

AIM:
To initialize Port C as an Output port and port B in mode 0 and to explain the BIT
set and reset features of PORT C
APPARATUS REQUIRED:
8086 MP kit, 50 core cable, 8255 kit
IT Dept/KLNCE

29

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

PROCEDURE:
1. Connect the 8086 kit with 8255 using core cable.
8. Enter the program starting from user RAM address 1000H
9. Type and execute the program in 8086 kit
10. Verify the result at LEDS after changing the datas

OBJECT CODES:To initialize PORT A as input port and port B as output port in mode-0

Memory Address

Object Codes

Mnemonics

1000
1002
1004
1006
1008
100A
100B
100C

B0 80
E6 C6
B0 01
E6 C4
B0 07
E6 C6
F4

ORG 1000H
MOV AL,80
OUT C6,AL
MOV AL,01
OUT C4,AL
MOV AL,07
OUT C6,AL
HLT

Ex.No 13.i.

INTERFACING & PROGRAMMING WITH ADC

Aim:
To design an ADC converting using 8086
Algorithm:
1. Select the channel and insert the ALE by sending corresponding data C8
2. Assert the SOC(Start of Conversion) signal high and provide some delay
3. After the delay make the SOC signal low and wait for the EOC(End of
Conversion)
4. Read the converted digital data and stores it in the memory location.
Procedure:
Place jumper J2 in A position
Place jumper J5 in A position
Enter and execute the program
Vary the analog input (using trimpot ) and verify the digital data displayed with
that data stored in memory location 1100H
Program:
Address
Opcode/Oper Label
Mnemonics
Comments
and
1000
C6 C0 10
MOV AL,10
IT Dept/KLNCE

30

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1003
1005
1008
100A
100D
100F
1012
1015
1018
101B
101D
101F
1022
1025
1027
1029

E6 C8
C6 C0 18
E8 C8
E6 C0 01
E6 D0
C6 C0 00
C6 C0 00
C6 C0 00
C6 C0 00
E6 D0
E4 D8
80 E0 01
80 E0 01
75 F6
E4 C0
C7 C3 00 11

102D

88 07

102F

F4

LOOP

OUT C8,AL
MOV AL,18
OUT C8,AL
MOV AL,01
OUT D0,AL
MOV AL,00
MOV AL,00
MOV AL,00
MOV AL,00
OUT D0,AL
IN AL,D8
AND AL,01
CMP AL,01
JNZ LOOP
IN AL,C0H
MOV
BX,1100
MOV
[BX],AL
HLT

Result:
Ex.No 13.ii. INTERFACING & PROGRAMMING WITH DAC
Aim
To generate the square wave at the output of DAC 2.
Algorithm
1. Initialize AL and move 00 to AL
2. The accumualator content of AL is then sent to C8
3. After calling 1010 the content of FF is moved to accumulator content AL
4. Again the content of AL is sent to C8 and 1010 is called
5. The 05FF is moved to the CX and looped the content to1013
6. Return the program
Program
Address
Opcode
Mnemonics
Comments
1000
1002
1004
1007
1009
100B
100E
1010

C6 C0 00
E6 C8
E8 09 00
B0 FF
E6 C8
E8 02 00
EB F0
B FF 05

MOV AL,00
OUT C8,AL
CALL 1010
MOV AL,FF
OUT C8,AL
CALL 1010
JMP 1000
MOV CX,05FF
IT Dept/KLNCE

31

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1013
1015

E2 FE
C3

LOOP 1013
RET

2.AIM: To create a saw tooth wave at the output of DAC


Algorithm:
1. Initialize AL and move the first data 00 to AL
2. After moving to AL,the accumulator content of AL is sent to c0
3. The accumulator content of AL is ncremented by 1
4. After incrementing ,if it is non zero ,jump to 1002
5. After checking for non zero , jump to 1000
Program:
Address
Opcode
Label
Mnemonics
Comments
1000
B0 00
L2
MOV AL,00
1002
E6 C0
L1
OUT C8,AL
1004
FE C0
INC AL
1006
75 FA
JNZ L1
1008
EB F6
JMP L2
3.Aim:
To generate the triangular waveform at DAC 2 output
Algorithm
1. Initialize BL and move 00 to BL
2. Move the content of BL to AL as its content
3. The content moved to accumulator content AL is then sent to C8
4. The content of BL is incremented by 1
5. If the data is m=non zero , then jump to STEP2
6. Move the content of FF to BL & then to AL
7. After moving content to AL,it is sent to C8
8. Decrement BL by 1
9. If it is non zero , then jump on to 100C
10. Jump to step 1
Program
Address
Opcode
Label
Mnemonics
Comments
1000
B3 00
L2
MOV BL,00
1002
88 D8
MOV AL,BL
1004
E6 C8
OUT C8,AL
1006
FE C3
INC BL
1008
75 F8
JNZ 1002
100A
B3 FF
MOV BL,FF
100C
88 D8
L1
MOV AL,BL
100E
E6 C8
OUT C8,AL
1010
FE CB
DEC BL
1012
75F8
JNZ L1
IT Dept/KLNCE

32

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

1014

EB EA

JMP L2

JUMP TO L2

EX.NO 14
ARITHMETIC OPERATIONS USIGN 8051
AIM
To write an ALP to perform
Add 2 given 8 bit numbers
Subtract 2 given 8 bit numbers
Multiply 2 8 bit numbers
Divide 2 8 bit numbers
Array addition
APPARATUS REQUIRED
1.8051 Microprocessor kit
2.Eliminator
Algorithm
8 Bit Addition
1.Load the first data into accumulator & 2nd data in RO register.
2.Initialize the carry register(Rl) with OoH and initialize the data pointer with
address of the result location.
3.Add the accumulator content with the second data.
4.Check for carry flag if carry exits then increment carry register by one otherwise
5. go to next step.
6.Store the accumulator and Rl content into memory whose address pointed by
data pointer.
7.Stop the program.
Program
Address

Opcodes

L1

Mnemonics
MOV R1,#00H
MOV A,#FEH
MOV R0,#10H
MOV DPTR,#4500
ADD A,R0
JNC L1
INC R1
MOVX @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A

Comments

IT Dept/KLNCE

33

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

L2

SJMP L2

8 BIT SUBTRACTION
ALGORTITHM
1.Load the first data into accumulator & 2nd data in r0 register
2.Initialize the carry register (R1) with 00H and initialize the data pointer with
address of the result location
3.Subtract the second data from accumulator content
4.Check for carry flag if carry exists then increment carry register by one by one
otherwise go to next step
5.Store the accumulator and R1 content into memory whose address pointed by data
pointer
6.Stop the program
Address

Opcode

Operand

Label

L1

L2

Mnemonics
Comments
MOV R1,#00H
MOV A,#FEH
MOV R0,#10H
MOV DPTR,#4500
SUB A,R0
JNC L1
INC R1
MOVX @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
SJMP L2

8 BIT MULTIPLICATION
ALGORITHM
1. Load the accumulator and B register with first and second data
2. Multiply the B register with content of A register
3. Initialize the data pointer with address of the result location
4. Store the accumulator content into the memory location pointed by
the data pointer and then increment data pointer by one
5. Move the B register content to A
6. Store A's content into memory location pointed by DPTR
7. Stop the program
Program
Address Opcode Operand

Label

Mnemonics
MOV A,#05H
MOV B,#03H
MOV DPTR,#4500

Comments

IT Dept/KLNCE

34

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

L2

MUL A,B
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
SJMP L2

DIVISION OF 8 BIT NUMBERS


ALGORITHM
1. Load accumulator and B register with divided and divisor data
respactively
2. Divide the accumulator content by the content of B register
3. Initialize the data pointer with the address of the result location
4. Store the accumulator content into the memory location pointed by
the pointer and then increment the data pointer by one
5. Move the B register content to the accumulator
6. Store the accumulator content into the memory location pointed
out by the data pointer
7. Stop the program
Program
Address

Opcode

Operand

Label

L1

Mnemonics
MOV A,#05H
MOV B,#03H
MOV DPTR,#4500
DIV A,B
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
SJMP L1

Comments

8 BIT ARRAY ADDITION


ALGORITHM
1. Initialize the data pointer with the starting address of the source
array , also initialize the countert (R0) with number of bytes going
to be added
2. Initialaize the sum register (R2) and carry register (R1) with 00H
3. Load accumulator with data byte pointed by the data pointer
4. Add the accumulator content with content of sum register(B) and
store the result in the same sum register
5. Check for carry flag status if carry is set,then increment
carry(R1)by one,else go to next step
IT Dept/KLNCE

35

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

6. Increment tha data pointer by one to point to the next data byte
7. Decrement the count register (R0) by one and check whether the
decremented value equal to zero or not,if not go to step 4 else go
to next step
8. Store the content of sum register(B) and carry (R1) into the 2
consecutive memory locations on pointed by data pointer
9. Stop the program
Program:Array addition
Address
Opcode
Operand Label Mnemonics
Comments
MOV DPTR,#4700
MOV R0,#05H
MOV R2,#00H
MOV R1,#00H
L2
MOVX A,@DPTR
ADD A,R2
MOV R2,A
JNC L1
INC R1
L1
INC DPTR
DJNZ R0,L2
MOV A,R2
MOV @DPTR,A
INC DPTR
MOV A,R1
MOVX @DPTR,A
L3
SJMP L3
Result
EX.NO 14.
LOGICAL AND BIT MANIPULATION IN 8051
(B) i LOGICAL OPERATORS
AIM:
To perform logical & but manipulation in 8051
ALOGRITHM
1. Get 1st byte in R1
2. Get 2nd operand in R2
3. Move R1 to Accumulator
4. And the Accumulator with R2
5. Move the content of the accumulator to R0.
6. Move R1 to Accumulator
7. Or the Accumulator with R2
8. Move Accumulator content to R3
9. Move R1 to Accumulator
IT Dept/KLNCE

36

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

10. Take compliment for the Accumulator content


11. Move R4 to Accumulator
Program:
Address Opcode

Operand

Label Mnemonics
MOV R1,#20H
MOV R2 #10H
MOV A,R1
ANL A, R2
MOV R0, A
MOV A,R1
ORL A, R2
MOV R3,A
MOV A, R1
CPL A
MOV R4,A
MOV A,R1
XRL A,R2
MOV R5,A
LCALL 0003H

Comments
First BYTE
Second BYTE
ANDING
R0=R1 AND R2
ORING
R3=R1 OR R2
NEGATION
R4=~R1
XORING
R5=R1 XOR R2

11. (B)ii. 8051 HEXADECIMAL TO DECIMAL CONVERSION


AIM:
To perform hexadecimal to decimal conversion
ALGORITHM:
1.Load the number to be converted into the accumulator
2.If the number is less than 100(64H), go to next step; otherwise, subtract
100 (64H) repeatedly until the remainder is less than 100(64H). Have the
count (100s value) in separate register which is the carry.
3.If the number is less than 10 (0AH), go to next step; otherwise, subtract
10 (0AH) repeatedly until the remainder is less than 10(0AH). Have the
count (tens value) in separate register.
4.The accumulator now has the units
5.Multiply the tens value by 10 and add it with the units.
6.Store the result and carry in the specified memory location.
Address Opcode Operand
Label
Mnemonics
Comments
MOV DPTR, #4500
MOVX A, @DPTR
MOV B, #64
DIV A, B
MOV DPTR, #4501
MOV @DPTR, A
MOV A,B
IT Dept/KLNCE

37

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

HLT:

MOV B, #0A
DIV A, B
INC DPTR
MOVX @DPTR, A
INC DPTR
MOV A,B
MOVX @DPTR,A
SJMP HLT

Result:
The given hexadecimal number is converted into decimal number
11.(b)iii. 8051 DECIMAL TO HEXADECIMAL CONVERSION
AIM:
To perform decimal to hexadecimal conversion
ALGORITHM:
1.Load the number to be converted in the accumulator
2.Separate the higher order digit from lower order.
3.Multiply the higher order digit by 10 and add it with the lower order digit
4.Store the result in the specified memory location
Address Opcode

Operand

Label

HLT:

Mnemonics
MOV DPTR, #4500
MOVX A, @DPTR
MOV B, #0A
MUL A,B
MOV B, A
INC DPTR
MOVX A ,@DPTR
ADD A,B
INC DPTR
MOVX @DPTR, A
MOV DPTR, #4500
MOVX A, @DPTR
SJMP HLT

Comments

RESULT:
The given decimal number is converted to hexadecimal number

IT Dept/KLNCE

38

cseitquesions.blogspot.in | cseitquesions.blogspot.in | cseitquesions.blogspot.in

IT Dept/KLNCE

39