NBA Final MPMC Lab Manual

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 93

MICROPROCESSORS & MICROCONTROLLER LAB

MICROPROCESSOR & MICROCONTROLLER


LAB MANUAL

DEPARTMENT OF ELECTRONICS
AND COMMUNICATION
ENGINEERING ,
VASIREDDY VENKATADRI
INSTITUTE OF TECHNOLOGY,

NAMBUR.

VVIT, Department of Electronics and Communication Engineering Page 1


MICROPROCESSORS & MICROCONTROLLER LAB

INDEX

Page.
S.No. Contents
No
1 Syllabus 4
2 Equipment required for laboratory 5
3 Introduction to 8086, Masm/Tasm Editor 7
4 Turbo Assembler Linker Debugger 10
5 Introduction to the trainer & Instructions to user 12
6 Hexadecimal keypad legend interpretation 15
7 Function Key Operation 15

PART-I: MICROPROCESSOR 8086 (17 – 72)

Exp. Page.
NAME OF PROGRAM
No. No
1 8 bit addition 17
2 16 bit addition 19
3 8 bit subtraction 21
4 16 bit subtraction 23
5 Multibyte addition 25
6 Multibyte subtraction 27
7 4 digit decimal number addition 29
8 Multiplication of 8-bit signed number by 16-bit signed number 31
9 Multiplication of 16 -bit unsigned number by 16-bit unsigned number 33
10 Division of 16 -bit unsigned number by 16-bit unsigned number 35
11 Division of 16-bit signed number by 8-bit signed number 37
12 Packed BCD to unpacked BCD conversion 39
13 Packed BCD to ASCII conversion 41
14 ASCII addition 43
15 ASCII subtraction 45
16 Count the number of even and odd numbers from a series 47
17 Count the numbers consists of ‘1’ as a sixth bit 49
18 Arrange a series of 8-bt signed numbers in descending order 51
19 Arrange a series of 16-bt unsigned numbers in ascending order 53
20 String transfer in forward direction 55

VVIT, Department of Electronics and Communication Engineering Page 2


MICROPROCESSORS & MICROCONTROLLER LAB

21 String transfer in reverse direction 57


22 String insertion 59
23 String deletion 62
24 Display of message using dos interrupts 65
25 To read a string of characters from key board dos interrupts 66
26 String check for palindrome 68
27 String comparision using dos interrupts 70
28 Password access using dos interrupts 72

PART-II: INTERFACING WITH MICROPROCESSOR (73 - 85

Exp. Page.
No. NAME OF PROGRAM No
1 Add two 8 bit numbers 73
2 Subtraction two 8 bit numbers 74
3 Division two 8 bit numbers 75
4 Add two 16 bit numbers 76
5 Subtraction two 16 bit numbers 77
6 Division two 16 bit numbers 78
7 8279 – keyboard display- write a program to display a string of characters 79
8 8255 – PPI-write alp to generate sinusoidal wave using ppi 82
9 8259 – programmable interupt controller 84
10 8251 – USART 85

PART-III: MICROCONTROLLER 8051 (87 – 89)

Exp. Page.
NAME OF PROGRAM
No. No
1 Reading and writing on a parallel port 87
2 Timer in differnent modes 88
3 Serial communication implementation 89

PART-IV: INTERFACING WITH MICROCONTROLLER (90 – 92)


Exp. Page.
NAME OF PROGRAM
No. No
1 Add two 8 bit numbers 90
2 Subtraction two 8 bit numbers 91
3 Multiplication two 8 bit numbers 92

VVIT, Department of Electronics and Communication Engineering Page 3


MICROPROCESSORS & MICROCONTROLLER LAB

III Year B.Tech. ECE. II-Sem T P C


0 3 2

MICROPROCESSORS AND MICROCONTROLLERS LAB

The students are required to develop the necessary Algorithm, Flowchart and Assembly
Language Program Source Code for executing the following functions using MASM/TASM
software and to verify the results with necessary Hardware Kits.

PART-I: MICROPROCESSOR 8086

1. Introduction to MASM/TASM.
2. Arithmetic operation- Multi byte Addition and Subtraction, Multiplication and Division-
Signed and unsigned Arithmetic operation, ASCII- Arithmetic operation.
3. Logic operations-Shift and rotate- Converting packed BCD to unpacked BCD, BCD to ASCII
conversion.
4. By using string operation and Instruction prefix: Move Block, Reverse string, Sorting,
Inserting, Deleting, Length of the string, String comparison.
5. DOS/BIOS programming: Reading keyboard (Buffered with and without echo) - Display
characters, Strings.

PART-II: INTERFACING WITH MICROPROCESSOR

1. 8259 – Interrupt Controller-Generate an interrupt using 8259 timer.


2. 8279 – Keyboard Display- Write a program to display a string of characters.
3. 8255 – PPI-Write ALP to generate sinusoidal wave using PPI.
4. 8251 – USART-Write a program in ALP to establish Communication between two processors.

PART-III: MICROCONTROLLER 8051

1. Reading and Writing on a parallel port.


2. Timer in different modes.
3. Serial communication implementation.

PART-IV: INTERFACING WITH MICROCONTROLLER

Write C programs to interface 8051 chip to Interfacing modules to Develop single chip solutions.
1. Simple Calculator using 6 digit seven segment display and Hex Keyboard interface to 8051.
2. Alphanumeric LCD panel and Hex keypad input interface to 8051.
3. External ADC and Temperature control interface to 8051.
4. Generate different waveforms Sine, Square, Triangular, and Ramp etc. using DAC interface to
8051; change the frequency and Amplitude.

VVIT, Department of Electronics and Communication Engineering Page 4


MICROPROCESSORS & MICROCONTROLLER LAB

EQUIPMENT REQUIRED FOR LABORATORY

1. MASM/TASM software 2. 8086 Microprocessor Kits

1. 8051 Micro Controller kits

2. Interfaces/peripheral subsystems

i) 8259 PIC

ii) 8279-KB/Display

iii) 8255 PPI

iv) 8251 USART

5. A/D and D/AC Interface.

VVIT, Department of Electronics and Communication Engineering Page 5


MICROPROCESSORS & MICROCONTROLLER LAB

VVIT, Department of Electronics and Communication Engineering Page 6


MICROPROCESSORS & MICROCONTROLLER LAB

INTRODUCTION TO 8086, MASM/TASM EDITOR

An editor is a program, which allows you to create a file containing the assembly language
statements for your program. As you type in your program, the editor stores the ASCII codes
for the letters and numbers in successive RAM locations. When you have typed in all of your
programs, you then save the file on a floppy of hard disk. This file is called source file. The
next step is to process the source file with an assembler. In the TASM assembler, you should
give your source file name the extension, .ASM

ASSEM BLER
An assembler program is used to translate the assembly language mnemonics for instructions
to the corresponding binary codes. When you run the assembler, it reads the source file of
your program the disk, where you saved it after editing on the first pass through the source
program the assembler determines the displacement of named data items, the offset of
labels and pails this information in a symbol table. On the second pass through the source
program, the assembler produces the binary code for each instruction and inserts the offset
etc that is calculated during the first pass. The assembler generates two files on floppy or
hard disk. The first file called the object file is given the extension. OBJ. The object file
contains the binary codes for the instructions and information about the addresses of the
instructions. The second file generated by the assembler is called assembler list file. The list
file contains your assembly language statements, the binary codes for each instructions and
the offset for each instruction. In TASM assembler, TASM source file name ASM is used to
assemble the file. Edit source file name LST is used to view the list file, which is
generated, when you assemble the file.

LINKER
A linker is a program used to join several object files into one large object file and convert to
an exe file. The linker produces a link file, which contains the binary codes for all the
combined modules. The linker however doesn’t assign absolute addresses to the program, it
assigns is said to be reloadable because it can be put anywhere in memory to be run. In
TASM, TLINK source filename is used to link the file.

DEBUGGER
A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot are debug it the debugger allows you to look
at the contents of registers and memory locations after your program runs. It allows you to
change the contents of register and memory locations after your program runs. It allows you
to change the contents of register and memory locations and return the program. A debugger
also allows you to set a break point at any point in the program. If you inset a breakpoint the
debugger will run the program upto the instruction where the breakpoint is set and stop
execution. You can then examine register and memory contents to see whether the results
are correct at that point. In TASM, td filename is issued to debug the file.

VVIT, Department of Electronics and Communication Engineering Page 7


MICROPROCESSORS & MICROCONTROLLER LAB

DEBUGGER FUNCTIONS:
1. Debugger allows looking at the contents of registers and memory locations.
2. We can extend 8-bit register to 16-bit register which the help of extended register option.
3. Debugger allows setting breakpoints at any point with the program.
4. The debugger will run the program upto the instruction where the breakpoint is set and
then stop execution of program. At this point, we can examine registry and memory
contents at that point.
5. With the help of dump we can view register contents.
6. We can trace the program step by step with the help of F7.
7. We can execute the program completely at a time using F8.

DEBUGGER COMMANDS

ASSEMBLE: To write assembly language program from the given address.


A starting address <cr> Eg: a 100 <cr>
Starts program at an offset of 100.

DUMP: To see the specified memory contents


D memory location first address last address
(While displays the set of values stored in the specified range, which is given above) Eg: d
0100 0105 <cr>
Display the contents of memory locations from 100 to 105(including).

ENTER: To enter data into the specified memory locations(s).


E memory location data data data data data …<cr>
Eg: e 1200 10 20 30 40 ….
Enters the above values starting from memory locations 1200 to 1203, by loading 10 into 1200,
20 into 1201 and soon.

GO: To execute the program


G: one instruction executes (address specified by IP)
G address <cr>: executes from current IP to the address specified
G first address last addresses <cr>: executes a set of instructions specified between the given
addresses.

MOVE: Moves a set of data from source location to destination location


M first address last address destination address
Eg: m100 104 200
Transfers block of data (from 100 to 104) to destination address 200.

QUIT: To exit from the debugger.


Q <cr>

REGISTER: Shows the contents of Registers


R register name: Eg: r ax Shows the contents of register.

VVIT, Department of Electronics and Communication Engineering Page 8


MICROPROCESSORS & MICROCONTROLLER LAB

TRACE: To trace the program instruction by instruction.


T = 0100 <cr>: traces only the current instruction. (Instruction specified by IP)
T = 0100 02 <cr>: Traces instructions from 100 to 101, here the second argument specifies
the number of instructions to be traced.

UNASSEMBLE: To unassembled the program.


Shows the opcodes along with the assembly language program.
U 100 <cr>: unassembled 32 instructions starting from 100th location. U 0100 0109 <cr>:
unassebles the lines from 100 to 104

VVIT, Department of Electronics and Communication Engineering Page 9


MICROPROCESSORS & MICROCONTROLLER LAB

Using Turbo – Assembler – Linker – Debugger


(TASM, TLINK, TD)
1. Open an MSDOS window.
2. Set the PATH so that the TASM programs are available
The TASM 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:\TASM\BIN
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

4. Compile the source code to create an object module. tasm/z/zi proj.asm


The /z switch causes TASM to display the lines that generate compilation errors. The /zi
switch enables information needed by the debugger to be included in the .OBJ file. Note that
you should use "real mode" assembler, TASM.EXE. Do not use the "protected mode"
assembler TASM32.EXE for the assignments that will be given in class

5. Run Linker TLINK.EXE- generate .EXE file from the .OBJ file tlink/v proj

6. 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: proj
If you want to use the debugger to examine the instructions, registers, etc., type: td proj
This brings up the regular full-screen version of the Turbo debugger.

1. Tracing the Program's Execution


The Turbo debugger first starts, a Module Window which displays the . Executable lines of
program code, marked with a bullet in the left column of the window. You can set
breakpoints or step to any of these lines of code. An arrow in the first column of the
window indicates the location of the instruction pointer. This always points to the next
statement to be executed. To execute just that instruction use one of the two methods listed
under the Run menu item:

Trace into (can use F7 key): executes one instruction; traces "into" procedures.

Step over (can use F8 key): executes one instruction; skips (does not trace into)
procedures. Hitting either of these executes the instruction, and moves the arrow to the next
instruction. As each instruction executes, the effects might be visible in the Registers Window
and Watches Window
 Trace into (can use F7 key): executes one instruction; traces "into" procedures.
 Step over (can use F8 key): executes one instruction; skips (does not trace into)

VVIT, Department of Electronics and Communication Engineering Page


10
MICROPROCESSORS & MICROCONTROLLER LAB

procedures. Hitting either of these executes the instruction, and moves the arrow to the
next instruction. As each instruction executes, the effects might be visible in the Registers
Window and Watches Window
2. Setting and Removing Breakpoints
To set a breakpoint, position the cursor on the desired line of source code and press F2.
The line containing the breakpoint will turn red. Pressing F2 again removes the breakpoint.
To execute all instructions from the current instruction pointer up to the next encountered
breakpoint, choose Run (can use F9 key) from the Run menu item.

3. Examining Registers
Another window, the Registers Window, can be opened to examine the current value of
the CPU registers and flags. The View menu can be used to open this Registers Window.
The registers and flags might change as each instruction is executed.

4. Examining Memory
To examine memory, you will need to open an Inspector window. An Inspector window
shows the contents of a data structure (or simple variable) in the program you are debugging.
It also allows you to modify the contents of the data structure or variable. To open an
Inspector window, place the cursor on what you want to inspect and press CTRL-I. After
you've examined the data item, press the ESC key to remove the Inspector window.

5. Viewing the Program's Output


Output written to the screen by a program is not immediately visible, since the main purpose
of using a debugger is to examine the internal operation of the program. To observe what the
user would see, press ALT-F5. The entire screen will change to a user-view showing the
program's input and output (and possibly that of previous programs as well). Press any key to
return to the debugger screen.

VVIT, Department of Electronics and Communication Engineering Page


11
MICROPROCESSORS & MICROCONTROLLER LAB

Introduction to the trainer & Instructions to user


INTRODUCTION
ESA 86/88 is a powerful, general-purpose microcomputer system, which can be operated
either with 8086 CPU or with 8086CPU. It is generally supplied with 8086 CPU. To change it
to 8088, user has to just remove the 8086, insert 8088 into that socket and set a DIP switch.
The 8086 and 8088 are third generation CPU is from INTEL that differ primarily in their
external data paths. 8088 uses and 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, 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, operating at 8MHz in maximum mode (Supplied with 8086 CPU). (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:


128K bytes using 6255s (64K bytes supplied using 2x62556s. The other two sockets are for

VVIT, Department of Electronics and Communication Engineering Page


12
MICROPROCESSORS & MICROCONTROLLER LAB

user expansion). RAM has battery backup facility.

Peripherals and Controllers

8251A: Programmable Communication Interface for serial communication supporting all


standard from 110-19,200 (Baud is selected through on-board Dipswitch).

8253-5: (2 Nos.) programmable peripheral Interface devices provide 48 Programmable I/O


lines.

8259A: Programmable interrupt Controller provides interrupt vectors for 8 sources

8288: Bus controller used for generating control signals.

Interrupts

External: NMI for INTR Keyboard.

INTER 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: De-multiplexed 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. (Connector details compatible to our other microcomputer trainers).

Serial I/O: RS-232 C through on-board 9pin D-type female connector.

Power supply (optional): +5V @ 3.0Amp

CONFIGURATION AND INSTALLATION

Configuration 86/88-2
86/88-2-microcomputer trainer is versatile and can be configured in a number of ways, as

VVIT, Department of Electronics and Communication Engineering Page


13
MICROPROCESSORS & MICROCONTROLLER LAB

determined by the setting of a DIP switch and other jumpers. (Refer to the component
layout diagram in appendix C to locate the DIP switch and the jumpers).

Operational mode selection


86/88-2 can be operated either in the serial mode or in Hexadecimal keypad mode. In the
serial mode, the trainer 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)

Printer Enable/Disable
86/88-2 firmware includes the driver program fro 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, 86/88-2 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. (Refer to
chapter 5 for a detailed discussion of the Hardware).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:
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.

VVIT, Department of Electronics and Communication Engineering Page


14
MICROPROCESSORS & MICROCONTROLLER LAB

DEVICE DIP SWITCH JUMPER


SW7 SW6
27256 ON OFF JP10 – 1-2

Hexadecimal keypad legend interpretation

Hexadecimal Acronym Name Acronym Name


Examine
0 - EB/AX EB AX Accumulator
Byte
Examine
1- ER/BX ER BX Base Register
Register
2 - GO/CX GO Go CX Count Register
3 - ST/DX ST Single Step DX Data Register
4 - IB/SP IB Input Byte SP Stack Pointer
5 - OB/BP OB Output Byte BP Base Pointer
6 - MV/SI MV Move SI Source Index
Examine Destination
7 - EW/DI EW DI
Word index
8 - IW/CS IW Input word CS Code Segment
9 - OW/DS OW Output Word DS Data Segment
A - /SS None N/A SS Stack Segment
B- /ES None N/A ES Extra Segment
Instruction
C - /IP None N/A IP
Pointer
D - /FL None N/A FL Flag Register
E None N/A none N/A
F None N/A none N/A

Function Key Operation:

Function
Operation
Key

VVIT, Department of Electronics and Communication Engineering Page


15
MICROPROCESSORS & MICROCONTROLLER LAB

The RESET key allows you to terminate any present activity and to return
your ESA 86/88-2 to an initialize state. When pressed, the sign-on
RESET
message appears in the display and the monitor is ready for command
entry.

The INTR (interrupt) key is used to generate an immediate non-maskable


type 2 interrupt (NM). The NMI interrupt vector is initialized on power
KB INT up or system reset to point to a routine within the monitor which causes
all of the 8086/8088’s registers to be saved. Control is returned to the
monitor for subsequent command entry.

The + (plus) key allows you to add two hexadecimal values. This function
+ simplifies relative addressing by allowing you to readily calculate an
address location relative to a base address.

The – (minus) key allows you to subtract one hexadecimal value from

another.

The : (colon) key is used to separate an address to be entered into two


:
parts; a segment value and an offset value.

The REG (register) key allows you to use the contents of any of the
REG
8086/8088’s registers as an address or data value.

The NEXT key is used to separate keypad entries and to increment the
NEXT
address field to the next consecutive memory location.

The PREV key is used to decrement the address field to previous memory
PREV
location.

The dot key is the command terminator. When pressed, the current
EXEC (.)
command is executed.
1) NEXT or, means the same operation
NOTE
2) EXEC or, means the same operation

VVIT, Department of Electronics and Communication Engineering Page


16
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: 8BIT ADDITION


Aim : To add two 8-bit hexadecimal numbers.

Registers used: AX, BX,DS

Program:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DB 0A9H
NUM2 DB 0F3H
ORG 5000H
RES DW 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AL, NUM1
MOV BL, NUM2
ADD AL, BL
MOV AH, 0H
ADC AH, 0H
MOV RES, AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

MOV (Move):

ADD (Addition):

ADC (Add with carry):

VVIT, Department of Electronics and Communication Engineering Page


17
MICROPROCESSORS & MICROCONTROLLER LAB

Theoretical calculations:

Observations:

Result:

VVIT, Department of Electronics and Communication Engineering Page


18
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: 16-BIT ADDITION


Aim : To add two 16-bit hexadecimal numbers.

Registers used: AX, BX, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DW 8A41H
NUM2 DW 6BC5H
ORG 5000H
RES DW 0H
CAR DB 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, NUM1
MOV BX, NUM2
ADD AX, BX
MOV RES, AX
MOV AH, 0H
ADC AH, 0H
MOV CAR, AH
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

ADC (Add with carry):

VVIT, Department of Electronics and Communication Engineering Page


19
MICROPROCESSORS & MICROCONTROLLER LAB

INT 21H:

Theoretical calculations:

Observations:

CS: 19C7H, DS: 14B6H

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002
DS:5003 DS:5003

Result:

VVIT, Department of Electronics and Communication Engineering Page


20
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: 8-BIT SUBTRACTION


Aim : To subtract two 8-bit hexadecimal numbers.

Registers used: AX, BX, DS

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DB 45H
NUM2 DB 20H
ORG 5000H
RES DB 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AL, NUM1
MOV BL, NUM2
SUB AL, BL
MOV RESULT, AL
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

MOV (Move):

SUB (Subtraction):.

VVIT, Department of Electronics and Communication Engineering Page


21
MICROPROCESSORS & MICROCONTROLLER LAB

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000H
DS:2001 DS:2001H
DS:2002 DS:2002H
DS:2003 DS:2003H

DS:5000H DS:5000H
DS:5001H DS:50001
DS:5002H DS:5002H
DS:5003H DS:5003H

Result:

VVIT, Department of Electronics and Communication Engineering Page


22
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: 16-BIT SUBTRACTION


Aim : To subtract two 16-bit hexadecimal numbers.

Registers used: AX, BX, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DW 8A41H
NUM2 DW 62C5H
ORG 5000H
RES DW 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, NUM1
MOV BX, NUM2
SUB AX, BX
MOV RES, AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

SUB (Subtraction):.

VVIT, Department of Electronics and Communication Engineering Page


23
MICROPROCESSORS & MICROCONTROLLER LAB

INT 21H:.

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000H
DS:2001 DS:2001H
DS:2002 DS:2002H
DS:2003 DS:2003H

DS:5000H DS:5000H
DS:5001H DS:50001
DS:5002H DS:5002H
DS:5003H DS:5003H

Result:

VVIT, Department of Electronics and Communication Engineering Page


24
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: MULTIBYTE ADDITION


Aim : TO ADD TWO MULTIBYTE NUMBERS.

Registers used: AX, BX, CX, DX, DS

Program:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DD 4A59 322BH
NUM2 DD 59B6 ABCDH
ORG 5000H
RES DD 0H
CAR DB 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, WORD PTR [NUM1]
MOV BX, WORD PTR [NUM2]
MOV CX, WORD PTR [NUM1+2]
MOV DX, WORD PTR [NUM2+2]
ADD AX, BX
ADC CX, DX
MOV WORD PTR [RES], AX
MOV WORD PTR [RES+2], CX
MOV AH, 0H
ADC AH, 0H
MOV CAR, AH
MOV AH, 4CH

VVIT, Department of Electronics and Communication Engineering Page


25
MICROPROCESSORS & MICROCONTROLLER LAB

INT 21H
CODE ENDS
END START

Instruction description:

ADC (Add with carry):

INT 21H:.

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000H
DS:2001 DS:2001H
DS:2002 DS:2002H
DS:2003 DS:2003H
DS:2004 DS:2004
DS:2005 DS:2005
DS:2006 DS:2006
DS:2007 DS:2007

DS:5000H DS:5000H
DS:50001 DS:50001
DS:5002H DS:5002H
DS:5003H 00H DS:5003H

Result:

VVIT, Department of Electronics and Communication Engineering Page


26
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: MULTIBYTE SUBTRACTION


Aim : To subtract two multisystem numbers.

Registers used: AX, BX, CX, DX, DS

Program:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DD 4A59 322BH
NUM2 DD 59B6 ABCDH
ORG 5000H
RES DD 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, WORD PTR [NUM1]
MOV BX, WORD PTR [NUM2]
MOV CX, WORD PTR [NUM1+2]
MOV DX, WORD PTR [NUM2+2]
SUB AX, BX
SBB CX, DX
MOV WORD PTR [RES], AX
MOV WORD PTR [RES+2], CX
MOV AH, 4CH
INT 21H
CODE ENDS
END START

VVIT, Department of Electronics and Communication Engineering Page


27
MICROPROCESSORS & MICROCONTROLLER LAB

Instruction description:

SBB (Subtraction with borrow):

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000H
DS:2001 DS:2001H
DS:2002 DS:2002H
DS:2003 DS:2003H
DS:2004 DS:2004
DS:2005 DS:2005
DS:2006 DS:2006
DS:2007 DS:2007

DS:5000H DS:5000H
DS:50001 DS:50001
DS:5002H DS:5002H
DS:5003H DS:5003H

VVIT, Department of Electronics and Communication Engineering Page


28
MICROPROCESSORS & MICROCONTROLLER LAB

Result:

PROGRAM: 4 DIGIT DECIMAL NUMBER ADDITION


Aim : To add two 4- digit decimal numbers.

Registers used: AX, BX, DS

Program:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DW 9999H
NUM2 DW 8888H
ORG 5000H
RES DW 0H
CAR DB 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, NUM1
MOV BX, NUM2
ADD AL, BL
DAA
MOV BYTE PTR [RES], AL
ADC AH, BH
MOV AL, AH
DAA

VVIT, Department of Electronics and Communication Engineering Page


29
MICROPROCESSORS & MICROCONTROLLER LAB

MOV BYTE PTR [RES+1], AL


MOV AH, 0H
ADC AH, 0H
MOV CAR, AH
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

DAA (Decimal Adjust Accumulator):

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000H
DS:2001 DS:2001H
DS:2002 DS:2002H
DS:2003 DS:2003H

DS:5000H DS:5000H
DS:5001H DS:50001
DS:5002H DS:5002H
DS:5003H DS:5003H

Result:
VVIT, Department of Electronics and Communication Engineering Page
30
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: MULTIPLICATION OF 8-BIT SIGNED


NUMBER BY 16-BIT SIGNED NUMBER
Aim : To multiply a 8-bit signed number by a 16-bit signed number

Registers used: AX, DX, DS

Program:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DB 8AH
NUM2 DW 4595H
ORG 5000H
RES DW 02H DUP 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AL, NUM1
CBW
IMUL NUM2
MOV RES, AX
MOV RES+2, DX
MOV AH, 4CH
INT 21H
VVIT, Department of Electronics and Communication Engineering Page
31
MICROPROCESSORS & MICROCONTROLLER LAB

CODE ENDS
END START

Instruction description:

IMUL:

CBW (Convert Signed Byte to Word):

Theoretical calculations:

Observations:

CS: DS:

Before Execution after Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003

DS:5000H DS:5000
DS:5001H DS:5001
DS:5002H DS:5002
DS:5003H DS:5003

Result:

VVIT, Department of Electronics and Communication Engineering Page


32
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: MULTIPLICATION OF 16 -BIT UNSIGNED


NUMBER BY 16-BIT UNSIGNED NUMBER
Aim : To multiply a 16-bit unsigned number by a 16-bit unsigned number.

Registers used: AX, DX,DS

Program:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DW 0FFFH
NUM2 DW 0FA3H
ORG 5000H
RES DW 02H DUP 0H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX, NUM1
MUL NUM2
MOV RES, AX
MOV RES+2, DX
MOV AH,4CH
INT 21H
CODE ENDS

VVIT, Department of Electronics and Communication Engineering Page


33
MICROPROCESSORS & MICROCONTROLLER LAB

END START

Instruction description:

MUL (Multiplication):

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002
DS:5003 DS:5003

Result:

VVIT, Department of Electronics and Communication Engineering Page


34
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: DIVISION OF 16 -BIT UNSIGNED NUMBER


BY 16-BIT UNSIGNED NUMBER
Aim : To divide a 16-bit unsigned number by a 16-bit unsigned number.

Registers used: AX, BX, DX,DS

Program:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DW 1012H
NUM2 DB 0800H
ORG 5000H
QUO DW 0H
REM DB 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, NUM1
MOV DX, 0H
MOV BX, NUM2
IDIV BX
MOV QUO, AX
MOV REM, DX
MOV AH, 4CH
VVIT, Department of Electronics and Communication Engineering Page
35
MICROPROCESSORS & MICROCONTROLLER LAB

INT 21H
CODE ENDS
END START

Instruction description:

IDIV:

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002
DS:5003 DS:5003

Result:
.

VVIT, Department of Electronics and Communication Engineering Page


36
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: DIVISION OF 16-BIT SIGNED NUMBER BY


8-BIT SIGNED NUMBER
Aim : To divide 16-bit signed number by an 8-bit signed number.

Registers used: AX, DX, DS

Program:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
NUM1 DW 4647H
NUM2 DB 0A4H
ORG 5000H
QUO DB 0H
REM DB 0H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX, NUM1
IDIV NUM2
MOV QUO, AL
MOV REM, AH
MOV AH,4CH
INT 21H
CODE ENDS
END START

VVIT, Department of Electronics and Communication Engineering Page


37
MICROPROCESSORS & MICROCONTROLLER LAB

Instruction description:

IDIV:

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002
DS:5003 DS:5003

Result:

VVIT, Department of Electronics and Communication Engineering Page


38
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: PACKED BCD TO UNPACKED BCD


CONVERSION
Aim : To convert a packed BCD number in to unpacked BCD form.

Registers used: AX, BX, CX, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
PACK_BCD DB 75H
ORG 5000H
UNPACK_BCD DW 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AL, PACK_BCD
MOV AH, PACK_BCD
AND AL, 0FH
AND AH, 0F0H
MOV CL, 04H
ROR AH, CL
MOV UNPACK_BCD, AX
MOV AH, 4CH
INT 21H
CODE ENDS

VVIT, Department of Electronics and Communication Engineering Page


39
MICROPROCESSORS & MICROCONTROLLER LAB

END START

Instruction description:

AND:

ROR:

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002
DS:5003 DS:5003

Result:

VVIT, Department of Electronics and Communication Engineering Page


40
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: PACKED BCD TO ASCII CONVERSION


Aim : To convert a packed BCD number in to ASCII form.

Registers used: AX, BX, CX, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
PACK_BCD DB 75H
ORG 5000H
ASCII DB 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AL, PACK_BCD
MOV AH, PACK_BCD
AND AL, 0FH
AND AH, 0F0H
MOV CL, 04H
ROR AH, CL
OR AX, 3030H
MOV ASCII, AX
MOV AH, 4CH

VVIT, Department of Electronics and Communication Engineering Page


41
MICROPROCESSORS & MICROCONTROLLER LAB

INT 21H
CODE ENDS
END START

Instruction description:

OR:

ROL:

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002
DS:5003 DS:5003

VVIT, Department of Electronics and Communication Engineering Page


42
MICROPROCESSORS & MICROCONTROLLER LAB

Result:

PROGRAM: ASCII ADDITION


Aim : To add two ASCII numbers.

Registers used: AX, BX, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
ASCII1 DB ‘4’
ASCII2 DB ‘7’
ORG 5000H
RES DW 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS,AX
MOV AH, 0H
MOV AL, ASCII1
MOV BL, ASCII2
ADD AL, BL
AAA
OR AX, 3030H
MOV RES, AX
VVIT, Department of Electronics and Communication Engineering Page
43
MICROPROCESSORS & MICROCONTROLLER LAB

MOV AH, 4CH


INT 21H
CODE ENDS
END START

Instruction description:

AAA:

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002
DS:5003 DS:5003

VVIT, Department of Electronics and Communication Engineering Page


44
MICROPROCESSORS & MICROCONTROLLER LAB

Result:

PROGRAM: ASCII SUBTRACTION


Aim : To subtract two ASCII numbers.

Registers used: AX, BX, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
ASCII1 DB ‘8’
ASCII2 DB ‘4’
ORG 5000H
RES DW 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AH, 0H
MOV AL, ASCII1
MOV BL, ASCII2
SUB AL, BL
AAS

VVIT, Department of Electronics and Communication Engineering Page


45
MICROPROCESSORS & MICROCONTROLLER LAB

OR AX, 3030H
MOV RES, AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

AAS:

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002

VVIT, Department of Electronics and Communication Engineering Page


46
MICROPROCESSORS & MICROCONTROLLER LAB

DS:5003 DS:5003

Result:

PROGRAM: COUNT THE NUMBER OF EVEN AND ODD


NUMBERS FROM A SERIES
Aim : To count the number of even and odd numbers from a series of 16-bit numbers.

Registers used: AX, CX, SI, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
SERIES DW 4539H, 0A429H, 4129H, 46F3H, 25ABH, 0BCDAH, 71A3H, 0CA19H,
47FBH, 1234H
CNT DB 0AH
ORG 5000H
ODD_CNT DB 0H
EVEN_CNT DB 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX

VVIT, Department of Electronics and Communication Engineering Page


47
MICROPROCESSORS & MICROCONTROLLER LAB

LEA SI, SERIES


MOV CL, CNT
AGAIN: MOV AX, [SI]
SHR AX, 01H
JC GO
INC EVEN_CNTR
JMP NXT
GO: INC ODD_CNTR
NXT: INC SI
DEC CL
JNZ AGAIN
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:
INC:
DEC:
SHR:
LEA (Load Effective Address) :.
JNZ (Jump No Zero):.

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

D
S:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003
DS:2004 DS:2004
DS:2005 DS:2005
DS:2006 DS:2006
DS:2007 DS:2007
DS:2008 DS:2008
DS:2009 DS:2009
DS:200A DS:200A
VVIT, Department of Electronics and Communication Engineering Page
48
MICROPROCESSORS & MICROCONTROLLER LAB

DS:200B DS:200B
DS:200C DS:200C
DS:200D DS:200D
DS:200E DS:200E
DS:2010 DS:2010
DS:2011 DS:2011
DS:2012 DS:2012
DS:2013 DS:2013
DS:2014 DS:2014

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002
DS:5003 DS:5003

Result:

PROGRAM: COUNT THE NUMBERS CONSISTS OF ‘1’


AS A SIXTH BIT
Aim : To count the numbers consists of ‘1’ as a sixth bit.

Registers used: AX, CX, SI, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
SERIES DW 4539H, 0A429H, 4129H, 46F3H, 25ABH, 0BCDAH,
71A3H, 0CA19H, 47FBH, 1234H
CNT DW 0AH
ORG 5000H
COUNTER DW 0H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA

VVIT, Department of Electronics and Communication Engineering Page


49
MICROPROCESSORS & MICROCONTROLLER LAB

MOV DS, AX
LEA SI, SERIES
MOV CX, CNT
AGAIN: MOV AX, [SI]
AND AX, 0020H
JZ GO
INC CNTR
GO: INC SI
LOOP AGAIN
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

INC:
DEC:
SHR:
Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS
:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003
DS:2004 DS:2004
DS:2005 DS:2005
DS:2006 DS:2006
DS:2007 DS:2007
DS:2008 DS:2008
DS:2009 DS:2009
DS:200A DS:200A
DS:200B DS:200B
DS:200C DS:200C
DS:200D DS:200D
DS:200E DS:200E

VVIT, Department of Electronics and Communication Engineering Page


50
MICROPROCESSORS & MICROCONTROLLER LAB

DS:2010 DS:2010
DS:2011 DS:2011
DS:2012 DS:2012
DS:2013 DS:2013
DS:2014 DS:2014

DS:5000 DS:5000
DS:5001 DS:5001
DS:5002 DS:5002
DS:5003 DS:5003

Result:

PROGRAM: ARRANGE A SERIES OF 8-BT SIGNED


NUMBERS IN DESCENDING ORDER
Aim : To arrange a series of 8-bt signed numbers in descending order.

Registers used: AX, CX, SI, DX, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
SERIES DB 46H, 8BH, 0B7H, 71H, 52H, 0A3H, 5BH, 69H, 0F4H,
0FFH
CNT DW 09H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV DX, CNT
NXT_MOPR: MOV CX, DX

VVIT, Department of Electronics and Communication Engineering Page


51
MICROPROCESSORS & MICROCONTROLLER LAB

LEA SI, SERIES


AGAIN: MOV AL, [SI]
INC SI
CMP AL, [SI]
JGE NXT
XCHG AL, [SI]
DEC SI
MOV [SI], AL
INC SI
NXT: LOOP AGAIN
DEC DX
JNZ NXT_MOPR
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

LOOP:

XCHG (Exchange):

CMP:

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003
DS:2004 DS:2004
DS:2005 DS:2005
DS:2006 DS:2006
DS:2007 DS:2007
DS:2008 DS:2008
DS:2009 DS:2009

VVIT, Department of Electronics and Communication Engineering Page


52
MICROPROCESSORS & MICROCONTROLLER LAB

Result:

PROGRAM: ARRANGE A SERIES OF 16-BT UNSIGNED


NUMBERS IN ASCENDING ORDER
Aim : To arrange a series of 16-bt unsigned numbers in ascending order.

Registers used: AX, CX, SI, DX, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
SERIES DW 4539H, 0A429H, 4129H, 46F3H, 25ABH,
0BCDAH, 71A3H, 0CA19H, 47FBH, 1234H
CNT DW 09H
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV DX, CNT
NXT_MOPR: MOV CX, DX

VVIT, Department of Electronics and Communication Engineering Page


53
MICROPROCESSORS & MICROCONTROLLER LAB

LEA SI, SERIES


AGAIN: MOV AX, [SI]
ADD SI, 02H
CMP AX, [SI]
JBE NXT
XCHG AX, [SI]
SUB SI, 02H
MOV [SI], AX
ADD SI, 02H
NXT: LOOP AGAIN
DEC DX
JNZ NXT_MOPR
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

JBE:

JNZ:

Theoretical calculations:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003
DS:2004 DS:2004
DS:2005 DS:2005
DS:2006 DS:2006
DS:2007 DS:2007
DS:2008 DS:2008

VVIT, Department of Electronics and Communication Engineering Page


54
MICROPROCESSORS & MICROCONTROLLER LAB

DS:2009 DS:2009
DS:200A DS:200A
DS:200B DS:200B
DS:200C DS:200C
DS:200D DS:200D
DS:200E DS:200E
DS:200F DS:200F
DS:2010 DS:2010
DS:2011 DS:2011
DS:2012 DS:2012
DS:2013 DS:2013

Result:

PROGRAM: STRING TRANSFER IN FORWARD


DIRECTION
Aim : To transfer a string in forward direction.

Registers used: AX, CX, SI, DI, DS, ES

Program:

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


DATA SEGMENT
ORG 2000H
SOURSE_STG DB ‘GOOD’
CNT DW $ - SOURSE_STG
DATA ENDS
EXTRA SEGMENT
ORG 5000H
DESTINATION_STG DB 40H DUP (0H)
EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA

VVIT, Department of Electronics and Communication Engineering Page


55
MICROPROCESSORS & MICROCONTROLLER LAB

MOV DS, AX
MOV AX, EXTRA
MOV ES, AX
LEA SI, SOURSE_STG
LEA DI, DESTINATION_STG
CLD
MOV CX, CNT
REP MOVSB
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

MOVSB:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003
DS:2004 DS:2004

DS:5000 DS:5000
DS:5001 DS:5001

VVIT, Department of Electronics and Communication Engineering Page


56
MICROPROCESSORS & MICROCONTROLLER LAB

DS:5002 DS:5002
DS:5003 DS:5003

Result:

PROGRAM: STRING TRANSFER IN REVERSE


DIRECTION
Aim : To transfer a string in reverse direction.

Registers used: AX, CX, SI, DI, DS, ES

Program :

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


DATA SEGMENT
ORG 2000H
SOURSE_STG DB ‘GOOD’
CNT DW $ - SOURSE_STG
DATA ENDS
EXTRA SEGMENT
ORG 5000H
DESTINATION_STG DB 40H DUP (0H)
EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA
VVIT, Department of Electronics and Communication Engineering Page
57
MICROPROCESSORS & MICROCONTROLLER LAB

MOV DS, AX
MOV AX, EXTRA
MOV ES, AX
LEA SI, SOURSE_STG
LEA DI, DESTINATION_STG
CLD
MOV CX, CNT
ADD DI, CX
DEC DI
NXT_CHAR: MOVSB
SUB DI, 02H
LOOP NXT_CHAR
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

LOOP:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000 67
DS:2001 DS:2001 6F
DS:2002 DS:2002 6F
DS:2003 DS:2003 64
DS:2004 DS:2004 00

DS:5000 DS:5000 64

VVIT, Department of Electronics and Communication Engineering Page


58
MICROPROCESSORS & MICROCONTROLLER LAB

DS:5001 DS:5001 6F
DS:5002 DS:5002 6F
DS:5003 DS:5003 67

Result:

PROGRAM: STRING INSERTION


Aim : To insert a string. .

Registers used: AX, CX, SI, DI, DS,ES

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


DATA SEGMENT
ORG 2000H
STRING1 DB 'EMPTY VESSELS MORE NOISE$'
STRLEN EQU ($-STRING1)
DATA ENDS
EXTRA SEGMENT
ORG 5000H
STRING2 DB STRLEN+5 DUP (0)
EXTRA ENDS
CODE SEGMENT

START: MOV AX, DATA


MOV DS, AX
MOV SI, OFFSET STRING1

VVIT, Department of Electronics and Communication Engineering Page


59
MICROPROCESSORS & MICROCONTROLLER LAB

MOV DI, OFFSET STRING2


CLD
MOV CX, 14
REP MOVSB
MOV DL, 5
BACK: MOV AH, 01
INT 21H
STOS STRING2
DEC DL
JNZ BACK
MOV CX, 11
REP MOVSB
NOP
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

NOP:

CLD:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003
DS:2004 DS:2004
DS:2005 DS:2005
DS:2006 DS:2006

VVIT, Department of Electronics and Communication Engineering Page


60
MICROPROCESSORS & MICROCONTROLLER LAB

DS:2007 DS:2007
DS:2008 DS:2008
DS:2009 DS:2009
DS:200A DS:200A
DS:200B DS:200B
DS:200C DS:200C
DS:200D DS:200D
DS:200E DS:200E
DS:200F DS:200F
DS:2010 DS:2010
DS:2011 DS:2011
DS:2012 DS:2012
DS:2013 DS:2013
DS:2014 DS:2014
DS:2015 DS:2015
DS:2016 DS:2016
DS:2017 DS:2017

ES:5000 ES:5000
ES:5001 ES:5001
ES:5002 ES:5002
ES:5003 ES:5003
ES:5004 ES:5004
ES:5005 ES:5005
ES:5006 ES:5006
ES:5007 ES:5007
ES:5008 ES:5008
ES:5009 ES:5009
ES:500A ES:500A
ES:500B ES:500B
ES:500C ES:500C
ES:500D ES:500D
ES:500E ES:500E
ES:500F ES:500F
ES:5010 ES:5010
ES:5011 ES:5011
VVIT, Department of Electronics and Communication Engineering Page
61
MICROPROCESSORS & MICROCONTROLLER LAB

ES:5012 ES:5012
ES:5013 ES:5013
ES:5014 ES:5014
ES:5015 ES:5015
ES:5016 ES:5016
ES:5017 ES:5017
ES:5018 ES:5018
ES:5019 ES:5019
ES:501A ES:501A
ES:501B ES:501B
ES:501C ES:501C

Result:

PROGRAM: STRING DELETION


Aim : To delete a string .

Registers used: AX, CX, SI, DI, DS, ES

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


DATA SEGMENT
ORG 2000H
STRING1 DB 'EMPTY VESSELS MAKE MORE NOISE$'
STRLEN EQU ($-STRING1)
DATA ENDS
EXTRA SEGMENT
ORG 5000H
STRING2 DB STRLEN-5 DUP (0)
EXTRA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AX, EXTRA

VVIT, Department of Electronics and Communication Engineering Page


62
MICROPROCESSORS & MICROCONTROLLER LAB

MOV ES, AX
MOV SI, OFFSET STRING1
MOV DI, OFFSET STRING2
CLD
MOV CX, 13
REP MOVSB
CLD
MOV SI, 18
MOV CX, 12
REP MOVSB
MOV AH, 4CH
INT 21H
CODE ENDS
END START

DESCRIPTION:

MOVSB:

Observations:

CS: DS:

Before Execution After Execution

DS:2000 DS:2000
DS:2001 DS:2001
DS:2002 DS:2002
DS:2003 DS:2003
DS:2004 DS:2004
DS:2005 DS:2005

VVIT, Department of Electronics and Communication Engineering Page


63
MICROPROCESSORS & MICROCONTROLLER LAB

DS:2006 DS:2006
DS:2007 DS:2007
DS:2008 DS:2008
DS:2009 DS:2009
DS:200A DS:200A
DS:200B DS:200B
DS:200C DS:200C
DS:200D DS:200D
DS:200E DS:200E
DS:200F DS:200F
DS:2010 DS:2010
DS:2011 DS:2011
DS:2012 DS:2012
DS:2013 DS:2013
DS:2014 DS:2014
DS:2015 DS:2015
DS:2016 DS:2016
DS:2017 DS:2017
DS:2018 DS:2018
DS:2019 DS:2019
DS:201A DS:201A
DS:201B DS:201B
DS:201C DS:201C
ES:5000 ES:5000
ES:5001 ES:5001
ES:5002 ES:5002
ES:5003 ES:5003
ES:5004 ES:5004
ES:5005 ES:5005
ES:5006 ES:5006
ES:5007 ES:5007
ES:5008 ES:5008
ES:5009 ES:5009
ES:500A ES:500A
ES:500B ES:500B
ES:500C ES:500C
ES:500D ES:500D
ES:500E ES:500E
ES:500F ES:500F
ES:5010 ES:5010

VVIT, Department of Electronics and Communication Engineering Page


64
MICROPROCESSORS & MICROCONTROLLER LAB

ES:5011 ES:5011
ES:5012 ES:5012
ES:5013 ES:5013
ES:5014 ES:5014
ES:5015 ES:5015
ES:5016 ES:5016
ES:5017 ES:5017

Result:

PROGRAM: DISPLAY OF MESSAGE USING DOS


INTERRUPTS
Aim : To display a message on the standard output using DOS interrupts.

Registers used: AX, DX, DS

Program :

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ORG 2000H
MSG DB OAH, ODH, ”VVIT”, OAH, ODH, “$”
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX

VVIT, Department of Electronics and Communication Engineering Page


65
MICROPROCESSORS & MICROCONTROLLER LAB

LEA DX, MSG


MOV AH, 09H
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

MOV AH, O9H

INT 21H

Observations:

Result:

PROGRAM: TO READ A STRING OF CHARACTERS


FROM KEY BOARD DOS INTERRUPTS
Aim : To read a string of characters from the keyboard using DOS interrupts.

Registers used: AX, BX, DX, DS, DI, ES

Program :

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


DATA SEGMENT
ORG 2000H
MSG DB OAH, ODH, ”ENTER YOUR STRING:” , OAH, ODH, “$”
ORG 5000H
DESTINATION_STG DB 40H DUP (0H)
LNT_STG DW 0H
DATA ENDS
VVIT, Department of Electronics and Communication Engineering Page
66
MICROPROCESSORS & MICROCONTROLLER LAB

CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV BX, 0H
CLD
LEA DI, DESTINATION_STG
LEA DX, MSG
MOV AH, 09H
INT 21H
NXT_CHAR: MOV AH, 01H
INT 21H
CMP AL, ODH
JE TERM
INC BX
STOSB
JMP NXT_CHAR
TERM: MOV LNT_STG, BX
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

MOV AH, O1H

INT 21H

STOSB:

Observations:

ENTER YOUR STRING: _____________________________

Result:

VVIT, Department of Electronics and Communication Engineering Page


67
MICROPROCESSORS & MICROCONTROLLER LAB

PROGRAM: STRING CHECK FOR PALINDROME


Aim : To check whether a string is palindrome or not.

Registers used: AX, BX, DX, DS, DI, ES

Program :

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


DATA SEGMENT
ORG 2000H
MSG1 DB OAH, ODH, ”ENTER YOUR STRING: ”, OAH, ODH, “$”
MSG2 DB OAH, ODH, ”IT IS A PALINDROME ”, OAH, ODH, “$”
MSG3 DB OAH, ODH, ”IT IS NOT A PALINDROME ”, OAH, ODH, “$”
MSG4 DB OAH, ODH,”D U W TO CONT.: (Y/N) ”, OAH, ODH, “$”
ORG 3000H

VVIT, Department of Electronics and Communication Engineering Page


68
MICROPROCESSORS & MICROCONTROLLER LAB

STG1 DB 40H DUP (0H)


ORG 4000H
STG2 DB 40H DUP (0H)
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
AGAIN: MOV BX, 0H
CLD
LEA SI, STG1
LEA DI, STG2
LEA DX, MSG1
MOV AH, 09H
INT 21H
NXT_CHAR: MOV AH, 01H
INT 21H
CMP AL, ODH
JE TERM
INC BX
STOSB
JMP NXT_CHAR
DEC DI
MOV CX, BX
BACK: MOV AL, [DI]
MOV [SI], AL
INC SI
DEC DI
LOOP BACK
LEA DI, STG2
LEA DI, STG2
MOV CX, BX
REPE CMPSB
JE PALIN
LEA DX, MSG3
MOV AH, 09H
INT 21H
JMP CONT
PALIN: LEA DX, MSG2
MOV AH, 09H
INT 21H
CONT: LEA DX, MSG4
MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
CMP AL, ‘Y’
JE AGAIN
VVIT, Department of Electronics and Communication Engineering Page
69
MICROPROCESSORS & MICROCONTROLLER LAB

CMP AL, ‘N’


JE TERM
JMP CONT
TERM: MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

MOV AH, O1H

INT 21H

Observations:

Result:

PROGRAM: STRING COMPARISION USING DOS


INTERRUPTS
Aim : To compare two strings
Registers used: AX, BX, DX, DS, DI, ES
Program :

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


DATA SEGMENT
ORG 2000H
MSG1 DB OAH, ODH,”ENTER STRING1: ” OAH, ODH, “$”
MSG2 DB OAH, ODH,”ENTER STRING2: ” OAH, ODH, “$”
MSG3 DB OAH, ODH,”BOTH THE STRINGS ARE EQUAL”, OAH, ODH, “$”
MSG4 DB OAH, ODH,”STRINGS ARE NOT EQUAL”, OAH, ODH, “$”
MSG5 DB OAH, ODH,”D U W TO CONTINUE: (Y/N)”, OAH, ODH, “$”
ORG 3000H

VVIT, Department of Electronics and Communication Engineering Page


70
MICROPROCESSORS & MICROCONTROLLER LAB

STG1 DB 40H DUP (0H)


ORG 4000H
STG2 DB 40H DUP (0H)
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV ES,AX
AGAIN: MOV BX, 0H
CLD
LEA SI, STG1
LEA DI, STG2
LEA DX, MSG1
MOV AH, 09H
INT 21

LEFT AS AN EXERCISE
CONT: LEA DX, MSG5
MOV AH, 09H
INT 21H
MOV AH, 01H
INT 21H
CMP AL, ‘Y’
JE AGAIN
CMP AL, ‘N’
JE TERM
JMP CONT
TERM: MOV AH, 4CH
INT 21H
CODE ENDS
END START
Result:

Instruction description:

CMPSB:

Observations:

ENTER STRING 1: _____________________________


ENTER STRING 2: _____________________________

BOTH THE STRINGS ARE EQUAL / STRINGS ARE NOT EQUAL


DO U WANT TO CONTINUE: (Y/N)

VVIT, Department of Electronics and Communication Engineering Page


71
MICROPROCESSORS & MICROCONTROLLER LAB

Y N
ENTER YOUR STRING 1: ________ Go back to command
window

PROGRAM: PASSWORD ACCESS USING DOS


INTERRUPTS
Aim : To access a password.

Registers used: AX, BX, DX, DS, DI, ES

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


DATA SEGMENT
ORG 2000H
MSG1 DB OAH, ODH,”ENTER UR PASSWORD: ” OAH, ODH, “$”
MSG2 DB OAH, ODH,”SORRY, ACESS IS DENIED: ” OAH, ODH, “$”

VVIT, Department of Electronics and Communication Engineering Page


72
MICROPROCESSORS & MICROCONTROLLER LAB

MSG3 DB OAH, ODH,”YES, U CAN RUN UR APPLICATION ON THE SYSTEM”, OAH,


ODH, “$”
ORG 3000H
STG1 DB 40H DUP (0H)
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
AGAIN: MOV BX, 0H
CLD
--------------------------------------------------
LEFT AS AN EXERCISE
--------------------------------------------
TERM: MOV AH, 4CH
INT 21H
CODE ENDS
END START

Instruction description:

CMP :

Observations:
ENTER UR PASSWORD: _____________________________
After 3 attempts
SORRY, ACCESS IS DENIED / YES, U CAN RUN UR APPLICATION ON THE SYSTEM

Result:

INTERFACING WITH MICROPROCESSOR 8086

PROGRAM: To Add Two 8 Bit Numbers

AIM: Write a program to Add 8 bytes stored from 2000H and store the result from 3000H using 8086.

Apparatus:

1. Microprocessor trainer kit

VVIT, Department of Electronics and Communication Engineering Page


73
MICROPROCESSORS & MICROCONTROLLER LAB

2. Keyboard

3. Power cable

Program Description:

1. Starting address of the program: 2000H

2. Address of input values: 2000H, 2004H

3. Address of output values: 3000H

4. Registers used: al,bl,ah,ax

Program:

Address Label Mnemonics Hexcodes Comments


1000H Mov Al, [2000H]
1004H Mov Bl, [2001H]
1008H Add Al, Bl
100AH Adc Ah,0h
100DH Mov [3000h],Ax
1011H Hlt

Result:

PROGRAM: To Subtraction Two 8 Bit Numbers

AIM: Write a program to Add 8 bytes stored from 2000H and store the result from 3000H using 8086.

Apparatus:

1.8086 Microprocessor trainer kit.

2. Keyboard.

3. Power cable.
VVIT, Department of Electronics and Communication Engineering Page
74
MICROPROCESSORS & MICROCONTROLLER LAB

Program Description:

1. Starting address of the program: 2000H

2. Address of input values: 2000H, 2004H

3. Address of output values: 3000H

4. Registers used: al, bl, ax

Program:

Address Label Mnemonics Hexcodes Comments


1000H Mov Al,[2000H]
1004H Mov Bl,[2001H]
1008H Sub Al,Bl
100AH Mov [3000h],Ax
100DH Hlt

Result:

PROGRAM: To Division Two 8 Bit Numbers

AIM: Write a program to Add 8 bytes stored from 2000H and store the result from 3000H using 8086.

Apparatus:

1.8086 Microprocessor trainer kit.

2. Keyboard.

3. Power cable.

Program Description:

1. starting address of the program :2000H

VVIT, Department of Electronics and Communication Engineering Page


75
MICROPROCESSORS & MICROCONTROLLER LAB

2. Address of input values: 2000H, 2004H

3. Address of output values: 3000H

4. Registers used: al,bl,ax

Program:

Address Label Mnemonics Hexcodes Comments


1000H Mov Al,[2000H]
1004H Mov Bl,[2001H]
1008H Div,Bl
100AH Mov [3000h],Ax
100DH Hlt

Result:

PROGRAM: To Add Two 16 Bit Numbers

AIM: Write a program to Add 8 bytes stored from 1000H and store the result from 2000H using 8086.

Apparatus:

1.8086 Microprocessor trainer kit.

2.Keyboard.

3.Power cable.

Program Description:

1.starting address of the program :1000H

2.Address of input values :1000H,1004H


VVIT, Department of Electronics and Communication Engineering Page
76
MICROPROCESSORS & MICROCONTROLLER LAB

3.Address of output values :2000H

4.Registers used : ax,bx,ah,ax

Program:

Address Label Mnemonics Hexcodes Comments


1000H Mov Ax,[1000H]
1004H Mov Bx,[1001H]
1008H Add Ax,Bx
100AH Adc Ah,0h
100DH Mov [2000H],Ax
1011H Hlt

Result:

PROGRAM: To Subtraction Two 16 Bit Numbers

AIM: Write a program to Add 8 bytes stored from 1000H and store the result from 2000H using 8086.

Apparatus:

1.8086 Microprocessor trainer kit.

2.keyboard.

3.Power cable.

Program Description:

1.starting address of the program :1000H

2.Address of input values :1000H,1004H

3.Address of output values :2000H


VVIT, Department of Electronics and Communication Engineering Page
77
MICROPROCESSORS & MICROCONTROLLER LAB

4.Registers used : ax,bx ,ax

Program:

Address Label Mnemonics Hexcodes Comments

1000H Mov Ax,[1000H]

1004H Mov Bx,[1001H]

1008H Sub Ax,Bx

100AH Mov [2000H],Ax

100DH Hlt

Result:

PROGRAM: To Division Two 16 Bit Numbers

AIM: Write a program to Add 8 bytes stored from 1000H and store the result from 2000H using

8086.

Apparatus:

1.8086 Microprocessor trainer kit.

2.Keyboard.

3.Power cable.

Program Description:

1.starting address of the program :1000H

VVIT, Department of Electronics and Communication Engineering Page


78
MICROPROCESSORS & MICROCONTROLLER LAB

2.Address of input values :1000H,1004H

3.Address of output values :2000H

4.Registers used : ax,bx,,ax

Program:

Address Label Mnemonics Hexcodes Comments


1000H Mov Ax,[1000H]
1004H Mov Bx,[1001H]
1008H Div Bx
100AH Mov [3000H],Ax
100DH Hlt

Result:

8279 – Keyboard Display- Write a program to display a string of characters

AIM: Write a program to display a string of characters on seven segment display using 8086.

Apparatus:

1.8086 Microprocessor trainer kit.

2.8279 Inetrfacing kit.

3.Keyboard.

3.Power cable.

Program Description:

1.starting address of the program :1000H

2.Address of input values :1200H

3. Registers used : si,cx,dx,al


VVIT, Department of Electronics and Communication Engineering Page
79
MICROPROCESSORS & MICROCONTROLLER LAB

4.Address of command more registers : 00c2H

5.Address of data registers : D0C0H

Program:

Address Label Mnemonics Hexcodes Comments


1000H Start: Mov si,1200H
1004H Mov cx,000FH
1008H Mov al,18H
100BH Out c2,al
100DH Mov al,0CCH
1010H Out c2,al
1012H Mov al,90H
1015H Out c2,al
1017H go: Mov al,[si]
1019H Out c0,al
101BH Call Delay
101EH Inc si
101FH Loop go
1020H Jmp start

1200H FF FF FF FF
FF FF FF FF
98 68 7C 7C
0C FF FF FF

Address Label Mnemonics Hexcodes Comments


1500H Delay: Mov dx,0aoffh
1504H again: Dec dx
1505H Jnz again
1507H Ret

VVIT, Department of Electronics and Communication Engineering Page


80
MICROPROCESSORS & MICROCONTROLLER LAB

Seven Segment Display

D7 D6 D5 D4 D3 D2 D1 D0
A3 A2 A1 A0 B3 B2 B1 B0

D C B A DP G F E
1 0 0 1 1 0 0 0 98H
0 1 1 0 1 0 0 0 68H
0 1 1 1 1 0 0 0 7CH
0 0 0 0 1 1 0 0 0CH

VVIT, Department of Electronics and Communication Engineering Page


81
MICROPROCESSORS & MICROCONTROLLER LAB

Result:

8255 – PPI-Write ALP to generate sinusoidal wave using PPI

AIM: Write a program to generate a sinwave from using DAC 8255 using 8086.

Apparatus:

1.8086 Microprocessor trainer kit.

2.8255 inetrfacing kit.

3.Cathode Ray Osciloscope.

4.Multioutput Power Supply.

5.keyboard.6. Power cable

Program Description:

1.starting address of the program :1000H

2.Address of input values :1000H,1200H

3. Registers used : al,cl

Program:

VVIT, Department of Electronics and Communication Engineering Page


82
MICROPROCESSORS & MICROCONTROLLER LAB

Address Label Mnemonics Hexcodes Comments


1000H MOV AL,80H C6 C0 80
1003H OUT 0026H,AL E6 26
1005H MOV SI,1200H C7 C6 00 12
1009H MOV CL,46H C6 C1 46
100CH MOV AL,[SI] 8A 04
100EH OUT 0020H,AL E6 20
1010H INC SI 46
1011H DEC CL FE C9
1013H JNZ GO 75 F7
1015H JMP AGAIN E9 ED FF
1200H 7F 8A 95 A0
1204H AA B5 BF C8
1208H D1 D9 E0 E7
120CH ED F2 F7 FA
1210H FC FE FF FE
1214H FC FA F7 F2
1218H ED E7 ED D9
121CH D1 C8 BF B5
1220H AA A0 95 8A
1224H 75 74 69 5F
1228H 53 49 3F 36
122CH 2D 25 10 17
1230H 10 0B 07 04
1234H 01 00 01 04
1238H 07 0B 10 17
123CH 1D 25 2D 36
1240H 3F 49 53 5F
1244H 69 74

VVIT, Department of Electronics and Communication Engineering Page


83
MICROPROCESSORS & MICROCONTROLLER LAB

Result: .

8259 – PROGRAMMABLE INTERUPT CONTROLLER


AIM: To interface Programmable Interrupt Controller with 8086 microprocessor.

APPARATUS:
1. 8086 TRAINER KIT
2. 8259 STUDY CARD
3. KEYBOARD, CABLES, ETC…

PROGRAM:

ORG 1000H
MOV AL,17H
OUT 0C0H, AL
MOV AL,08H
OUT 0C2H, AL
MOV AL,01H
OUT 0C2H, AL
MOV AL,FEH
OUT 0C2H, AL
STI
HERE: JMP HERE
MOV AL,20H
LOOP 0C0H,AL
INT 02H

VVIT, Department of Electronics and Communication Engineering Page


84
MICROPROCESSORS & MICROCONTROLLER LAB

Interrupt Vector:-
0000:0200 00h
0000:0021 12h
0000:0022 00h
0000:0023 00h

OBSERVATIONS:

INPUT:

OUTPUT:

RESULT:

8251 – USART
AIM: To interface USART (Universal Synchronous Asynchronous Receiver Transmitter) with 8086 microprocessor.

APPARATUS:
1 8086 TRAINER KIT
2 8251 STUDY CARD
3 ADAPTER, KEYBOARD, CABLES, ETC…
PROGRAM:

TRANSMITTER END:
ORG 1000H
MOV AL,36H
OUT 0CEH, AL
MOV AL,10H
OUT 0C8H, AL
MOV AL,00H
OUT 0C8H, AL
MOV AL,4EH
OUT 0C2H, AL
MOV AL,37H
OUT 0C2H, AL
LOOP1:IN AL,0C2H
AND AL,04H
JZ LOOP1
MOV AL,41H

VVIT, Department of Electronics and Communication Engineering Page


85
MICROPROCESSORS & MICROCONTROLLER LAB

OUT 0C0H,AL
INT 02H

RECEIVER END:
ORG 1200H
MOV AL,36H
OUT 0CEH, AL
MOV AL,10H
OUT 0C8H, AL
MOV AL,00H
OUT 0C8H, AL
MOV AL,4EH
OUT 0C2H, AL
MOV AL,37H
OUT 0C2H, AL
LOOP2:IN AL,0C2H
AND AL,04H
JZ LOOP2
IN AL,0C0H
MOV BX,I500H
MOV [BX],AL
INT 02H

OBSERVATIONS: INPUT: OUTPUT:

RESULT:

MCS 51 DEVELOPMENT TOOLS


Using Command Line

1. Edit the program using ‘EDIT’ editor


2. Save as name .A51
3. Assemble using A51.EXE
C: A51 name .A51
Result: name .LST, name .OBJ
4. LINK & Convert to Hex format using OH51.EXE
C: OH51 name .OBJ
Result: name .HEX
5. Simulate Using SIM31.EXE
C: SIM31
Using Integrated Design Environment (IDE)
KEIL µVision – (Windows)
An Integrated design environment consists of all the tools needed for the development of software for the
MCS 51 family. These tools are linked together in one environment. The main feature of IDE is the
BUILD process. The BUILD ensures that the target file is current. In order to keep modular development
the PROJECT feature is provided.

VVIT, Department of Electronics and Communication Engineering Page


86
MICROPROCESSORS & MICROCONTROLLER LAB

1. Select START\PROGRAMS\KEIL <Left Click>


2. Create New project
Select PROJECT\NEW\<Left Click> “enter name’<Left Click>
Choose TARGET\INTEL\8051 <Left Click>
Choose BUILD OPTIONS
Check Box HEX <OK><Left Click>
3. Create File <ALT><F><N> ‘name of file .ASM’ <Left Click> Edit File & Save
4. SELECT PROJECT WINDOW – ADD FILE – SELECT - <Left Click>
5. PROJECT\BUILD\ <Left Click>
If no errors goto 7 else 3
DEBUG\START\ <Left Click>

MICROCONTROLLER 8051
Reading and Writing on a parallel Port
AIM: Write a program to intialise a port and transfer the data between ports.

Program:

i) ORG 00H
MOV P0,#05H
MOV P0,#0AH
MOV P2, #50H
MOV P3, #0A5H
JMP $
END

ii) ORG 00H


MOV P1,#0FFH
MOV P2,#0FFH
MOV P3, #00H
MOV A, P1
MOV R0,P2

VVIT, Department of Electronics and Communication Engineering Page


87
MICROPROCESSORS & MICROCONTROLLER LAB

ADD A, R0
MOV P3,A
JMP $
END

RESULT:

Timer in Differnent Modes

AIM: Write a program to Generate 10µs of delay using instructions.

Program:

ORG 00H
MOV R0, #05H
X:
DJNZ R0,X
JMP $
END

AIM: Write a program to Generate 65,35msec of delay using instructions.

ORG 00H

VVIT, Department of Electronics and Communication Engineering Page


88
MICROPROCESSORS & MICROCONTROLLER LAB

MOV TMOD, #0000 0001H


SWT B TRO
JMB TF0,$
CLR TR0
CLR TF0
END

RESULT:

Serial Communication Implementaion


AIM: Write a program to receive the data serially and transmit the data to port1.

Program:

ORG 00H
MOV TMOD, #20H
MOV TH1, #0FWH
SETB TR1
MOV SCON, #50H
X:
JNB RI,$
MOV R0,SBUT
MOV P1,R0
CLR RI
JMP X
END

VVIT, Department of Electronics and Communication Engineering Page


89
MICROPROCESSORS & MICROCONTROLLER LAB

RESULT:

INTERFACING WITH MICROCONTROLER 8051

PROGRAM: To Add Two 8 Bit Numbers

AIM: Write a program to Add 8 bytes stored from 4100H and store the result from 4500H using 8051.

Apparatus:

1.Microcontroler trainer kit


2.Keyboard
3.Power cable

Program Description:

1.starting address of the program :4100H

VVIT, Department of Electronics and Communication Engineering Page


90
MICROPROCESSORS & MICROCONTROLLER LAB

2.Address of input values :4100H—20H, 4102—10H

3.Address of output values :4500H -- 30H

Program:

Address Label Mnemonics Hexcodes Comments


4100H CLR C C3
4101H MOV A,#DATA1 74
4103H ADD A,#DATA2 94
4105H MOV DPTR,#4500 90
4108H MOVX @DPTR,A F0
4109H HERE: SJMP HERE 80

Result:

PROGRAM: To Subtraction Two 8 Bit Numbers

AIM: Write a program to Add 8 bytes stored from 4100H and store the result from 4500H using 8051.

Apparatus:

1.Microcontroler trainer kit


2.Keyboard
3.Power cable

Program Description:

1.starting address of the program :4100H

2.Address of input values :4100H—20H, 4102—10H

3.Address of output values :4500H -- 10H

Program:

Address Label Mnemonics Hexcodes Comments


4100H CLR C C3
4101H MOV A,#DATA1 74
4103H SUBB A,#DATA2 94
4105H MOV DPTR,#4500 90
VVIT, Department of Electronics and Communication Engineering Page
91
MICROPROCESSORS & MICROCONTROLLER LAB

4108H MOVX @DPTR,A F0


4109H HERE: SJMP HERE 80

Result:

PROGRAM: To Multiplication Two 8 Bit Numbers

AIM: Write a program to Add 8 bytes stored from 4100H and store the result from 4500H using 8051.

Apparatus:

1.Microcontroler trainer kit


2.Keyboard
3.Power cable

Program Description:

1.starting address of the program :4100H

2.Address of input values :4100H—0AH,


4102—88H
3.Address of output values :4500H -- 50H
4501H—05H
Program:

Address Label Mnemonics Hexcodes Comments


4100H MOV A,#DATA1 74
4102H MOV B, #DATA2 75
4105H MUL AB A4
4106H MOV DPTR,#4500 90
4109H MOVX @DPTR,A F0
410AH INC DPTR A3
410BH MOV A,B E5
410DH MOVX @DPTR,A F0
410EH HERE: SJMP HERE 80

VVIT, Department of Electronics and Communication Engineering Page


92
MICROPROCESSORS & MICROCONTROLLER LAB

Result:

“All of sciences nothing more

than refinement of every day

thinking”

--- Albert Einstein

VVIT, Department of Electronics and Communication Engineering Page


93

You might also like