You are on page 1of 7

Lab 6

Ex.No.6: BCD To Hexadecimal Conversion And Hexadecimal To BCD Conversion


6.1 Introduction:
The purpose of this experiment is to obtain the BCD to HEXADECIMAL and viceversa
of a given data using 8051 micro controller trainer kit.
6.2 Hardware Requirement:
The 8051 Microcontroller kit, Power supply.
6.3 Program Logic:
In this program, 8 bit two digit Hexadecimal number system into BCD number system.
The hexadecimal number system (also called base-16) is a number system that uses 16 unique
symbols to represent a particular value. Those symbols are 0-9 and A-F. 8 bit two digit BCD
number system into Hexadecimal number system. Binary coded decimal (BCD) is a system of
writing numerals that assigns a four-digit binary code to each digit 0 through 9 in a decimal
(base-10) numeral.
6.4 Program:
BCD to HEXADECIMAL:
LABEL

MNEMONICS
MOV DPTR,#4600
MOVX A,@DPTR
MOV R5,A
ANL A,#F0
SWAP A
MOV R1,A
MOV A,R5
ANL A,#0F
MOV R2,A
MOV A,R1
MOV F0,#0A

MUL AB
ADD A,R2
INC DPTR
MOVX @DPTR,A
SJMP HERE
HERE
Hexadecimal to BCD
LABEL

MNEMONICS
MOV DPTR,#4600
MOVX A,@DPTR
MOV F0,#64
DIV AB
INC DPTR
MOVX @DPTR,A
MOV A,F0
MOV F0,#0A
DIV AB
SWAP A
ADD A,F0
INC DPTR
MOVX @DPTR,A

HERE

SJMP HERE

6.4 Pre-Lab Questions:


1. Upon reset, all ports of the 8051 are configured as _____________ (output,
input).
2. Which ports of the 8051 have internal pull-up resistors?
3. Which ports of the 8051 require the connection of external pull-up
resistors in order to be used for I/O? Show the drawing for the connection.

6.5 Post-Lab Questions:


1. How the DPTR register is classified, explain its functions?
2. What is the function of EA pin in 8051?
3. List out the special function registers in 8051.

Lab 7
Ex.No.7: ASCII To Decimal Conversion And Decimal To ASCII Conversion
7.1 Introduction:
The purpose of this experiment is to obtain the ASCII To Decimal and vice versa of a
given data using 8051 micro controller trainer kit.
7.2 Hardware Requirement:
The 8051 Microcontroller kit, Power supply.
7.3 Program Logic:
In this program, 8 bit two digit ASCII number system into decimal number system. Acronym
for the American Standard Code for Information Interchange. Pronounced ask-ee, ASCII is a code for
representing English characters as numbers, with each letter assigned a number from 0 to 127 into
decimal number and vice versa.

7.4 Program:
ASCII to DECIMAL:
LABEL

MNEMONICS
MOV DPTR,#4500
MOV A,#DATA
CLR C
SUBB A,#30
CLR C
SUBB A,#0A
JC STR
MOV A,#0FF
SJMP LOOP

STR

ADD A,#0A

LOOP

MOVX @DPTR,A

HERE

SJMP HERE

DECIMAL TO ASCII:

LABEL

MNEMONICS

MOV DPTR,#4500
MOVX A,@DPTR
MOV R0,#30
ADD A,R0
INC DPTR
MOVX @DPTR,A
HERE

SJMP HERE

7.5 Pre-Lab Questions:


1. What is the major difference between 8051 and 8086?
2. What is meant by the term immediate addressing?
3. There is no stop instruction in the 8051 instruction. Describe a method for implementing
a program stop.
7.6 Post-Lab Questions:
1. Write an assembly language program to find ones and twos complement without using CPL
instruction.
2. What are the two registers in 8051 which are used for indirect addressing?
3. What is the function of program counter in 8051?
4. Explain the bit level logical instructions of 8051.

Lab 8

Ex.No.8: Square Root Of A Given Data


8.1 Introduction:
The purpose of this experiment is to obtain the Square root of a given data using 8051
micro controller trainer kit.
8.2 Hardware Requirement:
The 8051 Microcontroller kit , Power supply.
8.3 Program Logic:
In this program, the square root of a number can be found out by division and subtraction
method.
8.4 Program:
LABEL

MNEMONICS
MOV DPTR,#5600
MOVX A,@DPTR
MOV R1,A
MOV R2,#01

LOOP

MOV A,R1
MOV F0,R2
DIV AB
MOV R3,A
MOV R4,F0
SUBB A,R2
JZ RESULT
INC R2
SJMP LOOP

RESULT

MOV DPTR,#5700
MOV A,R3
MOVX @DPTR,A

HERE

SJMP HERE

8.5 Pre-Lab Questions:

1. Why are program counter and stack pointer are 16-bit registers?
2. What are register banks?
3. Mention any 3 applications of microcontroller?
4. How to program the microcontroller 89C51?
8.6 Post-Lab Questions:
1.

Explain power down mode of 8051.

2.

Explain the function of RXD and TXD pins of 8051 microcontroller.

3.

Explain the reset circuit in 8051.

4.

What is the difference between power-on reset and manual reset?

You might also like