Sunteți pe pagina 1din 56

Vivakonqndo College

af Engineering & Technology

TCPO3

[Sponsored by Vivekonondo Vidyovordhoko Songha, Puttur @]

P.ev 1.2

Aff iliated to Visvesvoroya Technologicol University


Approved bv AICTE New Delhi & 6ovt of Karnotaka
COURSE LABORATORY MANUAL

ECE

29/12/?Ots

A. LABORATORY OVERVIEW
Desree:

BE

Programme:

ECE

Semester:

VI
Microprocessor Laboratory
)-0-3-0

Academic Year:
Laboratory Code:
Duration of USE:
USE Marks:

20t5-16

lA Marks:

z5

Laboratory Title:
L-T-P-S:
Iotal Contact Hours:
Lab Manual Author:

lhecked By:

42Hrs

Sisn *:
Sign G---:-'*

Shivaprasad
Nirupama K

1OECL68
180 Minutes
50 Marks

Dt:

t91tz)ts

Dt: 2-qlris

B. DESCRIPTION
I. PREREQUISITES:
I
Should have the fundamental knowledge of MP-8085.
a
Basics of assembly level language.
a
Basics of Microcontroller 8051 programming (l0EC42)
.

BASE COURSE:

.
.

Micropro..rro.8085
Microcontroller 8051

}. COURSE OUTCOMES :
At the end of the course, the student will be able to;
. Write the assembly level programs for 8086 microprocessor.
' Interface external devices like stepper motor,Logical controller,T segment display to
microprocessor 8086.
. Interface keyboard to microprocessor.
. Analyze and apply working of 8086.
1. RESqURSES

REQUIRED:
MASM: (Microsoft assembler)
PCI card
Logical Interface module
Seven segment display module
Keyboard interface module
Stepper motor module

ea(il\r

g;:j,;,'

-\t^ *

Shivaprasad

Checked by:Nirupama

Nehru Nagar, Puttur - 574 2O3,

DK, Karnataka state -

HOD

INDIA.pnone:+s1-82s1-23ssss,234sss

Fax :+91-8251-236444, web: www.vcetputtur.ac.in , E-Mail: aemc@vcetouttur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

5. RELEVANCE OF THE COURSE:


Upon completion of this course students should be able to apply knowledge gained
To implement VLSI design(10EC56)
Embedded system design(10EC74)
Real time sytems(10EC766)
DSP architecture and algorithms(10EC751)
6. GENERAL INSTRUCTIONS:
Be punctual to Laboratory, students are supposed to be present in the Lab 5 minutes in
advance prior to commencement of every lab.
Maintain discipline in the Lab, do not change your places once it is been fixed by lab
instructor.
Do bring the observation regularly to the laboratory, completed with respect to all.
Go through the programs which is supposed to be done in every Lab.
7. CONTENTS:
Expt
Title of the Experiments
Blooms Level
No.
1 Data transfer instructions like:
L3
i)Byte and word data transfering using different
addressing modes.
ii)Block move(with and without overlap)
iii)Block interchange
2 Arithmatic & logical operations like:
L3
i)Addition and subtraction of multi precision nos.
ii)Multiplication and Division of signed and
unsigned hexadecimal nos.
iii)ASCII adjustment instructions
iv)Code conversions
v)Arithmatic programs to find LCM,GCD,factorial.
3 Bit manipulation instructions like checking:
L3
i)Whether given data is positive or negative
ii)Whether given data is odd or even
iii)Logical 1's and 0's in a given data
iv)Bit wise and nibble wise palindrome.
4 Branch/Loop instructions like:
L3
i)Arrays: addition/subtraction of N numbers
Finding largest and smallest numbers
Ascending and descending order
ii)Near and Far conditional and unconditional
jumps,calls and returns
5 Programs on string manipulation like string L3
transfer,string reversing,searching for a string.
i)Program to transfer a string message from one
location to another
ii)Program to reverse the string.
iii)Program to reverse the string and check whether
it is palindrome or not
iv)Program to check a character in the string
Nehru Nagar, Puttur - 574 203,

DK

CO
CO1,CO4

CO1,CO4

CO1,CO4

CO1,CO4

CO1,CO4

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

6 Interfacing 8086 with the Stepper motor module


L3
7 Experiments on interfacing 8086 with Logical L3
controller interface
8 Interfacing 8086 with Seven segment display L3
module
9 Interfacing 8086 with Matrix keyboard module
L3
10. REFERENCE:
1. Intel- 8085 by Ramesh Gaonkar
2. Advanced microprocessors

TCP03
Rev 1.2
ECE
29/12/2015

CO2
CO2
CO2
CO3

C. EVALUATION SCHEME
1. Record writing: 10 Marks - 10 marks to each experiment to be awarded and average of all
experiments is taken.
2. Laboratory Activities: 5 Marks
3. Laboratory IA tests: 10 Marks IAs should follow in the succeeding week of theory IA.
Minimum 2 IAs are mandatory. For final Lab IA, average of best 2 of total number of
IAs.
4. Internal Assessment (IA Marks) = 1 + 2 + 3 = 25 Marks
5. SEE : 50 Marks
D1. ARTICULATION MATRIX
Mapping of CO to PO
PO'S
COs
1 2 3 4 5 6 7 8 9 10 11 12
1 Write the assembly level programs for 3 2 2 - 2 1 - - - 8086 microprocessor.
2 Interface external devices like stepper 2 2 2 - 1 1 - - - motor,Logical controller,7 segment display
to microprocessor 8086.
3 Interface keyboard to microprocessor.
2 2 2 - 1 1 - - - 4 Analyze and apply working of 8086.
2 2 2 - 1 1 - - - D2. ARTICULATION MATRIX CO VS PSO's
Mapping of CO to PSO
PSO'S
COs
1
2
3
4
1 Write the assembly level programs for
1
1
1
8086 microprocessor.
2 Interface external devices like stepper
2
1
motor,Logical controller,7 segment display
to microprocessor 8086.
3 Interface keyboard to microprocessor.
2
1
4 Analyze and apply working of 8086.
1
1
E. EXPERIMENTS
1. EXPERIMENT NO:1
2. TITLE: DATA TRANSFER OPERATION
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

3. LEARNING OBJECTIVES:

To write the assembly language program for data transfer programs like byte and word data transfer
and block move /interchange using 8086.

4. AIM:DATA TRANSFER OPERATION


Byte and word data transfer using different addressing modes.
Block move(with and without overlap)
Block interchange
5.
MATERIAL / EQUIPMENT REQUIRED:
Microsoft Macro assembler (MASM)
PCI card
Power supply
6. THEORY / HYPOTHESIS:
This program is to make the user familiar in writing assembly language programs in 8086.
Here the different addressing modes, like, immediate addressing, register addressing,
indirect addressing, direct addressing, base relative addressing, and relative base indexed
addressing is used to study how data can be moved from one location to another.
7.
PROCEDURE / PROGRAMME / ACTIVITY:
1 BYTE AND WORD DATA TRANSFERING USING DIFFERENT ADDRESSING
MODES
a)Program to load 8 bit immediate data into registers
ASSUME CS:CODE
CODE SEGMENT
START: MOV AL,88H;immediate data to accumulator
MOV BL,AL
MOV CL,AL
MOV DL,AL
MOV AH,4CH;program termination
INT 21H
CODE ENDS
END START
b)Program to load 16 bit immediate data into registers
ASSUME CS:CODE
CODE SEGMENT
START: MOV AX,1234H;immediate data to accumulator
MOV BX,AX
MOV CX,AX
MOV DX,AX
MOV AH,4CH ;program termination
INT 21H
CODE ENDS
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

END START
c)Program to load 8 bit immediate data into a memory location
DATA SEGMENT
LOC DB ?

;reserve byte mem locn

DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV LOC,88H ;immediate data to memory locn.
MOV AH,4CH ;program termination
INT 21H
CODE ENDS
END START
d)Program to load 16 bit immediate data into a memory location
DATA SEGMENT
LOC DW ?

;reserve word memory location

DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV LOC,0ABCDH

;immediate data to mem locn.

MOV AH,4CH ;program termination


INT 21H
CODE ENDS
END START
e)Program to transfer data from one memory into another memory location
DATA SEGMENT
LOC1 DB 45h
LOC2 DB ?

;reserve byte mem locn

DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

START: MOV AX,DATA


MOV DS,AX
MOV BL,LOC1 ;Transfer location1 data to BL reg.
MOV LOC2,BL
MOV AH,4CH ;program termination
INT 21H
CODE ENDS
END START
f)Program to exchange the contents of two memory location
DATA SEGMENT
LOC1 DB 45h
LOC2 DB 88h
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV BL,LOC1 ;Transferlocation1 data to BL reg.
MOV CL,LOC2 ;Transferlocation2 data to CL reg.
MOV LOC1,CL
MOV LOC2,BL ;Exchange the contents
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
II)Block move programs:
a)Program to transfer a block of data from one memory location to another
DATA SEGMENT
ORG 8500h
BLK1 db 10h,20h,30h,40h,50h
ORG 9500h
BLK2 db 5 dup(?)
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

START: MOV AX,DATA


MOV DS,AX
MOV CX,0005H ;Load count to CX
LEA SI,BLK1 ;Offset address of BLK1 is loaded to SI
LEA DI,BLK2 ;Offset address of BLK2 is loaded to DI
up: MOV AL,[SI]
MOV [DI],AL
INC SI
INC DI
LOOP up
MOV AH,4CH ;program termination
INT 21H
CODE ENDS
END START
b)Program to transfer a block of data from one memory location to another in reverse order
DATA SEGMENT
ORG 8500h
BLK1 db 10h,20h,30h,40h,50h
ORG 9500h
BLK2 db 5 dup(?)
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CX,0005H ;Load count to CX
LEA SI,BLK1 ;Offset address of BLK1 is loaded to SI
LEA DI,[BLK2+4] ;Offset address of BLK2 is loaded to DI
up: MOV AL,[SI]
MOV [DI],AL
INC SI
INC DI
LOOP up
MOV AH,4CH ;program termination
INT 21H
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

CODE ENDS
END START
c)Program to exchange the block of data bytes using XCHG instruction
DATA SEGMENT
ORG 8500h
BLK1 db 10h,20h,30h,40h,50h
ORG 9500h
BLK2 db 11h,22h,33h,44h,55h
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CX,0005H ;Load count to CX
LEA SI,BLK1 ;Offset address of BLK1 is loaded to SI
LEA DI,BLK2 ;Offset address of BLK2 is loaded to DI
up: MOV AL,[SI]
XCHG AL,[DI]
MOV [SI],AL
INC SI
INC DI
LOOP up
MOV AH,4CH ;program termination
INT 21H
CODE ENDS
END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:
9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:
10.
FORMULA / CALCULATIONS:
11.
GRAPHS / OUTPUTS
NA

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

12. RESULTS & ANALYSIS:


II.a)Program to transfer a block of data from one memory location to another
Before execution:
Memory
8005
8006
8007
8008
8009
address
Content

10

20

30

40

50

Memory
address

9005

9006

9007

9008

9009

Content

xx

xx

xx

xx

xx

After execution:
Memory
8005
address

8006

8007

8008

8009

Content

10

20

30

40

50

Memory
address

9005

9006

9007

9008

9009

Content

10

20

30

40

50

II.c)Program to exchange the block of data bytes using XCHG instruction


Before Execution:
Memory address 8005
8006
8007
8008

8009

Content

10

20

30

40

50

Memory address

9005

9006

9007

9008

9009

Content

60

70

80

90

A0

After Execution:
Memory address

8005

8006

8007

8008

8009

Content

60

70

80

90

A0

Memory address

9005

9006

9007

9008

9009

Content

10

20

30

40

50

13. OUTCOMES & CONCLUSIONS:


Byte, Word, Block transfer of data using different addressing modes are verified
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

14. APPLICATION AREAS:


Various sorting algorithms like bubble sort, insertion sort and selection sort.
Binary search algorithm.
15. REMARKS:
FACULTY SIGNATURE
1.EXPERIMENT NO:2
2. TITLE: ARITHEMATIC & LOGICAL OPERATIONS
3. LEARNING OBJECTIVES:
To write the assembly language program for addition, subtraction , multiplication and
division using 8086.
To write the assembly language program for arithmetic operations like GCD, LCM,
Fibonacci series and Factorial.
4. AIM:
To write assembly language program for arithmetic and logical operations using 8086
Microprocessors
5. MATERIAL / EQUIPMENT REQUIRED:
Masm assembler
6. THEORY / HYPOTHESIS:
This program is to make the user familiar in writing assembly language programs in 8086. Here
the different aritematic operations like additions, subtraction, multiplication and division.
7.

PROCEDURE / PROGRAMME / ACTIVITY:

I ADDITION AND SUBTRACTION OF MULTI PRECISION NOS:


(A)ADDITION OF TWO 16 BIT NUMBERS
ASSUME CS:CODE
CODE SEGMENT
START:MOV CX, 0000H
MOV AX,24H
MOV BX, 76H
ADD AX,BX
JNC L1
;Check for carry
INC CX
;If carry exists, increment the CX
L1 : MOV DX,CX
;Store the carry
MOV BX, AX
;Store the sum
MOV AH,4CH
;program termination
INT 21H
CODE ENDS
END START
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

(B)SUBTRACTION OF TWO 16 BIT NUMBERS


ASSUME CS:CODE
CODE SEGMENT
START:MOV CX, 0000H
MOV AX,[1200]
MOV BX, [1202]
SUB AX,BX
JNC L1
;Check for borrow
INC CX
;If borrow exists, increment the CX
L1 : MOV [1206],CX
;Store the borrow
MOV [1204], AX
;Store the difference
MOV AH,4CH
;program termination
INT 21H
CODE ENDS
END START
II)Multiplication and Division:
A)MULTIPLICATION OF 16-BIT NUMBERS:
ASSUME CS:CODE
CODE SEGMENT
START:MOV AX, 0200h ; Get the first data
MOV BX, 1200h
; Get the second data
MUL BX
;Multiply both
MOV CX,AX
;Store the lower order product in CX , higher order product in DX
MOV AH,4CH
;program termination
INT 21H
CODE ENDS
END START
B)DIVISION OF TWO 16 BIT NUMBERS
ASSUME CS:CODE
CODE SEGMENT
START:MOV AX,1200h
;Get the first data
MOV BX, 0200h
;Get the second data
DIV BX
;Divide the dividend by divisor
MOV CX,AX
;Store the lower order product
MOV AH,4CH
;program termination
INT 21H
CODE ENDS
END START
III)ASCII adjustment instructions:
A)ASCII adjustment after addition
ASSUME CS:CODE
CODE SEGMENT
START:MOV AH,00h
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

MOV AL,39h ; for subtraction replace with


ADD AL,31h ;
AAA ;
ADD AX,3030h
MOV AH,4Ch
INT 21h
CODE ENDS
END START
B)ASCII adjustment after subtraction
ASSUME CS:CODE
CODE SEGMENT
START:MOV AH,00H
MOV AL,39H
SUB AL,31h
AAS
ADD AX,3030h
MOV AH,4Ch
INT 21h
CODE ENDS
END START

IV)CODE CONVERSIONS:
A)PROGRAM TO CONVERT THE GIVEN PACKED BCD NO TO ITS 7-SEGMENT LED
CODE
DATA SEGMENT
Table db 3FH,06H,5BH,4FH,66H,6DH,5BH,70H,7AH,7BH
Sevenseg db ?
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV BX,OFFSET Table ;offset of Table to BX
MOV AL,84H

; Load the number

MOV DL,AL

;save the number

AND AL,0FH

;unpack by anding with 0FH

XLAT

;Accsess code from table

MOV Sevenseg,AL
MOV AL,DL
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

AND AL,0F0H

; Andwith 0F0H

MOV CL,04H

;Rotate 4 times to get unpached MSB

TCP03
Rev 1.2
ECE
29/12/2015

ROR AL,CL
XLAT

;Accsess code from table

MOV Sevenseg+1 ,AL


MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
b)Program to convert the BCD no. to its binary(Hex) equivalent
DATA SEGMENT
ORG 8500h
Num db 64h
ORG 9500h
Result db ?
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV BL,Num

;Load number

MOV AL,BL

;Store number

AND AL,0FH

;And with 0Fh to get unpacked BCD1

MOV DL,AL
MOV AL,BL
AND AL,0F0h

;And with F0h and rotate 4 times to get

MOV CL,04h
ROL AL,CL
MOV BH,0AH
MUL BH

;unpacked BCD2 X 10H

ADD AL,DL

;Add the result with unpacked BCD1

MOV Result,AL
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

END START
c)Program to convert the Binary(Hex) no. to its BCD equivalent
DATA SEGMENT
ORG 8500h
Num db 0FDh
ORG 9500h
Result db ?
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AL,Num

;Load number

MOV BL,64H
CMP AL,BL

;Compare the number with 64H

JC Next

; If num>64H;divide it by 64H else divide by 0AH

MOV AH,0H
DIV BL
MOV Result,AL
MOV AL,AH
Next:MOV CH,0AH
MOV AH,0H
DIV CH
MOV Result+1,AL
MOV Result+2,AH
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
d)Program to convert the Hex no. to its ASCII equivalent
DATA SEGMENT
ORG 8500h
Num db 8Dh
ORG 9500h
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

Result db ?
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AL,Num

;Load number

MOV BL,AL

;Store the number

AND AL,0FH
CMP AL,0AH

;And with 0Fh to get unpacked number


;Compare with 0AH,If > 0A,then add 37H else add 30H

JC Down
ADD AL,07H
Down: ADD AL,30H
MOV Result,AL
MOV AL,BL
AND AL,0F0H

;And with F0h and rotate 4 times to get unpacked BCD2

MOV CL,04H
ROR AL,CL
CMP AL,0AH

;Compare with 0AH,If > 0A,then add 37H else add 30H

JC Down1
ADD AL,07H
Down1: ADD AL,30H
MOV Result+1,AL
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
e)Program to convert the ASCII to its Hex equivalent
DATA SEGMENT
ORG 8500h
Num db 45h
ORG 9500h
Result db ?
DATA ENDS
ASSUME CS:CODE,DS:DATA
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AL,Num

;Load number

CMP AL,30H

;Compare with 30H,If > 30H Subtract 37H else subtract 30H JC Down

SUB AL,07H
Down: SUB AL,30H
MOV Result,AL
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
(V)Number conversion programs using procedure method
(a)Program to convert the BCD no. to its binary(Hex) equivalent
DATA SEGMENT
MSG1 DB "ENTER BCD NO:$"
MSG2 DB 0AH,0DH,"THE HEX EQT:$"
MESB DB "BCD$"
MESH DB "H$"
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
PRINT PROC NEAR
PUSH AX
MOV AH,09H
INT 21H

;09h is the dos function for string or character display


;offset of message is assumed to be stored in dx

POP AX
RET
PRINT ENDP
INPUT PROC NEAR
MOV AH,01H
INT 21H

;09H IS THE DOS FUNCTION FOR READING

AND AL,0FH
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

MOV BL,10H
MUL BL
MOV CL,AL
MOV AH,01H
INT 21H
AND AL,0FH
ADD AL,CL

;ENTERED NUMBER IS STORED IN AL AS PACKED NUMBER

RET
INPUT ENDP
BCDBIN PROC
MOV BL,AL
AND AL,0FH
MOV DL,AL
MOV AL,BL
AND AL,0F0H
MOV CL,04H

;BCD2BIN CONVERSION ROUTINE

ROL AL,CL
MOV BH,0AH
MUL BH
ADD AL,DL
CALL OUTPUT
RET
BCDBIN ENDP
OUTPUT PROC NEAR
MOV CH,A
AND AL,0F0H
MOV CL,04H
ROL AL,CL
CMP AL,0AH
JC DOWN
ADD AL,07H
DOWN:ADD AL,30H

;ascii equivalent of higher order nibble


; for display

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

MOV AH,02

TCP03
Rev 1.2
ECE
29/12/2015

;02h is the dos function for outputting a char

MOV DL,AL
INT 21H
AND CH,0FH
CMP CH,0AH
JC L1
ADD CH,07H
L1:ADD CH,30H

;ASCII EQUIVALENT OF LOWER ORDER NIBBLE

FOR DISPLAY
MOV AH,02H
MOV DL,CH
INT 21H
RET
OUTPUT ENDP
START:MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
CALL PRINT
CALL INPUT
LEA DX,MESB
CALL PRINT
LEA DX,MSG2
CALL PRINT
CALL BCDBIN
LEA DX,MESH
CALL PRINT
MOV AH,4CH
INT 21H
CODE ENDS
END START
(b)Program to convert the binary(Hex) no. to its BCD equivalent
DATA SEGMENT
MSG1 DB "ENTER BINARY NO:$"
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

MSG2 DB 0AH,0DH,"THE BCD EQT:$


MSG3 DB "BCD$"
MSG4 DB "H$"
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
PRINT PROC NEAR
PUSH AX
MOV AH,09H

;09h is the dos function for string

INT 21H

;or character display; offset of message is assumed

POP AX

;to be stored in dx

RET
PRINT ENDP
INPUT PROC NEAR
MOV AH,01H
INT 21H
CMP AL,39H
JC DOWN
ADD AL,09H

;if the num >39,add 09h to get the hex eqt.

DOWN:AND AL,0FH
MOV BL,10H
MUL BL
MOV CL,AL
MOV AH,01H
INT 21H
CMP AL,39H
JC DOWN1
ADD AL,09H
DOWN1:AND AL,0FH
ADD AL,CL

;packed hex number is in al

RET
INPUT ENDP
BINBCD PROC
MOV AH,00H
MOV BL,0AH
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

DIV BL
MOV CL,04H

;bin2bcd conversion routine

ROL AL,CL
ADD AL,AH
CALL OUTPUT
RET
BINBCD ENDP
OUTPUT PROC NEAR
MOV CH,AL
AND AL,0F0H
MOV CL,04H
ROL AL,CL
ADD AL,30H

;ascii equivalent of higher order nibble for display

MOV AH,02H
MOV DL,AL
INT 21H
AND CH,0FH
ADD CH,30H

;ascii equivalent of lower order nibble for display

MOV AH,02H
MOV DL,CH
INT 21H
RET
OUTPUT ENDP
START:MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
CALL PRINT
CALL INPUT
LEA DX,MES4
CALL PRINT
LEA DX,MSG2
CALL PRINT
CALL BINBCD
LEA DX,MES3
CALL PRINT
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

MOV AH,4CH
INT 21H
CODE ENDS
END START
(c)Program to convert the binary(Hex) no. to its ASCII equivalent
DATA SEGMENT
MSG1 DB "ENTER HEX NO:$"
MSG2 DB 0AH,0DH,"THE ASCII EQT IS:$"
MES3 DB "H$"
MES4 DB "ASCII$"
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
PRINT PROC NEA
PUSH AX
MOV AH,09H
INT 21H
POP AX
RET
PRINT ENDP
INPUT PROC NEAR
MOV AH,01H
INT 21H
MOV BH,AL
MOV AH,01H
INT 21H
MOV BL,AL
RET
INPUT ENDP
HEX2ASC PROC NEAR
MOV CH,AL
AND AL,0F0H
MOV CL,04H
ROL AL,CL
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

CMP AL,0AH
JC L1
ADD AL,07H
L1:ADD AL,30H
MOV DL,AL
CALL OUTPUT
AND CH,0FH
CMP CH,0AH
JC L11
ADD CH,07H
L11:ADD CH,30H
MOV DL,CH
CALL OUTPUT
RET
HEX2ASC ENDP
OUTPUT PROC NEAR
MOV AH,02H
INT 21H
RET
OUTPUT ENDP
START:MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
CALL PRINT
CALL INPUT
LEA DX,MES3
CALL PRINT
LEA DX,MSG2
CALL PRINT
MOV AL,BH
CALL HEX2ASC
MOV AL,BL
CALL HEX2ASC
LEA DX,MES4
CALL PRINT
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

MOV AH,4CH
INT 21H
CODE ENDS
END START
(D)PROGRAM TO CONVERT THE ASCII NO. TO ITS BINARY(HEX) EQUIVALENT
DATA SEGMENT
MSG1 DB "ENTER ASCII NO:$"
MSG2 DB 0AH,0DH,"THE HEX EQT:$"
MES3 DB "ASCII $"
MES4 DB "H $"
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
PRINT PROC NEAR
PUSH AX
MOV AH,09H
INT 21H
POP AX
RET
PRINT ENDP
INPUT PROC NEAR
MOV AH,01H
INT 21H
MOV BH,AL
MOV AH,01H
INT 21H
MOV BL,AL
RET
INPUT ENDP
ASC2HEX PROC NEAR
AND BH,0FH
AND BL,0FH
MOV AL,10H
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

MUL BH
ADD AL,BL
MOV DL,AL
MOV AH,02H
INT 21H
RET
ASC2HEX ENDP
START:MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
CALL PRINT
CALL INPUT
LEA DX,MES3CALL PRINT
LEA DX,MSG2
CALL PRINT
CALL ASC2HEX
LEA DX,MES4
CALL PRINT
MOV AH,4CH
INT 21H
CODE ENDS
END START
v)Arithmetic programs to find LCM,GCD,Factorial and Fibonacci.
(a)Program to find the factorial of given number
ASSUME CS:CODE
CODE SEGMENT
START:MOV AX,01H
MOV BX,08H

;get the number

L1:MUL BX
DEC BX

;multiply with ax
;decrement bx

JNZ L1
MOV BX,AX

;store the result in bx

MOV AH,4CH

;terminate the program

INT 21H
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

CODE ENDS
END START
(B)PROGRAM TO GENERATE THE FIBONACCI SERIES
DATA SEGMENT
FIBO DB 25 DUP (?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV AL,0H
MOV BL,01H
MOV SI,OFFSET FIBO
MOV [SI],AL
INC SI
MOV [SI],BL
INC SI
MOV CH,0H
MOV CL,07H
SUB CL,02H
BACK: ADD AL,BL
DAA
MOV [SI],AL
MOV AL,BL
MOV BL,[SI]
INC SI
LOOP BACK
MOV AH,4CH
INT 21H
CODE ENDS
END START
(c)Program to find LCM of two numbers
ASSUME CS:CODE
CODE SEGMENT
START:MOV AX,00H
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

MOV BX,00H
MOV AL,24H
MOV BL,36H
PUSH AX;
PUSH BX;
CMP AX,BX
JNC L1

TCP03
Rev 1.2
ECE
29/12/2015

;FIRST NUMBER
;SECOND NUMBER
;CHECK THE LARGER NUMBER AND STORE

;IT IN AX SMALLER NUMBER IN BX

MOV CX,AX
MOV AX,BX
MOV BX,CX
L1:DIV BL

;div ax by bl

MOV AL,BL

;store b in a

MOV BL,AH

;store rem in b

MOV AH,00
CMP BL,00H
JNZ L1

;continue till b is zero

MOV DL,AL

;gcd is stored in dl register

POP BX
POP AX
MUL BL
DIV DL
MOV DH,AL

;lcm is stored in dh register

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

(d)Program to find GCD of two numbers


ASSUME CS:CODE
CODE SEGMENT
START:MOV AX,00H
MOV BX,00H
MOV AL,24H
;first number
MOV BL,36H
;second number
CMP AX,BX
;check the larger number and store
JNC L1

;it in ax smaller number in bx register

MOV CX,AX
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

MOV AX,BX
MOV BX,CX
L1:DIV BL

;div ax by bl

MOV AL,BL

;store b in a

MOV BL,AH

;store rem in b

MOV AH,00
CMP BL,00H
JNZ L1

;continue till b is zero

MOV DL,AL

;gcd is stored in dl register

MOV AH,4CH
INT 21H
CODE ENDS
END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:
NA
9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:
NA
10. FORMULA / CALCULATIONS:
NA
11. GRAPHS / OUTPUTS:
NA
12. RESULTS & ANALYSIS:
I.A)ADDITION OF TWO 16 BIT NUMBERS
Before execution
Registers
Contents
AX

24

BX

76

CX

DX

After execution
Registers

Contents

AX

9A

BX

9A

CX

DX
0
I.C)MULTIPLICATION OF TWO 16 BIT NUMBERS
Nehru Nagar, Puttur - 574 203, DK, Karnataka State INDIA.Phone :+91-8251-235955, 234555
Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

Before execution
Registers
Contents
AX

0200h

BX

1200h

CX

DX

0
After execution
Contents

Registers
AX

4C00h

BX

1200h

CX

0000h

DX
0024h
I.D)DIVISION OF TWO 16 BIT NUMBERS
Before execution
Registers
Contents
AX

1200h

BX

0200h

CX

DX

0
After execution
Contents

Registers
AX

4C09h

BX

0200h

CX

0009h

DX

V(A)PROGRAM TO FIND THE FACTORIAL OF GIVEN NUMBER


Before execution
Registers
Contents
AX
BX
Registers

1
8h
After execution
Contents

AX

4c80h

BX

9d80h

V(C)GCD AND LCM OF GIVEN TWO NUMBERS


Nehru Nagar, Puttur - 574 203, DK, Karnataka State INDIA.Phone :+91-8251-235955, 234555
Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

Before execution

TCP03
Rev 1.2
ECE
29/12/2015

After execution

Registers

Contents

Registers

Contents

AX

24(36D)

DH

6C(LCM)

BX

36(54D)

DL

12(GCD)

13. OUTCOMES & CONCLUSIONS:


The outputs for various arithmetic operations like addition, subtraction, multiplication and
division are observed and verified using MASM assembler
The programs like GCD, LCM, Factorial and Fibonacci series are implemented using 8086
14. APPLICATION AREAS:
The arithmetic operations studied here will act as base for implementing complex
algorithm.
Code conversions methods find applicable in the field of Digital circuits.
Code conversions methods find applicable in Digital clocks.
15. REMARKS:

FACULTY SIGNATURE
1. EXPERIMENT NO:3

2.

TITLE: BIT MANIPULATION INSTRUCTIONS

3. LEARNING OBJECTIVES:
Understand how bit manipulation operations can tbe used to check whether the number is
odd, even,positive or negative
Understand how bit manipulation operations can be used to check whether the number is
bitwise or nibblewise palindrome
4. AIM:
-TO WRITE ASSEMBLY LANGUAGE TO PERFORM VARIOUS BIT
MANIPULATION OPERATIONS
5. MATERIAL / EQUIPMENT REQUIRED:
MASM assembler
6. THEORY / HYPOTHESIS:
Shift and rotate instruction in instruction set of 8086 can be used to check the bits in byte or
word to determine whether the number is odd, even,positive,negative
This instructions can also be used to check whether the number is palindrome or not.
Nehru Nagar, Puttur - 574 203, DK, Karnataka State INDIA.Phone :+91-8251-235955, 234555
Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

7. PROGRAM/PROCEDURE/ACTIVITY:
(a)Program to check whether number is even or odd
ASSUME CS:CODE
CODE SEGMENT
START:CLC
MOV AL,50H

;READ DATA

SHR AL,01H

;CHECK THE LSB

JC L1
MOV BX,00H

;NUM IS EVEN

JMP L2
L1:MOV BX,0FFH

;NUM IS ODD

L2:MOV AH,4CH
INT 21H
CODE ENDS
END START
(b)Program to check whether number is positive or negative
ASSUME CS:CODE
CODE SEGMENT
START:CLC
MOV AL,0F0H ;READ DATA
SHL AL,01H ;CHECK THE LSB
JC L1
MOV BX,00H ;NUM IS POSITIVE
JMP L2
L1:MOV BX,0FFH ;NUM IS NEGATIVE
L2:MOV AH,4CH
INT 21H
CODE ENDS
END START
(c)Program to find the no. of 1s in a given data byte
ASSUME CS:CODE
CODE SEGMENT
START:MOV AL,98H
MOV CX,08H
MOV BH,0H
Up:

RCR AL,01H ;rotate accumulator content 8 times


JNC Last

;if CY=1,increment counter

INC BH
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

Last:

TCP03
Rev 1.2
ECE
29/12/2015

LOOP Up
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
(d)Program to check the given number is nibble wise PALINDROME
ASSUME CS:CODE
CODE SEGMENT
START:MOV AL,48H ;Load number to accumulator
MOV BL,AL;store in BL
MOV CL,04H
ROR AL,CL ; Rotate acc content 4 times
CMP AL,BL ;compare the rotated number with original number
JZ Pali

;if both are equal then number is


Palindrome;store FF in BH

MOV BH,0H
JMP Last
Pali:
Last:

MOV BH,0FFH
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
(e)Program to check the given number is bitwise PALINDROME
ASSUME CS:CODE
CODE SEGMENT
START:MOV AL,24H ;Load number to accumulator
MOV BL,AL ; Copy The number to BL
MOV CX,04H
repeat: ROL AL,01H
JC Down

;rotate accumulator left and check for carry

ROR BL,01H ;if no carry ,rotate BL right


JC notpali
Again:

;if CY=1,then num is not palindrome

LOOP repeat ;repeat for 4 times


MOV BH,0FFH
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

JMP Last
Down:

ROR BL,01H
JC again

notpali: MOV BH,0H


Last:

MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
(f)To detect if data is 2 out of 5 code
DATA SEGMENT
CODE_GIVEN DB 00010001B
VALID DB "CODE IS VALID$"
INVALID DB "CODE IS INVALID$"
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV CX,0003H
MOV SI, OFFSET CODE_GIVEN
MOV AL,[SI]
BACK: SAL AL,01
JC NOTVALID
LOOP BACK
MOV BL,00H
MOV CX,0005H
MOV AL,[SI]
BACK1: SAR AL,01
JNC BACK2
INC BL
BACK2: LOOP BACK1
CMP BL, 02H
JNE NOTVALID
LEA DX, VALID
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

MOV AH,09
INT 21H
JMP EXIT
NOTVALID: LEA DX, INVALID
MOV AH,09
INT 21H
EXIT: MOV AH, 4CH
INT 21H
CODE ENDS
END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:
NA
9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:
NA
10. FORMULA / CALCULATIONS:
NA
11. GRAPHS / OUTPUTS:
NA
12. RESULTS & ANALYSIS:
I.A Program to check whether the number is odd or even
Before execution
After execution
Register

Content

Register

Content

AX

50h

AX

28h

BX

00h

BX

00h(even)

B. Program to check whether the number is positive or negative


Before execution
After execution
Register

Content

Register

Content

Al

0f0h

Al

0e0h

BX

00h

BX

ffh(negative)

D.Program to check whether the number is nibble wise palindrome


Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

Before execution

TCP03
Rev 1.2
ECE
29/12/2015

After execution

Register

Content

Register

Content

Al

48h

Al

xx

bh
0
bh
E.
Program to check whether the number is bit wise palindrome
Before execution
After execution

0ffh(palindrome)

Register

Content

Register

Content

Al

24h

Al

xx

bh

bh

0ffh(palindrome)

13. OUTCOMES & CONCLUSIONS:


The bit manipulation instructions and its application for the various programs involving
checking whether the number is even, odd, positive and negative number is studied and
verified
14. APPLICATION AREAS:
Bit manipulation instruction can be used to perform multiplication, division on byte or word
Bit manipulation instruction is also used in Binary search algorithms
15. REMARKS:
FACULTY SIGNATURE
1. EXPERIMENT NO:4
2. TITLE: BRANCH / LOOP INSTRUCTIONS
3. LEARNING OBJECTIVES:
Understand the importance of looping to perform repeated arithmetic operations
Understand the importance of non sequential branch operation and use of stack memory
4. AIM:
To write assembly language programs involving Branch and Loop instrucions
5. MATERIAL / EQUIPMENT REQUIRED:
Masm assembler
6. THEORY / HYPOTHESIS:
Loop instrucions plays a pivotal role in most of the programming langauges involving bulk
or array of data's. Instead of repeating the same instrucion repeatedly again and again, loop
instrucions can be used to speed up the process
Branch instructions will change the order of the sequential programming language. This
type of modular programming concept will also speed up the process.
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

7. PROCEDURE / PROGRAMME / ACTIVITY:


I(a)Program to add N data bytes
DATA SEGMENT
ORG 8500h
ARRAY db 10h,20h,30h,40h,50h
ORG 9500h
SUM db ?
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AL,0H
MOV BL,0H

;Initialise registers to 0h

MOV SI,0H
MOV CX,05H

;count in CX

up: ADD AL,ARRAY[SI]


JNC down
INC BL

;Add number with accumulator content

;check for carry


;If CY=1,increment carry register

down:INC SI
LOOP up
MOV SUM,AL

;Store result

MOV SUM+1,BL
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
IB. Program to add N data words
DATA SEGMENT
ORG 8500h
ARRAY DW 0ADEFH,0FFFFh,0ABCDH,8888h,4567h
ORG 9500h
SUM DW ?
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,0H
MOV BX,0H

;Initialise registers to 0h

MOV SI,0H
MOV CX,05H

;count in CX

up: ADD AX,ARRAY[SI] ;Add number with accumulator content


JNC down
INC BX

;check for carry


;If CY=1,increment carry register

down:ADD SI,02H
LOOP up
MOV SUM,AX ;Store result
MOV SUN+2,BX
MOV AH,4CH ;program termination
INT 21H
CODE ENDS
END START
I(c)Program to find the largest among N data bytes
DATA SEGMENT
ORG 8500h
ARRAY db 10h,0ABh,30h,40h,50h
ORG 9500h
LARGEST db ?
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV CX,05H

;Counter

LEA SI,ARRAY

; Offset address of ARAY is loaded to SI

MOV AL,[SI]
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

UP: INC SI
CMP AL,[SI]

;compare the two numbers

JNC LAST

;If CY=1,copy largest num to AL

MOV AL,[SI]
LAST: LOOP UP
MOV LARGEST,AL
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
I(d)Program to arrange N data bytes in an ARRAY in ascending order
DATA SEGMENT
ORG 8500h
ARRAY db 10h,0ABh,30h,0FFh,50h
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV BX,04H
again:MOV CX,BX

;External counter
;internal counter

LEA SI,NUM

;Offset address of ARAY is loaded to SI

up: MOV AL,[SI]


CMP AL,[SI+1]
JC down

;compare the two numbers

;if CY=0,swap the two numbers else


retain as it is

XCHG [SI+1],AL
MOV [SI],AL
down:INC SI
LOOP up
DEC BX
JNZ again
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:
-NA
9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:
NA
10. FORMULA / CALCULATIONS:
NA
11. GRAPHS / OUTPUTS:
NA
12. RESULTS & ANALYSIS:
I.a Program to find sum of N data bytes
Before execution:
After execution:
8500 8501 8502

8503 8504

9500

8500

8501

8502

8503

8504 9500

10

40

XX

10

20

30

40

50

20

30

50

F0

I.c Program to find largest number in array


Before execution:

After execution:

8500

8501

8502

8503

8504

9500

8500

8501

8502

8503

8504

9500

10

20

30

40

50

XX

10

20

30

40

50

50

I(d)Program to arrange N data bytes in an ARRAY in ascending order


Before execution
After execution
8500

8501

8502

8503

8504

8500

8501

8502

8503

8504

30

10

20

50

40

10

20

30

40

50

13. OUTCOMES & CONCLUSIONS:


Loop instructions and branch instructions are studied and applied for various programs like
sum of N numbers, largest of N numbers, Sorting an array.
14. APPLICATION AREAS:
Bubble sort, Selection sort and insertion sort
Sum of N numbers, Largest of N numbers
15. REMARKS:
FACULTY SIGNATURE
-

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

1. EXPERIMENT NO:5
2. TITLE: PROGRAMS ON STRING MANIPULATION
3. LEARNING OBJECTIVES:
Understand how exactly a character or group of characters(strings) are stored in memory
Understand ascii notations for characters
4. AIM:
To write programs involving string manipulation operations
5. MATERIAL / EQUIPMENT REQUIRED:
Microsoft macro assembler(Masm) assembler
6. THEORY / HYPOTHESIS:
Strings are group of characters stored in consecutive memory locations.
Various operations can be performed on the string data like string copy, string compare,
string store, string load etc.
7.
PROCEDURE / PROGRAMME / ACTIVITY:
5(a)program to transfer a string message from one location to another
DATA SEGMENT
ORG 8500H
Loc1 db SHASTRI
DATA ENDS
EXTRA SEGMENT
ORG 9500H
Loc2 db(?)
EXTRA ENDS
ASSUME CS:CODE,DS:DATA,ES:EXTRA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
LEA SI,Loc1
LEA DI,Loc2
MOV CX,07h
CLD
rep MOVSB
MOV AH,4CH

;program termination

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

INT 21H
CODE ENDS
END START
5(b)Program to reverse a given string message
DATA SEGMENT
ORG 8500H
Loc1 db SHASTRI
DATA ENDS
EXTRA SEGMENT
ORG 9500H
Loc2 db(?)
EXTRA ENDS
ASSUME CS:CODE,DS:DATA ,ES:EXTRA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
LEA SI ,[Loc1+07h]
LEA DI, Loc2

;SI pointing to last loc1


;DI pointing to first loc2

MOV CX,08h
CLD
UP: MOVSB
DEC SI
DEC SI
LOOP UP
MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
5(c)Program to check the given string message is PALINDROME
DATA SEGMENT
ORG 8500H
Loc1 db MALAYALAM
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

DATA ENDS
EXTRA SEGMENT
ORG 9500H
Loc2 db MALAYALAM
EXTRA ENDS
ASSUME CS:CODE,DS:DATA ,ES:EXTRA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
LEA SI ,[Loc1+08h]

;SI pointing to last loc1

LEA DI, Loc2

;DI pointing to first loc2

MOV CX,04H
UP:

CMPS Loc1,Loc2
JNZ notpali
INC SI
DEC DI
LOOP UP
MOV BL,0FFH
JMP last

Notpali:MOV BL,0H
Last:

MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
5(d)Program to check the character is present in a given string message
EXTRA SEGMENT
ORG 8500H
Message db SHASTRI
EXTRA ENDS
ASSUME CS:CODE,ES:EXTRA
CODE SEGMENT
START: MOV AX,EXTRA
MOV ES,AX
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

LEA DI, Message

TCP03
Rev 1.2
ECE
29/12/2015

;DI pointing to first loc2

MOV CX,08h
CLD
MOV AL,B
REPNE SCAS Message

;Scan for the character B

CMP CX,0H
JNZ down
MOV BL,0H
JMP last
Down: MOV BL,0FFH
Last:

MOV AH,4CH

;program termination

INT 21H
CODE ENDS
END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:
-NA
9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:
NA
10. FORMULA / CALCULATIONS:
NA
11. GRAPHS / OUTPUTS:
NA
12. RESULTS & ANALYSIS:
5.a Program to copy string from one location to another location
Before execution
After execution
8500

8501

8502

8503

8504 8505 8506 9500 9501 9502 9503 9504

9505 9506

53

48

41

53

54

53

53

49

53

48

41

53

54

49

5.c Program to check whether the given string is palindrome or not


Before execution

BX

XX

8500

8501

8502

8503

8504

8505

8506

8507

8508

4D

41

4C

41

59

41

4C

41

4D

After execution

BX

8500

8501

8502

8503

8504

8505

8506

8507

8508

4D

41

4C

41

59

41

4C

41

4D

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

13. OUTCOMES & CONCLUSIONS:


String manipulation operations like string copy, reversing a string, checking a character in a
string is studied and verified
14. APPLICATION AREAS:
Used to check whether the sub string is present in the main string
Used to represent real time objects
15. REMARKS:
1. EXPERIMENT NO:6
2. TITLE: STEPPER MOTOR INTERFACE
3. LEARNING OBJECTIVES:
Understand the application of stepper motor in robotics and automation.
Speed of stepper motor can be controlled by cahnging the delay.
Should be able to create and control directional program with position record and linking.
Sould become familiar with the various operating modes of a motor controller.
4. AIM: Program to rotate the stepper motor in the clockwise direction by n turns
5. MATERIAL / EQUIPMENT REQUIRED:
Microsoft Macro (Masm) assembler
PCI card
Stepper motor module
6. THEORY / HYPOTHESIS:
A stepper motor is an electromechanical device which converts electrical pulses into
discrete mechanical movements.
The basic design of a stepper motor is such that it has a stator which is the stationary part of
the motor and a rotor which is the moving part of the motor which will be the shaft of the
motor. The rotor is a permanent magnet. The stator has coils which are energised by the
pulses. So the stator are electromagnets.
7.
PROCEDURE / PROGRAMME / ACTIVITY:
Program to rotate stepper motor in CLK wise for N rotations
DATA SEGMENT
PA EQU 0B800H
CR EQU 0B803H
COUNT EQU 1000
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

START:MOV AX,DATA
MOV DS,AX
MOV DX,CR
MOV AL,80H ;control word to configure PA as o/p
OUT DX,AL
Again: MOV AL,88H ;bit format for half step mode
MOV DX,PA
MOV CX,Count ;Count for N rotations
Back: OUT DX,AL
CALL Delay
ROR AL,01H
LOOP Back
JMP Again
MOV AH,4CH
INT 21H
Delay PROC NEAR
PUSH CX
MOV BX,0FF0H
Up: MOV CX,1000
L1:

LOOP L1
DEC BX
JNZ Up
POP CX
RET
Delay ENDP

CODE ENDS
END START
8.

BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

In Fig. 1 the rotor has aligned itself with the electromagnet which is powered. In Fig. 2 we see that the
electromagnet which is to the east of the previous electromagnet is now powered and the rotor now
aligns itself accordingly. Similarly as each electromagnet is powered in a cycle the rotor aligns itself
accordingly in a stepwise motion. The example above is shown for a step angle of 90 which is for
demonstration only. Stepper motors have smaller steps. Typically we have 1.8 per step, however there
are hybrid motors built with 3.6 and resolutions as fine as .72 per step.

9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:


NA
10.

FORMULA / CALCULATIONS:
NA

11. GRAPHS / OUTPUTS:


NA
12. RESULTS & ANALYSIS:
Stepper motor rotates in stepwise
13. OUTCOMES & CONCLUSIONS:
Speed of the stepper motor can be controlled
Direction of the stepper motor can also be controlled
14. APPLICATION AREAS:
Robotics and automation
CNC machines
3D printers
Intelligent lighting
15. REMARKS:
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

1. EXPERIMENT NO:7
2. TITLE: BCD UP COUNTER USING LOGICAL INTERFACE
3. LEARNING OBJECTIVES:
Build and test cascaded BCD counters for multi digital operation
To study the fundamentals of basic sequential logic concepts and circuits
To become familiar with various types of latches and flipflops.
4. AIM:
Program to interface logic controller to 8086 for BCD counter operation
5. MATERIAL / EQUIPMENT REQUIRED:
Masm assembler
PCI card
logic controller interface
6. THEORY / HYPOTHESIS:
Counting is frequently required in digital computers and other digital systems to record the
number of events occurring in a specified interval of time. Normally an electronic counter is
used for counting the number of pulses coming at the input line in a specified time period.
The counter must possess memory since it has to remember its past states.
BCD counter counter disgits from 00 to 99
7.
PROCEDURE / PROGRAMME / ACTIVITY:
PROGRAM TO GENERATE BCD UP COUNTER USING LED DISPLAY
Data segment
pa equ 0b800h
cr equ 0b803h
Data ends
assume cs:code,ds:data
code segment
start:mov ax,data
mov ds,ax
MOV DX,CR
MOV AL,80H ;control word to configure PA as o/p
OUT DX,AL
mov al,0h
up:

;Initial count in AL

out dx,al
call delay
add al,01h
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

daa
cmp al,99h ;Compare with maximum count
jc up
out dx,al
call delay
loop: jmp loop
mov ah,4ch
int 21h
DELAY PROC NEAR
PUSH CX
MOV BX,0FFH
Up1: MOV CX,0FFH
L1:

LOOP L1
DEC BX
JNZ Up1
POP CX
RET
DELAY ENDP

CODE ENDS
END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:
NA
9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:
NA
10. FORMULA / CALCULATIONS:
NA
11. GRAPHS / OUTPUTS:
NA
12. RESULTS & ANALYSIS:
Counter counts from 00 to 99 on logical interface
13. OUTCOMES & CONCLUSIONS:
The BCD counter counts the digits from 00 to 99.
Delay can be used to increase or decrease the counting speed.
14. APPLICATION AREAS:
BCD counters are used in consumer appliances
Digital clocks, VCR clocks
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

15. REMARKS:
1. EXPERIMENT NO:8
2. TITLE: SEVEN SEGMENT DISPLAY INTERFACE TO 8086
3. LEARNING OBJECTIVES:
Gain familiarity with BCD codes
How to use seven segment LED assemblies to create decimal digit displays
How to identify and use both active low and active high logic inputs
4. AIM:
Program to interface seven segment module to 8086.
5. MATERIAL / EQUIPMENT REQUIRED:
Masm assembler
PCI card
Seven segment display module
6. THEORY / HYPOTHESIS:
Seven segment display is a form of electronic display device for diplaying decimal
numericals that is an alternative more complex dot matrix displays.
Seven segment displays are widely used in digital clocks, electronic meters, basic
calculators etc.
7. PROCEDURE / PROGRAMME / ACTIVITY:
PROGRAM TO DISPLAY FIRE HELP ALTERNATIVELY
Data segment
pb equ 0b801h
pc equ 0b802h
cr equ 0b803h
Table db 086H,088H,0F9H,08EH [1S complement of 7seg code right to left]
db 08CH,0C7H,086H,089H [P,L,E,H]
Data ends
assume cs:code,ds:data
code segment
start:mov ax,data
mov ds,ax
MOV DX,CR
BACK: XOR CX,CX
MOV AL,80H ;control word to configure PA as o/p
OUT DX,AL
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

LEA SI, Table


MOV BH,02H ;Count for two lines
Nextw: MOV BL,04H ;For 4 characters
Nextc: MOV CL,08H
MOV AL,[SI]
Nextb: ROL AL,01H
MOV DX,PB ;Sends bit by bit thro PB0 line
OUT DX,AL
PUSH AX
MOV AL,00H
MOV DX,PC
OUT DX,AL
INC AL
OUT DX,AL ;Low to-high clock pulse
POP AX
LOOP Nextb
INC SI
DEC BL
JNZ Nextc
CALL DELAY
DEC BH
JNZ Nextw
JMP BACK
mov ah,4ch
int 21h
DELAY PROC NEAR
PUSH CX
PUSH DX
MOV DX,4FFFH
Up2: MOV CX,0FFFFH
L1: LOOP L1
DEC DX

JNZ Up2
POP DX
POP CX
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

RET
DELAY ENDP
CODE ENDS
END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:

In this module 6 seven segment dispay LEDs are used. Each of these is selected one at a
time and the data is sent to be displayed. Port C is used to send the select signal to each
display and port A is use to send the display data. Both port A and port C are used as
output ports. The control word therefore must be selected for this mode of operation.
A table of all the hexadecimal characters which are displayed using a seven segment display is
given below.
Hex
h
g
f
e
d
c
b
a
Hex
character
code

8E

F8

88

86

89

86

C7

8C

9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:


NA
10. FORMULA / CALCULATIONS:

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

11. GRAPHS / OUTPUTS:


NA
12. RESULTS & ANALYSIS:
Fire and Help messages are displayed on seven segment interface module
13. OUTCOMES & CONCLUSIONS:
The ASCII codes for messages FIRE and HELP stored in the consecutive memory locations
are transferred to the seven segment display.
14. APPLICATION AREAS:
Digital clock
Basic calculators
15. REMARKS:
1. EXPERIMENT NO:9
2. TITLE: KEYBOARD INTERFACE TO 8086
3. LEARNING OBJECTIVES:
To understand the various components incorporated in keyboard
To program the keyboard module using 8086
4. AIM:
To interface keyboard module to 8086 and to verify the different keys incorporated within.
5. MATERIAL / EQUIPMENT REQUIRED:
Keyboard interface module
Masm assembler
PCI card
Power supply
6. THEORY / HYPOTHESIS:
Keyboard is a collection of push button type switches, which is commonly used as an input
device to microcontroller based system.
Each key is assigned a particular operation.
When a key is pressed the CPU identifies the pressed key by using either software based or
hardware based technique and then performs the assigned operations.
The keyboard module used is a 38 matrix keyboard. The program is written to display the
characters pressed on the module on the monitor. The character displayed when each of the keys
is pressed is shown in the table above.
Port A is connected to the columns of the keyboard matrix.
Port C is connected to the rows. Out of 8 lines only 3 are used since there are only three rows.
On running the program the message Enter any key from module: is displayed. On pressing
any key from the module the message: Entered key is: is displayed and the value of the key is
displayed alongside the message and the program terminates. The control word is 92H where
port C is used as output port and Port A is used as input port. Two procedures are used. scan
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

and disp.
7. PROCEDURE / PROGRAMME / ACTIVITY:
Program for matrix keyboard interfacing
Data segment

promt db 0dh,0ah,press key on keyboard to return to dos,$


msg1 db 0dh,0ah,pressed key=,$
keyp db ?
table db 0123456789.+-*/%cck=nrmm,$
pa equ 0b800h
pc equ 0b802h
cr equ 0b803h
Data ends
assume cs:code,ds:data
display_VAL MACRO VAL
MOV DL,VAL
MOV AH,02H;dos command for display
INT 21H
ENDM
DISPLAY_MSG MACRO MSG
LEA DX,MSG
MOV AH,09H
INT 21H
ENDM
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV AL,90H ;Control word 10010000 for I/O mode wit PA=i/p &
PC=o/p
MOV DX,CR
OUT DX,AL
DISPLAY_MSG PROMPT

AGAIN: MOV AH,0BH;Dos command to display message prompt


INT 21H
CMP AL,255;If AL=FFh,quit
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

JE QUIT
CALL SCAN
CMP DI,00H;DI is initialized with 00h as flag
JE AGAIN ;If DI=00H,no key is pressed. wait till a key
Is pressed
LEA DI,TABLE
ADD DI,SI ;Add DI with SI,where SI points to the key
position of row-0/row-1/row-2
MOV AL,[DI]
MOV KEYP,AL
DISPLAY_MSG MSG1 ;Call display macro
DISPLAY_VAL KEYP
CALL DELAY
JMP START;Go for next key
QUIT: MOV AH,4CH
INT 21H
SCAN PROC NEAR
MOV SI,00H;SI pointing to row-0
MOV DI,00H;DI=00H as flag register
MOV CX,03H;CX=03H as count for 3 rows
MOV AL,80H;AL=10000000
Nextrow:ROL AL,01H;AL=00000001 means logic 1 is sent
thro Row-0(PC0)
MOV BL,AL
MOV DX,PC
OUT DX,AL
MOV DX,PA
IN AL,DX ;Read columns thro PA
CMP AL,00H ;If (AL) is not 00h,key press detected
JNZ KEYID ;If (AL)=00h;go to next row
ADD SI,08H ;send 1 thro next row
LOOP Nextrow
RET
KEYID: MOV DI,01H;flag register is set to indicate key pressed
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

MOV CX,08H ;count for checking key position


AGAIN2:ROR AL,01H ;AL content is rotated till column is detected
JC SKIP

If carry, column is detected else go for loop

INC SI
LOOP AGAIN2
SKIP: RET
SCAN ENDP
DELAY PROC NEAR
PUSH CX
PUSH DX
MOV DX,4FFFH
Up2: MOV CX,0FFFFH
L1:

LOOP L1
DEC DX
JNZ Up2
POP DX
POP CX
RET
DELAY ENDP

CODE ENDS
END START
8.

BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:


NA
10. FORMULA / CALCULATIONS:
NA
11. GRAPHS / OUTPUTS:
NA
Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

Vivekananda College of Engineering & Technology


[Sponsored by Vivekananda Vidyavardhaka Sangha, Puttur ]

Affiliated to Visvesvaraya Technological University


Approved by AICTE New Delhi & Govt of Karnataka
COURSE LABORATORY MANUAL

TCP03
Rev 1.2
ECE
29/12/2015

12. RESULTS & ANALYSIS:


All the keys of the keyboards are successfully verified and observed on the monitor
13. OUTCOMES & CONCLUSIONS:
All the keys of keyboards are observed and verified
14. APPLICATION AREAS:
Provides human interaction with PC's
TV and radios
Instrument panels
15. REMARKS:
-

Nehru Nagar, Puttur - 574 203,

DK

, Karnataka State INDIA.Phone :+91-8251-235955, 234555


Fax :+91-8251236444, Web: www.vcetputtur.ac.in , E-Mail: aemc@vcetputtur.ac.in

S-ar putea să vă placă și