View
218
Download
0
Category
Preview:
Citation preview
7/30/2019 Microprcessor & Interfacing Lab-2
1/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CONTENTS
Page no.
List of Experiments (as per JNTU) - 1, 2
Microprocessor 8086 Programming
Introduction to MASM and TASM - 3,4
Arithmetic operations:
1) Arithmetic Operations on 8 bit data - 5
2) Arithmetic Operations on 16 bit data -
9
3) Multibyte addition and subtraction -
13
4) Signed Operations on 8 bit data -
17
5) ASCII Arithmetic Operations -
19
Logic Operations:
6) BCD to ASCII Conversion - 23
7) ASCII to BCD Conversion - 25
8) No. of Positive nos & Negative nos. - 27
9) No. of Odd nos & Even nos. - 31
10) Packed BCD to Unpacked BCD Conversion - 35
String Operations:
11) Transfer Block of Data - 37
12) Reversal of given String - 39
13) Sorting of N numbers - 43
14) Length of the given String - 47
15) Comparison of two Strings - 49
DOS/BIOS Programming:
16) Reading Keyboard buffered with echo - 53
17) Reading Keyboard buffered with out echo - 55
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 1
7/30/2019 Microprcessor & Interfacing Lab-2
2/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE18) Display String by using DOS Commands - 57
Page no.
Interfacing with (8086) programs:
19) To generate triangle wave by using DAC with 8086 - 59
20) To generate square wave by using DAC with 8086 - 61
21) Keyboard Display Interfacing (8279) - 63
Microcontroller (8051) programs:22) Reading & writing data by 8051 - 67
23) Square wave generator using Timer in different modes - 69
24) Serial communication - 71
ADDITIONAL PROGRAMS:
1) Arithmetic operations on 8 bit data by using 8051 - 75
2) Stepper Motor Interfacing Using 8255 PPI - 79
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 2
7/30/2019 Microprcessor & Interfacing Lab-2
3/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
INTRODUCITION TO MASM/TASM
ASSEMBLY LANGUAGE PROGRAMMING USING MASM SOFTWARE:
This software is used to write a program (8086, Pentium processors etc.).The programs arewritten using assembly language in editor and then compile it. The complier converts assemblylanguage statements into machine language statements/checks for errors. Then execute the compiled
program. Programs for different processor instructions (Pentium, 8086) programming manner differfor each model.
There are different soft wares developed by different companies for assembly languageprogramming which are:
MASM - Microsoft Company.
TASM - Bore Land Company.
MERITS OF MASM:
1. produces binary code2. Referring data items by their names rather than by their address.
HOW TO ENTER INTO MASM EDITOR:
Click Starton the desktop. Then select Run
Then it Shows inbox
Then type Command (CMD) which enters You into DOS prompt
Path setting
Suppose it display path as C:\ DOCUME-\ADMIN>
Then type CD\
i.e.; C:\DOCUME\\ADMIN>CD\
Then the path is C :\>Then type CD MASM
Then the path is C: MASM>
Then type edit i.e.; C: MASM>edit
Then you enter into MASM text editor.
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 3
7/30/2019 Microprcessor & Interfacing Lab-2
4/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEThen enter to file and select New.And name it and then write the ALP (Assembly Language Program) in this editor.
After that save it as filenamesThen exit from the editor and go to prompt.Then type MASM filename.ASM
I.e. C: MASM>MASM filename.ASM or C: MASM filename.ASM, , ;Then link this file using C: MASM>LINKfilename.OBJor C: MASM>LINK filename.OBJ , , ;
i.e link the program in assembly with DOSthen to debug to create exe file
C:MASM>debug filename. EXE
Then it display --on the screenAfter that type Rdisplays the registers contents steps and starting step of the program.
TTracing at contents of program step by step.
Suppose you need to go for break point debugging. Then type that instruction no where you need tocheck your register. For example T10 it will display the contents of register after executing 10instructions.
DEBUG:
This command utility enables to write and modify simple assembly language programs in aneasy fashion. It provides away to run and test any program in a controlled environment.
We can change any part of the program and immediately execute the program with anhaving to resemble it. We can also run machine language(Object files) directly by using DEBUG
DEBUG COMMANDS:ASSEMBLE A [address] ; Assembly the instructions at a particular addressCOMPARE C range address ; Compare two memory ranges
DUMP D [range] ; Display contents of memory
ENTER E address [list] ; Enter new or modifies memory contents beginning at
specific Location
FILL F range list ; Fill in a range of memory
GO G [=address] [addresses] ; Execute a program in memory
HEX H value1 value2 ; Add and subtract two Hex values
INPUT I port
LOAD L [address] [drive] [first sector] [number]
MOVE M range address
NAME N [pathname] [arg list]
OUTPUT O port byte
PROCEED P [=address] [number]
QUIT Q
REGISTER R [register]
SEARCH S range list
TRACE T [=address] [value]
UNASSEMBLE U [range]
WRITE W [address] [drive] [first sector] [number]ALLOCATE expanded memory XA [#pages]
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 4
7/30/2019 Microprcessor & Interfacing Lab-2
5/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEDEALLOCATE expanded memory XD [handle]
MAP expanded memory pages XM [Lpage] [Ppage] [handle]
DISPLAY expanded memory status XS
EXP. NO : 1 DATE:
ARITHMETIC OPERATIONS ON 8 BIT DATA
ABSTRACT: Assembly language program to perform all arithmetic operations on 8bit dataPORTS USED:NoneREGISTERS USED: AX, BLALGORITHM:
Step1: StartStep2: Initialize data segmentStep3: Copy the contents from memory location [0000] to ALStep4: Copy the contents from memory location [0001] to BLStep 5: Perform additionStep6: Move the result to the memory location [0002]Step7: Copy the contents from memory location [0000] to ALStep8: Perform subtractionStep9: Move the result to the memory location [0003]Step10: Copy the contents from memory location [0000] to ALStep11: Perform multiplicationStep12: Move the result to the memory location [0004]Step13: Copy the contents from memory location [0000] to ALStep14: Perform divisionStep15: Move the result to the memory location [0006]Step16: stop.
PROGRAM:ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 DB 04H
N2 DB 06H
RESULT DB 06H DUP (00)
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATAMOV DS, AX
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 5
7/30/2019 Microprcessor & Interfacing Lab-2
6/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEMOV AL, N1
MOV BL,N2
ADD AL,BL
MOV [RESULT], AL
MOV AL, N1
SUB AL, BL
MOV [RESULT+1], AL
MOV AH,00H
MOV AL, N1MUL BL
MOV [RESULT+2], AL
MOV [RESULT+3], AH
MOV AL, N1
MOV AH, 00H
DIV BL
MOV [RESULT+4], AL
MOV [RESULT+5], AH
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 6
7/30/2019 Microprcessor & Interfacing Lab-2
7/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CALCULATIONS:
MOV AH, 4CH
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 7
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
8/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEINT 21H
CODE ENDS
END START
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 8
7/30/2019 Microprcessor & Interfacing Lab-2
9/90
MICROPROCESSORS LAB MANUAL DEPT OF ECECODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 9
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
10/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 2 DATE: ARITHMETIC OPERATIONS ON 16 BIT DATA
ABSTRACT: Assembly language program to perform all arithmetic operations on 16bit dataPORTS USED: NoneREGISTERS USED: AX, BX, SIALGORITHM:
Step1: StartStep2: Initialize data segmentStep3: Load SI with memory location 5000Step4: Move the contents from memory location [0000] to AXStep5: Move the contents from memory location [0001] to BXStep6: Perform additionStep7: Move the result to the memory location specifiedStep8: Copy the contents from the memory location [0000] to AXStep9: Perform subtraction
Step10: Move the result to the memory location [SI+02]Step11: Copy the contents from the memory location [0000] to AXStep12: Perform multiplicationStep13: Move the result to the memory location [SI+04] & [SI+06]Step14: Copy the contents from the memory location [0000] to AXStep15: Perform divisionStep16: Move the result to the memory location [SI+08] & [SI+0A]Step17: Stop.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 EQU 8888H
N2 EQU 4444H
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
MOV SI, 5000H
MOV AX, N1MOV BX, N2
ADD AX, BX
MOV [SI], AX
MOV AX, N1
SUB AX, BX
MOV [SI+2], AX
MOV DX, 0000H
MOV AX, N1
MUL BX
MOV [SI+4], AX
MOV [SI+6], DX
MOV AX, N1
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 10
7/30/2019 Microprcessor & Interfacing Lab-2
11/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEMOV DX, 0000H
DIV BX
MOV [SI+8], AH
MOV [SI+0AH], DX
CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 11
7/30/2019 Microprcessor & Interfacing Lab-2
12/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
MOV AH, 4CH
INT 21H
CODE ENDS
END START
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 12
7/30/2019 Microprcessor & Interfacing Lab-2
13/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
RESULT:
\
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 13
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
14/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 3 DATE: MULTIBYTE ADDITIONS AND SUBTRACTION
ABSTRACT: Assembly language program to perform multibyte addition and subtractionPORT USED: NoneREGISTERS USED: AL, BX, CXALGORITHM:
Step1: StartStep2: Initialize data segmentStep3: Load the CX register with countStep4: Load the BX register with no: of bytesStep5: Copy the contents from the memory location n1 [bx] to ALStep6: Perform addition with second number n2 [bx]Step7: Move the result to the memory location sum [bx]Step8: Decrement BXStep9: Decrement CX, if CX not equal to Zero jump to step5Step10: Load CX register with countStep11: Load the BX register with no: of bytes
Step12: Move the contents from memory location n1 [bx] to ALStep13: Perform subtraction with second number n2 [bx]Step14: Move the result to the memory location sum [bx]Step15: Decrement BXStep16: Decrement CX, if CX not equal to Zero jump to step12Step17: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 DB 33H, 33H, 33H
N2 DB 11H, 11H, 11H
COUNT EQU 0003H
SUM DB 03H DUP (00)
DIFF DB 03H DUP (00)
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AXMOV CX, COUNT
MOV BX, 0002H
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 14
7/30/2019 Microprcessor & Interfacing Lab-2
15/90
MICROPROCESSORS LAB MANUAL DEPT OF ECECLC
BACK: MOV AL, N1 [BX]
ADC AL, N2 [BX]
MOV SUM [BX], AL
DEC BX
LOOP BACK
MOV CX, COUNT
MOV BX, 0002H
BACK1: MOV AL, N1 [BX]SBB AL, N2 [BX]
CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 15
7/30/2019 Microprcessor & Interfacing Lab-2
16/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
MOV DIFF [BX], AL
DEC BX
LOOP BACK1MOV AH, 4CH
INT 21H
CODE ENDS
END START
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 16
7/30/2019 Microprcessor & Interfacing Lab-2
17/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
RESULT:
CODE TABLE:
CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 17
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
18/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 4 DATE:SIGNED OPERATIONS ON 8 BIT DATA
ABSTRACT: Assembly language program to perform signed operationsPORT USED:NoneREGISTERS USED: AL, BLALGORITHM:
Step1: StartStep2: Initialize data segmentStep3: Load AL with first numberStep4: Negate the contents of ALStep5: Load BL with second numberStep6: Perform signed MultiplicationStep7: Move the result to the memory location [0000]Step8: Load AL with first numberStep9: Negate the contents of ALStep11: Perform signed divisionStep12: Move the result to the memory location [0002]
Step13: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 DB 08H
N2 DB 04H
RESULT DW 02H DUP (00)
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AL, N1
NEG AL
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 18
7/30/2019 Microprcessor & Interfacing Lab-2
19/90
MICROPROCESSORS LAB MANUAL DEPT OF ECECBW
MOV BL, N2
IMUL BL
MOV [RESULT], AX
MOV AL, N1
NEG AL
CBW
IDIV BL
MOV [RESULT+2], AX
MOV AH, 4CHINT 21H
CODE ENDS
END START
RESULT:
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 19
7/30/2019 Microprcessor & Interfacing Lab-2
20/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 20
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
21/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEEXP. NO : 5 DATE:
ASCII ARITHMETIC OPERATIONS
ABSTRACT: Assembly language program to perform ASCII arithmetic operations
PORT USED:None
REGISTERS USED: AL, BL, SI
ALGORITHM:
Step1: Start
Step2: Initialize data segment
Step3: Load SI with Memory location
Step4: Load AL with first number
Step5: Load BL with Second number
Step6: Perform additionStep7: Perform ASCII adjustment after addition
Step8: Copy the result to the memory location [SI]
Step9: Load AL with first number
Step10: Perform subtraction
Step11: Perform ASCII adjustment after subtraction
Step12: Copy the result to the memory location [SI+01]
Step13: Load AL with first numberStep14: Perform multiplication
Step15: Perform ASCII adjustment after multiplication
Step16: Copy the result to the memory location [SI+02]
Step17: Load AL with first number
Step18: Perform division
Step19: Perform ASCII adjustment before division
Step20: Copy the result to the memory location [SI+03]
Step21: Stop
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 21
7/30/2019 Microprcessor & Interfacing Lab-2
22/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 DB 8N2 DB 4
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV SI, 2000H
XOR AX, AX
XOR BX, BXMOV AL, N1
MOV BL, N2
ADD AX, BX
AAA
MOV [SI], AX
MOV AL, N1
MOV AH,00
SUB AL, BL
AAS
MOV [SI+2], AX
MOV AL, 08H
MOV BL, 04H
MUL BL
AAM
MOV [SI+4], AX
AAD
DIV BL
MOV [SI+6], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 22
7/30/2019 Microprcessor & Interfacing Lab-2
23/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 23
7/30/2019 Microprcessor & Interfacing Lab-2
24/90
MICROPROCESSORS LAB MANUAL DEPT OF ECERESULT:
CODE TABLE:
CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 24
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
25/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 6 DATE:
BCD TO ASCII CONVERSIONABSTRACT: Assembly language program to convert BCD number to ASCII numberPORT USED:NoneREGISTERS USED: AL, AH, CXALGORITHM:
Step1: StartStep2: Initialize data segment
Step3: Load AL with BCD numberStep4: Load CX register with count 04HStep5: Copy the contents from AL to AHStep6: Perform AND operation AL with 0FHStep7: Perform AND operation AL with F0HStep8: Rotate the AH contentsStep9: Perform OR operation AL with 30HStep10: Perform OR operation AH with 30HStep11: Move the result to the memory locationStep12: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
BCD DB 17H
ASCII DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV AL, BCD
MOV CL, 04H
MOV AH, AL
AND AL, 0FH
AND AH, 0F0H
ROR AH, CL
OR AL, 30H
OR AH, 30HMOV ASCII, AX
MOV AH, 4CH
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 25
7/30/2019 Microprcessor & Interfacing Lab-2
26/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEINT 21H
CODE ENDS
END START
RESULT:
CODE TABLE:
CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 26
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
27/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 7 DATE:
ASCII TO BCD CONVERSIONABSTRACT: Assembly language program convert ASCII number to BCD number
PORT USED:None
REGISTERS USED: AL, BL, CX
ALGORITHM:
Step1: Start
Step2: Initialize data segment
Step3: Load AL with first ASCII number
Step4: Load CX register with count 04H
Step5: Load BL with second ASCII number
Step6: Perform AND operation AL with 0FH
Step7: Perform AND operation BL with 0FH
Step8: Rotate the contents of AL with CL count
Step9: Perform OR operation AL with BL
Step10: Move the result to the memory location
Step11: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATADATA SEGMENT
ASCII1 DB 1
ASCII2 DB 7
BCD DB ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV CL, 04H
MOV AL, ASCII1
MOV BL, ASCII2AND AL, 0FH
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 27
7/30/2019 Microprcessor & Interfacing Lab-2
28/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEAND BL, 0FH
ROR AL, CL
OR AL, BL
MOV BCD, AL
MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 28
7/30/2019 Microprcessor & Interfacing Lab-2
29/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 8 DATE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 29
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
30/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
NO OF POSITIVE AND NEGATIVE NUMBERS
ABSTRACT: Assembly language program to count number of positive and negative numbers
PORT USED:None
REGISTERS USED: SI, DX, CX, AL
ALGORITHM:
Step1: Start
Step2: Initialize data segment
Step3: Load CX register with count
Step4: Initialize DX with 0000
Step5: Load SI with offset list
Step6: Move the contents from memory location SI to AL
Step7: Rotate left the contents of ALStep8: Jump to step13 if carry
Step9: Increment DL
Step10: Increment SI
Step11: Decrement CX and jump to step6 if no zero
Step12: Jump to step16
Step13: Increment DH
Step14: Increment SI
Step15: Decrement CX and jump to step6 if no zero
Step16: Move the result to the memory location
Step17: Stop
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 30
7/30/2019 Microprcessor & Interfacing Lab-2
31/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB 0FFH, 0DDH, 04H, 05H, 98H
RESULT DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
LEA SI, LISTMOV CX, 0005H
MOV DX, 0000H
BACK: MOV AL, [SI]
ROL AL, 01H
JC NEGATIVE
INC DL
INC SI
LOOP BACK
JMP EXIT
NEGATIVE: INC DH
INC SI
LOOP BACK
EXIT: MOV [RESULT], DX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 31
7/30/2019 Microprcessor & Interfacing Lab-2
32/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CALCULATIONS:
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 32
7/30/2019 Microprcessor & Interfacing Lab-2
33/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 33
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
34/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 9 DATE:
NO OF ODD AND EVEN NUMBERS
ABSTRACT: Assembly language program to count number of odd and even numbers
PORT USED: None
REGISTERS USED: AL, CX, DL, DH, SI
ALGORITHM:
Step1: Start
Step2: Initialize data segment
Step3: Load CX register with count
Step4: Initialize DX with 0000
Step5: Load SI with offset list
Step6: Move the contents from memory location SI to AL
Step7: Rotate right the contents of AL
Step8: Jump to step13 if carry
Step9: Increment DL
Step10: Increment SI
Step11: Decrement CX and jump to step6 if no zero
Step12: Jump to step16
Step13: Increment DH
Step14: Increment SI
Step15: Decrement CX and jump to step6 if no zero
Step16: Move the result to the memory location
Step17: Stop
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 34
7/30/2019 Microprcessor & Interfacing Lab-2
35/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB 05H,01H,03H,04H,08H,02HCOUNT DW 0006H
RESULT DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV CX, COUNT
MOV DX, 0000H
MOV SI, OFFSET LIST
BACK: MOV AL, [SI]
ROR AL, 01H
JC ODD
INC DL
INC SI
LOOP BACK
JMP EXIT
ODD: INC DH
INC SI
LOOP BACK
EXIT: MOV [RESULT], DX
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 35
7/30/2019 Microprcessor & Interfacing Lab-2
36/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEMOV AH, 4CH
INT 21H
CODE ENDS
END START
CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 36
7/30/2019 Microprcessor & Interfacing Lab-2
37/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
RESULT:
CODE TABLE:
CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 37
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
38/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 10 DATE:
PACKED BCD TO UNPACKED BCD CONVERSION
ABSTRACT: Write a program to convert packed BCD number into Unpacked BCD number.REGISTERS USED: AL, BLPORTS USED:None.ALOGARITHM:
Step1: Start
Step2: Initialize the data segmentStep3: Move packed number into AL registerStep4: Move packed number into BL registerStep5: Initialize the count CX with 04H.Step6: AND operation AL with 0FH.Step7: AND operation BL with 0F0H.Step8: Rotate right without carry operation on BL by CL times.Step9: Move the result into location 0000 and 0001.Step10: Stop.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N EQU 29H
RESULT DB 02H DUP (00)
DATA ENDS
CODE SEGMENT
ORG 2000h
START: MOV AX, DATA
MOV DS, AX
MOV AL, N
MOV BL, N
MOV CL, 04H
AND AL, 0FH
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 38
7/30/2019 Microprcessor & Interfacing Lab-2
39/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEAND BL, 0F0H
ROR BL, CL
MOV [RESULT], BL
MOV [RESULT+1], AL
MOV AH, 4CH
INT 21H
CODE ENDSEND START
RESULT:
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 39
7/30/2019 Microprcessor & Interfacing Lab-2
40/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 11 DATE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 40
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
41/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
TRANSFER BLOCK OF DATA
ABSTRACT: Assembly language program to transfer a block of data.PORT USED:None.REGISTERS USED: AX, BL.ALGORITHM:
Step1: StartStep2: Initialize data segment & extra segmentStep3: Load CX register with countStep4: Initialize DI with memory locationStep5: Load SI with offset listStep6: Repeat the process of moving string byte from SI to DI until count equals to zeroStep7: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: DATA
DATA SEGMENT
LIST DB SRI SAI ADITYA
COUNT EQU 14H
DATA ENDS
CODE SEGMENT
ORG 1 000H
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV CX, COUNT
MOV DI, 5000H
LEA SI, LISTREP MOVSB
MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 41
7/30/2019 Microprcessor & Interfacing Lab-2
42/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CALCULATIONS:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 42
7/30/2019 Microprcessor & Interfacing Lab-2
43/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 12 DATE:
REVERSAL OF GIVEN STRING
ABSTRACT: Assembly language program to reverse a given string
PORT USED:None
REGISTERS USED: AX, BL
ALGORITHM:
Step1: Start
Step2: Initialize data segment & extra segment
Step3: Load CX register with countStep4: Copy the contents from CX to AX
Step5: Load SI with offset list
Step6: Initialize DI with (count-1)
Step7: Initialize BX with 02H
Step8: Perform division with BX
Step9: Copy the contents from AX to CX
Step10: Move the contents from memory location SI to ALStep11: Exchange the contents of AL with [DI]
Step12: Move the contents from memory location AL to SI
Step13: Increment SI
Step14: Decrement DI
Step15: Decrement CX and jump to step10 if no zero
Step16: Stop
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 43
7/30/2019 Microprcessor & Interfacing Lab-2
44/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 44
Physical address
Hex
code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
45/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB MICRO PROCESSOR
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 45
7/30/2019 Microprcessor & Interfacing Lab-2
46/90
MICROPROCESSORS LAB MANUAL DEPT OF ECECOUNT EQU ($-LIST)
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV CX, COUNT
MOV AX, CX
MOV SI, OFFSET LIST
MOV DI, (COUNT-1)
MOV BX, 02H
DIV BX
MOV CX, AXBACK: MOV AL,[SI]
XCHG AL,[DI]
MOV [SI], AL
INC SI
DEC DI
LOOP BACK
MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 46
7/30/2019 Microprcessor & Interfacing Lab-2
47/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 47
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
48/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEEXP. NO : 13 DATE:
SORTING OF N NUMBERS
ABSTRACT: Assembly language program to do sorting of numbers in a given series
PORT USED:None
REGISTERS USED: CX, DX, AL, SI
ALGORITHM:Step1: Start
Step2: Initialize data segment
Step3: Load CX register with count
Step4: Copy the contents from CX to DX
Step5: Load SI with offset list
Step6: Copy the contents from DX to CX
Step7: Move the contents from memory location SI to AL
Step8: Increment SI
Step9: Compare AL contents with [SI]
Step10: Jump to step15 if carry
Step11: Exchange the contents of AL with [SI]
Step12: Decrement SI
Step13: Move the contents from AL to memory location SI
Step14: Increment SI
Step15: Decrement CX and jump to step7 if no zero
Step16: Decrement DX and jump to step5 if no zero
Step17: Stop
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 48
7/30/2019 Microprcessor & Interfacing Lab-2
49/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 49
7/30/2019 Microprcessor & Interfacing Lab-2
50/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB 56H, 12H, 72H,32H
COUNT EQU 0003H
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV CX, COUNT
MOV DX, CX
AGAIN: MOV SI, OFFSET LIST
MOV CX, DX
BACK: MOV AL, [SI]
INC SI
CMP AL, [SI]
JC NEXT
XCHG [SI], AL
DEC SI
MOV [SI], AL
INC SI
NEXT: LOOP BACK
DEC DX
JNZ AGAIN
MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 50
7/30/2019 Microprcessor & Interfacing Lab-2
51/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 51
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
52/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
\
EXP. NO : 14 DATE:
LENGTH OF THE GIVEN STRING
ABSTRACT: Assembly language program to find the Length of a stringPORT USED:NoneREGISTERS USED: AX, BLALGORITHM:
Step1: StartStep2: Initialize data segment & extra segmentStep3: Load AL with $
Step4: Load SI with offset listStep5: Initialize DX with 0000Step6: Scan string byte from DI memory location until AL =ES: DIStep7: Jump to step10 if equalStep8: Increment DXStep9: Jump to step6Step10: Move the result to the memory locationStep11: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: DATA
DATA SEGMENT
LIST DB SRI SAI ADITYA$
LEN DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV AL,$
LEA SI, LISTMOV DX, 0000H
BACK: SCASB
JE EXIT
INC DX
JMP BACK
EXIT: MOV LEN, DX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 52
7/30/2019 Microprcessor & Interfacing Lab-2
53/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
RESULT:
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 53
7/30/2019 Microprcessor & Interfacing Lab-2
54/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 54
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
55/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEEXP. NO :15 DATE:
COMPARISON OF TWO STRINGS
ABSTRACT: Assembly language program to compare two strings.PORT USED:NoneREGISTERS USED: AX, BLALGORITHM:
Step1: Start
Step2: Initialize data segment & extra segment
Step3: Load AX with length1
Step4: Load BX with length2
Step5: Compare AX with BX
Step6: Jump step14 if not equal
Step7: Copy the contents from AX to CX
Step8: Load SI with first string
Step9: Load DI with second string
Step10: Repeat comparing string byte until count equals to zero
Step11:jump to step 14 if not equal
Step12: Move the result to the memory location
Step13: Jump to step 15
Step14: Move another result to the memory location
Step15: Stop
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 55
7/30/2019 Microprcessor & Interfacing Lab-2
56/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 56
7/30/2019 Microprcessor & Interfacing Lab-2
57/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: DATALIST1 DB SRI SAI ADITYA
LEN1 EQU ($-LIST1)
LIST2 DB SRI SAI ADITYA
LEN2 EQU ($-LIST2)
RESULT DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV ES, AXMOV AX,LEN1
MOV BX, LEN2
CMP AX, BX
JNE EXIT
MOV CX, AX
MOV SI, OFFSET LIST1
MOV DI, OFFSET LIST2
REP CMPSB
JNE EXIT
MOV RESULT, 5555H
JMP NEXT
EXIT: MOV RESULT, 0FFFFH
NEXT: MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 57
7/30/2019 Microprcessor & Interfacing Lab-2
58/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 58
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
59/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO :16 DATE:
READING KEYBOARD (WITH Echo)
ABSTRACT: To Reading the Keyboard (Buffered with Echo).REGISTERS USED: AH, AL, SI.
PORTS USED:None.ALGORITHM:
Step1: Start.Step2: Load the number 13H into AL register.Step3: Initialize the AH register with 00Step4: Key board InterruptStep5: Initialize the AL register with 00Step6: Key board InterruptStep7: Compare the data in AL register and character q.Step8: If equal to zero go to step 12.Step9: Move the number 0FH into BL register.Step10: Move the number 14 into AH register.Step11: Keyboard Interrupt.
Step12: Load the number 4C in AH registers.Step13: Stop.
PROGRAM:
ASSUME CS: CODE
CODE SEGMENT
ORG 1000H
START: MOV AL, 13H
MOV AH, 00H
INT 10H
BACK: MOV AH, 00H
INT 16HCMP AL, q
JE EXIT
MOV BL, 0FH
MOV AH, 14
INT 10H
JMP BACK
EXIT: MOV AH, 4CH
INT 21H
CODE ENDSEND START
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 59
7/30/2019 Microprcessor & Interfacing Lab-2
60/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
RESULT:
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 60
7/30/2019 Microprcessor & Interfacing Lab-2
61/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 17 DATE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 61
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
62/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
READING KEYBOARD (without echo)
ABSTRACT: To Display the string or character (without ECHO) by using DOS CommandREGISTERS USED: AH, AL, SIPORTS USED:None.ALGORITHM:
Step1: StartStep2: Initialize SI with Offset Result.
Step3: Initialize AH with 00HStep4: Set the wait for KEY press..Step5: Compare AL with q.Step6: Copy the contents AL into SI register.Step7: If equal to zero go to step 10Step8: Increment the value of SI.Step9: Go to step 3 without condition.Step10: Terminate the program.Step11: Stop.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
ORG 3000H
RESULT DB 50h DUP (00)
DATA ENDS
CODE SEGMENT
ORG 1000h
START: MOV SI, OFFSET RESULT
BACK: MOV AH, 00h
INT 16h
CMP AL, qMOV [SI], AL
JE EXIT
INC SI
JMP BACK
EXIT: MOV AH, 4Ch
INT 21h
CODE ENDS
END START
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 62
7/30/2019 Microprcessor & Interfacing Lab-2
63/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 63
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
64/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 18 DATE:
DISPLAY STRING BY USING DOS COMMANDS
ABSTRACT: To display the string character by using DOS commands.REGISTER USED: AL, AH, SI.PORTS USED:NoneALGORITHM:
Step1: StartStep2: Set the screen in Graphic modeStep3: Initialize AH with 00HStep4: Set the keyboard display mode.Step5: Initialize SI with 0000H.Step6: Copy the contents SI into AL register.
Step7: Compare AL register with null character !Step8: If equal go to step 11.Step9: Move the number 14H into AH register.Step10: Move the number 05H into BL register.Step11: Set keyboard display mode.Step12: Go to step 6.Step 13: Terminate the program.Step14: Stop.
PROGRAM:
ASSUME CS: CODE, DS: DATADATA SEGMENT
TEXT DB SRI SAI ADITYA MICROPROCESSORS LAB!'
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV AL, 13H
MOV AH, 00
INT 10H
MOV SI, 00H
BACK: MOV AL, TEXT [SI]CMP AL,'!'
JE EXIT
MOV AH, 14
MOV BL, 05H
INT 10H
INC SI
JMP BACK
EXIT: MOV AH, 4CH
INT 21H
CODE ENDS
END START
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 64
7/30/2019 Microprcessor & Interfacing Lab-2
65/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
RESULT:
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 65
Physical addressHex code
MnemonicsCommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
66/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 19 DATE:
To generate square waveform by DAC interfacing with 8086
AIM: To generate square waveform by DAC interfacing with 8086 kit
REGISTERS USED: general purpose registers: AL, CXPORTS USED: PORT A.ALGORITHM :
Step 1: Start
Step 2: Load AL with 80H.Step 3: Write AL onto the address 26H.Step 4: Load AL with 00.Step 5: Write AL onto the address 20H.Step 6: Jump to step 11.Step 7: Load AL with 0FFH.Step 8: Write AL onto the address 20HStep 9: Jump to step 11.Step 10: Jump to step 4.Step 11: Load CX with 93HStep 12:. If CX not equal to zero,jump to step 12
. otherwise goto step 13.Step 13: Return to main program.Step 14: Stop.
PROGRAM:
MOV AL,80H
OUT 26H,AL
AGAIN: MOV AL,00H
OUT 20H,AL
CALL DELAY
MOV AL,0FFH
OUT 20H,AL
CALL DALAY
JMP AGAIN
DELAY: MOV CX,093H
BACK: LOOP BACK
RET
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 66
7/30/2019 Microprcessor & Interfacing Lab-2
67/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
RESULT:
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 67
7/30/2019 Microprcessor & Interfacing Lab-2
68/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 68
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
69/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEEXP. NO : 20 DATE:
To generate triangular waveform by DAC interfacing with 8086
AIM: To generate triangular waveform by DAC interfacing with 8086 kit.
REGISTERS USED: general purpose registers: AL, CXPORTS USED: PORT A
ALGORITHM:
Step 1: StartStep 2: Load AL with 80H.Step 3: Write AL onto the address 26H.Step 4: Load AL with 00.Step 5: Load register CX with 0FFHStep 6: Write AL onto the address 20H.Step 7: Increment value of AL.Step 8: Decrement CX.Step 9: If CX not equal to zero,jump to step 6.Step 10:Load CX with 0FFHStep 11:Write AL onto the address 20H.Step 12:Decrement AL.Step 13:Decrement CX.Step 14:.If CX not equal to zero,jump to step 10.Step 15: Jump to step 12.Step 16: Stop.
Program:
MOV AL,80H
OUT 26H,AL
AGAIN: MOV AL,00H
MOV CX,0FFH
BACK: OUT 20H,AL
INC AL
DEC CX
JNZ BACK
MOV CX,0FFH
BACK1: OUT 20H,AL
DEC ALDEC CX
JNZ BACK1
JMP AGAIN
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 69
7/30/2019 Microprcessor & Interfacing Lab-2
70/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 70
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
71/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 21 DATE:
KEYBOARD INTERFACINGAIM:To display a string through interfacing 8279 by using 8086.
REGISTERS USED: AX, BX, CX, DX, SI
PORTS USED: command port, data port
ALGORITHM:
Step1: Start
Step2: Load SI with 1200H.
Step3: Load CX with 000FH.
Step4: Load al with 10H
Step5: Write al onto address C2H
Step6: Load al with CCH
Step7: Write al onto address C2H
Step8: Load al with 90H
Step9: Write al onto address C2H
Step10: Load al with contents of SI
Step11: Write al onto address C0H
Step12: Jump to step 16
Step13: Increment SI
Step14: Decrement CX if not equal to zero.
Step 15: Jump to step 12
Step 16: Load DX with 0A0FFHStep 17:.Decrement DX
Step18: If DX not equal to zero jump to step 17 otherwise jump to step 18.
Step 19:Return to main program
Step 20: Stop
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 71
7/30/2019 Microprcessor & Interfacing Lab-2
72/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 72
7/30/2019 Microprcessor & Interfacing Lab-2
73/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
PROGRAM:
START: MOV SI,1200H
MOV CX, 000FH
MOV AL, 10H
OUT 0C2, AL
MOV AL, 0CCH
OUT 0C2, AL
MOV AL,90H
OUT 0C2,AL
NEXT: MOV AL,[SI]
OUT 0C0,AL
CALL DELAY
INC SI
LOOP NEXT
JMP START
DELAY: MOV DX,0A0FFH
LOOP: DEC DX
JNZ LOOP
RET
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 73
7/30/2019 Microprcessor & Interfacing Lab-2
74/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 74
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effectiv
e
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
75/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 75
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effectiv
e
address
Opcode Operan
d
7/30/2019 Microprcessor & Interfacing Lab-2
76/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 22 DATE:
Reading & Writing data from parallel port by using 8051 kit
Aim : To perform reading & writing data from parallel port by using 8051 kit
Ports used: noneRegisters used: A,DPTR
Algorithm:
Step 1: StartStep 2: Move FFH into the port 1Step 3: Move contents into port1 into register AStep 4: Move 4150H into register DPTRStep 5: Move contents of register a into contents of DPTRStep 6: Jump to step 6Step 7: Move 55 into register A
Step 8: Move contents of register A into the port1Step 9: Jump to step 9Step 10:Stop
PROGRAM FOR READING :
MOV P1,#0FFH
MOV A, P1
MOV DPTR,#4150H
MOVX @DPTR,AHLT: SJMP HLT
PROGRAM FOR WRITING :
MOV A,#55H
MOV P1,A
HLT: SJMP HLT
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 76
7/30/2019 Microprcessor & Interfacing Lab-2
77/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 77
Physical address
Hex code
Mnemonics
CommentsSegmentaddress
Effectiveaddress
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
78/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 23 DATE:
Write a program to generate square wave using timer in different modes
by using 8051
AIM:To generate square wave using timer in different modes by using 8051
REGISTERS USED: general purpose registers: AL, CXPORTS USED: PORT A
ALGORITHM:
Step 1: StartStep 2: Move 01 into the register tmodStep 3: Move 3e into the register tl0Step 4: Move 3b into the register th0Step 5: Compliment part1Step 6: Setbit the register bits tcon.4Step 7: Compare the value of tf0 and 4100 jump if not belowStep 8: Clear the 5th bit of register tcon.4Step 9: Clear the 6th bit of register tcon.5
Step 10: Jump to step2Step 11: Stop
Program:
AGAIN: MOV TMOD,#01
MOV TL0,#3E
MOV TH0,#3B
CPL P1(90)
SETB TCON.4(8C)
HERE: JNB TF0(8D),HERE
CLR TCON.4(8C)
CLR TCON.5(8D)
SJMP AGAIN
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 78
7/30/2019 Microprcessor & Interfacing Lab-2
79/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
RESULT:
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 79
7/30/2019 Microprcessor & Interfacing Lab-2
80/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 80
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
81/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEEXP. NO : 24 DATE:
Serial communication
AIM: To transmit data serially to the pc at baud rate 9600
REGISTERS USED: General purpose registers: AL, CX
PORTS USED: PORT A
ALGORITHM:
Step1: Start
Step2: Load R0 with 06H
Step3: Load DPTR with 4150H
Step4: Load SCON with 50H
Step5: Load TMOD with 20H
Step6: Load TH1 with FD
Step7: Set bit TR1
Step8: Load A with contents of DPTR
Step9: Load SBUF with contents of A
Step10: Repeat the step 10 until TI=1 i.e check whether TI=1 if TI=1 go to step 8
Step11: Clear TI
Step12: Increment DPTR
Step13: Decrement R0, if R0#0,goto step 8
Step14: Jump to step2
Step15: Stop
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 81
7/30/2019 Microprcessor & Interfacing Lab-2
82/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 82
7/30/2019 Microprcessor & Interfacing Lab-2
83/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
PROGRAM:
AGAIN: MOV R0,#06H
MOV DPTR,#4150H
MOV SCON,#50H
MOV TMOD,#20H
MOV TH1,#0FDH
SETB 8EH
NEXT: MOVX A,@DPTR
MOV SBUF,A
HERE: JNB 99H,HERE
CLR TI
INC DPTR
DJNZ R0,NEXT
SJMP AGAIN
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 83
7/30/2019 Microprcessor & Interfacing Lab-2
84/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 84
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effective
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
85/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
EXP. NO : 25 DATE:
Arithmetic operations on 8bit data by using 8051 kit
Aim: to perform arithmetic operation on 8bit data using 8051 kit
Ports used: none
Registers used: a,b,dptr
Algorithm:
Step1: Start
Step2: Move 20 into the register A.
Step3: Add the contents of register A with 30, along with carry.
Step4: Move 4150 to register DPTR
Step5: Move the contents of register A into contents of data pointer.
Step6: Move 6 into register AStep7: Subtract the contents of register A from 3 with borrow.
Step8: Increment DPTR
Step9: Move the contents of register A into contents of data pointer.
Step10: Move 6 into register A.
Step11: Move 2 into register B.
Step12: Perform multiplication on contents of register A,B.
Step13: Increment DPTR
Step14: Move the contents of register A into contents of data pointer.
Step15: Move 8 into register A.
Step16: Move 4 into register B.
Step17: Perform division on contents of register A,B.
Step18: Increment DPTR
Step19: Move the contents of register A into contents of data pointer.
Step20: Stop
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 85
7/30/2019 Microprcessor & Interfacing Lab-2
86/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 86
7/30/2019 Microprcessor & Interfacing Lab-2
87/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
PROGRAM:
MOV A,#20H
ADDC A,#30H
MOV DPTR,#4150H
MOVX @DPTR,A
MOV A,#06H
SUBB A,#03H
INC DPTR
MOVX @DPTR,A
MOV A,#06H
MOV B,#02H
MUL AB
INC DPTR
MOVX @DPTR,A
MOV A,#08H
MOV B,#04H
DIV AB
INC DPTR
MOVX @DPTR,A
HLT: SJMP HLT
RESULT:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 87
7/30/2019 Microprcessor & Interfacing Lab-2
88/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
CODE TABLE:
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 88
7/30/2019 Microprcessor & Interfacing Lab-2
89/90
MICROPROCESSORS LAB MANUAL DEPT OF ECE
SRI SAI ADITYA INSTITUTE OF SCIENCE&TECHNOLOGY 89
Physical address
Hex code
Mnemonics
CommentsSegment
address
Effectiv
e
address
Opcode Operand
7/30/2019 Microprcessor & Interfacing Lab-2
90/90
MICROPROCESSORS LAB MANUAL DEPT OF ECEEXP. NO : 26 DATE:
STEPPER MOTOR INTERFACING
AIM: Program to design a stepper motor to rotate shaft of a 4 phase stepper motor in clockwiserotations.REGISTERS USED: General purpose registers: AL , DX , CXPORTS USED: Port B, port C (out)ALGORITHM:
Step 1: StartStep 2: Load dx with 0026Step 3: Load AX with 80h.Step 4: Write AX onto the DX register.Step 5: Load DX with 20hStep 6: Load AX with 00hStep 7: Write DX onto the AX registerStep 8: Load BX with 2300Step 9: Decrement BXStep 10: If BX not equal to zero jump to step 9 otherwise jump to step 11.Step 11: Load CL with 01hStep 12: Rotate AL left CL no.of timesStep 13: Goto step 7Step 14: Stop.
PROGRAM:
MOV DX, 0026H
MOV AX, 80H
OUT DX, AX
MOV DX,20H
MOV AX, 0011
RPT: OUT DX, AXMOV BX, 0300
DELAY: DEC BX
JNZ DELAY
MOV CL,01H
ROL AL, CL
JMP RPT
Recommended