You are on page 1of 53

MICROPROCESSORS AND

MICROCONTROLLERS

LAB MANUAL

Subject Code : EE606PC


Regulations : R18
Class : III Year II Semester

Department of Electrical & Electronics Engineering

PALLAVI ENGINEERING COLLEGE

(Formerly Nagole Institute of Technology and Sciences)


Kuntloor (V), Hayath Nagar (M), R.R District-501 505

DEPARTMENT OF EEE
PALLAVI ENGINEERING COLLEGE
Kuntloor (V), HayathNagar (M), R.R District-501 505

DEPARTMENT OF ELECTRICAL & ELECTRONICS ENGINEERING


EE606PC: MICROPROCESSORS AND MICROCONTROLLERS LAB

B.Tech. III Year II Semester LTPC


0 0 3 1.5
List of Experiments

Cycle 1: Using 8086 Processor Kits and/or Assembler (5 Weeks)


Assembly Language Programs to 8086 to Perform
1. Arithmetic, Logical, String Operations on 16 Bit and 32-Bit Data.
2. Bit level Logical Operations, Rotate, Shift, Swap and Branch Operations.

Cycle 2: Using 8051 Microcontroller Kit (6 weeks)


Introduction to IDE
1. Assembly Language Programs to Perform Arithmetic (Both Signed and Unsigned) 16 Bit
Data Operations, Logical Operations (Byte and Bit Level Operations), Rotate, Shift, Swap and Branch
Instructions
2. Time delay Generation Using Timers of 8051.
3. Serial Communication from / to 8051 to / from I/O devices.
4. Program Using Interrupts to Generate Square Wave 10 KHZ Frequency on P2.1 Using Timer 0 8051
in 8 bit Auto reload Mode and Connect a 1 HZ Pulse to INT1 pin and Display on Port 0. Assume Crystal
Frequency as 11.0592 MHZ

Cycle 3: Interfacing I/O Devices to 8051(5 Weeks)


1. 7 Segment Display to 8051.
2. Matrix Keypad to 8051.
3. Sequence Generator Using Serial Interface in 8051.
4. 8 bit ADC Interface to 8051.
5. Triangular Wave Generator through DAC interfaces to 8051.

DEPARTMENT OF EEE
INDEX

S.NO. NAME OF THE EXPERIMENT PAGE


NO

I Introduction to ESA 86/88E trainer Kit 7


II Introduction to MASM 11
III CYCLE: 1
1 Programs for 16 bit arithmetic operations for 13
8086
2 Program for string manipulations for 8086 21
3 Program Using Logical Instructions 31
4 Program Using Shift,Rotate & Branch 32
Instructions
CYCLE:2
1 Programming using arithmetic, logical and bit 35
manipulation instructions of 8051
2 Time delay Generation Using Timers of 8051. 42
3 Serial Communication from / to 8051 to / from 43
I/O devices
4 Program to Generate Square wave 44
CYCLE: 3
1 Interfacing of 7 Segment Display to 8051 45
2 Interfacing Matrix/Keyboard to 8051 47
3 Sequence Generator Using Serial Interface in 49
8051
4 8 Bit ADC Interface to 8051 51
5 Triangular wave Generators through DAC 53
Interfaces to 8051

DEPARTMENT OF EEE
I.Introduction to the trainer & Instructions to user
ESA 86/88 –2 is a powerful, general-purpose microcomputer system, which can be operated either
with 8086 CPU or with 8088 CPU. It is generally supplied with 8086 CPU.
The 8086 and 8088 are third generation CPU is from INTEL that differ primarily in their external
data paths. 8088 uses 8-bit wide data bus while 8086 uses a 16-bit wide bus. ESA86/88-2 can be operated
with either CPU and the only possible difference would be in the speed of execution (with 8088 CPU, a
small speed degradation occurs because of the 8-bit wide data bus). In either case, the CPU is operated
in the maximum mode.

Following are the system capabilities:

● Examine and optionally modify the contents of memory (byte or word format)

● Examine and optionally modify the processor registers.

● Assemble and Disassemble 8086/8088 instructions (via line assembler, disassembler).

● Perform fast numerical computations using the optional 8087 Numeric data processor.

● Execute the user program at full speed.

● Debug user program through single step and Breakpoint facilities.

● Write or read data to or from I/O ports (byte or word format).

● Move a block of data or program within the memory

● Download user programs into ESA 86/88-2 from a host computer system.

SPECIFICATIONS:
Central processor
8086 CPU operates at 8MHz. (Memory cycles have zero wait states and I/O cycles have one wait
state).

Co-Processor

On-board 8087 Numeric Data processor (optional)


Memory

EPROM: 4 JEDEC compatible slots offer the following options:


64K bytes using 27128s or,
128K bytes using 27256s or,
256K bytes using 27512s
(System firmware is supplied in 2x27256s. The other two sockets are for user
expansion).

RAM: 4 JEDEC Compatible offer the following:

DEPARTMENT OF EEE
128K bytes using 6255s
(64K bytes supplied using 2x62556s. The other two sockets are for user
expansion).
RAM has battery backup facility.

Peripherals and Controllers

8251A: Programmable Communication Interface for serial communication supporting all standards
with baud rates from 110-19,200 (Baud rate can be selected through on-board Dip switch).
8253-5: (2 Nos.) programmable peripheral Interface devices provide 48 Programmable I/O lines each.
8259A: Programmable interrupt Controller provides interrupt vectors for 8 sources
8288: Bus controller used for generating control signals.
Interrupts
External: NMI and INTR
INTR controlled through 8259A, on-board Interrupt Controller provides interrupt vectors for eight
sources. Complete flexibility in selecting off-board or on-board interrupt sources.
On-board interrupt sources

# 8251 (TxRDY and RxRDY)


# 8253-5 (OUT1 and OUT2)
# 8255A (PC0 and PC3 in handshake mode)
# 8087 (NDP INT)
Internal: Interrupt vectors 1(single step) and 3 (breakpoint) reserved for monitor.

Interface Signals

CPU Bus: Demultiplexed and fully buffered, TTL compatible, Address, Data & Control signals are
available on two 50-pin ribbon cable connectors.
Parallel I/O:48 Programmable parallel I/O lines (TTL compatible) through two
26-pin ribbon cable connectors.
Serial I/O:RS 232 C through on-board 9pin D-type female connector.
Power supply: +5V @ 3.0Am

CONFIGURATION AND INSTALLATION

Configuration of ESA 86/88-2 :


ESA 86/88-2 micro computer trainer kit is a versatile and can be configured in a number of ways, as
determined by the setting of a DIP switch and other jumpers.
Operational mode selection
ESA 86/88-2 can be operated either in the serial mode or in Hexadecimal keypad mode. In the serial
mode, the trainer kit is connected to a CRT terminal or to a host computer system (like PC
compatible) through an RS 232 C interface. In the keypad mode, the trainer is operated through
Hexadecimal keypad.

SW4 of the DIP switch Operational mode


OFF Serial mode
ON Hexadecimal keypad mode*
(*Factory installed Option)

DEPARTMENT OF EEE
Printer Enable/Disable
ESA 86/88-2 firmware includes the driver program for centronics compatible parallel printer interface.
This driver can be enabled/ disabled as shown below:

SW5 of the DIP Switch Printer Driver


OFF Disabled*
ON Enabled
.
(*Factory installed Option)

Baud rate selection


In the serial mode of operation, ESA 86/88E configures an 8251A USART
as follows:

▪ Asynchronous mode

▪ 8-bit character length

▪ 2 stop bits

▪ No parity

▪ Baud rate factor of 16X

Timers 0 of an 8253 provide the Transmit and receive baud clocks for the
USART. This timer is initialized by the system firmware to provide proper baud clock based on the
settings of the DIP Switch as shown below.

DIP SWITCH
SW3 SW2 SW1 Baud rate
OFF OFF ON 9,600

Memory selection:

ESA 86/88-2 has four sockets, labeled U9, U8, U7, U6 for RAM. These sockets are configured
for 62256(32X 4) devices. Two of these sockets are populated (providing 64K Bytes of RAM) and
two are for user expansion.

DEVICE DIP SWITCH JUMPER

SW7 SW6
27256 ON OFF JP10 – 1-2

DEPARTMENT OF EEE
INTRODUCTION OF MICROPROCESSOR
INTRODUCTION:
Microprocessor is regarded as one of the most important devices in our everyday
machines called computers. Microprocessor is an electronic circuit that functions as the
CPU of a computer, providing computational control. Microprocessor are also used in other
advanced electronic systems, such as computer printers, automobiles and jet airlines

The first Microprocessor was the Intel 4004, produced in 1971. Originally
developed for a calculator and revolutionary for its time, it contained 2300 transistors on a
4-bit microprocessor that could perform only 60,000 operations per second. The first 8-bit
microprocessor was the Intel 8008, developed in 1972 to run computer terminals.

INTEL MICROPROCESSOR:
8086(1979):

Created as a cheaper version of Intel’s 8086, the 8088 was a 16-bit processor with
an 8-bit external bus

80286(1982):

With 16MB of addressable memory and 1GB of a virtual memory, this 16-bit chip
is referred to as the first “modern” microprocessor. It contained 130,000 transistors and
packed serious compute power 12MHz

80386(1985):

The price/performance curve continued its steep climb with the 386 and later the
486- 32 bit processors that brought real computing to the masses. The 386, featured
275,000 transistors, the 486 had more than a million

Pentium (1993):

Adding systems-level characteristics to enormous raw compute power, the Pentium


supports demanding I/O, graphics and communications intensive applications with more
than 3 million transistors

DEPARTMENT OF EEE
MICROPROCESSORS &MICROCONTROLLERS LAB

Pentium Pro (1995):

he nearest Pentium has dynamic instruction execution and the chip package is
more than 5.5 million transistors

Pentium II (1997):
The 7.5 million transistors Pentium II processor incorporates Intel MMX-TM
technology, which is designed specially to process video, audio and graphics data
efficiently

Pentium III (1999):

The Pentium III processor features 70 new instructions. It designed to significantly


enhance Internet experience, allowing users to do such things as browse through realistic
online museums and stores and download high-quality video. The processor incorporates
9.5 million transistors, and was introduced using 0.25 micron technology.

Pentium-IV (2000):

The Pentium-4 is fabricated in Intel’s 0.18 micron CMOS process. Its die size is
217 , power consumption is 50W. The Pentium-4 is available in 1.4GHz & 1.5Hz bins

Buses and operation:


8086 has all internal registers are as well as internal and external data buses, were
16 bits wide, finally estimating the “16 bit micro processor” identity of the 8086. A 20 bit
external address bus gave a 1MB physical address space (220=1,048,576). This address
space was addressed by means of internal ‘segmentation ‘. The data was multiplexed with
the address bus in order to fit a standard 40-pin dual in line package. 16 bit I/O address
meant 64KB of separate I/O space (216=65,536). The maximum linear address space was
limited to 64KB.Simply because internal registers were only 16 bits wide, programming
over 64KB, boundaries involved adjusting segment register.

Some of the control pins which carry essential signals for all external operations
had more than one function depending upon whether the device operated in ‘min’ or ‘max’
mode. The former was intended for small single processor systems while latter was for
medium and large systems, using more than one processor.
Page
7

DEPARTMENT OF EEE
INTRODUCTION TO MASM SOFTWARE

INTRODUCTION

MASM & TASM are the software’s used for programming the microprocessor 8086.
They are very popular for domestic and commercial use. MASM stands for Macro
Assembler and TASM stands for Turbo Assembler. MASM and TASM programs are
compatible to a lot of extent. We use the MASM software in our Labs.

The MASM software package comes with Three.exe files mentioned below:
• MASM
• LINK
• DEBUG

Using Macro – Assembler – Linker – Debugger (MASM, LINK,


DEBUG)

1. Open an MSDOS window.


2. Set the PATH so that the MASM programs are available. The MASM
programs are on the C drive; set the path so that DOS can find them. This
only needs to be done once each time you open an MSDOS prompt. set
PATH=%PATH%;C:\MASM\BIN
OR
To enter specified path in directory CD PATH
3. Use a Text Editor to edit the .ASM File
Create your file using one of the following programs:
notepad
proj.asm
wordpad
proj.asm
edit
proj.asm

1
Procedure For Program Execution :

Syntax: edit filename.asm <ENTER>

This is where the assembly programs are typed.

e.g., edit add1.asm <ENTER>

where add1 is the assembly language program file which will be created and in
this file the user types his/her assembly code program.
.asm is the extension of the assembly file.

Once the program typing is over, we have to SAVE the program file and EXIT
from EDITOR and return to MS – DOS.

4.Then we compile the source code to create an object module.

Syntax: masm filename.asm <ENTER>

The switch causes MASM to display the lines that generate compilation errors.
The switch enables information needed by the debugger to be included in the
.OBJ file.
.

5. Then we run the Linker LINK.OBJ- this generates .EXE file from the .OBJ
file
Syntax: link filename.OBJ <ENTER>

6. Finally, we run the Program


Your final program (if there were no errors in the previous step) will have an
.EXE ending. To just run it, type:
Syntax: DEBUG filename.EXE <ENTER>

This brings up the regular full-screen version of the Macro debugger.

Department of EEE
II.MASM – INTRODUCTION
MICROSOFT MACRO ASSEMBLER:

A program called assembler is used to convert the mnemonics of the


instructions along with the data into equivalent object code modules, these object
code modules may further be converted into executable code using the linker
and loader programs. This type of programming is called assembly level
programming. The assembler is a program that converts an assembly input file
also called source file to object file that can be converted into machine codes or
an executable file using linker.
The assembly level programming is done using MASM and TASM,which
along with it uses a link program to structure the codes operated by MASM in
the form of an executable file. It reads source program as an input and provides
an object file. The LINK file accepts the .obj file produced by MASM as an input
and produces an .exe file.

ENTERING A ROGRAM:
The programs are generally entered using the text editor and we use
‘turboc’ as editor. For every assembly language program .asm extension must
be there. The MASM accepts the file name only with extension of .asm .Even if
the file name is without the extension it provides an extension of .asm to it.
SYNTAX: MASM filename.asm;
On the next line the expected .obj file name is to be on the next line entered hy
creates the objects of the assembly language program. The .obj file is allocated
with the entered file name and the .obj extension on the next line a file name is
entered and an extension for the expected listing file of the source file in the
same way as the object file is entered as an extension of .lst exists. The successful
assembly process may generate the .obj, .lst and .crf files which would further
be used by linker to generate an .exe file.

LINKING A PROGRAM:
The dos linking program LINK.EXE is used by MASM to link one different
object modules of the source program and function library routines to generate an

Department of EEE
integrated executable code of the source program. The main input to the linker is
the .obj file that contains the object modules of the source program. Other
supporting information is obtained by the files generated by MASM. The linker
program is invoked using the following syntax.
SYNTAX: LINK filename.obj;
The output of the link program is an executable file whose extension is generated
as .exe. MASM 5.0 uses the complete procedure of assembling and linking under
a single menu invoked compile function.

DEBUGGING A PROGRAM:
Syntax: DEBUG filename.exe
It is a DOS utility that facilitates the debugging and trouble shooting of
the assembly language programs. The debug utility enables us to have the control
of the resources. The debug command at the DOS prompt invokes this facility. A
‘-‘display signals the successful invoke operation to the debug that is further used
as debug prompt for entering the various debugging commands as listed:
COMMAND CHARACTER FUNCTIONS:
-R: display all the registers and flags.
-D: display 128 memory locations of RAM
-E: enter hexadecimal data at current display pointer.
-F: fill memory area byte by byte
-a: assemble from current CS: IP
-u: assemble from current CS: IP
-g: execute from current CS: IP
-s: searches a byte or string of bytes
-q: quit the debug
-t: trace the program execution step by step.
-m: trace the move and bytes from offset1
-n: set file name pointer to filename.
-l: loads the filename.exe in the ram.

Department of EEE
Exp No.1: Programs for 16 bit arithmetic operations for 8086
(Using Various Addressing Modes).

i) 16 bit addition:
1.a) AIM: Write an assembly language program to add two 16-bit numbers

EQUIPMENT REQUIRED: Personal Computer, Macro assembler


(ESA/MASM) , 8086 Microprocessor kit, RPS(+5V)

Algorithm for 16- bit addition


Step1: start the program
Step2: Declare data segment and code segment
Step3: In the data segment declare the two operands to perform addition and one
variable for storing the result
Step4: Take the two operands in AX and BX registers
Step5: add two numbers
Step6: store the result which is in the AX register in to the variable which is
declared in the data segment
Step7: end the program

PROGRAM: ASSUME CS: CODE, DS: DATA


DATA SEGMENT
NUM 1 DW 4343H
NUM2 DW 1111H
RESULT DW 02H DUP (00)
DATA ENDS
CODE SEGMENT

START: MOV AX, DATA


MOV DS, AX
MOV AX, NUM1
MOV BX, NUM2
ADD AX, BX
MOV [RESULT], AX
JNC GO
MOV [RESULT+1], 01H
GO: INT 3
CODE ENDS
END START

RESULT:
-g
AX=5454 BX=1111 CX=0023 DX=0000 SP=0000 BP=0000
SI=0000 DI=0000 DS=0B7F

Department of EEE
1.(b). AIM: write an assembly language program to subtract two 16-
bit numbers

EQUIPMENT REQUIRED: Personal Computer, Macro assembler


(ESA/MASM) , 8086 Microprocessor kit, RPS(+5V)

Algorithm for 16 bit subtraction


Step1: start the program
Step2: Declare data segment, code segment and stack segment
Step3: In the data segment declare the two operands to perform subtraction and
one variable for storing the result
Step4: Take the two operands in AX and BX registers
Step5: subtract two numbers i.e, ( AX – BX)
Step6: store the result which is in the AX register in to the variable which is
declared in the stack segment
Step7: end the program

PROGRAM: ASSUME CS: CODE, DS: DATA, SS: STACK


DATA SEGMENT
A DW 4000H
B DW 2000H
DATA ENDS
STACK SEGMENT
RESULT DW 02 DUP (0)
STACK ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, 0000H
MOV AX, A
SUB AX, B
MOV [RESULT], AX
JNB GO
MOV [RESULT+1],01H
GO:INT 03
CODE ENDS
END START

RESULT:
-G AX=2000 BX=2000 CX=0000 DX=0000 SP=0000BP=0000
SI=0000 DI=0000 DS=0B7F

Department of EEE
1.(c)AIM: write an assembly language program to multiplication of
two 16-bit numbers

EQUIPMENT REQUIRED: Personal Computer, Macro assembler


(ESA/MASM) , 8086 Microprocessor kit, RPS(+5V).

Algorithm for 16 bit Multiplication


Step1: start the program
Step2: Declare data segment, code segment
Step3: In the data segment declare the two operands to perform multiplication
and one variable for storing the result
Step4: Take the two operands in AX and BX registers
Step5: Multiply two numbers i.e, (DX,AX <---AX * BX)
Step6: Store the result which is in the AX (lower word) and DX (upper word)in
to the variable RESULT which is declared in the data segment
Step7: end the program

PROGRAM: ASSUME CS: CODE, DS: DATA


DATA SEGMENT
A DW 4000H
B DX 0002H
RESULT DW 02 DUP (0)
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, 0000H
MOV AX, A
MOV BX, B
MUL BX
MOV [RESULT], AX
MOV [RESULT+2], DX
INT 03
CODE ENDS
END START

RESULT:
-G AX=8000 BX=0002 CX=0000 DX=0000 SP=0000BP=0000
SI=0000 DI=0000 DS=0B7F

Department of EEE
1.(d)AIM: write an assembly language program to perform division
between two 16-bit numbers

EQUIPMENT REQUIRED: Personal Computer, Macro assembler


(ESA/MASM) , 8086 Microprocessor kit, RPS(+5V).

Algorithm for 16 bit by 8 bit division


Step1: start the program
Step2: Declare data segment, code segment
Step3: In the data segment declare the two operands to perform division and one
variable for storing the result
Step4: Take the two operands in AX and BL registers
Step5: perform the division between the two numbers i.e, (AX<---AX / BL)
Step6: Store the result which is in the AL (quotioent) and AH (remainder) in to
the variable RESULT which is declared in the stack segment
Step7: end the program

PROGRAM: ASSUME CS: CODE, DS: DATA ,SS:STACK


DATA SEGMENT
A DW 0040H
B DB 02H
DATA ENDS
STACK SEGMENT
RESULT DW 01 DUP (0)
STACK ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, 0000H
MOV AX, A
MOV BL,B
DIV BL
MOV [RESULT] , AX
INT 03H
CODE ENDS
END START

RESULT:
-G AX=0020 BX=0002 CX=0000 DX=0000 SP=0000BP=0000
SI=0000 DI=0000 DS=0B7F

Department of EEE
PROGRAMS USING 8086 KIT

a)
16 bit addition:

MEMORY LABEL MNEMONIC


LOCATION
8000 MOV AX,4343
MOV BX,1111
ADD AX,BX
INT 3

Output:

Input output
Register Dat Register Data
a
AX 434 AX 5454
3
BX 111
1

b)16 bit subtraction:

MEMORY LABEL INSTRUCTION


LOCATION
80000 MOV AX,4343
MOV BX,1111
SUB AX,BX
INT 3

Output:

Department of EEE
Input output
Register Data Register Data
AX 4343 AX 3232
BX 1111

16 bit multiplication:

MEMORY LABEL INSTRUCTION


LOCATION
80000 MOV AX,4343
MOV BX,1111
MUL BX
INT 3

OUTPUT:
Input Output
Register Data Regis Data
ter
AX 4343 AX EA73
BX 1111 DX 047B

Department of EEE
d)16bit by 8 bit division:

MEMORY LOCATION LABEL MNEMONIC


4000 MOV AX,0100H
MOV BX,0FFH
DIV BL
INT 3

OUTPUT:

Input Output
Register Data Register Data
AX 0100H AL 01
BL FFH AH 01

Viva:

1) How many bits can process 8086 microprocessor at a time ?

2) What is the size of data bus of 8086?

3) What is the size of address bus of 8086?

4) What is the max memory addressing capacity of 8086?

5) Which are the basic parts of 8086?

EXERCISE:

1. Write an alp program for addition and subtraction of two 16bit numbers?

1) A278

2) B634

Department of EEE
2. Write an alp program for multiplication and division of two 16bit numbers?

1) 0012

2) 0006

OUT COMES:
1. Able to write the assembly language programs for arithmetical operations.
2. Able to use different segments to store the data.

Department of EEE
EXP NO: 2 Program for string manipulations for 8086.

(a) Program for searching for a number or character in a string


for 8086.

AIM: Write an assembly language program for searching for a number or


character in string
EQUIPMENT REQUIRED: Personal Computer, Macro Assembler
(ESA/MASM) , 8086 Microprocessor kit, RPS(+5V).

PROCEDURE:
1. Required number or character load into AL or AX register
2. Using the SCAN instruction search is performed
3. If the required number or character is present in a string then we
will get display “found” otherwise get the display “notfound”
PROGRAM:
ASSUME CS:CODE,DS:DATA ,ES:EXTRA
DATA SEGMENT
STRING1 DB 0AH,0DH,"ENTER A CHARACTER:",0AH,0DH,"$"
STRE DB "FOUND$"
STRNE DB "NOT FOUND$"
DATA ENDS
EXTRA SEGMENT
STRING2 DB "CMRCE$"
STRLEN EQU ($-STRING2)
EXTRA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV DX,OFFSET STRING1
MOV AH,09H
INT 21H
MOV AH,08H
INT 21H
MOV DI,OFFSET STRING2
REPNE SCASB
JZ LABLE
MOV DX,OFFSET STRNE
MOV AH,09H
INT 21H
JMP EXIT
LABLE:MOV DX,OFFSET STRE
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
EXIT: INT 03H

Department of EEE
CODE ENDS
END START

RESULT: ENTER A CHARACTER: ‘M’

Output: FOUND

Viva:

1) What is the size of instruction queue in 8086?

2) Which are the registers present in 8086?

3) What do you mean by pipelining in 8086?

4) How many 16 bit registers are available in 8086?

5) Specify addressing modes for any instruction?

Department of EEE
2(b): Program for transfer of a string from one location to other
location
AIM: Write an assembly language program for block transfer of given string from
data segment to extra segment

EQUIPMENT REQUIRED: Personal Computer, Macro Assembler (ESA/MASM) ,


8086 Microprocessor kit, RPS(+5V).

PROCEDURE:
1. Load the given string into the source location. i.e into data segment
2. Using the string instructions like MOVSB, CMPSB,SCASB perform the string
operations

HINT: For string operations source is data segment, destination is extra segment

PROGRAM:
ASSUME CS:CODE, DS:DATA ,ES:EXTRA
DATA SEGMENT
SRCDATA DB “MPMC LAB $”
COUNT EQU 08H
DATA ENDS
EXTRA SEGMENT
DSTDATA DB 08 DUP(0)
EXTRA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:EXTRA
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV SI,OFFSET SRCDATA
MOV DI,OFFSET DSTDATA
MOV CL, COUNT
CLD
REP MOVSB
MOV DI,OFFSET DSTDATA
MOV AX,[DI)]
MOV BX,[DI+2]
MOV CX,[DI+4]
MOV DX,[DI+6]
INT 03H
CODE ENDS
END START

Department of EEE
Result:

AX=4C24 BX=0000 CX=0000 DX=0000

d ds:0
0B40:0000 4D 50 4D 43 20 4C4142 20 24 MPMC LAB $
0B40:0010 4D 50 4D 43 20 4C 42 20 24 MPMC LAB $

Department of EEE
2(c) program for reverse of a string
AIM: Write an assembly language program for reverse of a given string

EQUIPMENT REQUIRED: Personal Computer, Macro Assembler


(ESA/MASM) , 8086 Microprocessor kit, RPS(+5V).

PROGRAM: ASSUME CS: CODE, DS: DATA, ES: EXTRA


DATA SEGMENT
STRING1 DB “MPMC LAB $”
STRLEN EQU ($-STRING1)
DATA ENDS
EXTRA SEGMENT
STRING2 DB 01 DUP (0)
EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX,EXTRA
MOV ES,AX
MOV BX,OFFSET STRING1
MOV SI,BX
MOV DI,OFFSET STRING2
ADD DI,STRLEN-1
CLD
MOV CX, STRLEN
A1: MOV AL,[SI]
MOV ES:[DI],AL
INC SI
DEC DI
LOOP A1
MOV DX,OFFSET STRING2
MOV AH,09H
INT 21H
MOV AH,4CH
INT 03H
CODE ENDS
END START

RESULT:

AX=4C24 BX=0000 CX=0000 DX=0000

D DS:0

0B40:0000 4D 50 4D 43 20 4C 41 42 20 24 42 41 4C 20 43 40 MPMC LAB $


BAL CMPM

Department of EEE
2(d) program for comparison of two strings

(iii) AIM: Write an assembly language program for comparison of two


strings

EQUIPMENT REQUIRED: Personal Computer, Macro Assembler


(ESA/MASM) , 8086 Microprocessor kit, RPS(+5V).

PROGRAM: ASSUME CS:CODE,DS:DATA,ES:EXTRA

DATA SEGMENT
STRING1 DB 'EMPTY$'
STRLEN EQU ($-STRING1)
NOTSFUL DB 'STRINGS ARE UNEQUAL$'
SFUL DB 'STRINGS ARE EQUAL$'
DATA ENDS
EXTRA SEGMENT
STRING2 DB 'EMPTY$'
EXTRA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV CX,STRLEN
CLD
MOV SI,OFFSET STRING1
MOV DI,OFFSET STRING2
REP CMPSB
JZ FORW
MOV DX,OFFSET NOTSFUL
MOV AH,09H
INT 21H
JMP EXITP
FORW:MOV DX,OFFSET SFUL
MOV AH,09H
INT 21H
EXITP:
NOP
MOV AH,4CH
INT 21H
CODE ENDS
END START

Result: STRINGS ARE EQUAL

Department of EEE
PROGRAMS USING 8086 KIT:

A) Moving block of data from one memory location to another memory


location

MEMORY LABEL MNEMONIC


LOCATION
8000 MOV SI,2000
MOV DI,2008
MOV CX,0008
REP
MOVSB
INT 3

OUTPUT:

output
Input
MEMORY Data MEMORY Data
LOCATION LOCATION

2000 01 2008 01
2001 04 2009 04
2002 03 200A 03
2003 02 200B 02
2004 01 200C 01
2005 04 200D 04
2006 03 200E 03
2007 02 200F 02

Department of EEE
B) Reverse of a data:

MEMORY LAB MNEMON


LOCATION EL IC
8000 MOV SI,2000
MOV DI,2008
MOV CX,0008
ADD SI,07
UP MOV AL,[SI]
MOV [DI],AL
DEC SI
INC DI
DEC CX
JNZ UP
INT 3

OUTPUT:

Input outpu
t
MEMORY Data MEMORY Data
LOCATION LOCATION

2000 01 2008 08
2001 02 2009 07
2002 03 200A 06
2003 04 200B 05
2004 05 200C 04
2005 06 200D 03
2006 07 200E 02
2007 08 200F 01

Department of EEE
C) Comparison of TWO strings

MEMORY LABEL MNEMONIC


LOCATION
8000 MOV SI,2000
MOV DI,2008
MOV CX,0005
REP
CMPSB
JNZ GO
MOV AL,00H
JMP EXIT

EXIT: GO: MOV AL,FFH

INT 3

OUTPUT:

Out put
Input
MEMORY String MEMORY String 2 AL=00,
1 data Indicates
data That Two
LOCATION LOCATION Strings Are
Equal
2000 01 2008 01
2001 02 2009 02
2002 03 200A 03
2003 04 200B 04
2004 05 200C 05

Viva:

1) What do you mean by assembler directives?

2) What .model small stands for?

3) What is the supply requirement of 8086?

Department of EEE
4) What is the relation between 8086 processor frequency & crystal Frequency?

5) Functions of Accumulator or AX register?

EXERCISE:

1. Write an alp for insert or delete a byte in a given string with SI memory location
is 4000 and DI location is 6000?

Department of EEE
EXP NO: 3 Program Using Logical Instructions
AIM: Write an assembly language program to perform logical AND,OR
and XOR operations.

EQUIPMENT REQUIRED: Personal Computer, Macro Assembler


(ESA/MASM) , 8086 Microprocessor kit, RPS(+5V).

PROGRAM: ASSUME CS:CODE,DS:DATA,ES:EXTRA

DATA SEGMENT
NUM1 DW 1234H
NUM2 DW 4567h
DATA ENDS
EXTRA SEGMENT
RESULT DW 03 dup(0000h)
EXTRA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV AX,NUM1
MOV BX,NUM2
AND AX,BX
MOV [RESULT],AX
MOV AX,NUM1
MOV BX,NUM2
OR AX,BX
MOV [ RESULT+2],AX
MOV AX,NUM1
MOV BX,NUM2
XOR AX,BX
MOV [ RESULT+4],AX
INT 3H
CODE ENDS
END START

RESULT:NUM1:1234H, NUM2:4567H

AND OPERATION OUTPUT:AX=0024H

OR OPERATION OUTPUT AX:5777H

XOR OPERATION OUTPUT AX:5753H

Department of EEE
EXP NO: 4 (a) Program Using Shift & Branch
Instructions

AIM:TO WRITE ALP FOR TO COUNTING THE NUMBER OF ONES


APPARATUS: MASM S/W, PC
PROGRAM:
DATA SEGMENT
NUM DB 34H,
DATA ENDS
ASSUME CS:CODE, DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,DATA
MOV AL,NUM
MOV CL,08H
GO:SHR AL, O1
JNC NEXT1
INC BL
NEXT1: DEC DL
JNZ GO
CODE ENDS
END START
RESULT: ALP FOR COUNTING NUMBEROF ONES IS PERFORMED.
EXPECTED OUTPUT:

I/P: NUM=34H
O/P :BL=03H ( NUMBER OF ONE’S IN A GIVEN NUMBER)

Department of EEE
4(B) Program Using Rotate Instructions

AIM: To Write a ALP for Conversion of BCD To ASCII Number


APPARATUS: MASM S/W, PC
PROGRAM:
DATA SEGMENT
BCD DB 34H
ASCII DB 2 DUP (‘$’)
DATA ENDS

CODE SEGMENT
ASSUME DS:DATA, CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV CL,04H
MOV AL,BCD
ROL AL,CL
ROR AL,CL
MOV BL,AL
MOV AL,BCD
ROR AL,04H
MOV BH,AL
ADD BX,3030H
MOV ASCII,BX
INT 3H
CODE ENDS
END START

RESULT: ALP for Conversion Of BCD To ASCII is Performed and the result is
stored in the memory location .

EXPECTED OUTPUT:

BCD VALUE: 34H


ASCII VALUE IS: 3334H

Department of EEE
(ii) AIM: To Write a ALP for Conversion of ASCII to BCD Number
APPARATUS: MASM S/W, PC
PROGRAM: DATA SEGMENT
NUM DW 3435H
DATA ENDS

CODE SEGMENT
ASSUME DS:DATA, CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV CL,04H
MOV AX,NUM
ROL AL,CL
ROR AL,CL
MOV BL,AL
MOV AH,NUM
ROL AL,04H
MOV AL,BL
INT 3H
CODE ENDS
END START

RESULT: ALP for Conversion of ASCII to BCD is Performed and the result
is stored in AL

Expected output:
ASCII num= 3435h
BCD=45h

Department of EEE
Cycle 2: Using 8051 Microcontroller Kit
Exp.No.1: Programming using arithmetic, logical and bit
manipulation Instructions of 8051.
1(a)AIM: Write an assembly language program to perform Addition of two
16 bit numbers present in data memory locations 9000 : 9003.Store the result
in 9004& 9005 .

EQUIPMENT REQUIRED: 8051 Micro Controller kit


5V Power Supply
Keyboard

PROGRAM: MOV DPTR,#9000H


MOVX A,@DPTR
MOV B,A
MOV DPTR,#9002H
MOVX A,@DPTR
ADD A,B
MOV DPTR,#9004
MOVX @DPTR,A
MOV DPTR,#9001H
MOVX A,@DPTR
MOV B,A
MOV DPTR,#9003H
MOVX A,@DPTR
ADDC A,B
MOV DPTR,#9005
MOVX @DPTR,A
LCALL 0003

Result:

Input: Output:
MD 9000,9001 4567H MD 9004 CEH
9002,9003 5567H 9005 9AH

Department of EEE
1(b). AIM: Write an assembly language program to perform logical AND operation
of two 16 bit numbers present in a data memory locations 9000 : 9003.Store the
result in 9004 &9005 Data Memory?

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard

PROGRAM: MOV DPTR,#9000H


MOVX A,@DPTR
MOV B,A
MOV DPTR,#9002H
MOVX A,@DPTR
ANL A,B
MOV DPTR,#9004
MOVX @DPTR,A
MOV DPTR,#9001H
MOVX A,@DPTR
MOV B,A
MOV DPTR,#9003H
MOVX A,@DPTR
ANL A,B
MOV DPTR,#9005
MOVX @DPTR,A
LCALL 0003

Result:

Input: Output:
MD 9000,9001 4567H MD 9004 67H
9002,9003 5567H 9005 40H

Department of EEE
1(c). AIM: Write an assembly language program to perform Subtraction of two 16
bit numbers present in a data memory locations 9000 : 9003.Store the result in 9004
&9005 Data Memory?

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard

PROGRAM: MOV DPTR,#9000H


MOVX A,@DPTR
MOV B,A
MOV DPTR,#9002H
MOVX A,@DPTR
SUBB A,B
MOV DPTR,#9004
MOVX @DPTR,A
MOV DPTR,#9001H
MOVX A,@DPTR
MOV B,A
MOV DPTR,#9003H
MOVX A,@DPTR
SUBB A,B
MOV DPTR,#9005
MOVX @DPTR,A
LCALL 0003

Result:

Input: Output:
MD 9000,9001 4567H MD 9004 00H
9002,9003 5567H 9005 F0H

Department of EEE
1(d). AIM: Write an assembly language program to perform Multiplication of two
16-bit numbers present in data memory locations . Store the result in R4,R5,R6&R7
Registers?

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard

PROGRAM:

ORG 0000H
MOV R0,#0FFH ;MSB1
MOV R1,#0EFH ;MSB2
MOV R2,#0FFH ;LSB1
MOV R3,#9DH ;LSB2
MOV A,R2
MOV B,R3
MUL AB
MOV R4,A
MOV R5,B
MOV A,R2
MOV B,R1
MUL AB
MOV R6,B
ADDC A,R5
MOV R5,A
MOV A,R1
MOV B,R4
MUL AB
ADDC A,R5
MOV R5,A
MOV A,B
ADDC A,R6
MOV R6,A
MOV A,R1
MOV B,R2
MUL AB
ADDC A,R6
MOV R6,A
MOV A,B
ADDC A,#00H
MOV R7,A
END

Department of EEE
Result:

Input: Output:
MD NUM1: FFFFH MD R5 R4: 1063H
NUM2: EF90H R7 R6: EF9CH

Department of EEE
1 (e). AIM: Write an assembly language program to perform Logical OR Operation
of two numbers present in a data memory locations 9000 : 9003.Store the result in
9004 &9005 Data Memory?

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard

PROGRAM: MOV DPTR,#9000H


MOVX A,@DPTR
MOV B,A
MOV DPTR,#9002H
MOVX A,@DPTR
ORL A,B
MOV DPTR,#9004
MOVX @DPTR,A
MOV DPTR,#9001H
MOVX A,@DPTR
MOV B,A
MOV DPTR,#9003H
MOVX A,@DPTR
ORL A,B
MOV DPTR,#9005
MOVX @DPTR,A
LCALL 0003

Result:

Input: Output:
MD 9000,9001 05 05H MD 9004: 07H
9002,9003 06 06H 9005: 07H

Department of EEE
1(f). AIM: Write an assembly language program to perform Logical XOR Operation
of two numbers present in a data memory locations 9000 and 9001.Store the result in
9002 Data Memory?

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard

PROGRAM: MOV DPTR,#9000


MOVX A,@DPTR
MOV B,A
MOV DPTR,#9001
MOVX A,@DPTR
XRL A,B
MOV DPTR,#9002
MOVX @DPTR,A
LCALL 0003

Result:

Input: Output:
MD 9000 05 MD 9002 03
9001 06

Viva:
1.Differences between 8086 & 8051
2. What is the Internal memory of 8051
3.Write flag register of 8051
4.Explain stack operation in 8051
5. Explain the registers 0f 8051

Department of EEE
EXP.NO.2: Time delay Generation Using Timers of 8051.

AIM: Write an assembly language program to verify timer or counter in 8051.


EQUIPMENT REQUIRED:
8051 Micro Controller Hardware kit
5V Power Supply
Keyboard
Keil software

PROGRAM:
MOV TMOD,#01 ;Timer 0, mode 1(16-bit mode)
HERE: MOV TL0,#0F2H ;TL0=F2H, the low byte
MOV TH0,#0FFH ;TH0=FFH, the high byte
CPL P1.5 ; toggle P1.5
ACALL DELAY
SJMP HERE

DELAY:
SETB TR0 ;start the timer 0
AGAIN: JNB TF0,AGAIN ; monitor timer flag 0
;until it rolls over
CLR TR0 ;stop timer 0
CLR TF0 ;clear timer 0 flag
RET

Output:
Port1 5th bit is toggled for every 3.3 milli seconds

Department of EEE
EXP. NO.3: Serial Communication from / to 8051 to / from
I/O devices
(a) AIM: Write an assembly language program to Transfer Serial data in 8051.

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard
Keil software
PROGRAM:
ORG 8000H
MOV SCON,#50H
MOV TMOD,#20H
MOV TH1,#0FDH
SETB TR1
MOV A,#"H"
MOV SBUF,A
L1:JNB TI,L1
CLR TI
LCALL 03H
END

output: H

(b)AIM: Write an assembly language program to Transfer Serial data in 8051.

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard
Keil software

PROGRAM:

MOV TMOD, #20H ; timer 1,mode 2(auto reload)


MOV TH1, #-3 ; 9600 baud rate
MOV SCON, #50H ; 8-bit, 1 stop, REN enabled
MOV SBUF,#A0H
SETB TR1 ; start timer 1
HERE: JNB RI, HERE; wait for char to come in
MOV A, SBUF ; saving incoming byte in A
MOV P2, A ; send to port 2
CLR RI ; get ready to receive next byte
SJMP HERE ; keep getting data

OUTPUT: P2=A0H

Department of EEE
EXP.NO.4: Program to Generate Squarewave.

AIM: Write an assembly language program to generate square wave.

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard
Keil software

PROGRAM:

MOV P1, #00000000B


MOV TMOD, #00000001B
MAIN: SETB P1.0
ACALL DELAY
CLR P1.0
ACALL DELAY
SJMP MAIN
DELAY: MOV TH0,#0FFH
MOV TL0,#0CEH
SETB TR0
HERE: JNB TF0,HERE
CLR TR0
CLR TF0
SETB P1.0
RET
END

OUTPUT: 10kHz Square wave is generated using timers.

Cycle 3: Interfacing I/O Devices to 8051

Department of EEE
EXP No: 1. Interfacing of 7 Segment Display to 8051.

AIM: Write an assembly language program for Interfacing of 7 Segment Display to


8051.
EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit
PC
5V Power Supply
Keyboard
Keil software
7 segment interface module
FRC cable
Software: Xassembler (X8051
PROGRAM:
$MOD51
ORG 00H
LJMP MAIN
ORG 9500H

MAIN: MOV DPTR,#0A003H ;CONTROL WORD REGISTER(PPI 8255).


MOV A,#81H ;CONTROL WORD
MOVX @DPTR,A

MAIN1: MOV DPTR,#0A000H ;PA DATA WORD REGISTER(PPI 8255).


MOV A,#3FH ;DATA WORD
MOVX @DPTR,A

MOV DPTR,#0A001H ;PB DATA WORD REGISTER(PPI 8255).


MOV A,#11111110B ;DATA WORD
MOV R7,A ;BACK-UP
MOVX @DPTR,A
ACALL DELAY

MOV DPTR,#0A000H ;PA DATA WORD REGISTER(PPI 8255).


MOV A,#06H ;DATA WORD
MOVX @DPTR,A

MOV DPTR,#0A001H ;PB DATA WORD REGISTER(PPI 8255).


MOV A,#11111101B ;DATA WORD
MOV R7,A ;BACK-UP
MOVX @DPTR,A
ACALL DELAY

MOV DPTR,#0A000H ;PA DATA WORD REGISTER(PPI 8255).


MOV A,#5BH ;DATA WORD
MOVX @DPTR,A

MOV DPTR,#0A001H ;PB DATA WORD REGISTER(PPI 8255).


MOV A,#11111011B ;DATA WORD
MOV R7,A ;BACK-UP

Department of EEE
MOVX @DPTR,A
ACALL DELAY

MOV DPTR,#0A000H ;PA DATA WORD REGISTER(PPI 8255).


MOV A,#4FH ;DATA WORD
MOVX @DPTR,A

MOV DPTR,#0A001H ;PB DATA WORD REGISTER(PPI 8255).


MOV A,#11110111B ;DATA WORD
MOV R7,A ;BACK-UP
MOVX @DPTR,A
ACALL DELAY

MOV DPTR,#0A000H ;PA DATA WORD REGISTER(PPI 8255).


MOV A,#66H ;DATA WORD
MOVX @DPTR,A

MOV DPTR,#0A001H ;PB DATA WORD REGISTER(PPI 8255).


MOV A,#11101111B ;DATA WORD
MOV R7,A ;BACK-UP
MOVX @DPTR,A
ACALL DELAY

MOV DPTR,#0A000H ;PA DATA WORD REGISTER(PPI 8255).


MOV A,#6DH ;DATA WORD
MOVX @DPTR,A

MOV DPTR,#0A001H ;PB DATA WORD REGISTER(PPI 8255).


MOV A,#11011111B ;DATA WORD
MOV R7,A ;BACK-UP
MOVX @DPTR,A
ACALL DELAY
SJMP MAIN1

DELAY: MOV R1,#05H


LOOP1: MOV R0,#0FFH
LOOP: DJNZ R0,LOOP
DJNZ R1,LOOP1
RET
END

OUTPUT: Displayed the digits on 7-Segment display module.

EXP.NO.2: Interfacing Matrix/Keyboard to 8051.

Department of EEE
AIM: Write an assembly language program for interfacing keyboard to 8051

EQUIPMENT REQUIRED:
PC
8051 Micro Controller Hardware kit
5V Power Supply
Keyboard
Keil software
Keyboard interface module
FRC cable
Software: Xassembler (X8051)
PROGRAM:

;PROGRAM FOR HEX KEYBOARD


$MOD51
ORG 00H
LJMP MAIN
ORG 9800H
MAIN: MOV DPTR, #0A003H
MOV A, #81H
MOVX @DPTR, A

INIT: MOV R7,#04


MOV R6, #0EEH
MOV R5, #00
MOV R4, #00
MOV DPTR, #0A002H
SCAN: MOV A, R6 ;
MOVX @DPTR, A
NOP
MOVX A, @DPTR
ANL A, #0FH
CJNE A,#0FH, K1

MOV A, R6
RL A
MOV R6, A
MOV A,R5
ADD A,#04
MOV R5,A

DJNZ R7, SCAN


SJMP INIT
; KEYCODE
K1: SETB C
K2: RRC A
JC K3

Department of EEE
MOV A,R5
ADD A,R4
MOV DPTR, #0A004H
MOVX @DPTR, A
SJMP INIT

K3: INC R4

SJMP K2
END

Output: If key “ F” is typed from the keyboard then it is displayed on the display
as “1111”.

Department of EEE
Exp. No: 3 Sequence Generator Using Serial Interface in
8051.

Aim: Write a ALP to send a set of characters serially and receive at receiver
end .

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard
Keil software
Serial data transfer cable.

Program:

Transmitter:
$MOD51
ORG 8200H
MOV TMOD,#20H
MOV TH1, #-3
MOV SCON, #50H
SETB TR1
AGAIN: MOV A, #'Y'
ACALL TRANS
MOV A, #'E'
ACALL TRANS
MOV A, #'S'
ACALL TRANS
MOV A, #'#'
ACALL TRANS
SJMP $

TRANS: MOV SBUF, A


HERE: JNB TI, HERE
CLR TI
RET
END

Department of EEE
Receiver:
$MOD51

ORG 8300H
MOV TMOD, #20H
MOV TH1, #-3
MOV SCON,#50H
MOV DPTR, #8400H
SETB TR1
HERE: JNB RI, HERE
MOV A, SBUF
CLR RI
CJNE A,#'#',CONT
SJMP $

CONT: MOVX @DPTR, A


INC DPTR
SJMP HERE
END

output:

At receiver end, ASCII values if “yes” is received in the memory locations 8400h,
8401h,8402h

Department of EEE
EXP.NO:4 8 Bit ADC Interface to 8051.

AIM: Write a ALP for convert analog signal to digital signal using 8 -bit ADC.

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard
Keil software
ADC interface module

PROGRAM:

$MOD51
ORG 00H
LJMP MAIN
ORG 9600H

MAIN: MOV DPTR,#0A003H


MOV A,#98H
MOVX @DPTR,A
TOP: MOV DPTR,#0A002H
MOV A,#01H
MOVX @DPTR,A
MOV DPTR,#0A001H
MOV A,#0000001B
MOVX @DPTR,A
MOV A,#00000011B
MOVX @DPTR,A
MOV A,#00H
MOVX @DPTR,A
LOOP: MOV DPTR,#0A002H
MOVX A,@DPTR
JNB ACC.4,LOOP
MOV DPTR,#0A001H
MOV A,#00000100B
MOVX @DPTR, A

MOV DPTR,#0A000H
MOVX A,@DPTR
MOV DPTR, #0A004H
MOVX @DPTR, A

;ONE SECOND DELAY


AGAIN: MOV TMOD,#10H
MOV R3,# 20H
AGAIN1: MOV TL1,#08

Department of EEE
MOV TH1,#01
SETB TR1
BACK1: JNB TF1,BACK1
CLR TR1
CLR TF1
DJNZ R3,AGAIN1

LJMP TOP
END

Output:

For analog input: 5V


Output: 11111111

Department of EEE
EXP.NO:5 Triangular wave generators through DAC
Interfaces to 8051.

AIM: Write a ALP to generate triangular wave using DAC interfacing with 8051.

EQUIPMENT REQUIRED: 8051 Micro Controller Hardware kit


5V Power Supply
Keyboard
Keil software
DAC interface module

PROGRAM:

$MOD51
ORG 00H
LJMP MAIN
ORG 8200H
MAIN: MOV DPTR,#0A003H ;CONTROL WORD REGISTER(PPI 8255).
MOV A,#80H ;PORT A-INPUT, PORT B-OUTPUT
;PORT C(L)-OUTPUT, PORT C(U)-INPUT
MOVX @DPTR,A
MOV R1,#00H ;MOV 0 TO R1
TOP: MOV DPTR, #0A000H ;POINT TO PORT A WHICH IS CONNECTED
MOV A, R1 ;TO INPUT OF DAC
MOVX @DPTR, A ;R1 CONTENT IS SENT TO DAC INPUT
INC A ;IT IS INCREMENTED
MOV R1,A
LJMP TOP ;JUMP TO GIVE ANOTHER INPUT
END

OUT PUT:

Department of EEE

You might also like