0% found this document useful (0 votes)
29 views65 pages

MPMC Final - r18

This document provides an introduction to MASM and TASM assemblers. It discusses how to create a source file using an editor and then assemble it using MASM or TASM. The assembler generates three files - an object file, list file, and cross-reference file. It also discusses how to link the object file to create an executable file. The document describes different memory models and the format for assembly language programs using models or full segment definitions.

Uploaded by

navyach2424
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views65 pages

MPMC Final - r18

This document provides an introduction to MASM and TASM assemblers. It discusses how to create a source file using an editor and then assemble it using MASM or TASM. The assembler generates three files - an object file, list file, and cross-reference file. It also discusses how to link the object file to create an executable file. The document describes different memory models and the format for assembly language programs using models or full segment definitions.

Uploaded by

navyach2424
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 65

Electronics and Communication Engineering

Introduction to MASM /TASM

MASM: (Microsoft assembler)


To Create Source File: An editor is a program which allows you to create a file containing the
assembly language statements for your program. This file is called a source file.
Command to create a source file
C:\MASM\BIN> Edit filename. asm
The next step is to process the source file with an assembler. When you run the assembler, it
reads the source file of your program. On the first pass through the source program, the
assembler determines the displacement of named data items, the offset labels, etc. and puts 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 offsets, etc. that it calculated during
first pass.
C:\MASM\BIN > Masm filename. asm X, Y, Z
With this command assembler generates three files.
1. The first file (X) 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.
2. The second file (Y) generated by the assembler is called the assembler list file and is given the
extension .LST. The list file contains your assembly language statements, the binary codes for
each instruction and the offset for each instruction.
3. The third file (Z) generated by this assembler is called the cross-reference file and is given the
extension .CRF. The cross-reference file lists all labels and pertinent information required for
cross – referencing

NOTE : The Assembler only finds syntax errors : It will not tell you whether program does what
it is supposed to do. To determine whether your program works, you have to run the program
and test it.
Next step is to process the object file with linker.

C:\MASM\BIN>LINK filename . obj

1
MPMC LAB
Electronics and Communication Engineering
Run File [ Filename1.exe] : “filename1.exe”
List file [ nul.map] : NUL
Libraries [.lib] : library_name
Definitions File [ nul.def] :
Creation of Library: Refer Modular Programming Section
A Linker is a program used to join several object files into one layer object file

NOTE : On IBM PC – type Computers, You must run the LINK program on your .OBJ file even
if it contains only one assembly module.
The linker produces a link file with the .EXE extension (an execution file)
Next Run C:\MASM\BIN> filename

2
MPMC LAB
Electronics and Communication Engineering
TASM: (Turbo Assembler)
To Create Source File : An editor is a program which allows you to create a file containing the
assembly language statements for your program. This file is called a source file.
Command to create a source file
C:\TASM\BIN> Edit filename. Asm
The next step is to process the source file with an assembler. When you run the assembler, it
reads the source file of your program. On the first pass through the source program, the
assembler determines the displacement of named data items, the offset labels, etc. and puts 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 offsets, etc. that it calculated during
first pass.
C:\TASM\BIN > TASM filename. asm X, Y, Z
With this command assembler generates three files.
1. The first file (X) 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.
2. The second file (Y) generated by the assembler is called the assembler list file and is given the
extension .LST. The list file contains your assembly language statements, the binary codes for
each instruction and the offset for each instruction.
3. The third file (Z) generated by this assembler is called the cross-reference file and is given the
extension .CRF. The cross-reference file lists all labels and pertinent information required for
cross – referencing
NOTE: The Assembler only finds syntax errors : It will not tell you whether
program does what it is supposed to do. To determine whether your
program works, you have to run the program and test it.
Next step is to process the object file with linker.
C:\TASM\BIN>TLINK filename . obj
A Linker is a program used to join several object files into one layer object file
NOTE: On IBM PC – type Computers, You must run the LINK program on your .OBJ file even
if it contains only one assembly module.
The linker produces a link file with the .EXE extension (an execution file)
Next Run

3
MPMC LAB
Electronics and Communication Engineering
C:\TASM\BIN> TD filename.exe

Assembly Language Program Format :

The assembler uses two basic formats for developing S/W


a) One method uses MODELS and
b) Other uses Full-Segment Definitions
* The models are easier to use for simple tasks.
* The full – segment definitions offer better control over the assembly language
task and are recommended for complex programs.
a) Format using Models:
; ABSTRACT ; 8086 program
; Aim of Program
; REGISTERS ; Registers used in your program
; PORTS ; PORTS used in your program
. MODEL (type of model i.e. size of memory system)
EXAMPLE
. MODEL SMALL
. STACK size of stack ; define stack
. DATA ; define data segment
------
------Define variables
------
------
. CODE ; define code segment
HERE : MOV AX, @DATA ; load ES,DS
MOV ES, AX
MOV DS, AX
---------
---------
---------
. EXIT 0 ; exit to DOS

4
MPMC LAB
Electronics and Communication Engineering
END HERE (or)
. CODE ; Define Code Segment
. STARTUP
. EXIT 0
END
Memory Models for the Assembler
Model Type Description
TINY All data and code must fit into one
segment. Tiny programs are written
in .COM format, which means that the
program must be originated at location
100H
SMALL This model contains two segments:
one data segment of 64K bytes and
one code segment of 64K bytes.
MEDIUM This model contains one data segment
of 64K bytes and any number of code
segments for large programs.
COMPACT One code segment contains the
program, and any number of data
segments contains the data.
LARGE The large model allows any number of
code and data segments.
HUGE This model is the same as large, but
the data segments may contain more
than 64K bytes each.
FLAT Only available to MASM 6.X. The flat
model uses one segment of 512K bytes
to tore all data and code. Note that this
model is mainly used with Windows
NT

5
MPMC LAB
Electronics and Communication Engineering

INTRODUCTION TO ASSEMBLY LANGUAGE PROGRAMMING:

LEVELS OF PROGRAMMING:
There are three levels of programming
1. Machine language
2. Assembler language
3. High level language
Machine language programs are programs that the computer can understand and execute directly.
Assembly language instructions match machine language instructions, but are written using
character strings so that they are more easily understood. and High-level language instructions
are much closer to the English language and are structured.
Ultimately, an assembly language or high level language program must be converted into
machine language by programs called translators. If the program being translated is in assembly
language, the translator is referred to as an assembler, and if it is in a high level language the
translator is referred to as a compiler or interpreter.
ASSEMBLY LANGUAGE PROGRAM DEVELOPMENT TOOLS:
EDITOR: An editor is a program, which allows you to create a file containing the assembly
language statements for your program.
ASSEMBLER: An assembler program is used to translate the assembly language Mnemonic
instructions to the corresponding binary codes. The second file generated by assembler is called
the assembler List file.
LINKER: A Linker is a program used to join several object files in to one large object file. The
linkers produce link files with the .EXE extension.
DEBUGGER: If your program requires no external hardware, then you can use a debugger to
run and debug your program. A debugger is a program, which allows you to load your object
code program into system memory, execute the program, and troubleshoot or “debug” it.
ASSEMBLER DIRECTIVES:
An assembler is a program used to convert an assembly language program into the equivalent
machine code modules. The assembler decides the address of each label and substitutes the

6
MPMC LAB
Electronics and Communication Engineering
values for each of the constants and variables. It then forms the machine code for mnemonics
and data in assembly language program.
Assembler directives help the assembler to correctly understand assembly language programs to
prepare the codes. Commonly used assembler directives are DB, DD, DW, DUP, ASSUME,
BYTE, SEGMENT, MACRO, PROC, OFFSET, NEAR, FAR, EQU, STRUC, PTR, END,
ENDM, ENDP etc. Some directives generate and store information in the memory, while others
do not.
DB :- Define byte directive stores bytes of data in memory.
BYTE PTR :- This directive indicates the size of data referenced by pointer.
SEGMENT :- This directive is to indicate the start of the segment.
DUP (Duplicate) :- The DUP directive reserves memory locations given by the
number preceding it, but stores no specific values in any of
these locations.
ASSUME : - The ASSUME statement is only used with full segment
definitions. This statement tells the assembler what names have
been chosen for the code, data, extra and stack segments.
EQU : - The equate directive equates a numeric ASCII or label to another
label.
ORG : - The ORG (origin) statement changes the starting offset address
in a segment.
PROC and ENDP : - The PROC and ENDP directives indicate start and end of a procedure
(Sub routine). Both the PROC and ENDP directives require a label to indicate the name of the
procedure. The PROC directive, must also be followed with the NEAR or FAR. A NEAR
procedure is one that resides in the same code segment as the program. A FAR procedure may
reside at any location in the memory system.
A macro is a group of instructions that performs one task, just as a procedure. The difference is
that a procedure is accessed via a CALL instruction, while a macro is inserted in the program at
the point of usage as a new sequence of instructions.
MACRO : - The first statement of a macro is the MACRO directive preceded with name of the
macro.
ENDM : - The last statement of a macro is the ENDM instruction. Never place a label in front of
the ENDM statement.

7
MPMC LAB
Electronics and Communication Engineering
PUBLIC &EXTRN : - The public and extern directives are very important to modular
programming. We use PUBLIC to declare that labels of code, data or entire segments are
available to other program modules.
We use EXTRN to declare that labels are external to a module. Without this statement, we could
not link modules together to create a program using modular programming techniques.
OFFSET : - Offset of a label. When the assembler comes across the OFFSET operator along
with a label, it first computes the 16 – bit displacement of the particular label, and replaces the
string ‘OFFSET LABEL’ by the computed displacement.
LENGTH : - Byte length of the label. This directive is used to refer to the
length of data array or a string.
2. MICROPROCESSOR TRAINER KIT
The microprocessor trainer kit (microprocessor development kit) is an aid to understand the
architecture, interfacing and programming of a microprocessor. Here we describe the ESA 86/88
– 2-trainer kit.
ESA 86/88-2 is a powerful, general-purpose microcomputer system, which can be operated
either with 8086 CPU or with 8088 CPU. The basic system can be easily expanded through the
system BUS connector. The built in Assembler/ Disassembler feature simplifies the
programmers task of entering Assembly language programs .The on-board provision for 8087
numeric data processor makes it useful for number crunching applications. On board battery
back up provision is an added feature to take care of frequent power failures while conducting
experiments of the trainer using manually assembled code.
It is also provided with peripherals and controllers such as
8251A: Programmable communication Interface for serial communication.
8253-5 : Programmable Interval Timer
8255A: Two Programmable Peripheral Interface Devices provide 48 programmable I/O lines
8259A: Programmable Interrupt Controller provides interrupt vectors for 8 sources.
8288: Bus Controller for generating control signals
ESA 86/88-2 is operated from the CRT terminals or a host computer system via the serial
monitor and also can be operated from the on board key board.
8255 operational modes
8255 ports can be initialized in three different modes.
MODE 0: In this mode, all ports function as simple I/O ports without hand shaking.

8
MPMC LAB
Electronics and Communication Engineering
MODE 1: This mode is handshake mode where by port A and port B use the bits
Port C as handshake signals.
MODE 2: Only port A can be initialized in mode 2. In this mode port A can be used for
Bidirectional handshake data transfer. Port B can be initialized in mode 0 or
mode1.

COMMUNICATION WITH A HOST COMPUTER SYSTEM


ESA 86/88-2 operating in the serial mode can be connected to either CRT terminal or host
computer system. When computer system is the controlling element it must be executing the
driver software to communicate with ESA 86/88-2.
XT86 is a package which allows the user to establish a communication link between ESA 86/88-
2 system and a computer system. The link is established between asynchronous serial ports of the
computer and ESA 86/88-2.A suitable RS232-C cables have to be used for connecting the kit to
the computer system.
User can develop assembly language programs on the computer system, cross- assemble them
using a suitable cross assembler to generate object code files and then use XT86 to download
these object code files into the trainer kit for execution. User can terminate XT86 and return
control to DOS by typing Alt + X. XT86 also allows uploading of data from the memory of the
kit to the computer. The data so uploaded is same in a disk file.

9
MPMC LAB
Electronics and Communication Engineering
8086 Microprocessor Architecture:

10
MPMC LAB
Electronics and Communication Engineering

Intel 8086 MPU PROGRAMMING

USING DEBUG TO EXECUTE 80X86 PROGRAMS:


DEBUG is a utility program that allows a user to load an 80x 86 programs in to memory and
execute it step by step. DEBUG displays the contents of all processor registers after each
instruction executes, allowing user to determine if the code is performing the desired task.
DEBUG only displays the 16-bit portion of the general purpose registers. Code view is capable
of displaying the entire 32 bits. DEBUG is a very useful debugging tool. We will use DEBUG to
step through number of simple programs, gaining familiarity with DEBUG commands as we do.
DEBUG contains commands that can display and modify memory, assemble instructions,
disassemble code already placed into memory, trace through single or multiple instructions, load
registers with data, and do much more.
DEBUG loads into memory like any other program, in the first available slot. The memory space
used by DEBUG for the user program begins after the end of DEBUG code. If an .EXE or. COM
file were specified, DEBUG would load the program according to the accepted conventions.
To execute the program file PROG.EXE use this command: DEBUG PROG.EXE
DEBUG uses a minus as its command prompt, so you should see a “-”appear on display.
To get a list of some commands available with DEBUG is:
T trace (step by step execution)
U un assemble
D Dump
G go (complete execution)
H Hex
E.g.: to execute the program file PROG.ASM use the following procedure:
TASM PROG.ASM
TLINK PROG.OBJ
DEBUG PROG.EXE
Turbo Assembler Version 5.3 Copyright (c) 1988, 2000 Inprise Corporation
Syntax: TASM [options] source [,object] [,listing] [,xref]
/a, /s Alphabetic or Source-code segment ordering
/c Generate cross-reference in listing

11
MPMC LAB
Electronics and Communication Engineering
/h,/? Display this help screen
/iPATH Search PATH for include files
/jCMD Jam in an assembler directive CMD (eg. /jIDEAL)
/kh# Hash table capacity # symbols
/l,/la Generate listing: l=normal listing, la=expanded listing
/ml, /mx,/mu Case sensitivity on symbols: ml=all, mx=globals, mu=none
/mv# Set maximum valid length for symbols
/m# Allow # multiple passes to resolve forward references
/n Suppress symbol tables in listing
/os,/o,/op,/oi Object code: standard, standard w/overlays, Phar Lap, IBM
/p Check for code segment overrides in protected mode
/q Suppress OBJ records not needed for linking
/t Suppress messages if successful assembly
/uxxxx Set version emulation, version xxxx
/w0,/w1,/w2 Set warning level: w0=none, w1=w2=warnings on
/w-xxx,/w+xxx Disable (-) or enable (+) warning xxx
/x Include false conditionals in listing
/z Display source line with error message
/zi,/zd,/zn Debug info: zi=full, zd=line numbers only, zn=none
Turbo Link Version 4.01 Copyright (c) 1991 Borland International
Syntax: TLINK objfiles, exefile, mapfile, libfiles, deffile
@xxxx indicates use response file xxxx
/m Map file with publics /x No map file at all
/i Initialize all segments /l Include source line numbers
/L Specify library search paths /s Detailed map of segments
/n No default libraries /d Warn if duplicate symbols in libraries
/c Case significant in symbols /3 Enable 32-bit processing
/o Overlay switch /v Full symbolic debug information
/P[=NNNNN] Pack code segments /A=NNNN Set NewExe segment alignment
/ye Expanded memory swapping /yx Extended memory swapping
/e Ignore Extended Dictionary
/t Create COM file (same as /Tdc)

12
MPMC LAB
Electronics and Communication Engineering
/C Case sensitive exports and imports
/Txx Specify output file type
/Tdx DOS image (default)
/Twx Windows image
(third letter can be c=COM, e=EXE, d=DLL)
DEBUG- Testing and edition tool help ; MS-DOS based program.
MS-DOS prompt/debug [filename .exe/.com/others]
assembler A [address]
compare C range address
dump D [range]
enter E address [list]
fill F range list
go G [=address] [addresses]
hex H value1 value2
input I port
load L [address] [drive] [firstsector] [number]
move M range address
name N [pathname] [arglist]
output O port byte
proceed P [=address] [number]
quit Q
register R [register]
search S range list
trace T [=address] [value]
unassemble U [range]
write W [address] [drive] [firstsector] [number]
allocate expanded memory XA [#pages]
deallocate expanded memory XD [handle]
map expanded memory pages XM [Lpage] [Ppage] [handle]
display expanded memory status XS

13
MPMC LAB
Electronics and Communication Engineering

EXPERIMENT- 1
16 bit arithmetic operations for 8086 (using Various Addressing Modes)

AIM: - To write an assembly language program for arithmetic operations of two 16 bit
numbers, array arithmetic operations on 8 bit numbers

APPRATUS: 1.PC

2. TASM

PROGRAM: 16 bit addition (Immediate addressing mode)

ASSUME CS:CODE
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,1234H
MOV BX, 5678H
ADD AX,BX
MOV RESULT,AX
INT 03H
CODE ENDS
END START.

PROGRAM: 16 bit subtraction (Direct addressing mode &Register addressing mode)

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
NUM1 DW 4321H
NUM2 DW 1234H
RESULT DW 0000H
DATA ENDS
CODE SEGMENT

14
MPMC LAB
Electronics and Communication Engineering
START: MOV AX,DATA
MOV DS,AX
MOV AX,NUM1
MOV BX,NUM2
SUB AX,BX
MOV RESULT,AX
INT 03H
CODE ENDS
END START.
PROGRAM: 16 Bit Multiplication

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
NUM1 DW 2222H
NUM2 DW 1111H
RESULT1 DW 0000H
RESULT2 DW 0000H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,NUM1
MOV BX,NUM2
MUL BX
MOV RESULT1,AX
MOV RESULT2,DX
INT 03H
CODE ENDS
END START.

PROGRAM: 16 Bit Division


ASSUME CS:CODE,DS:DATA
DATA SEGMENT

15
MPMC LAB
Electronics and Communication Engineering
NUM1 DW 9FFFH
NUM2 DW 1A3EH
QUOTIENT DW 0000H
REMAINDER DW 0000H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,0000H
MOV DX,0000H
MOV AX,NUM1
MOV BX,NUM2
DIV BX
MOV QUOTIENT,AX
MOV REMAINDER,DX
INT 03H
MOV AH,4CH
INT 21H
CODE ENDS
END START
PROGRAM: Program for AND Operation

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
N1 dw 0001h
N2 dw 0002h
Data ends
Code Segment
START: MOV AX, DATA
MOV DS, AX
MOV AX, N1
MOV BX, N2
AND AX,BX

16
MPMC LAB
Electronics and Communication Engineering
INT 03H
CODE ENDS
END START.
PROGRAM: Program for OR Operation

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
N1 dw 0001h
N2 dw 0002h
Data ends
Code Segment
START: MOV AX, DATA
MOV DS, AX
MOV AX, N1
MOV BX, N2
OR AX, BX
INT 03H
CODE ENDS
END START.
PROGRAM: Program for NOT Operation

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
N1 dw 0001h
N2 dw 0002h
Data ends
Code Segment
START: MOV AX, DATA
MOV DS, AX
MOV AX, N1
MOV BX, N2
NOT BX
INT 03H

17
MPMC LAB
Electronics and Communication Engineering
CODE ENDS
END START.
PROGRAM: Program for XOR Operation

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
N1 dw 0001h
N2 dw 0002h
Data ends
Code Segment
START: MOV AX, DATA
MOV DS, AX
MOV AX, N1
MOV BX, N2
XOR AX, BX
INT 03H
CODE ENDS
END START.
PROGRAM: Reverse Of A Given String

ASSUME CS: CODE,DS:DATA


DATA SEGMENT
SRC DB 'MICROPROCESSOR $'
COUNT EQU ($-SRC)
DEST DB ?
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CX,COUNT
LEA SI,SRC
LEA DI,DEST
ADD SI,CX

18
MPMC LAB
Electronics and Communication Engineering
DEC SI
BACK: MOV AL,[SI]
MOV [DI],AL
DEC SI
INC DI
DEC CX
JNZ BACK
INT 03H
CODE ENDS
END START.
PROGRAM: Ascending Order

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
ARRAY DB 53H,19H,25H,02H,49H
COUNT EQU 05H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV DX,COUNT-1
AGAIN0: MOV CX,DX
MOV SI,OFFSET ARRAY
AGAIN1: MOV AL,[SI]
CMP AL,[SI+1]
JL BACK
XCHG [SI+1],AL
XCHG [SI],AL
BACK: ADD SI,01
LOOP AGAIN1
DEC DX
JNZ AGAIN0
INT 03H

19
MPMC LAB
Electronics and Communication Engineering
ODE ENDS
END START

PROGRAM: Descending Order

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
ARRAY DB 53H,19H,25H,02H,49H
COUNT EQU 05
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV DX,COUNT-1
AGAIN0: MOV CX,DX
MOV SI,OFFSET ARRAY
AGAIN1: MOV AL,[SI]
CMP AL,[SI+1]
JG BACK
XCHG [SI+1],AL
XCHG [SI],AL
BACK: ADD SI,01
LOOP AGAIN1
DEC DX
JNZ AGAIN0
MOV AH,4CH
INT 21H
CODE ENDS
END START.

RESULT: Program for sorting an array performed by using tasm software.

Program: Comparing Two Strings

20
MPMC LAB
Electronics and Communication Engineering

DATA SEGMENT
MSG1 DB 'SREE DATTHA$'
MSG2 DB 'SREE DATTHA $'
MSG3 DB 'STRING EQUAL $'
MSG4 DB 'STRING NOTEQUAL $'
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV ES,AX
MOV SI,OFFSET MSG1
MOV DI,OFFSET MSG2
MOV CX,09H
CLD
REPE CMPSB
JNE NEQUAL
MOV DX,OFFSET MSG3
MOV AH,09H
INT 21H
JMP EXIT
NEQUAL: MOV DX,OFFSET MSG4
MOV AH,09H
INT 21H
EXIT: INT 03H
CODE ENDS
END START
RESULT: Program for string manipulations are performed by using TASM software
PROGRAM: Ascending Order

ASSUME CS:CODE,DS:DATA
DATA SEGMENT

21
MPMC LAB
Electronics and Communication Engineering
ARRAY DB 53H,19H,25H,02H,49H
COUNT EQU 05H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV DX,COUNT-1
AGAIN0: MOV CX,DX
MOV SI,OFFSET ARRAY
AGAIN1: MOV AL,[SI]
CMP AL,[SI+1]
JL BACK
XCHG [SI+1],AL
XCHG [SI],AL
BACK: ADD SI,01
LOOP AGAIN1
DEC DX
JNZ AGAIN0
INT 03H
ODE ENDS
END START.
PROGRAM: Descending Order

ASSUME CS:CODE,DS:DATA
DATA SEGMENT
ARRAY DB 53H,19H,25H,02H,49H
COUNT EQU 05
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV DX,COUNT-1
AGAIN0: MOV CX,DX

22
MPMC LAB
Electronics and Communication Engineering
MOV SI,OFFSET ARRAY
AGAIN1: MOV AL,[SI]
CMP AL,[SI+1]
JG BACK
XCHG [SI+1],AL
XCHG [SI],AL
BACK: ADD SI,01
LOOP AGAIN1
DEC DX
JNZ AGAIN0
MOV AH,4CH
INT 21H
CODE ENDS
END START.

RESULT: Program for sorting an array performed by using tasm software.

23
MPMC LAB
Electronics and Communication Engineering
EXPERIMENT-02

Bit level logical Operations, Rotate, Shift, Swap and Branch Operations
Aim: To Write an ALP to perform bit level logical operations rotate, Shift, Swap and
Branch Operations.
Software required: TASM/NASM
Program for rotate Operation

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
N1 dw 0001h
N2 dw 0002h
Data ends
Code Segment
START: MOV AX, DATA
MOV DS, AX
MOV AX, N1
MOV BX, N2
ROR AX, 01
ROL BX, 01
INT 03H
CODE ENDS
END START.

Program for Swap Operation

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
N1 dw 0001h
N2 dw 0002h
Data ends
Code Segment
START: MOV AX, DATA
MOV DS, AX

24
MPMC LAB
Electronics and Communication Engineering
MOV AX, N1
MOV BX, N2
XCHG AX, BX
INT 03H
CODE ENDS
END START.
Program for Shift Operation

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
N1 dw 0001h
N2 dw 0002h
Data ends
Code Segment
START: MOV AX, DATA
MOV DS, AX
MOV AX, N1
MOV BX, N2
SHL BX, N2
SHR BX, 01
INT 03H
CODE ENDS
END START.

25
MPMC LAB
Electronics and Communication Engineering
EXPERIMENT-03

Programming using Arithmetic, Logical and Bit Manipulation


instructions of 8051

AIM: To write an Assembly Language Program to perform arithmetic, logical, and bit
manipulations instructions of 8051

APPARATUS:

8051 Trainer Kit with keyboard,

Micro Processor Power Supply.

ARITHMETIC OPERATIONS

Program: 8 Bit Addition

MOV A,#12
MOV B,#45
ADD A, B
LCALL 0003
Program: 8 Bit Subtraction
MOV A,#45
MOV B,#15
SUBB A, B
LCALL 0003
Program: 8 Bit Multiplication
MOV A,#12
MOV F0,#12
MUL AB
LCALL 0003
Program: 8 Bit Division
MOV A,#45
MOV F0,#5
DIV AB
LCALL 0003

26
MPMC LAB
Electronics and Communication Engineering
Program: Logical Operation

MOV A,#54

MOV R0,A

SWAP A

XRL A,R0

LCALL 0003

Program: Bit Manipulation Instructions

Exchange lower/higher nibble of ‘A’ then Exchange with R0

MOV A,#C5

SWAP A

MOV R0,#C6

XCH A,R0

LCALL 0003

RESULT: Programming using arithmetic, logical, and bit manipulations instructions of 8051
performed.

27
MPMC LAB
Electronics and Communication Engineering

EXPERIMENT-04

Time Delay Generation Using Timers of 8051

Aim: To Write the program to Generate time delay using 8051 Microcontroller

Software required: Keil Software

Program:

Org 0000h

Mov a, #00h

Mov tmod, #01h

Up: mov tl0, #00h

Mov th0, #00h

Cpla

Mov pl, a

Set b b0

Wait: jnb H0, wait

Clr tro

Clr tf0

Sjmp up

End

Result: Hence observed the output of time delay generation using 8051 Microcontroller.

28
MPMC LAB
Electronics and Communication Engineering

EXPERIMENT-05

Serial communication between two microprocessor kits using 8251

AIM: Interface the 8251 USART to the two 8086 microprocessor kits.

APPARATUS:

1. 8086 Trainer kit - 2no’s


2. 8251 USART
3. Power Supply
4. Connectors.
PROGRAM:

MOV AL,36
MOV DX,0086H
OUT DX,AL
MOV DX,0080H
MOV AL,0A
OUT DX,AL
MOV AL,00
OUT DX,AL
MOV SP,3000
MOV DX,0092
OUT DX,AL
OUT DX,AL
OUT DX,AL
OUT DX,AL
CALL DELAY
MOV AL,40
OUT DX,AL
CALL DELAY
MOV AL,CE

29
MPMC LAB
Electronics and Communication Engineering
OUT DX,AL
CALL DELAY
MOV AL,27
OUT DX,AL
CALL DELAY
MOV SI,2100
L1:MOV DX,0092
IN AL,DX
CMP AL,1B
JE L1
MOV DX,0090
IN AL,DX
AND AL,81
CMP BL,AL
JE L3
L2:MOV DX,0092
IN AL,DX
AND AL,81
CMP AL,81
JNE L2
MOV AL,BL
MOV DX,0090
OUT DX,AL
OUT DX,AL
MOV [SI],AL
INC SI
JMP L1
OUT DX,AL
INC SI
JMP L2
L3:INT 03

30
MPMC LAB
Electronics and Communication Engineering

DELAY PROGRAM:

MOV CX,0002
A3:LOOP A3
RET

RESULT: Program for serial communication between two microprocessors by using 8255
Performed

31
MPMC LAB
Electronics and Communication Engineering
EXPERIMENT-6

Program to Generate Square Wave Using Interrupts

AIM: 1. Write an Assembly Language Program For conversion of analog data to digital output.

2. Write an Assembly Language Program For conversion of digital data to analog output.
The analog output will be in the form of triangular wave, sine wave, saw tooth wave,
square wave/rectangular wave.

APPARATUS:

8086 Trainer Kit,

A/D,D/A Interface module (NIFC 27),

Micro Processor Power Supply,

RS-232 Cable,

26 FRC Cable,

4-Way Power Connector,

Cathode Ray Oscilloscope(CRO).

PROCEDURE:

1.Connect the 26 core FRC connecter to the 8086 trainer kit at connector no CN4 and the
Interface Module.

2.Connect the 4 Way Power mate connector to the interface module and the other side of the
connector to the power supply.The connections to the power supply are given
below.Connections(power supply)

Black : Ground

Red :+12V

Blue : +5V

Green:-12V

32
MPMC LAB
Electronics and Communication Engineering
3.Connect the RS-232 Cable Female nobe to COM1 of CPU and the Male nobe is connect to the
serial comm of 8086 Trainer kit.

4.On the power supply , Press RESET on the ALS –SDA -86-MEL kit ,”ALS SDA 86-STA”
will be displayed on the kit. After that keeping DIP Switches as ‘1’ and ‘5’ is “ON” position.

5.Open TALK software and go to OPTIONS and Select Settings

COMM SETTINGS

COMM Port COM1

Bits per Second 9600

Data bits 8

Parity None

Stop Bits 1

Flow Control None

Transfer Mode ASCII

And select(Click on) OK.

6.Go to OPTIONS Select Target Board and click on 8086 kit and OK,and go to options and
Connect.

7.Press RESET on the kit –“ALS-86-MONITOR- V2.2” will be displayed on the system.

8. Go to FILE and select Download Intel Hex File and choose NIFC 27 (DAC and ADC) Hex
file for downloading.

9.*#* symbol will be displayed on the system.

10.After dumping the program ,Change the DIP Switch to ‘1’ and ‘7’ in ON position & Press
Reset.

11.Press “G” for Execution and give starting address as 5000 and press enter.

GO <STARTING ADDRESS <ENTER (on the keyboard trainer).

12.Respective waveforms displayed on CRO.

33
MPMC LAB
Electronics and Communication Engineering
PROGRAM TO GENERATE SQUARE WAVE:

.OUTPUT 2500AD
; NIFC-06A
; 86 - ME

CONTROL EQU FFC6H ;CONTROL PORT ADDRESS FOR 8255


PORTA EQU FFC0H ;PORTA ADDRESS FOR 8255
PORTB EQU FFC2H ;PORTB ADDRESS FOR 8255
DSEG SEGMENT
ORG 0000:4000H
DSEG ENDS
CSEG SEGMENT
ORG 0000:5000H
ASSUME CS:CSEG,DS:DSEG

START:
MOV DX,CONTROL
MOV AL,88H ;INITIALISE ALL PORTS AS OUTPUT
OUT DX,AL ;PORTS
;STEP WAVEFORM GENERATION
;-----------------------------
DA00:
MOV AL,00H ;OUTPORT 00 FOR 0V LEVEL
CALL OUTPUT
MOV AL,0FFH
CALL OUTPUT
JMP DA00
;ROUTINE TO OUTPUT DIGITAL VALUE
;-------------------------------
OUTPUT:
MOV DX,PORTA
OUT DX,AL

34
MPMC LAB
Electronics and Communication Engineering
MOV DX,PORTB
OUT DX,AL
CALL DELAY
RET
DELAY:
MOV CX,0FFH ;TO VARY THE FREQUENCY ALTER THE DELAY COUNT
LUP1: LOOP LUP1
RET
CSEG ENDS
END

PROGRAM TO GENERATE STEP WAVE:

.OUTPUT 2500AD
; NIFC-27
; --------
;*******************************************************
;PROGRAM TO STUDY DIGITAL TO ANALOG CONVERTOR (DAC-0800)
;*******************************************************
CONTROL EQU FFC6H ;control port address for 8255
PORTA EQU FFC0H ;porta address for 8255
PORTB EQU FFC2H ;portb address for 8255
PORTC EQU FFC4H ;portc address for 8255
DSEG SEGMENT
ORG 0000:4000H
MSG DB ' Dac mode ',0h
MSG1 DB ' Step wave O/P ',0h
DSEG ENDS
CSEG SEGMENT
ORG 0000:5000H
ASSUME CS:CSEG,DS:DSEG
START:
MOV DX,CONTROL

35
MPMC LAB
Electronics and Communication Engineering
MOV AL,80H ;initialise all ports as output
OUT DX,AL ;ports
;displaying message on LCD
;------------------------------------------
call far f800:4bb1h;clear display
mov di,80h ;display in upper line
MOV SI,offset MSG ;
CALL FAR f800:4FC0h ;display output routine
MOV DI,C0H ;display in lower line
MOV SI,OFFSET MSG1
CALL FAR F800:4FC0H ;display output routine
;staircase waveform generation
;-----------------------------
DA00: MOV DX,PORTB
MOV AL,00H ;outport 00 for 0V level
CALL OUTPUT
MOV AL,7FH ;outport 7F for 2.5V level
CALL OUTPUT
MOV AL,FFH ;outport FF for 5V level
CALL OUTPUT
;look for NMI-INTR if user
JMP DA00 ;switch to ramp w/f generation

;routine to output digital value


;-------------------------------
OUTPUT:
OUT DX,AL
MOV CX,FFH
DELAY: LOOP DELAY
RET
CSEG ENDS
END

36
MPMC LAB
Electronics and Communication Engineering
PROGRAM TO GENERATE SINE WAVE:

.OUTPUT 2500AD
DSEG SEGMENT
ORG 0:4000H
BASE_ADDRESS EQU 0FFC0H
CONTROL EQU BASE_ADDRESS+ 06H
PORTA EQU BASE_ADDRESS+00H
PORTB EQU BASE_ADDRESS+02H
PORTC EQU BASE_ADDRESS+04H

LOOK_UP_TBL DB
80H,90H,0A1H,0B1H,0C0H,0CDH,0DAH,0E5H,0EEH,0F6H,0FBH,0FEH,0FFH
DB 0FEH,0FBH,0F6H,0EEH,0E5H,0DAH,0CDH,0C0H,0B1H,0A1H,90H,80H
DB 70H,5FH,4FH,40H,33H,26H,1BH,12H,0AH,05H,02H,00H
DB 02H,05H,0AH,12H,1BH,26H,33H,40H,4FH,5FH,70H
DSEG ENDS
CSEG SEGMENT
ASSUME CS:CSEG,DS:DSEG
ORG 0:5000H
ST0:
MOV DX,CONTROL
MOV AL,88H ;initialise all ports as output
OUT DX,AL ;ports
RPT:
MOV CX,24 ;48 ; NO. OF VALUES IN LOOKUP TBL
MOV BX,OFFSET LOOK_UP_TBL
DA00: MOV AL,[BX]
; CALL OUTPUT
MOV DX,PORTA
OUT DX,AL
MOV DX,PORTB
OUT DX,AL

37
MPMC LAB
Electronics and Communication Engineering
; CALL DELAY
INC BX
INC BX
LOOP DA00
NOP
NOP
NOP
JMP RPT
;OUTPUT:
; RET
DELAY: PUSH CX
MOV CX,0FFFFH
HERE: LOOP HERE
RET
CSEG ENDS
END
PROGRAM TO GENERATE TRAINGULAR WAVE:
.OUTPUT 2500AD
; NIFC - 06A
; -------
; 86 -ME

;*******************************************************

;PROGRAM TO STUDY DIGITAL TO ANALOG CONVERTOR (DAC-0800)

;*******************************************************

CONTROL EQU FFC6H ;control port address for 8255


PORTA EQU FFC0H ;porta address for 8255
PORTB EQU FFC2H ;portb address for 8255
PORTC EQU FFC4H ;portc address for 8255

DSEG SEGMENT

38
MPMC LAB
Electronics and Communication Engineering
ORG 0000:4000H
DSEG ENDS
CSEG SEGMENT
ORG 0000:5000H
ASSUME CS:CSEG,DS:DSEG
START:
MOV DX,CONTROL
MOV AL,88H ;initialise all ports as output
OUT DX,AL ;ports
;displaying message on LCD
;------------------------------------------
DA00:
MOV AL,00H ;outport 00 for 0V level
UP: CALL OUTPUT
INC AL
CMP AL,00H
JNZ UP
MOV AL,0FFH ;to change amplitude change count
UP1: CALL OUTPUT
DEC AL
CMP AL,0FFH
JNZ UP1
JMP DA00
;routine to output digital value
;-------------------------------
OUTPUT:
MOV DX,PORTA
OUT DX,AL
MOV DX,PORTB
OUT DX,AL
CALL DELAY
RET

39
MPMC LAB
Electronics and Communication Engineering
DELAY:
MOV CX,06H ;to vary the frequency alter the delay count
LUP1: LOOP LUP1
RET
CSEG ENDS
END
PROGRAM TO A/D CONVERTER:

.OUTPUT 2500AD
; NIFC-07A
; -------
; 86 - KITS
;*****************************************
;PROGRAM TO STUDY ADC-0809 IN POLLED MODE
; SELECTING CHANNEL NO. 0
;*****************************************
CONTROL EQU FFC6H ;control port address for 8255
PORTA EQU FFC0H ;porta address for 8255
PORTB EQU FFC2H ;portb address for 8255
PORTC EQU FFC4H ;portc address for 8255
KBDT EQU F800:4EECH ;4EEDH
DBDTA EQU F800:4F1FH
DSPLY EQU F800:4FC0H
CLRDSP EQU F800:4BB1H
DSEG SEGMENT
ORG 0000:4000H
CH_NO DB 0
DSEG ENDS
CSEG SEGMENT
ASSUME CS:CSEG,DS:DSEG
ORG 0000:5000H
MOV AX,0000H
MOV DS,AX

40
MPMC LAB
Electronics and Communication Engineering
;AD00:

MOV AL,90H ;control word for PPI


MOV DX,CONTROL
OUT DX,AL ;portA->i/p port,portB->o/p port
;portC->o/p port.
AD00:
MOV AL,CH_NO ;output channel number
MOV DX,PORTC
OUT DX,AL
;start conversion
MOV AL,0FH ;PC7 (START/ALE) set
MOV DX,CONTROL
OUT DX,AL
PUSH CX
MOV CX,3FFFH
DEL1:
LOOP DEL1
POP CX
MOV AL,0EH ;PC7 reset
MOV DX,CONTROL
OUT DX,AL
;look for EOC
MOV AL,0CH ;reset PC6 to read EOC
OUT DX,AL
AD01:
MOV DX,PORTA
IN AL,DX ;poll the EOC line which
AND AL,80H ;is connected to PA7 line
CMP AL,80H
JNZ AD01

41
MPMC LAB
Electronics and Communication Engineering
;if EOC (PA7) is high read the digital value otherwise
;again check for EOC (PA7) line
MOV AL,0DH ;set OE (PC6) to read value
MOV DX, CONTROL
OUT DX, AL
; Before reading data from ADC set PC6 line
MOV DX, PORTA
IN AL, DX ;read digital value
MOV AH, 00H
MOV SI, AX
PUSH CX
CALL FAR DBDTA ;display digital value
POP CX
JMP AD00
CSEG ENDS
END
RESULT: Program for interfacing ADC & DAC to 8086 performed

42
MPMC LAB
Electronics and Communication Engineering
EXPERIMENT-07

Seven Segment Display to 8051

AIM: To Write an Assembly Language Program to LCD Display and Interface to 8051 microcontroller.

APPARATUS:

8051 Trainer Kit,

LCD Interface Card(NIFC 12),

Micro Processor Power Supply

RS-232 Cable

26 FRC Cable

4-Way Power Connector.

PROCEDURE:

1.Connect the 26 core FRC connecter to the 8051 trainer kit at connector no p1, and the Interface
Module.

2.Connect the 4 Way Power mate connector to the interface module and the other side of the connector to
the power supply.The connections to the power supply are given below.

Black & Red : Ground

Blue & Green: +5V

3.Connect the RS-232 Cable Female nobe to COM1 of CPU and the Male nobe is connect to the serial
comm of 8051 Trainer kit.

4.Switch on the power supply ,Press RESET on the ALS –SDA -51-MEL kit ,”ALS SDA 51/31-STA”
will be displayed on the kit.

5.Open TALK software and go to OPTIONS and Select Settings

COMM SETTINGS

COMM Port COM1

Bits per Second 9600

Data bits 8

Parity None

43
MPMC LAB
Electronics and Communication Engineering
Stop Bits 1

Flow Control None

Transfer Mode ASCII

And select(Click on) OK.

6.Go to OPTIONS Select Target Board and click on 8051 kit and OK,and go to options and Connect.

7.Press ‘E’ on the 8051 Trainer kit Keyboard,and it will display “**SERIAL MODE**” on the LCD of
8051 kit.

8.”ALS-8051/31 Moniter V1.0” will be displayed on the system.

9.Go to FILE and select Download Intel Hex File and select 8051 MEL and click on NIFC12.

10.After Completion of Downloading Press Reset on 8051 MEL kit.

11.Press “G” for Execution and give starting address as 9000 and press enter.

GO <STARTING ADDRESS <ENTER (on the keyboard of trainer kit).

12.”LCD MODULE IS OK” is displayed on the LCD.

RESULT: Program for interfacing an LCD with 8051 micro controller performed.

44
MPMC LAB
Electronics and Communication Engineering

EXPERIMENT-08

Interfacing Matrix/Keyboard to 8051.

AIM: Write an Assembly Language Program to KEYBOARD Display and Interface to 8051
microcontroller.

APPARATUS:

8051 Trainer Kit,

KEYBOARD Display Interface Card (NIFC 09),

Micro Processor Power Supply

RS-232 Cable

26 FRC Cable

4-Way Power Connector.

PROCEDURE:

1. Connect the 26 core FRC connecter to the 8051 trainer kit at connector no p1, and the Interface
Module.

2. Connect the 4 Way Power mate connector to the interface module and the other side of the connector to
the power supply.The connections to the power supply are given below.

Black & Red : Ground

Blue & Green: +5V

3.Connect the RS-232 Cable Female nobe to COM1 of CPU and the Male nobe is connect to the serial
comm. of 8051 Trainer kit.

4.Switch on the power supply ,Press RESET on the ALS –SDA -51-MEL kit ,”ALS SDA 51/31-STA”
will be displayed on the kit.

5. Open TALK software and go to OPTIONS and Select Settings

COMM SETTINGS

COMM Port COM1

Bits per Second 9600

45
MPMC LAB
Electronics and Communication Engineering
Data bits 8

Parity None

Stop Bits 1

Flow Control None

Transfer Mode ASCII

And select (Click on) OK.

6. Go to OPTIONS Select Target Board and click on 8051 kit and OK,and go to options and Connect.

7. Press ‘E’ on the 8051 Trainer kit Keyboard, and it will display “**SERIAL MODE**” on the LCD of
8051 kit.

8.”ALS-8051/31 Monitor V1.0” will be displayed on the system.

9. Go to FILE and select Download Intel Hex File and select 8051 MEL and click on NIFC09.

10. After Completion of Downloading Press Reset on 8051 MEL kit.

11. Press “G” for Execution and give starting address as 9000 and press enter.

GO <STARTING ADDRESS <ENTER (on the keyboard of trainer kit).

12. Press the KEYS on the keyboard of interfacing module it will display the output

RESULT: Program for interfacing an Keyboard display with 8051 micro controller performed.

46
MPMC LAB
Electronics and Communication Engineering

EXPERIMENT-09

8 bit ADC Interface to 8051

AIM: To Write Assembly Language Program to interface an 8051 microcontroller trainer kit to
pc and establish a communication between them through RS 232.

APPARATUS:

1. ALS 8051 Trainer kit


2. 8251 USART,
3. PC
4. Power Supply
5. Connectors.
PROGRAM:
MOV A,#36
MOV DPTR,#2043
MOVX @DPTR,A
MOV DPTR,#2040
MOV A,#0A
MOVX @DPTR,A
MOV A,#00
MOVX @DPTR,A
MOV R1,#3000
MOV DPTR,#0092
MOVX @DPTR,A
MOVX @DPTR,A
MOVX @DPTR,A
MOVX @DPTR,A
CALL DELAY
MOV A,#40
MOVX @DPTR,A
CALL DELAY

47
MPMC LAB
Electronics and Communication Engineering
MOV A,#CE
MOVX @DPTR,A
CALL DELAY
MOV A,#27
MOVX @DPTR,A
CALL DELAY
MOV DPTR,9000
MOV DPTR,#0092
UP:MOVX @DPTR,A
CMP A,1B
JE UP
MOV DPTR,#0090
MOVX @DPTR,A
ANL A,81
CJNE B,A.DOWN
MOV DPTR,#0092
UP1:MOVX @DPTR,A
ANL A,81
CJNE AL,81.UP1
MOV A,B
MOV DPTR,#0090
MOVX @DPTR,A
MOVX @DPTR,A
MOV R3,9700
MOV R3,A
INC R3
JMP UP
MOVX @DPTR,A
INC R3
JMP UP
INT 03
Down:MOV CX,0002

48
MPMC LAB
Electronics and Communication Engineering
Delay: LOOP HERE
Here:RET

RESULT: Thus, the 8251 USART can be used to establish communication between two
processors by receiving the characters from the USART and displaying these characters on the
console.

49
MPMC LAB
Electronics and Communication Engineering

EXPERIMENT-10

Triangular Wave Generator through DAC Interface to 8051

AIM: 1. Write an Assembly Language Program For conversion of analog data to digital output.

2. Write an Assembly Language Program For conversion of digital data to analog output.
The analog output will be in the form of triangular wave, sine wave, saw tooth wave,
square wave/rectangular wave.

APPARATUS:

8086 Trainer Kit,

A/D,D/A Interface module (NIFC 27),

Micro Processor Power Supply,

RS-232 Cable,

26 FRC Cable,

4-Way Power Connector,

Cathode Ray Oscilloscope(CRO).

PROCEDURE:

1.Connect the 26 core FRC connecter to the 8086 trainer kit at connector no CN4 and the
Interface Module.

2.Connect the 4 Way Power mate connector to the interface module and the other side of the
connector to the power supply.The connections to the power supply are given
below.Connections(power supply)

Black : Ground

Red :+12V

Blue : +5V

50
MPMC LAB
Electronics and Communication Engineering
Green:-12V

3.Connect the RS-232 Cable Female nobe to COM1 of CPU and the Male nobe is connect to the
serial comm of 8086 Trainer kit.

4.On the power supply , Press RESET on the ALS –SDA -86-MEL kit ,”ALS SDA 86-STA”
will be displayed on the kit. After that keeping DIP Switches as ‘1’ and ‘5’ is “ON” position.

5.Open TALK software and go to OPTIONS and Select Settings

COMM SETTINGS

COMM Port COM1

Bits per Second 9600

Data bits 8

Parity None

Stop Bits 1

Flow Control None

Transfer Mode ASCII

And select(Click on) OK.

6.Go to OPTIONS Select Target Board and click on 8086 kit and OK,and go to options and
Connect.

7.Press RESET on the kit –“ALS-86-MONITOR- V2.2” will be displayed on the system.

8. Go to FILE and select Download Intel Hex File and choose NIFC 27 (DAC and ADC) Hex
file for downloading.

9.*#* symbol will be displayed on the system.

10.After dumping the program ,Change the DIP Switch to ‘1’ and ‘7’ in ON position & Press
Reset.

11.Press “G” for Execution and give starting address as 5000 and press enter.

GO <STARTING ADDRESS <ENTER (on the keyboard trainer).

12.Respective waveforms displayed on CRO.

51
MPMC LAB
Electronics and Communication Engineering

PROGRAM TO GENERATE SQUARE WAVE:

.OUTPUT 2500AD
; NIFC-06A
; 86 - ME

CONTROL EQU FFC6H ;CONTROL PORT ADDRESS FOR 8255


PORTA EQU FFC0H ;PORTA ADDRESS FOR 8255
PORTB EQU FFC2H ;PORTB ADDRESS FOR 8255
DSEG SEGMENT
ORG 0000:4000H
DSEG ENDS
CSEG SEGMENT
ORG 0000:5000H
ASSUME CS:CSEG,DS:DSEG

START:
MOV DX,CONTROL
MOV AL,88H ;INITIALISE ALL PORTS AS OUTPUT
OUT DX,AL ;PORTS
;STEP WAVEFORM GENERATION
;-----------------------------
DA00:
MOV AL,00H ;OUTPORT 00 FOR 0V LEVEL
CALL OUTPUT
MOV AL,0FFH
CALL OUTPUT
JMP DA00
;ROUTINE TO OUTPUT DIGITAL VALUE
;-------------------------------
OUTPUT:
MOV DX,PORTA

52
MPMC LAB
Electronics and Communication Engineering
OUT DX,AL
MOV DX,PORTB
OUT DX,AL
CALL DELAY
RET
DELAY:
MOV CX,0FFH ;TO VARY THE FREQUENCY ALTER THE DELAY COUNT
LUP1: LOOP LUP1
RET
CSEG ENDS
END

PROGRAM TO GENERATE STEP WAVE:

.OUTPUT 2500AD
; NIFC-27
; --------
;*******************************************************
;PROGRAM TO STUDY DIGITAL TO ANALOG CONVERTOR (DAC-0800)
;*******************************************************
CONTROL EQU FFC6H ;control port address for 8255
PORTA EQU FFC0H ;porta address for 8255
PORTB EQU FFC2H ;portb address for 8255
PORTC EQU FFC4H ;portc address for 8255
DSEG SEGMENT
ORG 0000:4000H
MSG DB ' Dac mode ',0h
MSG1 DB ' Step wave O/P ',0h
DSEG ENDS

53
MPMC LAB
Electronics and Communication Engineering
CSEG SEGMENT
ORG 0000:5000H
ASSUME CS:CSEG,DS:DSEG
START:
MOV DX,CONTROL
MOV AL,80H ;initialise all ports as output
OUT DX,AL ;ports
;displaying message on LCD
;------------------------------------------
call far f800:4bb1h;clear display
mov di,80h ;display in upper line
MOV SI,offset MSG ;
CALL FAR f800:4FC0h ;display output routine
MOV DI,C0H ;display in lower line
MOV SI,OFFSET MSG1
CALL FAR F800:4FC0H ;display output routine
;staircase waveform generation
;-----------------------------
DA00: MOV DX,PORTB
MOV AL,00H ;outport 00 for 0V level
CALL OUTPUT
MOV AL,7FH ;outport 7F for 2.5V level
CALL OUTPUT
MOV AL,FFH ;outport FF for 5V level
CALL OUTPUT
;look for NMI-INTR if user
JMP DA00 ;switch to ramp w/f generation

;routine to output digital value


;-------------------------------
OUTPUT:
OUT DX,AL

54
MPMC LAB
Electronics and Communication Engineering
MOV CX,FFH
DELAY: LOOP DELAY
RET
CSEG ENDS
END

PROGRAM TO GENERATE SINE WAVE:

.OUTPUT 2500AD
DSEG SEGMENT
ORG 0:4000H
BASE_ADDRESS EQU 0FFC0H
CONTROL EQU BASE_ADDRESS+ 06H
PORTA EQU BASE_ADDRESS+00H
PORTB EQU BASE_ADDRESS+02H
PORTC EQU BASE_ADDRESS+04H

LOOK_UP_TBL DB
80H,90H,0A1H,0B1H,0C0H,0CDH,0DAH,0E5H,0EEH,0F6H,0FBH,0FEH,0FFH
DB 0FEH,0FBH,0F6H,0EEH,0E5H,0DAH,0CDH,0C0H,0B1H,0A1H,90H,80H
DB 70H,5FH,4FH,40H,33H,26H,1BH,12H,0AH,05H,02H,00H
DB 02H,05H,0AH,12H,1BH,26H,33H,40H,4FH,5FH,70H
DSEG ENDS
CSEG SEGMENT
ASSUME CS:CSEG,DS:DSEG
ORG 0:5000H
ST0:
MOV DX,CONTROL
MOV AL,88H ;initialise all ports as output
OUT DX,AL ;ports
RPT:
MOV CX,24 ;48 ; NO. OF VALUES IN LOOKUP TBL
MOV BX,OFFSET LOOK_UP_TBL
DA00: MOV AL,[BX]

55
MPMC LAB
Electronics and Communication Engineering
; CALL OUTPUT
MOV DX,PORTA
OUT DX,AL
MOV DX,PORTB
OUT DX,AL
; CALL DELAY
INC BX
INC BX
LOOP DA00
NOP
NOP
NOP
JMP RPT
;OUTPUT:
; RET
DELAY: PUSH CX
MOV CX,0FFFFH
HERE: LOOP HERE
RET
CSEG ENDS
END
PROGRAM TO GENERATE TRAINGULAR WAVE:
.OUTPUT 2500AD
; NIFC - 06A
; -------
; 86 -ME

;*******************************************************

;PROGRAM TO STUDY DIGITAL TO ANALOG CONVERTOR (DAC-0800)

;*******************************************************

CONTROL EQU FFC6H ;control port address for 8255

56
MPMC LAB
Electronics and Communication Engineering
PORTA EQU FFC0H ;porta address for 8255
PORTB EQU FFC2H ;portb address for 8255
PORTC EQU FFC4H ;portc address for 8255

DSEG SEGMENT
ORG 0000:4000H
DSEG ENDS
CSEG SEGMENT
ORG 0000:5000H
ASSUME CS:CSEG,DS:DSEG
START:
MOV DX,CONTROL
MOV AL,88H ;initialise all ports as output
OUT DX,AL ;ports
;displaying message on LCD
;------------------------------------------
DA00:
MOV AL,00H ;outport 00 for 0V level
UP: CALL OUTPUT
INC AL
CMP AL,00H
JNZ UP
MOV AL,0FFH ;to change amplitude change count
UP1: CALL OUTPUT
DEC AL
CMP AL,0FFH
JNZ UP1
JMP DA00
;routine to output digital value
;-------------------------------
OUTPUT:
MOV DX,PORTA

57
MPMC LAB
Electronics and Communication Engineering
OUT DX,AL
MOV DX,PORTB
OUT DX,AL
CALL DELAY
RET
DELAY:
MOV CX,06H ;to vary the frequency alter the delay count
LUP1: LOOP LUP1
RET
CSEG ENDS
END
PROGRAM TO A/D CONVERTER:

.OUTPUT 2500AD
; NIFC-07A
; -------
; 86 - KITS
;*****************************************
;PROGRAM TO STUDY ADC-0809 IN POLLED MODE
; SELECTING CHANNEL NO. 0
;*****************************************
CONTROL EQU FFC6H ;control port address for 8255
PORTA EQU FFC0H ;porta address for 8255
PORTB EQU FFC2H ;portb address for 8255
PORTC EQU FFC4H ;portc address for 8255
KBDT EQU F800:4EECH ;4EEDH
DBDTA EQU F800:4F1FH
DSPLY EQU F800:4FC0H
CLRDSP EQU F800:4BB1H
DSEG SEGMENT
ORG 0000:4000H
CH_NO DB 0
DSEG ENDS

58
MPMC LAB
Electronics and Communication Engineering
CSEG SEGMENT
ASSUME CS:CSEG,DS:DSEG
ORG 0000:5000H
MOV AX,0000H
MOV DS,AX
;AD00:

MOV AL,90H ;control word for PPI


MOV DX,CONTROL
OUT DX,AL ;portA->i/p port,portB->o/p port
;portC->o/p port.
AD00:
MOV AL,CH_NO ;output channel number
MOV DX,PORTC
OUT DX,AL
;start conversion
MOV AL,0FH ;PC7 (START/ALE) set
MOV DX,CONTROL
OUT DX,AL
PUSH CX
MOV CX,3FFFH
DEL1:
LOOP DEL1
POP CX
MOV AL,0EH ;PC7 reset
MOV DX,CONTROL
OUT DX,AL
;look for EOC
MOV AL,0CH ;reset PC6 to read EOC
OUT DX,AL
AD01:
MOV DX,PORTA

59
MPMC LAB
Electronics and Communication Engineering
IN AL,DX ;poll the EOC line which
AND AL,80H ;is connected to PA7 line
CMP AL,80H
JNZ AD01

;if EOC (PA7) is high read the digital value otherwise


;again check for EOC (PA7) line
MOV AL,0DH ;set OE (PC6) to read value
MOV DX,CONTROL
OUT DX,AL
;before reading data from ADC set PC6 line
MOV DX,PORTA
IN AL,DX ;read digital value
MOV AH,00H
MOV SI,AX
PUSH CX
CALL FAR DBDTA ;display digital value
POP CX
JMP AD00
CSEG ENDS
END
RESULT: Program for interfacing ADC & DAC to 8086 performed

60
MPMC LAB
Electronics and Communication Engineering
Beyond the Syllabus
1.Program for Matrix Addition

AIM: To write an assembly language program to search a number or character from a given
string

APPARATUS: 1.PC
2.TASM
PROGRAM:

61
MPMC LAB
Electronics and Communication Engineering
; Declaration Part

.MODEL SMALL

.DATA

M DB 01H,02H,03H,04H ; Matrix M is a 4x4 Matrix

N DB 05H,06H,07H,08H ; Matrix N is a 4x4 Matrix

CNT DB 04H

RES DB ?

.CODE

START: MOV AX,@DATA

MOV DS,AX

MOV CL,CNT ; CL is loaded with CNT for looping

LEA SI ,M ; SI is loaded with address of Matrix M

LEA DI,N ; DI is loaded with address of Matrix N

;Matrix Adiition Part

L1:MOV AL,[SI]

MOV BL,[DI]

ADD AL,BL ; Add the Matrices

DAA ; Adjust the Result to show Decimal Value

PUSH AX ; Push the result for storing Operations, Since both SI and DI is used

INC SI

INC DI

LOOP L1

CALL STORE

62
MPMC LAB
Electronics and Communication Engineering
;Store Part

STORE PROC

POP AX ; POP the Unwanted values first

LEA SI,RES

ADD SI,04H

MOV CL,04H

L2:POP AX

; POP the last stored result. Here SI is added 4 and then decremented since PUSH-POP follows LIFO
Principle

MOV [SI],AL

DEC SI

LOOP L2

INT 3H ; Since Storing is completed terminate the program

RET

STORE ENDP

END START

2.Program for Palindrome checking

AIM: To write an assembly language program to search a number or character from a given string

APPARATUS: 1.PC

2.TASM

PROGRAM:

DATA SEGMENT

63
MPMC LAB
Electronics and Communication Engineering
BLOCK1 DB 'MADAM'

MSG1 DB "IT IS PALINDROME $"

MSG2 DB "IT IS NOT PALINDROME $"

PAL DB 00H

DATA ENDS

PRINT MACRO MSG

MOV AH,09H

LEA DX,MSG

INT 21H

INT 3H

ENDM

EXTRA SEGMENT

BLOCK2 DB 9 DUP(?)

EXTRA ENDS

CODE SEGMENT

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

START: MOV AX,DATA

MOV DS,AX

MOV AX,EXTRA

MOV ES,AX

LEA SI,BLOCK1

LEA DI,BLOCK2+8

MOV CX,00009H

64
MPMC LAB
Electronics and Communication Engineering
BACK: CLD

LODSB

STD

STOSB

LOOP BACK

LEA SI,BLOCK1

LEA DI,BLOCK2

MOV CX,0009H

CLD

REPZ CMPSB

JNZ SKIP

PRINT MSG1

SKIP: PRINT MSG2

CODE ENDS

END START

65
MPMC LAB

You might also like