Documente Academic
Documente Profesional
Documente Cultură
TCPO3
P.ev 1.2
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
HOD
INDIA.pnone:+s1-82s1-23ssss,234sss
TCP03
Rev 1.2
ECE
29/12/2015
DK
CO
CO1,CO4
CO1,CO4
CO1,CO4
CO1,CO4
CO1,CO4
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
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.
DK
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 ?
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 ?
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV LOC,0ABCDH
DATA ENDS
ASSUME CS:CODE,DS:DATA
CODE SEGMENT
Nehru Nagar, Puttur - 574 203,
DK
TCP03
Rev 1.2
ECE
29/12/2015
;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
TCP03
Rev 1.2
ECE
29/12/2015
DK
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
DK
TCP03
Rev 1.2
ECE
29/12/2015
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
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
DK
TCP03
Rev 1.2
ECE
29/12/2015
DK
TCP03
Rev 1.2
ECE
29/12/2015
DK
TCP03
Rev 1.2
ECE
29/12/2015
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
MOV DL,AL
AND AL,0FH
XLAT
MOV Sevenseg,AL
MOV AL,DL
Nehru Nagar, Puttur - 574 203,
DK
AND AL,0F0H
; Andwith 0F0H
MOV CL,04H
TCP03
Rev 1.2
ECE
29/12/2015
ROR AL,CL
XLAT
;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
MOV DL,AL
MOV AL,BL
AND AL,0F0h
MOV CL,04h
ROL AL,CL
MOV BH,0AH
MUL BH
ADD AL,DL
MOV Result,AL
MOV AH,4CH
;program termination
INT 21H
CODE ENDS
Nehru Nagar, Puttur - 574 203,
DK
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
JC Next
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
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
AND AL,0FH
CMP AL,0AH
JC Down
ADD AL,07H
Down: ADD AL,30H
MOV Result,AL
MOV AL,BL
AND AL,0F0H
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
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
POP AX
RET
PRINT ENDP
INPUT PROC NEAR
MOV AH,01H
INT 21H
AND AL,0FH
Nehru Nagar, Puttur - 574 203,
DK
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
RET
INPUT ENDP
BCDBIN PROC
MOV BL,AL
AND AL,0FH
MOV DL,AL
MOV AL,BL
AND AL,0F0H
MOV CL,04H
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
DK
MOV AH,02
TCP03
Rev 1.2
ECE
29/12/2015
MOV DL,AL
INT 21H
AND CH,0FH
CMP CH,0AH
JC L1
ADD CH,07H
L1:ADD CH,30H
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
TCP03
Rev 1.2
ECE
29/12/2015
INT 21H
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
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
RET
INPUT ENDP
BINBCD PROC
MOV AH,00H
MOV BL,0AH
Nehru Nagar, Puttur - 574 203,
DK
TCP03
Rev 1.2
ECE
29/12/2015
DIV BL
MOV CL,04H
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
MOV AH,02H
MOV DL,AL
INT 21H
AND CH,0FH
ADD CH,30H
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
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
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
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
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
L1:MUL BX
DEC BX
;multiply with ax
;decrement bx
JNZ L1
MOV BX,AX
MOV AH,4CH
INT 21H
Nehru Nagar, Puttur - 574 203,
DK
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
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
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
MOV DL,AL
POP BX
POP AX
MUL BL
DIV DL
MOV DH,AL
MOV AH,4CH
INT 21H
CODE ENDS
END START
MOV CX,AX
Nehru Nagar, Puttur - 574 203,
DK
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
MOV DL,AL
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
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
1
8h
After execution
Contents
AX
4c80h
BX
9d80h
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)
FACULTY SIGNATURE
1. EXPERIMENT NO:3
2.
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
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
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:
INC BH
Nehru Nagar, Puttur - 574 203,
DK
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
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
DK
TCP03
Rev 1.2
ECE
29/12/2015
JMP Last
Down:
ROR BL,01H
JC again
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
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)
Content
Register
Content
Al
0f0h
Al
0e0h
BX
00h
BX
ffh(negative)
DK
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)
DK
TCP03
Rev 1.2
ECE
29/12/2015
;Initialise registers to 0h
MOV SI,0H
MOV CX,05H
;count in CX
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
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
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
MOV AL,[SI]
Nehru Nagar, Puttur - 574 203,
DK
TCP03
Rev 1.2
ECE
29/12/2015
UP: INC SI
CMP AL,[SI]
JNC LAST
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
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
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
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
8501
8502
8503
8504
8500
8501
8502
8503
8504
30
10
20
50
40
10
20
30
40
50
DK
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
DK
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
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
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]
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
TCP03
Rev 1.2
ECE
29/12/2015
MOV CX,08h
CLD
MOV AL,B
REPNE SCAS Message
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
9505 9506
53
48
41
53
54
53
53
49
53
48
41
53
54
49
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
DK
TCP03
Rev 1.2
ECE
29/12/2015
DK
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.
DK
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.
FORMULA / CALCULATIONS:
NA
DK
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
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
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
TCP03
Rev 1.2
ECE
29/12/2015
JNZ Up2
POP DX
POP CX
Nehru Nagar, Puttur - 574 203,
DK
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
DK
TCP03
Rev 1.2
ECE
29/12/2015
DK
TCP03
Rev 1.2
ECE
29/12/2015
and disp.
7. PROCEDURE / PROGRAMME / ACTIVITY:
Program for matrix keyboard interfacing
Data segment
DK
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
TCP03
Rev 1.2
ECE
29/12/2015
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.
DK
TCP03
Rev 1.2
ECE
29/12/2015
DK
TCP03
Rev 1.2
ECE
29/12/2015
DK