Professional Documents
Culture Documents
LAB MANUAL
MICROCROPROCESSORS
LIST OF EXPERIMENTS
1. Write an assembly level programs for basic arithmetic operations using 8086 (i) Signed
and Unsigned Addition (ii) Subtraction (iii) Signed and Unsigned Multiplication (iv)
Signed and Unsigned Division
2. Write an assembly level programs assembly level programs for basic logical operation
using 8086 (i)To check number is positive or negative (ii)To count number of one’s &
zero’s
3. Write an assembly Level programs for code conversion of 8086
(i) ASCII to binary;
(ii) Decimal to Hex;
(iii) ASCII to Decimal;
(iv) Binary to BCD and vice versa
4. Write an assembly level programs for String operations using 8086
(i) Reverse the string , (ii)To check whether the string is palindrome or not
5. Write an assembly level programs using 8086 for sorting operations like ascending,
descending, largest and smallest in microprocessor
6. Interfacing of 8086 with (Assembly Level Programming)
i) Stepper motor
i) Seven segment Display
ii) Logic controller
(BCD up counter and Down counter)
iii)Keyboard Display Interface
7. Write a assembly level program for basic arithmetic and logical operations in
8051 microcontroller.
CO1 Write assembly level programs using 8086 to perform arithmetic and logical
operations.
CO2 Apply the knowledge of computer number system to write code conversion
programs in 8086.
CO3 Develop assembly code for string operations, sorting of numbers and branch
instructions of 8086.
CO4 Demonstrate the I/O interfacing of 8086 with peripheral devices.
CO5 Write 8051 assembly level programs to perform arithmetic and logical
operations.
CO6 Demonstrate the interfacing of 8051 with stepper motor, switches, LCD & LED
modules.
INDEX
Expt Page
Name of the Experiment
. No. NO
INTRODUCTION ABOUT 8086 MICROPROCESSOR & 8051 6-10
MICROCONTROLLER
1.3.1 Aim : Write an ALP for Multiplication of two signed 8 bit numbers. 15-16
1.3.2 Write an ALP for Multiplication of two signed 16-bit numbers. 17-18
1.3.3 Write an ALP for Multiplication of two unsigned 8 bit numbers 19-20
1.3.4 Write an ALP for Multiplication of two unsigned 16-bit numbers 21-22
2.1 Write an ALP to check whether the given number is Positive or Negative. 31-32
33-34
2.2 Write an ALP to find the number of 1s and 0s in a given number.
2.3 Write an ALP to find the given number is 2 out of 5 code or not 35-36
2.4 Write an ALP to transfer a block of data from source to destination 37-38
3.2.1 Write an ALP for conversion of ASCII code to Binary code 45-46
3.2.2 Write an ALP for conversion of Binary code to ASCII code 47-48
4.3 Write an ALP to check whether the given string is Palindrome or not 55-56
5.3 Write an ALP to sort the given array in an Ascending order. 61-62
5.4 Write an ALP to sort the given array in an Descending order. 63-64
C.2) Write an ALP to arrange the series of numbers in descending order 71-72
a)
Write an ALP to illustrate the Interrupts and UART operations in 8051 99-100
10.2 Microcontroller.
11 Write an ALP program to illustrate stepper motor Control interface to 8051. 101-102
Scheme of Evaluation
CIE – I 15 Marks
SEE 25 Marks
Dr.Sanjeev Sharma
HOD-ECE
Start
data segment
num1 dw 1234h, 5678h
num2 dw 0ab12h, 0cdefh
result dw 3 dup(?)
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov dx,00h
mov ax, num1
mov bx, num2
clc
add ax, bx
mov result, ax
mov ax, num1+2
mov bx, num2+2
adc ax, bx
mov result+2, ax
adc dx, 00h
mov result+4, dx
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program for addition of two 32 bit numbers is executed and the output is verified.
Start
data segment
n1 dw 0ba98h, 0fedch
n2 dw 5678h, 1234h
result dw 3 dup(?)
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov dx, 00h
mov ax, n1
mov bx, n2
clc
sub ax, bx
mov result, ax
mov ax, n1+2
mov bx, n2+2
sbb ax, bx
mov result+2, ax
sbb dx, 00h
mov result+4, dx
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program for Subtraction of two 32 bit numbers is executed and the output is verified.
Start
1.3.1. Aim : Write an ALP for Multiplication of two signed 8 bit numbers.
data segment
n1 db 0f4h
n2 db 12H
result dw 2dup(?)
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov al, n1
mov bl, n2
imul bl
mov result, ax
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program for multiplication of two signed 8 bit numbers is executed and the output is verified.
Start
1.3.2. Aim : Write an ALP for Multiplication of two signed 16-bit numbers.
Data segment
n1 dw 1234h
n2 dw ff40h
result dw (?)
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov ax, n1
mov bx, n2
imul bx
mov result, ax
mov result+2, dx
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program for multiplication of two signed 16 bit numbers is executed and the output is verified.
Start
1.3.3. Aim: Write an ALP for Multiplication of two unsigned 8 bit numbers.
data segment
n1 db 0ffh
n2 db 0fh
result dw ?
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov al, n1
mov bl, n2
mul bl
mov result, ax
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program for multiplication of two unsigned 8 bit numbers is executed and the output is verified.
Start
data segment
n1 dw 1234h
n2 dw 0ff40h
result dw ?, ?
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov ax, n1
mov bx, n2
mul bx
mov result, ax
mov result+2, dx
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program for multiplication of two unsigned 16 bit numbers is executed and the output is verified.
Start
Divide the word by byte or double word by word using signed division
RESULT: The program for division of two signed 8 bit numbers is executed and the output is verified .
Start
Divide the word by byte or double word by word using signed division
RESULT: The program for division of two signed 16 bit numbers is executed and the output is verified
Start
Convert one of the byte to word or word to double word by storing 00 in higher byte or word
Divide the word by byte or double word by word using unsigned division
RESULT: The program for division of two un signed 8 bit numbers is executed and the output is verified .
Start
Convert one of the byte to word or word to double word by storing 00 in higher byte or word
Divide the word by byte or double word by word using unsigned division
data segment
n1 dw 2244h Input: n1=2244H
n2 dw 0d6h n2=D6H
result dw 2 dup(?)
data ends
code segment Output:Quo=28H
assume cs:code,ds:data Rem=D4H
main:mov ax,data
mov ds,ax
mov ax, n1
cwd
mov bx, n2
div bx
mov result, ax
mov result+2,dx
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program for division of two un signed 16 bit numbers is executed and the output is verified .
EXPERIMENT NO: 2
2.1. Write an ALP to check whether the given number is Positive or Negative.
data segment
Msg1 db "Positive $"
Msg2 db "Negative $"
n1 db 88h
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov al, n1
test al,80h
jz pos
mov dx, offset Msg2
jmp display
pos: mov dx, offset Msg1
display: mov ah, 09h
int 21h
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to check whether the given number is Positive or Negative is executed and the output is
verified
Input: 98H
Output: Negative
Input: 41H
Output:Positive
data segment
n1 db 82h
ones db 1dup(?)
zeros db 1dup(?)
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov cx, 08h
mov al, n1
mov bl,00h
mov dl,00h
back: shr al, 01
jc l1
inc bl
jmp next
l1: inc dl
next: loop back
mov ones, dl
mov zeros,bl
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to find the number of 1s and 0s in a given number is executed and the output is verified
Input: 48H 55H
2.3. Write an ALP to find the given number is 2 out of 5 code or not
data segment
msg1 db "2 out of 5 code $"
msg2 db "Not 2 out of 5 code $"
n1 db 18h
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov al, n1
mov cx, 05h
mov bl,00h
and al, 0e0h
jnz ncode
mov al, n1
back: rcr al, 1
jnc noinc
inc bl
noinc: loop back
cmp bl, 02h
jne ncodeor jnz
mov dx, offset msg1
jmp display
ncode: mov dx, offset msg2
display: mov ah, 09
int 21h
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to find the given number is 2 out of 5 code or not is executed and the output is verified
Input: 78H
Output:Invalid
Input: 18H
Output:Valid
(Open ended experiment.)
Data segment
Org 1000h
Num1 db 10h,20h,30h,40h,50h
Org 2000h
Num2 db 5 dup(?)
Count equ 05h
Data ends
Code segment
Assume cs:code,ds:data
Main:MOV AX,DATA
MOV DS,AX
LEA SI,Num1
LEA DI,Num2
MOV CL,count
Back:MOV AL,[SI]
MOV [DI],AL
INC SI
INC DI
Loop Back
MOV AH,4CH
INT 21H
Code ends
End main
RESULT: The program to transfer a block of data from source to destination is executed and the output is
verified
Binary to BCD
Allocate memory to store result.
Initialize counter to 0.
Store DS reg. by starting address of data segment.
Binary to BCD is
N
Quotient = 0
?
Retrieve the reminder from stack and store the lower nibble in lower nibble position of the regist
N is
Left shift the contents of register by 4-bits Count = 0
?
Return
EXPERIMENT NO: 3
WRITE A MICROPROCESSOR 8086 PROGRAM TO ILLUSTRATE THE FOLLOWING CODE CONVERSIONS
3.1.1 Aim : To Write an ALP to Convert Binary to BCD Software Required : MASM Assembler
data segment
bcd dw 2 dup(?)
data ends Input: FFFFH Input: AAAAH
code segment Output: 0006 5535 Output: 0004 3690
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov ax,0ffffh
call bintobcd
mov bcd,ax
mov bcd+2,bx
mov ah, 4ch
int 21h
bintobcd proc near
push dx
push cx
mov bx,10
mov cx,00
divide: mov dx,00
div bx
push dx
inc cx
cmp ax,00
jnz divide
mov bx,00
number: pop dx
or ax,dx
dec cx
jz term
shl ax,1
rcl bx,1
shl ax,1
rcl bx,1
shl ax,1
rcl bx,1
shl ax,1
rcl bx,1
jmp number
term: pop cx
pop dx
ret
bintobcd end p
code ends end main
RESULT: The program to convert Binary to BCD is executed and the output is verified
Start
BCD to Binary
Allocate memory to store result.
BCD to Binary
is
N
Quotent = 0
?
Store the result in a memory
Y
Retrieve the reminder from stack and store the lower nibble in lower nibble position of the register
Code ends end main
is
Left shift the contents of register by 4-bitsN count = 0
?
Return
data segment
bcd dw 1234h
bin dw 0000h
data ends
code segment Input: 1234H Input: 4321H
Output:04D2 Output:10E1
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov ax, 0000H
mov bx,0001H
call convert
mov bx,000AH
call convert
mov bx,0064H
call convert
mov bx,03E8H
call convert
mov ah,4ch
int 21h
RESULT: The program to convert o BCD to Binary is executed and the output is verified
Data segment
Bcd dw 4596h
Result dw 2dup(?)
Data ends
Code segment
Assume cs:code,ds:data
Main: mov ax,data
mov ds,ax
mov ax,bcd
mov bx,ax
mov al,ah
mov bh,bl
mov cl,04h
ror ah,cl
ror bh,cl
and ax,0f0fh
and bx,0f0fh
mov cx,ax
mov ax,0000h
mov al,ch
mov di,03e8h
mul di
mov dh,00h
mov dl,bl
add ax,dx
mov dx,ax
mov ax,0064h
mul cl
add dx,ax
mov ax,000Ah
mul bh
add ax,dx
mov result,ax
mov ah,4ch
int 21h
code ends
end main
Start
A
is
Y
[AL] ≤ 46
?
Store DS reg. by starting address of data segment.
N
ASCII to Binary
Decrement counter
B Return
1.2.1. Aim : To Write an ALP for conversion of ASCII code to Binary code
Software Required : MASM Assembler
data segment
res dw 1 dup (?)
data ends Input: 31 32 33 34 Input: 34 33 32 31
RESULT: The program to convert o ASCII code to Binary code is executed and the output is verified
is
Y higher nibble ≤ 9
Store DS reg. by starting address of data segment. ?
Add 30h.
Binary to ASCII
Add 30h.
Code ends end main
Return
; Procedure is same for both 8 / 16bit data, but proc is called twice for 16bit data
push ax
and al,0f0h
mov cl,04h
ror al,cl
cmp al,09h
jbe skip1
add al,07h
mov bl,al
pop ax
and al,0fh
cmp al,09h
jbe skip2
add al,07h
mov cl,al
ret
ascii end p
code ends
end main
RESULT: The program to convert o Binary code to ASCII code is executed and the output is verified
Input: 4A01H Input: 003CH Input: 3C H Input: 4A H
Start
Load starting addr. of source to source index reg. and destination addr. to destination index reg.
EXPERIMENT NO: 4
data segment
Msgs db "Welcome to 8086 Lab$"
len equ ($ - Msgs)
Msgd db 25 dup (?)
Data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov es,ax
mov si, offset Msgs
mov di, offset Msgd
mov cx, len
cld
rep movsb
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to transfer a String from source to destination is executed and the output is verified
Load starting addr. of source to source index reg. and destination addr. to destination index reg.
Decrement count
is
N
count = 0
?
data segment
Msgs db "WELCOME$"
len equ ($ - Msgs)
Msgr db 25 dup(?)
Data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov es, ax
mov si, offset Msgs
mov di, offset Msgr
mov cx, len-1
add di, len-2
cld
reverse: movsb
dec di
dec di
loop reverse
mov byte ptr[di+len],’$’
mov dx,offset Msgr
mov ah,09h
int 21h
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to reverse a String is executed and the output is verified
r. of source to source index reg. and destination addr. to destination index reg. Y Print Msg2
Print Msg1
Decrement count
is
N
count = 0
?
4.3. Aim : To Write an ALP to check whether the given string is Palindrome or not
data segment
Msgs db "APPA$"
len equ ($ - Msgs) Input:MALAYALAM
Msgr db 20 dup(0) Output:Palindrome
Msgp db "Palindrome $"
Msgn db "Not Palindrome $"
Data ends
Input: MICRO
code segment Output: Not Palindrome
assume cs:code,ds:data
main : mov ax,data
mov ds,ax
mov es, ax
mov si, offset Msgs
mov di, offset Msgr
mov cx, len-1
add di, len-2
cld
reverse: movsb
dec di
dec di
loop reverse
mov byte ptr[di+len],’$’
mov si, offset Msgs
mov di, offset Msgr
mov cx, len
repe cmpsb
jz pal
mov dx, offset Msgn
jmp display
pal: mov dx, offset Msgp
display: mov ah, 09
int 21h
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to to check whether the given string is Palindrome or not is executed and the output is verified
EXPERIMENT NO: 5
data segment
array db 12h, 56h, 0feh, 34h, 90h, 0abh
len dw 06h
large db ?
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov si, offset array
mov al, [si]
mov cx, len
dec cx
search: inc si
cmp al, [si]
jnc nochange
mov al, [si]
nochange: loop search
mov large, al
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to find the largest number in an array is executed and the output is verified
data segment
array db 12h, 38h, 82h, 0cdh, 67h
len dw 05h
small db ?
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov si, offset array
mov cx, len
dec cx
mov al, [si]
search: inc si
cmp al, [si]
jc nochange
mov al, [si]
nochange: loop search
mov small, al
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to find the Smallest number in an array is executed and the output is verified
5.3. Aim: To Write an ALP to sort the given array in an Ascending order.
data segment
array db 45h, 0adh, 81h, 76h, 0feh
len equ 05h
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov bx, len-1
rpt: mov cx,bx
mov si,offset array
back: mov al.[si]
inc si
cmp al,[si]
jc skip
xchg al,[si]
dec si
mov [si,],al
inc si
skip: loop back
dec bx
jnz rpt
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to sort the given array in an Ascending order.is executed and the output is verified
5.4. Aim : To Write an ALP to sort the given number in Descending order
data segment
array db 45h, 0adh, 81h, 76h, 0feh
len equ 05h
data ends
code segment
assume cs:code,ds:data
main:mov ax,data
mov ds,ax
mov bx, len-1
rpt: mov cx,bx
mov si,offset array
back: mov al.[si]
inc si
cmp al,[si]
jnc skip
xchg al,[si]
dec si
mov [si,],al
inc si
skip: loop back
dec bx
jnz rpt
mov ah, 4ch
int 21h
code ends
end main
RESULT: The program to sort the given array in an Descending order. is executed and the output is verified
Input: 45H,ADH,81H,76H,FEH Intput: 01H 02H 03H 04H 05H
Algorithm:
EXPERIMENT NO: 6
TRIAL-01and 02
INPUT :
OUTPUT :
SOURCE
ADDRESS DATA
30H 01 05 DESTINATION
32H 03 03 40H 01 05
04 02 41H 02` 04
33H
42H 03 03
34H 05 01
43H 04 ` 02
44H 05 01
RESULT: The program to move a block of data from source to destination.is executed and the output is verified
Algorithm:
b) Aim : Write an ALP to TO EXCHANGE THE BLOCK OF DATA FROM SOURCE TO DESTINATION
TRIAL -01
OUTPUT :
TRIAL-02
OUTPUT :
RESULT: The program to exchange block of data from source to destination.is executed and the output is verified
Algorithm
c.1) Aim : Write an ALP TO ARRANGE THE SERIES OF NUMBERS IN ASCENDING ORDER
OUTPUT :
Before execution After execution
30H 09 30H 01
31H 02 31H 02
32H 10 32H 03
33H 01 33H 07
34H 03 34H 09
35H 07 35H 10
RESULT: The program TO ARRANGE THE SERIES OF NUMBERS IN ASCENDING ORDER .is executed and the
output is verified
Algorithm:
c.2) Aim : Write an ALP TO ARRANGE THE SERIES OF NUMBERS IN DESCENDING ORDER.
Software Required : Keil µVision
OUTPUT :
Before execution After execution
30H 01 30H 06
31H 02 31H 05
32H 03 32H 04
33H 04 33H 03
34H 05 34H 02
35H 06 35H 01
RESULT: The program TO ARRANGE THE SERIES OF NUMBERS IN DESCENDING ORDER .is executed and the
output is verified
Algorithm:
1. Make CY = 0
2. LOAD the low byte i,e., A = E7h
A= A + 8D
3. Save the low byte in R6
4. LOAD the high byte i,e., A = 3Ch
5. A = A + 3B + CY
6. ; SAVE the high byte of SUM in R7
EXPERIMENT NO: 7
(a) ADDITION
(b) SUBTRACTION
(c) MULTIPLICATION/SQUARE
(d) DIVISION
C
CLR C
MOV A, #0E7
ADD A, #8D
MOV R6, A
MOV A, #3C
ADDC A, #3B
MOV R7, A
END
OUTPUT:
OR
MOV R0,#20H
MOV R1,#30H
MOV A,@R0
ADD A,@R1
RESULT: The Program for ADDITION OF TWO 16-BIT NUMBERS .is executed and th
Algorithm
; MAKE CY = 0
; LOAD the low byte i.e., A = 62h
; A = A − 96 − CY
; SAVE the low byte in R6
; LOAD the high byte i.e., A = 27h
; A = A – 12 − CY
; SAVE the high byte of SUM in R7
; Transfers control to subroutine / ( Terminate the
program)
CLR C
MOV A, #62
SUBB A, #96
MOV R6, A
MOV A, #27
SUBB A, #12
MOV R7, A
END
OUTPUT :
RESULT: The Program for SUBTRACTION OF TWO 16-BIT NUMBERS .is executed and the output is verified
ALGORITHM:
1. Start.
2. Load the MSB’s of Data in two different registers.
3. Load the LSB’s of Data in other two different registers.
4. Successive multiplication is carried out.
5. The product obtained in the registers.
6. The output is stored in the registers.
7. End.
Org 0000h
mov r5,#00h
mov a,31h
mov b,33h
mul ab
mov 40h,a
mov r7,b
mov a,30h
mov b,33h
mul ab
addc a,r7
mov r7,a
mov a,b
addc a,#00h
mov r6,a
mov a,31h
mov b,32h
mul ab
addc a,r7
mov 41h,a
mov a,b
addc a,r6
mov r6,a
jnc xx
inc r5
xx:mov r6,a
mov a,30h
mov b,32h
mul ab
addc a,r6
mov 42h,a
mov a,b
addc a,r5
mov 43h,a
end
RESULT: The Program for MULTIPLICATION / SQUARE OF TWO 16-BIT NUMBER is executed and the output is verified
OUTPUT
Input 1 Output :
Src Address 1 Data Dst Address Data
30h FFh 40h 01
31h FFh 41h 00
32h FFh 42h FE
33h FFh 43h FF
mov a,40h
mov r0,#41h
mov b,60h
div ab
mov 50h,a
mov a,b
swap a
mov r1,a
mov a,@r0
anl a,#0f0h
swap a
add a,r1
mov b,60h
div ab
swap a
mov r2,a
mov a,b
swap a
mov r3,a
mov a,@ro
anl a,#0fh
add a,r3
mov b,60h
div ab
add a,r2
mov 51h,a
mov 52h,b
end
OUTPUT
Input 1 Output :
Src Address 1 Data Dst Address Data
40h FFh 50h ff
41h FFh 51h 3f
60h 04h
RESULT: The Program for DIVISION OF 16-BIT NUMBER BY A 8- BIT NUMBER is executed and the output is verified
ALGORITHM:
LOAD THE NUMBER 34H IN R0 REG.
1. // AND LOGICAL OPERATION
EXPERIMENT NO: 8
a) AND
b) OR
c) XOR
d) COMPLEMENT
e) CLEAR & SETTING A BIT.
f) ROTATE LOGICAL LEFT &RIGHT.
g) EXCHANGE OF UPPER & LOWER NIBBLE.
MOV A, R0
ANL A, #0F
MOV R1, A
MOV A, R0
ORL A, #0F
MOV R2, A
MOV A, R0
XRL A, #0F
MOV R3,A
MOV A, R0
CPL A
MOV R4, A
MOV A, R0
CLR A
MOV R5, A
OUTPUT:
MOV A,
R0
RR A
RR A
RR A
RR A
MOV R6,
A
MOV A,
R0
RL A
RL A
RL A
RL A
MOV R7,
A
MOV A,
R0
SWAP A
MOV B,
A
INPUT: O
U
T
P
U
T
:
ADDRESS DATA
ADDRESS DATA
(AND) R1 04
R0 34H
(OR) R2 3F
(XOR) R3 3A
(CPL) R4 8A
(CLR) R5 00
(RRA) R6 45
(RLA) R7 25
(SWAP) B 43
RESULT: The Program TO ILLUSTRATE LOGICAL & BIT MANIPULATION OPERATION is executed and the
output is verified
Algorithm :
1. ; LOAD THE (BCD) SRC ADDRESS 30H IN R0.
2. ; LOAD THE (ASCII) DSTN ADDRESS 40H INTO
R1.
3. ; LOAD count value of BCD digits of 03H TO R2.
4. ; MOVE BCD VALUE TO ACC.
5. ; OR CONTENTS OF A WITH IMMEDIATE
VALUE 30H
6. ; ASCII VALUE IN A IS STORED IN DSTN
ADDRESS
7. ; INCREMENT THE SRC ADDRESS
8. ; INCREMENT THEDSTN ADDRESS.
9. ; CHECK IF R2 = 0, JUMP TO LOC BACK
10. ; TERMINATE THE PROGRAM.
EXPERIMENT NO: 9
a) BCD – ASCII
b) ASCII - BCD
c) ASCII – DECIMAL
d) DECIMAL – ASCII
e) HEX – DECIMAL
f) DECIMAL - HEX
MOV R0,
#30h
MOV R1,
#40H
MOV R2,
#03
BACK: MOV A,
@R0
ORL A,
#30
MOV @R1,
A
INC R0
INC R1
DJNZ R2, BACK
LCALL 0003
OUTPU
INPUT: T:
ASCII
UNPACKE DST
SRC D ADDRES DAT
ADDRES S A
S BCDDATA 40H
34h
0
30H 4
0
31H 5 41H 35h
42H 36h
32H 06
Result : The Program to convert BCD to ASCII Code Conversion is Executed and the output is
verified
Algorithm :
TRIAL-01:
INPUT: OUTPUT:
SR ASCI UNPACKE
C I DSTN D
DAT
ADDRESS A ADDRESS BCD DATA
TRIAL-02:
INPUT: OUTPUT:
SR ASCI UNPACKE
C I DSTN D
DAT
ADDRESS A ADDRESS BCD DATA
Result : The Program to convert ASCII to BCD Code Conversion is Executed and the output is
verified
TRIAL-01:
INPUT: OUTPUT:
SR ASCI PACKED
C I DSTN BCD
DAT (DECIMAL)
ADDRESS A ADDRESS DATA
40H
35h 50H 54h
41H 34h 51H
TRIAL-02:
INPUT: OUTPUT:
ASCI
SRC I DSTN PACKED BCD
ADDRES DAT ADDRES
S A S (DECIMAL) DATA
50H 65H
40H 36
51H
41H 35
Result : The Program to convert ASCII to Decimal Code Conversion is Executed and the
output is verified
TRIAL-01:
INPUT: OUTPUT:
ASCI
SRC PACKED BCD DSTN I
(DECIMAL) DAT
ADDRESS DATA ADDRESS A
50
40H 95 H 35
51
41H H 39
TRIAL-02:
INPUT: OUTPUT:
ASCI
SRC PACKED BCD DSTN I
(DECIMAL) DAT
ADDRESS DATA ADDRESS A
Department of Electronics and Communication Engineering Page 101 of 124
ECE52 – Microcontrollers Lab Manual V sem [2020 -2021] - V Sem
50
40H 85 H 35
51
41H H 38
Result : The Program to convert Decimal to ASCII Code Conversion is Executed and the
output is verified
Algorithm :
TRIAL-01:
INPUT:
SRC HEX
ADDRESS DATA
02(REMAINDE
41H
R)
50H
: 05(REMAINDE
R
51H
TRIAL-02:
INPUT: OUTPUT
99H 03(REMAINDER)
40H 50H
05(REMAINDER
41H 51H
Result : The Program to convert Hex to Decimal Code Conversion is Executed and the output
is verified .
Algorithm :
MOV R0, #40h ; LOAD SRC (DECIMAL) ADDRESS 40H INTO R0.
MOV R1, #50H ; LOAD DSTN (HEX) ADDRESS 50H IN R1 REGISTER.
; LOAD THE DECIMAL VALUE IN
MOV A, @R0 ACC.
MOV R2, A ; COPY THE DECIMAL VALUE IN A TO R2 REG
; MASK HIGHER NIBBLE & SAVE LOWER NIBBLE IN
ANL A, #0Fh A.
MOV R3, A ; SAVE THE VALUE IN R3 .
; COPY THE HEXADECIMAL VALUE SAVED IN R2 TO
MOV A, R2 A.
; MASK LOWER NIBBLE & SAVE HIGHER NIBBLE IN
ANL A, #F0H A.
SWAP A ; EXCHANGE THE HIGHER & LOWER NIBBLE IN ACC.
; LOAD 0AH (DECIMAL-10) IN B
MOV B, #0AH REG.
; MULTIPLY A & B values, STORE LBYTE =A, H BYTE =
MUL AB B.
ADD A, R3 ; ADD CONTENTS OF A & R3 ,STORE RESULT IN A.
MOV @R1, A ; LOAD hex-decimal value in destination ADDRESS.
End ; TERMINATE THE PROGRAM.
TRIAL 01:
INPUT: OUTPUT:
TRIAL 02:
INPUT: OUTPUT:
Result : The Program to convert Decimal to Hex Code Conversion is Executed and the output
is verified
GATE0 starts and stops Timer 1, using a signal provided to the pin INT0 (P3.2):
o 1 - Timer 0 operates only if the bit INT0 is set
o 0 - Timer 0 operates regardless of the state of the bit INT0
C/T0 selects which pulses are to be counted up by the timer/counter 0:
o 1 - Timer counts pulses provided to the pin T0(P3.4)
o 0 - Timer counts pulses from internal oscillator
T0M1,T0M0 These two bits select the Timer 0 operating mode.
EXPERIMENT NO: 10
Result : The Program to verify the Timer in 8051 Microcontroller is Executed and the output is
verified
Serial port should be configured prior to being used. That determines how many bits one
serial “word” contains, what the baud rate is and what the pulse source for synchronization is.
All bits controlling this are stored in the SFR Register SCON (Serial Control)
10.2. Write an ALP to illustrate the Interrupts and UART operations in 8051 Microcontroller.
PROGRAM 1:
MOV TMOD,#20H
MOV TH1,-3H
MOV SCON,#50H
SETB TR1
AGAIN :MOV SBUF,#’A’
WAIT:JNB TI,WAIT
CLR TI
SJMP AGAIN
OUTPUT :
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
PROGRAM 2:
OUTPUT :
FOUR FOURFOURFOURFOURFOUR
Result : The Program to illustrate the Interrupts and UART operations in 8051 Microcontroller is
Executed and the output is verified
W1 W2 W3 W4
1 1 0 0
0 1 1 0
0 0 1 1
1 0 0 1
1 1 0 0
0 1 1 0
0 0 1 1
1 0 0 1
EXPERIMENT NO: 11
ORG 0000H
MOV A, #33H
BACK: MOV P0, A
RL A
ACALL DELAY
SJMP BACK
DELAY: MOV R0, #10H
LOOP1: MOV R1, #0FFH
LOOP2: DJNZ R1, LOOP2
DJNZ R0, LOOP1
RET
ORG 0000H
MOV A, #66H
MOV R0, #45H
BACK: MOV P0, A
RR A
ACALL DELAY
DJNZ R0, BACK
HERE: SJMP HERE
DELAY: MOV R1, #0FFH
LOOP1: MOV R2, #0FFH
LOOP2: DJNZ R2, LOOP2
DJNZ R1, LOOP1
RET
EXPERIMENT NO: 12
Program:
ORG 0000H
MOV A, #25H
BACK: MOV P0, A
ACALL DELAY
CPL A
SJMP BACK
DELAY: MOV R0, #10H
LOOP1: MOV R1, #0FFH
LOOP2: MOV R2, #0FFH
LOOP3: DJNZ R2, LOOP3
DJNZ R1, LOOP2
DJNZ R0, LOOP1
RET
EXPERIMENT NO: 13
Program:
EXPERIMENT NO: 14
Program:
ORG 0000H
MOV P1, #0FFH
BACK: MOV A, P1
CJNE A, #0FFH, CHECK
SJMP BACK
CHECK: ACALL DELAY
MOV A, P1
CPL A
MOV p0, A
SJMP BACK
DELAY: MOV R0, #10H
LOOP1: MOV R1, #0FFH
LOOP2: DJNZ R1, LOOP2
DJNZ R0, LOOP1
RET