65796993-r05-mp-lab-journal
Post on 26-Aug-2014
167 Views
Preview:
TRANSCRIPT
MICROPROCESSORS LAB MANUAL ECE Dept.
CONTENTS
Page no.
1. List of Experiments (as per JNTU) -1, 2
2. Microprocessor 8086 Programming
2.1 Introduction to MASM and TASM - 5
2.2 Arithmetic operationsa) Arithmetic Operations on 8 bit data - 8
b) Arithmetic Operations on 16 bit data -
14
c) Multibyte addition and subtraction -
20
d) Signed Operations on 8 bit data -
26
e) ASCII Arithmetic Operations -
31
2.3 Logic OperationsBCD to ASCII Conversion - 37
ASCII to BCD Conversion - 41
No. of Positive no’s & Negative no’s. - 45
No. of Odd no’s & Even no’s. - 51
Packed BCD to Unpacked BCD Conversion - 57
2.4 String OperationsTransfer Block of Data - 62
Reversal of given String - 66
Sorting of ‘N’ numbers - 72
Length of the given String - 78
Comparison of two Strings - 82
2.5 DOS/BIOS Programming
Reading Keyboard buffered with echo - 88
ADITYA ENGINEERING COLLEGE 1
MICROPROCESSORS LAB MANUAL ECE Dept.
Reading Keyboard buffered with out echo - 91
Display String by using DOS Commands - 94
Page no.
3. Interfacing with 8086
3.1. Programmable Peripheral Interfacing (8255) - 97
a) Digital to Analog Converters - 110
3.2. Keyboard Display Interfacing (8279) - 130
ADDITIONAL PROGRAMS
Dual Slope Analog to Digital Converter - 143
Stepper Motor Interfacing Using 8255 PPI - 150
ADITYA ENGINEERING COLLEGE 2
MICROPROCESSORS LAB MANUAL ECE Dept.LIST OF EXPERIMENTS
III Year B.Tech, ECE –II semester.II Year B.Tech, CSE & IT – II Semester
I MICROPROCESSOR 8086:
1. Introduction to MASM and TASM
2. Arithmetic Operations – Multi byte addition and subtraction, Multiplication and division-signed and unsigned Arithmetic operation, ASCII-arithmetic operation
3. Logic operations-Shift and rotate-Converting packed BCD to unpacked BCD, BCD to ASCII conversion.
4. By using string operation and Instruction prefix: Move Block, Reverse string, Sorting, Inserting. Deleting, length of the string, String comparison.
5. DOS/BIOS programming: Reading keyboard (with Buffered and without echo)-Display characters, Strings.
II. INTERFACING:
1. 8259-Interrupt controller : Generate an interrupt using 8259 timer.
2. 8279-Keyboard Display : Write a small program to display a string of Characters.
3. 8255-PPI : Write an ALP to generate sinusoidal wave Using PPI
4. 8251-USART : Write a program in ALP to establishcommunication between two processors
III. MICROCONTROLLER 8051:
1. Reading and Writing on a parallel port.
2. Timer in different modes.
3. Serial communication implementation.
ADITYA ENGINEERING COLLEGE 3
MICROPROCESSORS LAB MANUAL ECE Dept.LIST OF EXPERIMENTS
IV YEAR B.TECH EEE – I SEMESTERI MICROPROCESSOR 8086:
1. Introduction to MASM and TASM
2. Arithmetic Operations – Multi byte addition and subtraction, Multiplication and division-signed and unsigned Arithmetic operation, ASCII-arithmetic operation
3. Logic operations-Shift and rotate-Converting packed BCD to unpacked BCD, BCD to ASCII conversion.
4. By using string operation and Instruction prefix: Move Block, Reverse string, Sorting, Inserting. Deleting, length of the string, String comparison.
5. DOS/BIOS programming: Reading keyboard (with Buffered and without echo)-Display characters, Strings.
II. INTERFACING:
1. 8259-Interrupt controller : Generate an interrupt using 8259 timer.
2. 8279-Keyboard Display : Write a small program to display a string of Characters.
3. 8255-PPI : Write an ALP to generate sinusoidal wave Using PPI
4. 8251-USART : Write a program in ALP to establishcommunication between two processors
III. MICROCONTROLLER 8051:
1. Reading and Writing on a parallel port.
2. Timer in different modes.
3. Serial communication implementation.
4. Understanding three memory areas of 00-FF(Programs using above areas).
5. Using external Interrupts.
6. Programs using special instructions like swap, bit/byte, set/reset etc.
7. Programs based on short, page, absolute addressing.
ADITYA ENGINEERING COLLEGE 4
MICROPROCESSORS LAB MANUAL ECE Dept.
INTRODUCITION TO MASM/TASM
ASSEMBLY LANGUAGE PROGRAMMING USING MASM SOFTWARE:
This software used to write a program (8086, Pentium processors etc.)The programs are written using assembly language in editor then compile it. The complier converts assembly language statements into machine language statements/checks for errors. Then execute the compiled program. Programs for different processor instructions (Pentium, 8086) programming manner differ for each model.
There are different soft wares developed by different companies for assembly language programming are:
• MASM - Microsoft Company.• TASM - Bore Land Company.
MERIT OF MASM:
1. produces binary code2. Referring data items by their names rather than by their address.
HOW TO ENTER INTO MASM EDITOR:
Click “Start” on 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
ADITYA ENGINEERING COLLEGE 5
MICROPROCESSORS LAB MANUAL ECE Dept.Then you enter into MASM text editor.
Then 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 filename’sThen exit from the editor and go to prompt.Then type MASM filename.ASMI.e. C: MASM>MASM filename.ASM or C: MASM filename.ASM, , ;Then link this file using C: MASM>LINK filename.OBJ or C: MASM>LINK filename.OBJ , , ;i.e link the program in assembly with DOS then to debug to create exe fileC:MASM>debug filename. EXEThen it display “--” on the screenAfter that type ‘R’ displays the registers contents steps and starting step of the program.
‘T’ Tracing at contents of program step by step.Suppose you need to go for break point debugging. Then type that instruction no where you need to check your register. For example T10 it will display the contents of register after executing 10 instructions.
DEBUG:This command utility enables to write and modify simple assembly language programs in
an easy 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 an
having 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 address
COMPARE 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]
ADITYA ENGINEERING COLLEGE 6
MICROPROCESSORS LAB MANUAL ECE Dept.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]
DEALLOCATE expanded memory XD [handle]
MAP expanded memory pages XM [Lpage] [Ppage] [handle]
DISPLAY expanded memory status XS
ADITYA ENGINEERING COLLEGE 7
MICROPROCESSORS LAB MANUAL ECE Dept.
2.2 a) ARITHMETIC OPERATIONS ON 8BIT DATA
ABSTRACT: Assembly language program to perform all arithmetic operations on 8bit data
PORTS USED: None
REGISTERS USED: AX, BL
ALGORITHM:
Step1: Start
Step2: Initialize data segment
Step3: Copy the contents from memory location [0000] to AL
Step4: Copy the contents from memory location [0001] to BL
Step 5: Perform addition
Step6: Move the result to the memory location [0002]
Step7: Copy the contents from memory location [0000] to AL
Step8: Perform subtraction
Step9: Move the result to the memory location [0003]
Step10: Copy the contents from memory location [0000] to AL
Step11: Perform multiplication
Step12: Move the result to the memory location [0004]
Step13: Copy the contents from memory location [0000] to AL
Step14: Perform division
Step15: Move the result to the memory location [0006]
Step16: stop.
ADITYA ENGINEERING COLLEGE 8
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Copy the contents from memory location [0000] to AL
Perform addition
Move the result to the memory location [0002]
Copy the contents from memory location [0000] to AL
Perform subtraction
Move the result to the memory location [0003]
Copy the contents from memory location [0000] to AL
Perform multiplication
1
Initialize data segment
FLOW CHART
9
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Move the result to the memory location [0004]
Copy the contents from memory location [0000] to AL
Perform division
Move the result to the memory location [0006]
Stop
10
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:ASSUME CS: CODE, DS: DATA
DATA SEGMENTN1 EQU 04HN2 EQU 06HRESULT DB 04H DUP (00)DATA ENDSCODE SEGMENTSTART:
MOV AX , DATA
MOV DS , AX
MOV AL , N1
MOV BL, N2
ADD AL, BL
MOV [RESULT], AL
MOV AL, N1
SUB AL, BL
MOV [RESULT+1], AL
MOV AL, N1
MUL 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
MOV AH, 4CHINT 21H
CODE ENDSEND START
ADITYA ENGINEERING COLLEGE 11
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
RESULT: D 0000 04 06 0A FE 18 00 00 04
ADITYA ENGINEERING COLLEGE
Physical address Label Hex code Mnemonics Comments Segment address
Effective address
Opcode Operand
OD64 0000
0003
0005
0008
000C
000E
0011
0014
0016
0019
001C
001E
0021
0025
0028
002A
002C
002F
0033
0035
B8630D
8ED8
A00000
8A1E0100
02C3
A20200
A00000
2AC3
A20300
A00000
F6E3
A20400
88260500
A00000
B400
F6F3
A20600
88260700
B44C
CD21
MOV AX,0D63
MOV DS,AX
MOV AL,[0000]
MOV BL,[0001]
ADD AL,BL
MOV [0002],AL
MOV AL,[0000]
SUB AL,BL
MOV [0003],AL
MOV AL,[0000]
MUL BL
MOV [0004],AL
MOV [0005],AH
MOV AL,[0000]
MOV AH,00
DIV BL
MOV [0006],AL
MOV [0007],AH
MOV AH,4C
INT 21
;Initialize data segment
;Move the contents to AL
;Move the contents to BL
;Add BL contents with AL
;Move the contents to memory;Move the contents to AL
;Subtract BL contents with AL;Move the contents to memory;Move the contents to AL
;Multiply the contents of BLwithAL;Move the contents from AH
;Move the contents to AH
;Move the contents to AL
;Move 00 into AH register
;Division the contents of BL with AL;Move the contents to AL
;Move the contents from AH
;Terminate the Program
;Stop
12
MICROPROCESSORS LAB MANUAL ECE Dept.VIVA-VOCE QUESTIONS
1. What is meant by microprocessor?
2. What was the first company to bring out the microprocessor?
3. What was the semiconductor technology used for fabrication of the 8086µ P?
4. What are the main blocks of the microprocessor?
5. What is the word size of the 8086 µ P?
ADITYA ENGINEERING COLLEGE 13
MICROPROCESSORS LAB MANUAL ECE Dept.2.2(b) ARITHMETIC OPERATIONS ON 16BIT DATA
ABSTRACT: Assembly language program to perform all arithmetic operations on 16bit data
PORTS USED: None
REGISTERS USED: AX, BX, SI
ALGORITHM:
Step1: Start
Step2: Initialize data segment
Step3: Load SI with memory location 5000
Step4: Move the contents from memory location [0000] to AX
Step5: Move the contents from memory location [0001] to BX
Step6: Perform addition
Step7: Move the result to the memory location specified
Step8: Copy the contents from the memory location [0000] to AX
Step9: Perform subtraction
Step10: Move the result to the memory location [SI+02]
Step11: Copy the contents from the memory location [0000] to AX
Step12: Perform multiplication
Step13: Move the result to the memory location [SI+04] &[SI+06]
Step14: Copy the contents from the memory location [0000] to AX
Step15: Perform division
Step16: Move the result to the memory location [SI+08]&[SI+0A]
Step17: Stop.
ADITYA ENGINEERING COLLEGE 14
MICROPROCESSORS LAB MANUAL ECE Dept. :
ADITYA ENGINEERING COLLEGE
Start
Move the contents from memory location [0000] to AX
Move the contents from memory location [0001] to BX
Perform addition
Move the result to the memory location specified
Copy the contents from the memory location [0000] to AX]
Perform subtraction
Move the result to the memory location [SI+02]
1
Initialize data segment
Load SI with memory location 5000
FLOW CHART
15
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Copy the contents from the memory location [0000] to AX
Perform multiplication
Move the result to the memory location [SI+04] &[SI+06]
Copy the contents from the memory location [0000] to AX
Stop
Perform division
Move the result to the memory location [SI+08] &[SI+0A]
16
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENTN1 EQU 8888HN2 EQU 4444HDATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV SI, 5000H
MOV AX, N1
MOV BX, N2
ADD AX, BX
MOV [SI], AX
MOV AX, N1
SUB AX, BX
MOV [SI+2], AX
MOV AX, N1
MUL BX
MOV [SI+4], AX
MOV [SI+6], DX
MOV AX, N1
MOV DX, 0000
DIV BX
MOV [SI+8], AX
MOV [SI+0AH], DX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
ADITYA ENGINEERING COLLEGE 17
MICROPROCESSORS LAB MANUAL ECE Dept.Physical address Label Hex code Mnemonic Operand CommentsSegment address
Effective address
0D64 0000
0003
0005
0008
000B
000F
0011
0013
0016
0018
001B
001E
0020
0023
0026
0029
002C
002E
0031
0034
0036
B8 63 0D
8E D8
BE 00 50
A1 00 00
8B 1E 02 00
03 C3
89 04
A1 00 00
2B C3
89 44 02
A1 00 00
F7 E3
89 44 04
89 54 06
A1 00 00
BA 00 00
F7 F3
89 44 08
89 54 0A
B4 4C
CD 21
MOV AX,0D63
MOV DS,AX
MOV SI,5000
MOV AX,[0000]
MOV BX,[0002]
ADD AX,BX
MOV [SI],AX
MOV AX,[0000]
SUB AX,BX
MOV [SI+02],AX
MOV AX,[0000]
MUL BX
MOV [SI+04]AX
MOV [SI+06],BX
MOV AX,[0000]
MOV DX,0000
DIV BX
MOV [SI+08],AX
MOV [SI+0AH],AX
MOV AH,4C
INT 21h
;Initialize data segment
;Initialize SI with 5000
;copy the contents of 0000;Copy the contents of 0002;Add the contents of AX with BX;Copy the result in [SI]
;copy the contents of 0000;Subtract the contents of AX with BX;Move the result into [SI+2];Copy the contents of 0000;Multiply AX with BX
;Move the lower word of result into [SI+4];Move the higher word of result into [SI+6];Copy the contents of 0000;Initialize DX with 0000
;Perform division with BX;Move the quotient into [SI+8];Move the remainder into [SI+0A];Terminate the program
RESULT: D 5000: CC CC 44 44 20 64 68 24 02 00 00 00
VIVA-VOCE QUESTIONS
ADITYA ENGINEERING COLLEGE 18
MICROPROCESSORS LAB MANUAL ECE Dept.
1. Which technique is used in Stacks?
2. Give the number of flags in 8086 µ P?
3. What are the different interrupts in 8086 µ P?
4. How many address lines are there in 8086 µ P?
5. What are the different addressing modes available in 8086 µ P?
ADITYA ENGINEERING COLLEGE 19
MICROPROCESSORS LAB MANUAL ECE Dept.2.2 (C) MULTIBYTE ADDITIONS AND SUBTRACTION
ABSTRACT: Assembly language program to perform multibyte addition and subtraction
PORT USED: None
REGISTERS USED: AL, BX, CX
ALGORITHM:
Step1: Start
Step2: Initialize data segment
Step3: Load the CX register with count
Step4: Load the BX register with no: of bytes
Step5: Copy the contents from the memory location n1 [bx] to AL
Step6: Perform addition with second number n2 [bx]
Step7: Move the result to the memory location sum [bx]
Step8: Decrement BX
Step9: Decrement CX, if CX not equal to Zero jump to step5
Step10: Load CX register with count
Step11: Load the BX register with no: of bytes
Step12: Move the contents from memory location n1 [bx] to AL
Step13: Perform subtraction with second number n2 [bx]
Step14: Move the result to the memory location sum [bx]
Step15: Decrement BX
Step16: Decrement CX, if CX not equal to Zero jump to step12
Step17: Stop
ADITYA ENGINEERING COLLEGE 20
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Copy the contents from the memory location n1 [bx] to AL
Perform addition with second number n2 [bx]
Move the result to the memory location sum [bx]
Decrement BX
1
Initialize data segment
Get count into CX register
Load the BX register with no: of bytes
Decrement CX, &CX = 0
no
YES
FLOW CHART
21
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Move the contents from memory location n1 [bx] to AL
Perform subtraction with second number n2 [bx]
Move the result to the memory location sum [bx]
Stop
Decrement BX
Decrement CX, &If CX = 0
Get count into CX register &Load BX register with no of
bytes
no
YES
22
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:ASSUME CS: CODE, DS: DATADATA SEGMENTN1 DB 33H, 33H, 33HN2 DB 11H, 11H, 11HCOUNT EQU 0003HSUM DB 03H DUP (00)DIFF DB 03H DUP (00)DATA ENDSCODE SEGMENTORG 1000HSTART: MOV AX, DATA
MOV DS, AX
MOV CX, COUNT
MOV BX, 0002H
CLCBACK: 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]
MOV DIFF [BX], AL
DEC BX
LOOP BACK1
MOV AH, 4CH
INT 21H
CODE ENDSEND START
ADITYA ENGINEERING COLLEGE 23
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Physical address Label
Hex code Mnemonic Operand commentsSegment address
Effective address
0D64 1000
1003
1005
1008
100B
100F
1013
1017
1018
101A
101D
1020
1024
1028
102C
102D
102F
1031
L1
L2
B8 63 0D
8E D8
B9 03 00
BB 02 00
8A 87 00 00
12 87 00 00
88 87 06 00
4B
E2 F1
B9 03 00
BB 02 00
8A 87 00 00
1A 87 03 00
88 87 09 00
4B
E2 F1
B4 4C
CD 21
MOV AX,0D63
MOV DS,AX
MOV CX,0003
MOV BX,0002
MOV AL,[BX+0000]
ADC AL,[BX+0003]
MOV [BX+0006],AL
DEC BX
LOOP L1
MOV CX,0003
MOV BX,0002
MOV AL,[BX+0000]
SBB AL,[BX+0003]
MOV [BX+0009],AL
DEC BX
LOOP 1020
MOV AH,4C
INT 21
;Initialize the data segment
;Initialize the count CX with 0003;Move the value 02 in BX register;Copy the contents of BX+0000
;Perform ADC with[BX+0000]
;Move the result in BX+0006 location;Decrement the contents of BX
;Decrement the counter and go to L1 until CX is zero;Initialize the counter CX with 0003;Move the number 02 in BX register ;Copy the contents of BX+0000
;Perform SBB with [BX+0003]
;Move the result in BX+0009 location;Decrement the contents of BX
;Decrement the counter and go to L2 until CX is zero
;Terminate the program
RESULT:
D 0000: 33 33 33 11 11 11 44 44 44 22 22 22
VIVA-VOCE QUESTIONS
ADITYA ENGINEERING COLLEGE 24
MICROPROCESSORS LAB MANUAL ECE Dept.
6. What is the word length of 8086 µ P?
7. Which signal is used to separate address and data bus?
8. How many multiplexed lines are there in 8086 µ P?
9. What is the maximum memory addressing and I/O addressing capability of 8086 µ P?
10. From which the 8086 µ P starts execution after reset?
ADITYA ENGINEERING COLLEGE 25
MICROPROCESSORS LAB MANUAL ECE Dept.2.2 d) SIGNED OPERATIONS ON 8 BIT DATA
ABSTRACT: Assembly language program to perform signed operations
PORT USED: None
REGISTERS USED: AL, BL
ALGORITHM:
Step1: Start
Step2: Initialize data segment
Step3: Load AL with first number
Step4: Negate the contents of AL
Step5: Load BL with second number
Step6: Perform signed Multiplication
Step7: Move the result to the memory location [0000]
Step8: Load AL with first number
Step9: Negate the contents of AL
Step11: Perform signed division
Step12: Move the result to the memory location [0002]
Step13: Stop
ADITYA ENGINEERING COLLEGE 26
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Negate the contents of AL
Perform signed Multiplication
1
Initialize data segment
Get a first number in AL register
Load BL with second number
Get a first number in AL register
Negate the contents of AL
Move the result to the memory location [0000]
FLOW CHART
27
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Perform signed division
Move the result to the memory location [0002]
Stop
Decrement CX, if CX not equal to Zero jump to step12
28
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE , DS: DATADATA SEGMENTN1 DB 08HN2 DB 04HRESULT DW 02 DUP (00)DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AL, N1
NEG AL
CBW
MOV BL, N2
IMUL BL
MOV [RESULT], AX
MOV AL, N1
NEG AL
CBW
IDIV BL
MOV [RESULT+2], AX
MOV AH, 4CH
INT 21H
CODE ENDSEND START
ADITYA ENGINEERING COLLEGE 29
MICROPROCESSORS LAB MANUAL ECE Dept.CODE TABLE:
Physical address Label Hex code Mnemonic Operand comments
Segment address
Effective address
0D64 0000
0003
0005
0008
000A
000B
000F
0011
0014
0017
0019
001A
001C
001F
0021
B8 63 0D
8E D8
A0 00 00
F6D8
98
8A 1E 01 00
F6 EB
A3 02 00
A0 00 00
F6 D8
98
F6 FB
A3 04 00
B4 4C
CD 21
MOV AX,0D63
MOV DS,AX
MOV AL,[0000]
NEG AL
CBW
MOV BL,[0001]
IMUL BL
MOV [0002],AX
MOV AL,[0000]
NEG AL
CBW
IDIV BL
MOV [0004],AX
MOV AH,4C
INT 21
;Initialize the data segment
;Copy the [0000] in AL
;Negate contents of AL
;Convert Byte to Word
;Get second number in BL
;Perform IMUL with BL
;Move the result into [0002]
;Get first number in AL
;Negate the contents of AL
;Convert Byte to Word
;Perform IDIV with BL
;Move the result into [0004]
;Terminate the program
RESULT:D 0000: 08 04 E0 FF FE 00 00 00
VIVA-VOCE QUESTIONS
11. How does the 8086 µ P differentiate between an opcode and instruction data?
12. Which interrupt is having the highest priority?
13. what do you mean by addressing modes?
14. What is the addressing mode of an instruction communicated to the cpu?
15. What are the assembler directives?
ADITYA ENGINEERING COLLEGE 30
MICROPROCESSORS LAB MANUAL ECE Dept.2.2 e) 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 addition
Step7: 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 number
Step14: 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
ADITYA ENGINEERING COLLEGE 31
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Perform addition
Copy the result to the memory location [SI]
Perform subtraction
Perform ASCII adjustment after addition
1
Initialize data segment
Initialize SI with memory location
Get a first ASCII no in AL register
Get second ASCII no in BL register
Get first ASCII no in AL register & second ASCII no in BL register
FLOW CHART
32
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Perform ASCII adjustment after subtraction
Copy the result to the memory location [SI+01]
Stop
Perform multiplication
Perform ASCII adjustment after multiplication
Copy the result to the memory location [SI+02]
Perform division
Perform ASCII adjustment before division
Copy the result to the memory location [SI+03]
Get first ASCII no in AL register & second ASCII no in BL register
Get first ASCII no in AL register & second ASCII no in BL register
Decrement CX, if CX not equal to Zero jump to step12
33
MICROPROCESSORS LAB MANUAL ECE Dept.PROGRAM:
ASSUME CS: CODE, DS: DATADATA SEGMENTN1 DB ‘8’N2 DB ‘4’DATA ENDS
CODE SEGMENTORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV SI, 1000H
XOR AX, AX
XOR BX, BX
MOV AL, N1
MOV BL, N2
ADD AX, BX
AAA
MOV [SI], AX
XOR AX, AX
MOV AL, N1
SUB AL, BL
AAS
MOV [SI+2], AX
MOV AL, 08H
MOV BL, 04H
MUL BL
AAM
MOV [SI+4], AX
ADITYA ENGINEERING COLLEGE 34
MICROPROCESSORS LAB MANUAL ECE Dept.
AAD
DIV BL
MOV [SI+6], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical address Label Hex code Mnemonic Operand comments
Segment address
Effective address
0D64 1000
1003
1005
1008
100A
100C
100F
1013
1015
1016
1018
101B
101D
101E
B8 63 0D
8E D8
BE 00 10
33 C0
33 DB
A0 00 00
8A 1E 01 00
02 C3
37
89 04
A0 00 00
2A C3
3F
89 44 02
MOV AX,0D63
MOV DS,AX
MOV SI,1000
XOR AX,AX
XOR BX,BX
MOV AL,[0000]
MOV BL,[0001]
ADD AL,BL
AAA
MOV [SI],AX
MOV AL,[0000]
SUB AL,BL
AAS
MOV [SI+02],AX
;Initialize data segment
;Initialize SI with 1000
;Perform XOR operation on AX;Perform XOR operation on BX;Get first no. in AL
;Get second no. in BL
;Perform ADD AL , Bl
;Perform AAA
;Move the result in[SI]
;Get first no. in AL
;Perform SUB AL, BL
;Perform AAS
;Move the result in [SI+2]
ADITYA ENGINEERING COLLEGE 35
MICROPROCESSORS LAB MANUAL ECE Dept.1021
1023
1025
1027
1029
102C
102E
1031
1033
1035
B0 08
B3 04
F6 E3
D4 0A
89 44 04
D5 0A
F6 F3
89 44 06
B4 4C
CD 21
MOV AL,08
MOV BL,04
MUL BL
AAM
MOV [SI+04],AX
AAD
DIV BL
MOV [SI+06],AX
MOV AH,4C
INT 21
;Load AL with 08h
;Load BL with 04h
;Perform MUL with BL
; Perform AAM
;Move the result in [SI+4]
; Perform AAD
;Perform division with BL
;Move the result in [SI+6]
;Terminate the program
RESULT:D 1000: 02 01 06 00 02 03 20 00
VIVA-VOCE QUESTIONS
16. What are the Programmable peripheral interfacing chips available?
17. What is the memory capacity of 8086 µ P?
18. How data can be transferred without using the microprocessor?
19. How does the CPU identify between 8-bit and 16-bit operations?
20. What are the different instruction types of 8086 µ P?
ADITYA ENGINEERING COLLEGE 36
MICROPROCESSORS LAB MANUAL ECE Dept.2.3 a) BCD TO ASCII CONVERSION
ABSTRACT: Assembly language program to convert BCD number to ASCII number
PORT USED: None
REGISTERS USED: AL, AH, CX
ALGORITHM:
Step1: Start
Step2: Initialize data segment
Step3: Load AL with BCD number
Step4: Load CX register with count 04
Step5: Copy the contents from AL to AH
Step6: Perform AND operation AL with 0F
Step7: Perform AND operation AL with F0
Step8: Rotate the AH contents
Step9: Perform OR operation AL with 30
Step10: Perform OR operation AH with 30
Step11: Move the result to the memory location
Step12: Stop
ADITYA ENGINEERING COLLEGE 37
MICROPROCESSORS LAB MANUAL ECE Dept.FLOW CHART :
ADITYA ENGINEERING COLLEGE
Start
Perform AND operation AL with 0F
Rotate the AH contents
Perform OR operation AH with 30
Copy the contents from AL to AH
Perform AND operation AL with F0
Move the result to the memory location
Stop
Perform OR operation AL with 30
Initialize data segment
Get BCD no in AL register
Load the count 04 in CX register
38
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENTBCD DB 17HASCII DW?DATA ENDS
CODE SEGMENTORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV AL, BCD
MOV CL, 04
MOV AH, AL
AND AL, 0FH
AND AH, 0F0H
ROR AH, CL
OR AL, 30H
OR AH, 30H
MOV ASCII, AX
MOV AH, 4CH
INT 21H CODE ENDS
END START
ADITYA ENGINEERING COLLEGE 39
MICROPROCESSORS LAB MANUAL ECE Dept.CODE TABLE:
Physical address Label Hex code Mnemonic Operand comments
Segment address
Effective address
0D64 1000
1003
1005
1007
1009
100B
100D
1010
1012
1014
1017
101A
101C
B8630D
8ED8
B017
B104
8AE0
240F
80E4F0
D2CC
0C30
80CC30
A30100
B44C
CD21
MOV AX,0D63
MOV DS,AX
MOV AL,17
MOV CX,0004
MOV AH,AL
AND AL,0F
AND AH,F0
ROR AH,CL
OR AL,30
OR AH,30
MOV [0001],AX
MOV AH,4C
INT 21
;initialize data segment
;Get a number in AL
;Initialize CX with 0004
;Copy the contents of AL
;Perform AND ALwith 0F
;Perform AND AHwith F0
;Rotate right AH, CL
;Perform OR AL with 30
;Perform OR AH with 30
;Move the result in [0001]
;Terminate the program
RESULT:
D 0000: 17 37 31VIVA-VOCE QUESTIONS
21. What is a linker?
22. What are the DOS function calls?
23. How a CALL instruction will be executed?
24. What is the role of stack?
25. What is an interrupt vector table of 8086 µ P?
ADITYA ENGINEERING COLLEGE 40
MICROPROCESSORS LAB MANUAL ECE Dept.2.3 b) ASCII TO BCD CONVERSION
ABSTRACT: 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 04
Step5: Load BL with second ASCII number
Step6: Perform AND operation AL with 0F
Step7: Perform AND operation BL with 0F
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
ADITYA ENGINEERING COLLEGE 41
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Perform AND operation AL with 0F
Rotate the contents of AL with CL count
Move the result to the memory location
Perform AND operation BL with 0F
Stop
Perform OR operation AL with BL
Initialize data segment
Get first ASCII no in AL register
Load CX register with a count 04
Get second ASCII no in BL register
42
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENTASCII1 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, ASCII2
AND AL, 0FH
AND BL, 0FH
ROR AL, CL
OR AL, BL
MOV BCD, AL
MOV AH, 4CH
INT 21H
CODE ENDS
END START
ADITYA ENGINEERING COLLEGE 43
MICROPROCESSORS LAB MANUAL ECE Dept.CODE TABLE:
Physical address Label Hex code Mnemonic Operand comments
Segment address
Effective address
0D64 1000
1003
1005
1007
100A
100E
1010
1013
1015
1017
101A
101C
B8 63 0D
8E D8
B1 04
A0 00 00
8A 1E 01 00
24 0F
80 E3 0F
D2 C8
0A C3
A2 02 00
B4 4C
CD 21
MOV AX,0D63
MOV DS,AX
MOV CL,04
MOV AL,[0000]
MOV BL.[0001]
AND AL,0F
AND BL,0F
ROR AL,CL
OR AL,BL
MOV [0002],AL
MOV AH,4C
INT 21
;Initialize data segment
;Initialize count CX with 04
;Get 1st no. in AL register
;Get 2nd no. in BL register
;Perform AND AL with 0Fh
; Perform AND BL with 0Fh
;Rotate right AL , CL
;Perform OR, AL with BL
;Move the result in [0002]
; Terminate the program
RESULT:D 0000: 31 37 17
VIVA-VOCE QUESTIONS
26. What is the difference between near and far procedure?
27. What is the difference between macro and sub-routine?
28. What is a nested macro?
29. What is the difference between software and hardware interrupt?
30. What are the various modes available in 8255?
ADITYA ENGINEERING COLLEGE 44
MICROPROCESSORS LAB MANUAL ECE Dept.2.3 c) 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 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
ADITYA ENGINEERING COLLEGE 45
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize data segment and Load SI with offset list &
Get a count with CX register &Initialize DX with 0000
Move the contents from memory location SI to AL
Rotate the contents of AL to left
Increment DL and Increment SI
1
If carry equal to
zero
NOOo
FLOW CHART
YES
Decrement CX&If CX=0
YES
NOOo
2 JMP
3 4
46
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Increment DH & Increment SI
Stop
Increment SI
YES
4
NO
3
2
Decrement CX
If CX=0
Move the result to the memory location
47
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENTLIST DB 0FFH, 0DDH, 04H, 05H, 98HRESULT DW ?DATA ENDS
CODE SEGMENTORG 1000H
START: MOV AX, DATA
MOV DS, AX
LEA SI, LIST
MOV 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 ENDSEND START
ADITYA ENGINEERING COLLEGE 48
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Physical address Label Hex code Mnemonic Operand Comments
Segment address
Effective address
0D64 1000
1003
1005
1009
100C
100E
1010
1012
1014
1015
1017
1019
101A
101C
101D
101F
1023
1025
Back
L1
L2
B8630D
8ED8
8B360000
B90500
8A04
D0C0
7208
FEC2
46
E2F5
EB06
90
FEC6
46
E2ED
89160500
B44C
CD21
MOV AX,0D63
MOV DS,AX
LEA SI,[0000]
MOV CX,0005
MOV AL,[SI]
ROL AL,01
JB L1
INC DL
INC SI
LOOP Back
JMP L2
NOP
INC DH
INC SI
LOOP Back
MOV [0005],DX
MOV AH,4C
INT 21
;Initialize the data segment
;
; Load Effective addr. SI With 0000;Initialize the count CX with 0005;Copy the number of [SI] in AL;Rotate Left AL , 01
;If Barrow jump L1
; Increment value of DL
;Increment value of SI
;Decrement count and go to Back until CX = 0;Go to L2 without condition
;No Operation
:Decrement value of DH
;Increment value of SI
;Decrement counter and go to Back until CX=0;Move the result in [0005] location
;Terminate the program
RESULT:
D 0000: FF DD 04 05 98 02 03
ADITYA ENGINEERING COLLEGE 49
MICROPROCESSORS LAB MANUAL ECE Dept.
VIVA-VOCE QUESTIONS
31. What are the different registers in 8255?
32. What are the different registers in 8257?
33. What are the different registers in 8259?
34. What are the different registers in 8086?
35. What are the various modes of operation available in 8255?
ADITYA ENGINEERING COLLEGE 50
MICROPROCESSORS LAB MANUAL ECE Dept.
2.3 d) 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
ADITYA ENGINEERING COLLEGE 51
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize data segment and Load SI with offset list &
Get a count with CX register &Initialize DX with 0000
Move the contents from memory location SI to AL
Rotate the contents of AL to right
Increment DL and Increment SI
1
If carry equal to
zero
NOOo
FLOW CHART
YES
Decrement CX&If CX=0
YES
NOOo
2 JMP
3 4
52
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Increment DH & Increment SI
Start
Increment SI
YES
4
NO
3
2
Decrement CX
If CX=0
Move the result to the memory location
53
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB 05H,01H,03H,04H,08H,02H
COUNT 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
MOV AH, 4CH
INT 21H
CODE ENDS
END START
ADITYA ENGINEERING COLLEGE 54
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Physical address Label Hex code Mnemonic Operand comments
Segment address
Effective address
0D64 1000
1003
1005
1009
100C
100F
1011
1013
1015
1017
1018
101A
101C
101D
101F
1020
1022
1026
1028
Back
L1
L2
B8 63 0D
8E D8
8B 0E 06 00
BA 00 00
BE 00 00
8A 04
D0 C8
F2 08
FE C2
46
E2 F5
EB 06
90
FE C6
46
E2 ED
89 16 08 00
B4 4C
CD 21
MOV AX,0D63
MOV DS,AX
MOV CX,[0006]
MOV DX,0000
MOV SI,0000
MOV AL,[SI]
ROR AL,01
JB L1
INC DL
INC SI
LOOP Back
JMP L2
NOP
INC DH
INC SI
LOOP Back
MOV [0008],DX
MOV AH,4C
INT 21
;Initialize the data segment
;Initialize counter with [0006];Initialize DX register with 0000;Initialize SI with 0000
;Load the 1st no. in AL
;Rotate right AL,01
;If Barrow go to L1
;Increment the value of DL
;Increment the value of SI
;Decrement counter and go to Back until CX=0;Go to L2 without unconditional;No Operation
;Increment the value of DH
;Increment the Value of SI
;Decrement counter and go to Back until CX=0;Move the result in register DX
;Terminate the program
ADITYA ENGINEERING COLLEGE 55
MICROPROCESSORS LAB MANUAL ECE Dept.
RESULT:
D 0000: 05 01 03 04 08 02 06 00 03 03
VIVA-VOCE QUESTIONS
36. In how many modes does 8086 microprocessor works?
37. What are the conditions required to make 8086 to work in maximum mode?
38. What is the difference between maskable and non-maskable interrupts?
39. What is the difference between jump and loop instruction?
40. What is the difference between the respective shift and rotate instructions?
ADITYA ENGINEERING COLLEGE 56
MICROPROCESSORS LAB MANUAL ECE Dept.
2.3 e) PACKED BCD TO UNPACKED BCD CONVERSION
ABSTRACT: Write a program to convert packed BCD number into Unpacked BCD number.
REGISTERS USED: AL, BL
PORTS USED: None.
ALOGARITHM:
Step1: Start
Step2: Initialize the data segment
Step3: Move packed number into AL register
Step4: Move packed number into BL register
Step5: 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.
ADITYA ENGINEERING COLLEGE 57
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize the data segment
FLOW CHART
Move the number 29 into AL register &
Move the value 29h into BL register
1
Initialize the counter CX with 0004
Logical AND ed between AL & 0Fh and
Logical AND ed between BL & 0F0h
58
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Stop
Rotate right BL with 04h times
Store the result in 0000 and 0001 location
59
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N EQU 29H
RESULT DB 02H DUP (0)
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
AND BL, 0F0h
ROR BL, CL
MOV [RESULT], BL
MOV [RESULT+1], AL
MOV AH, 4Ch
INT 21h
CODE ENDS
END START
ADITYA ENGINEERING COLLEGE 60
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Physical address Label Hex code Mnemonic
Op code operands
Comments
Segment address
Effective address
0B3C 2000 B8 3B 0B MOV AX,0B3B ;Initialize the data segment
2003 8E D8 MOV DS, AX
2005 B1 04 MOV CL,04h ; Initialize the count with 04h
2007 B8 29 MOV AL, N ;Packed number in AL
2009 B3 29 MOV BL, N ;Packed number in BL
200B 24 0F AND AL,0Fh ;AND Operation AL with 0F
200D 80 E3 F0 AND BL, 0F0h ;AND Operation BL with F0
2010 D2 CB ROR BL,CL ;Rotate right BL, Cl
2012 88 1E 00 00 MOV [0000],AL ; Move the result in [0000]
2016 A2 01 00 MOV [0001], BL ;Move the result in [0001]
2019 8A 07 MOV AH, 4Ch ;Terminate the program
201B CD 21 INT 21 ;Stop
RESULT:
D 0B42:0000 29 02 09VIVA-VOCE QUESTIONS
41. How will you enter the single step mode of 8086?
42. What is LOCK prefix? What is its use?
43. What is REP prefix? What is its use?
44. What is the difference between conditional and unconditional control transfer
instructions?
45. What are different string instructions?
ADITYA ENGINEERING COLLEGE 61
MICROPROCESSORS LAB MANUAL ECE Dept.
2.4 a) TRANSFER BLOCK OF DATA
ABSTRACT: Assembly language program to transfer a block of data.
PORT USED: None.
REGISTERS USED: AX, BL.
ALGORITHM:
Step1: Start
Step2: Initialize data segment & extra segment
Step3: Load CX register with count
Step4: Initialize DI with memory location
Step5: Load SI with offset list
Step6: Repeat the process of moving string byte from SI to DI until count equals to zero
Step7: Stop
ADITYA ENGINEERING COLLEGE 62
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize data segment and Initialize extra segment
FLOW CHART
Repeat the process of moving string byte from SI to DI until count equals to zero
Load CX register with count
Initialize DI with memory location & load SI with offset
list
Stop
63
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: DATA
DATA SEGMENT
LIST DB ‘ADITYA’
COUNT EQU 06H
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV CX, COUNT
MOV DI, 5000H
LEA SI, LIST
REP MOVSB
MOV AH, 4CH
INT 21H
CODE ENDS
END START
ADITYA ENGINEERING COLLEGE 64
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Physical address Label Hex code Mnemonic Operand Comments
Segment address
Effective address
0D64 1000
1003
1005
1007
100A
100D
1011
1013
1015
B8 63 0D
8E D8
BE C0
B9 06 00
BF 00 50
8D 36 00 00
F3 A4
B4 4C
CD 21
MOV AX,0D63
MOV DS,AX
MOV ES,AX
MOV CX,0006
MOV DI,5000
LEA SI,[0000]
REPZ MOVSB
MOV AH,4C
INT 21
;Initialize the data segment
Initialize extra segment
;Initialize counter with 06
;Initialize DI with 5000
;Load SI with effective adr
;Move the contents of SI into DI;Terminate the program
;Stop
RESULT:
D 0000: 61 64 69 74 79 61
D 5000: 61 64 69 74 79 61
A D I T Y A
VIVA-VOCE QUESTIONS
46. What is the difference between inter-segment call and intra-segment call?
47. What is meant by maskable interrupts?
48. What is meant by non-maskable interrupts?
49. What is meant by Program Status Word (PSW)?
50. Draw the flag register format?
ADITYA ENGINEERING COLLEGE 65
MICROPROCESSORS LAB MANUAL ECE Dept.
2.4 b) 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 count
Step4: Copy the contents from CX to AX
Step5: Load SI with offset list
Step6: Initialize DI with (count-1)
Step7: Initialize BX with 02
Step8: Perform division with BX
Step9: Copy the contents from AX to CX
Step10: Move the contents from memory location SI to AL
Step11: 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
ADITYA ENGINEERING COLLEGE 66
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize data segment and Initialize extra segment
FLOW CHART
Copy the contents from CX to AX and perform division with BX
load CX with count and SI with offset list
Initialize DI with count-1 and Initialize BX with 02h
1
67
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ADITYA ENGINEERING COLLEGE
Exchange the contents of AL to [DI] and move the contents from AL to SI
Increment SI and Decrement DI
Decrement CX and if CX=0
YES
Stop
NO
Copy the contents from AX to CX and move the contents from SI to AL
1
68
MICROPROCESSORS LAB MANUAL ECE Dept.ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB ‘MICRO PROCESSOR’
COUNT 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, 02
DIV BXS
MOV CX, AX
BACK: MOV AL,[SI]
XCHG AL,[DI]
MOV [SI], AL
INC SI
DEC DI
LOOP BACK
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
ADITYA ENGINEERING COLLEGE 69
MICROPROCESSORS LAB MANUAL ECE Dept.
Physical address Label Hex code Mnemonic Operand CommentsSegment address
Effective address
0D64 1000
1003
1005
1007
100A
100C
100F
1012
1015
1017
101A
101B
101D
101F
1020
1021
1023
1025
Back
B8 63 0D
8E D8
8E C0
B9 0F 00
8B C1
BE 00 00
BF 0E 00
BB 02 00
F7 F3
8B C8
8A 04
86 05
88 04
46
4F
E2 F6
B4 4C
CD 21
MOV AX,0D63
MOV DS,AX
MOV ES,AX
MOV CX,000F
MOV AX,CX
MOV SI,0000
MOV DI,000E
MOV BX,0002
DIV BX
MOV CX,AX
MOV AL,[SI]
XCHG AL,[DI]
MOV [SI],AL
INC SI
DEC DI
LOOP Back
MOV AH,4C
INT 21
;Initialize the data segment
;Initialize the extra segment
;Initialize the counter with 000F;Load AX with CX value
;Initialize SI with 0000
;Initialize DI with 000e
;Move the value 02 in BX
;Division operation with BX
;Move AX value in CX
;Load the 1st no. in AL
;Exchange AL,[DI]
;Move the no in AL into [SI]
;Increment the value of SI
;Decrement the value of DI
;Decrement the counter and go to Back until CX=0;Terminate the program
;Stop
RESULT:D 0000: 72 6F 73 73 65 63 6F 72 70 20 6F 72 63 69 6D
R O S S E C O R P O R C I M
VIVA-VOCE QUESTIONS
ADITYA ENGINEERING COLLEGE 70
MICROPROCESSORS LAB MANUAL ECE Dept.51. What are the general purpose registers in 8086?
52. What is meant by stack pointer?
53. Which instructions are used for stack operations?
54. What is the length of physical address?
55. Distinguish between segment registers and index registers?
2.4 C) SORTING OF ‘N’ NUMBERS
ADITYA ENGINEERING COLLEGE 71
MICROPROCESSORS LAB MANUAL ECE Dept.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
ADITYA ENGINEERING COLLEGE 72
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize data segment and Load SI with offset list
&Get a count with CX register
Copy the contents from CX to DX
Copy to contents from SI to AL register
Compare the contents of AL and SI
1
Increment SI
If carry equal to
zero
NOOo
Exchange the contents of AL & SI
FLOW CHART
2
YES
3
4
73
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Decrement SI & move the contents of AL into SI
Start
Increment SI
Decrement CX
If CX =0
Decrement DX
If DX=0
YES
3
NO
2
NO
YES
4
74
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENTLIST DB 56H, 12H, 72,32HCOUNT EQU 0003HDATA ENDS
CODE SEGMENTORG 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 SINEXT: LOOP BACK
DEC DX
JNZ AGAIN
MOV AH, 4CH
INT 21HCODE ENDSEND START
ADITYA ENGINEERING COLLEGE 75
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Physical address Label Hex code Mnemonic Operands Comments
Segment address
Effective address
0D64 1000
1003
1005
1008
100A
100D
100F
1011
1012
1014
1016
1018
1019
101B
101C
101E
101F
1021
1023
L2
Back
L1
B8 63 0D
8E D8
B9 03 00
8B D1
BE 00 00
8B CA
8A 04
46
3A 04
72 06
86 04
4E
88 04
46
E2 F1
4A
75 E9
B4 4C
CD 21
MOV AX,0D63
MOV DS,AX
MOV CX,0003
MOV DX,CX
MOV SI,0000
MOV CX,DX
MOV AL,[SI]
INC SI
CMP AL,[SI]
JB L1
XCHG AL,[SI]
DEC SI
MOV [SI],AL
INC SI
LOOP Back
DEC DX
JNZ L2
MOV AH,4C
INT 21
;Initialize the data segment
;Initialize counter with 0003
;Load DX with Value of CX
;Initialize SI with 0000
;Get 1st no. in AL
;Increment value of SI
;Compare AL,[SI]
;If barrow go to L1
;Exchange the values of AL , SI;Decrement the value of SI
;Copy the AL reg into [SI]
;Increment the value of SI
;Decrement the counter and go to Back;Decrement the DX
;Jump no zero go to L2
;Terminate the program
RESULT: D 0000 12 32 56 72
ADITYA ENGINEERING COLLEGE 76
MICROPROCESSORS LAB MANUAL ECE Dept.
VIVA-VOCE QUESTIONS
56. How the physical address is calculated?
57. What is the difference between overlapping and non-overlapping segmentation?
58. What is the use of memory segmentation?
59. What is the clock frequency of 8086 microprocessor?
60. What is the function of overflow flag?
2.4 d) LENGTH OF THE GIVEN STRING
ADITYA ENGINEERING COLLEGE 77
MICROPROCESSORS LAB MANUAL ECE Dept.ABSTRACT: Assembly language program to find the Length of a string
PORT USED: None
REGISTERS USED: AX, BL
ALGORITHM:
Step1: Start
Step2: Initialize data segment & extra segment
Step3: Load AL with ‘$’
Step4: Load SI with offset list
Step5: Initialize DX with 0000
Step6: Scan string byte from DI memory location until AL =ES: DI
Step7: Jump to step10 if equal
Step8: Increment DX
Step9: Jump to step6
Step10: Move the result to the memory location
Step11: Stop
ADITYA ENGINEERING COLLEGE 78
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize data segment and Initialize extra segment
FLOW CHART
Scan string byte from DI memory location until AL =ES: DI
Load AL with “$” and SI with offset list
Initialize DX with 0000h
If equal
Increment DX and jump to back
Move the result to the memory location
yes
NO
Stop
79
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: DATA
DATA SEGMENT
LIST DB ‘ADITYA$’
LEN DB ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV AL,’$’
LEA SI, LIST
MOV DX, 0000H
BACK: SCASB
JE EXIT
INC DX
JMP BACK
EXIT: MOV LEN, DX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
ADITYA ENGINEERING COLLEGE 80
MICROPROCESSORS LAB MANUAL ECE Dept.CODE TABLE:
Physical address Label Hex code Mnemonic Operands Comments
Segment address
Effective address
0D64 1000
1003
1005
1007
1009
100D
1010
1011
1013
1014
1016
101A
101C
L2
L1
B8 63 0D
8E D8
8E C0
B0 24
8D3600 00
BA0000
AE
74 03
42
EBFA
8916 0700
B44C
CD21
MOV AX,0D63
MOV DS,AX
MOV ES,AX
MOV AL,24
LEA SI,[0000]
MOV DX,0000
SCASB
JZ L1
INC DX
JMP L2
MOV [0007],DX
MOV AH,4C
INT 21
;Initialize the data segment
;Initialize the extra segment
;Move 24 into AL register
;Load SI Effective address00
;Initialize the DX with 0000
;Scan string byte with SI
;If equal to zero go to L1
;Increment the value of DX
;Go to L2 with out condition
;Move the result into [0007]
;Terminate the program
RESULT:
D 0000: 61 64 69 74 79 61 24 06
A D I T Y A $
VIVA-VOCE QUESTIONS
61. What are the advantages of 8086 microprocessor over 8085 microprocessor?
62. What is the default register used in string operations?
63. What is the feature size of 8086 microprocessor?
64. What is meant by volatile memory?
65. What are the different non-volatile RAMs?
ADITYA ENGINEERING COLLEGE 81
MICROPROCESSORS LAB MANUAL ECE Dept.
2.4 e) COMPARISON OF TWO STRINGS
ABSTRACT: Assembly language program to compare two strings.
PORT USED: None
REGISTERS USED: AX, BL
ALGORITHM:
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
ADITYA ENGINEERING COLLEGE 82
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize data segment and Initialize extra segment
FLOW CHART
Compare AX with BX
Load AX with length 1 and Load BX with length 2
1
If equal
YES
NO
Copy the contents from AX to CX
Load SI with first string &Load DI with second string
Repeat comparing string byte until count equals to zero
2
83
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
If equal
NO
YES
Move the result to the memory location
Move another result to the memory location
Stop
2
84
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAMS:
ASSUME CS: CODE, DS: DATA, ES: DATA
LIST1 DB ‘ADITYA’
LEN1 EQU ($-LIST1)
LIST2 DB ‘ADITYA’
LEN2 EQU ($-LIST2)
RESULT DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV 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
ADITYA ENGINEERING COLLEGE 85
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:Physical address Label Hex code Mnemonics Operands Comments
Segment
address
Effective address
0D64 1000
1003
1005
1007
100A
100D
100F
1011
1013
1016
1019
101B
101D
1023
1025
1026
102C
102E
L1
L2
B8 63 0D
8E D8
8E C0
B8 06 00
BB 06 00
3B C3
75 15
8B C8
BE 00 00
BF 06 00
F3 A6
75 09
C7060C005555
EB07
90
C7060C00FFFF
B44C
CD21
MOV AX,0D63
MOV DS,AX
MOV ES,AX
MOV AX,0006
MOV BX,0006
CMP AX,BX
JNZ L1
MOV CX,AX
MOV SI,0000
MOV DI,0006
REPZ CMPSB
JNZ L1
MOV PTR[000C],5555
JMP L2
NOP
MOV PTR[000C],FFFF
MOV AH,4C
INT 21
;Initialize the data
segment
;Initialize extra segment
;Load AX with 0006
;Load BX with 0006
;Compare AX with BX
;If no 0 go to L1
;Copy the contents of AX into CX;Initialize SI with 0000
;Load DI with 0006
;Compare with SI
;If no 0 go to L1
;Get 5555 in 000C location;Go to unconditional L2
;No Operation
;Get FFFF into 000C location; Terminate the program
RESULT:
ADITYA ENGINEERING COLLEGE 86
MICROPROCESSORS LAB MANUAL ECE Dept.VIVA-VOCE QUESTIONS
66. What is meant by SRAM?
67. What does instruction-pipelining mean?
68. What is the difference between SRAM and DRAM?
69. What do ROM, EEPROM, and UVPROM mean?
70. What does masked ROM mean?
71. How data can be transferred in interrupt I/O?
ADITYA ENGINEERING COLLEGE 87
MICROPROCESSORS LAB MANUAL ECE Dept.
2.5 a) 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 00
Step4: Key board Interrupt
Step5: Initialize the AL register with 00
Step6: Key board Interrupt
Step7: 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 14h into AH register.
Step11: Keyboard Interrupt.
Step12: Load the number 4C in AH register.
Step13: Stop.
ADITYA ENGINEERING COLLEGE 88
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:ASSUME CS: CODE, DS: DATA
CODE SEGMENT
ORG 1000h
START: MOV AL, 13h
MOV AH, 00
INT 10h
BACK: MOV AH, 00h
INT 16h
CMP AL, ‘q’
JE EXIT
MOV BL, 0Fh
MOV AH, 14h
INT 10h
JMP BACK
EXIT: MOV AH, 4Ch
INT 21h
CODE ENDS
END START
ADITYA ENGINEERING COLLEGE 89
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Segment base address
Effective address
Label Hex code Mnemonics Operands Comment
0B3D 1000 B0 13 MOV AL, 13 ;Move the 13 into AL register
1002 B4 00 MOV AH, 00 ;Initialize the AH register with 00
1004 CD 10 INT 10 ;Keyboard Interrupt
1006 B4 00 MOV AH, 00 ; Initialize the AH register with 00
1008 CD 16 INT 21 ; Keyboard Interrupt
100A 3C 71 CMP AL, 71 ;Compare the data 71 with AL register
100C 74 08 JZ L1 ;If equal to zero go to L1
100E B3 0F MOV BL, 0F ;Move 0F into the BL register
1010 B4 0F MOV AH, 0F ;Move 0F into the AH register
1012 CD 10 INT 10 ;Keyboard Interrupt
1014 EB F0 JMP L2 ;Jump to L2
1016 B4 4C MOV AH, 4C ;Move 4C intoAH register
1018 CD 21 INT 21 ;Go to DOS commands
RESULT:
ADITYA ENGINEERING COLLEGE 90
MICROPROCESSORS LAB MANUAL ECE Dept.
2.5 b) READING KEYBOARD (without echo)
ABSTRACT: To Display the string or character (without ECHO) by using DOS Command
REGISTERS USED: AH, AL, SI
PORTS USED: None.
ALGORITHM:
Step1: Start
Step2: Initialize SI with Offset Result.
Step3: Initialize AH with 00h
Step4: 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 10
Step8: Increment the value of SI.
Step9: Go to step 3 without condition.
Step10: Terminate the program.
Step11: Stop.
PROGRAM:
ADITYA ENGINEERING COLLEGE 91
MICROPROCESSORS LAB MANUAL ECE Dept.ASSUME CS: CODE, DS: DATA
DATA SEGMENT
ORG 3000h
RESULT DB 50h DUP (0)
DATA ENDS
CODE SEGMENT
ORG 1000h
START: MOV SI, OFFSET RESULT
BACK: MOV AH, 00h
INT 16h
CMP AL, ‘q’
MOV [SI], AL
JE EXIT
INC SI
JMP BACK
EXIT: MOV AH, 4Ch
INT 21h
CODE ENDS
END START
CODE TABLE:
ADITYA ENGINEERING COLLEGE 92
MICROPROCESSORS LAB MANUAL ECE Dept.
Segment base address
Effective address
Label Hex code Mnemonics Operands Comment
0E42 1000 BE 00 30 MOV SI, 3000 ;Initialize the SI with 3000h
1003 L2 B4 00 MOV AH, 00 ;Initialize the AH register with 00
1005 CD 16 INT 16 ;Bios keyboard Interrupt
1007 3C 71 CMP AL, 71 ;Compare 71 with AL register
1009 88 04 MOV [SI] , AL ;Move the data in AL register into [SI]
100B 74 03 JZ L1 ;If zero go to L1
100D 46 INC SI ;Increment the value of SI
100E EB F3 JMP L2 ;Go to L2 with out condition
1010 L1 B4 4C MOV AH, 4Ch ;Terminate the program
1012 CD 21 INT 21 ;Stop
RESULT:
- D 3000
- 6D 69 63 72 6F 70 72 6F 63 65 73 73 6F 72 73 20 6C 61 62
M I C R O P R O C E S S O R S L A B
2.5 c) DISPLAY STRING BY USING DOS COMMANDS
ADITYA ENGINEERING COLLEGE 93
MICROPROCESSORS LAB MANUAL ECE Dept.
ABSTRACT: To display the string character by using DOS commands.
REGISTER USED: AL, AH, SI.
PORTS USED: None
ALGORITHM:
Step1: Start
Step2: Set the screen in Graphic mode
Step3: Initialize AH with 00h
Step4: 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:
ADITYA ENGINEERING COLLEGE 94
MICROPROCESSORS LAB MANUAL ECE Dept.ASSUME CS: CODE, DS: DATA
DATA SEGMENT
TEXT DB ‘ADITYA MICROPROCESSORS LAB!'
DATA ENDS
CODE SEGMENT
ORG 1000H
START: AX, DATA
MOV DS, AX
MOV AL, 13H; SET the screen in graphics mode
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 ENDSEND START
CODE TABLE:
ADITYA ENGINEERING COLLEGE 95
MICROPROCESSORS LAB MANUAL ECE Dept.Segment
base address
Effective address
Label Hex code Mnemonics Operands Comment
0B41 1000 B8 3F 0B MOV AX, 0B3F ;Initialize data segment
1003 8E D8 MOV DS, AX1005 B0 13 MOV AL,13 ;Move the13 into
AL register.1007 B4 00 MOV AH, 00 ;Initialize the AH
register with 00001009 CD 10 INT 10 ;Set the keyboard
display mode100B BE 00 00 MOV SI, 0000 ;Initialize SI with
0000 location100E L2 8A 80 40 00 MOV AL, [SI+00] ;Copy the contents
of SI into AL1012 3C 21 CMP AL, 21 ;Compare the
value 21 with AL register
1014 74 09 JZ L1 ;If equal to zero go to L1
1016 B4 0E MOV AH, 0E ;Load AH register with 0Eh
1018 B3 05 MOV BL, 05 ;Load BL register with 05h
101A CD 10 INT 10 ;Set the keyboard display mode
101C 46 INC SI ;Increment value of SI
101D EB FF JMP L2 ;Jump go to L2
with out condition101F L1 B4 4C MOV AH, 4Ch ;Terminate the
program1021 CD 21 INT 21 ;Dos command
interrupt
RESULT:
3.1. PROGRAMMABLE PERIPHERAL INTERFACING(8255)
ADITYA ENGINEERING COLLEGE 96
MICROPROCESSORS LAB MANUAL ECE Dept.
AIM: To study the functioning of programmable peripheral interfacing 8255.• With port A & port B as out put port • With port A as input and port B as output.
REGISTERS USED: AX, CX, DX.
PORTS USED: port A and port B.
CONNECTIONS: Study card; J1 of the study card adapter to I5 of ESA 8086/88.
DESCRIPTION:The 8255 is a general purpose programmable I/O device with 24 I/O
lines. These I/OLines are grouped as shown below:
Group A …. Port A (8 bits – PA0 to PA7) and Port C (4 bits – PC7 toPC4).
16 Group B …. Port B (8 bits – PB0 to PB7) and Port C (4 bits – PC3 toPC0).These groups can be operated in 3 different modes: mode 0, mode 1, and mode 2. InMode 0 the three ports, A, B, and C, may be programmed as input or output. In mode 1Ports A and B may be programmed as input or output, but port C is used to generateHandshake and interrupt signals. In mode 2, port A becomes a bi-directional port and 5I/O lines of port C are used for handshaking and interrupt signals. The pin-out of the8255 is given on the picture shown below.
ADITYA ENGINEERING COLLEGE 97
MICROPROCESSORS LAB MANUAL ECE Dept.Following is the description of the inputs and outputs used for interfacing to the 8255:CS’ – A low on this input pin enables communication between the 8255 and the deviceControlling it.47RD’ – A low on this input pin enables the 8255 to send data or status information to theDevice controlling the 8255.WR’ – A low on this input pin enables the device controlling the 8255 to write data orControl words to the 8255.A0 and A1 – These input address lines, in conjunction with the RD’ and WR’ signals,allow the selection of one of three ports or the control register, as defined by the tablegiven below:A1 A0 Location0 0 Port A0 1 Port B1 0 Port C1 1 Control RegisterRESET – A high on this input pin clears the control register and all ports are set to inputMode.To program the 8255 PPI, one must write a control word to the control register. ThisControl word will define how the 8255 is going to behave. The table shown below definesthe value of each bit of the control word:Control word bit FunctionD0 1 = Port C (lower) is input, 0 = Port C (lower) is outputD1 1 = Port A is input, 0 = Port A is outputD2 1 = Port B mode 1, 0 = Port B mode 0D3 1 = Port C (upper) is input, 0 = Port C (upper) is outputD4 1 = Port A is input, 0 = Port A is outputD5
D6
Port A00 = Mode 0, 01 = Mode 1, 1X = Mode 2D7 1 = Mode set flag active48Procedure
Write a program to:
1. Reset and initialize the 8255 to mode 0 with ports A, B, and C defined as outputs.
ADITYA ENGINEERING COLLEGE 98
MICROPROCESSORS LAB MANUAL ECE Dept.2. Create a menu of options to allow for the selection of which port is going to biased to simulate a three bits up-counter, and to quit the program.
3. When a port is selected from the menu, the screen should be cleared and message indicating which port is in use should be displayed.
The counting sequence should be displayed both on the screen and on the LED s associated withThe selected port until a key is pressed on the keyboard, at which time you start back at step 2.
ADITYA ENGINEERING COLLEGE 99
MICROPROCESSORS LAB MANUAL ECE Dept.
1. PORT A AND PORT B AS OUT PUT PORT:
ALGORITHM:
Step 1: start
Step 2: move the control word address 0FF46 to register DX
Step 3: move 80 to AL register.
Step 4: locate the contents in AL register to DX register using port out.
Step 5: move 55 to AL register.
Step 6: Initialize port A address.
Step 7: locate the contents in AL register to DX register using port out.
Step 8: Call subroutine program.
Step 9: complement the contents of AL register.
Step 10: initialize port B address.
Step 11: locate the contents in AL register to DX register using port “out”.
Step 12: Call subroutine program.
Step 13: Go step 6.
Step 14: Stop.
ALGORITHM FOR SUBROUTINE:
ADITYA ENGINEERING COLLEGE 100
MICROPROCESSORS LAB MANUAL ECE Dept.Step1: Load CX register with 0000h.
Step2: Decrement CX and go to step2 until the count CX equal to zero.
Step3: Return to main program.
ADITYA ENGINEERING COLLEGE 101
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize the control word register
FLOW CHART
Move the data 80h into AL register &Locate the contents in AL to DX register using port
out
Move the value 55h into AL register
1
Initialize port A address
Locate the contents of AL register to DX register using port out
Move the value 00 into CX register, decrement CX register and jump to main program if CX is equal to zero
Complement the contents of AL register
2
102
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Stop
2
Locate the contents in AL register into DX register using port out
Initialize port B address
Move the value 00 into CX register, decrement CX register and jump to main program if CX is equal to zero
Jump
103
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:MOV DX, 0FF46
MOV AX, 80
OUT DX, AL
MOV AX, 55
RPT: MOB DX, 0FF40
OUT DX, AX
CALL DELAY
NOT AX
MOV DX, 0FF42
OUT DX, AX
CALL DELAY
JMP RPT
DELAY PROGRAM:
MOV CX, 0000H
L1: LOOP L1
RET
ADITYA ENGINEERING COLLEGE 104
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Physical address Label Hex code Mnemonic
Op code operands
Comments
Segment address
Effective address
0000 5000 BA 46 FF MOV DX , FF46
Move FF46 to DX register
5003 B8 80 00 MOV AX, 0080 Load AX with 80
5006 EF OUT DX , AX Move AX content to DX
5007 B8 55 00 MOV AX , 0055 Move 55 to AX register.
500A Rpt BA 40 FF MOV DX , 0FF40
Move 0FF40 to DX register.
500D EF OUT DX,AX Move AX content to DX
500E E8 EE 1F CALL 6000 Go to subroutine
5011 FD D0 NOT AX Complement the AX register
5013 BA 42 FF MOV DX ,0FF42
Initialize the port B address.
5016 EF OUT DX , AX Move the contents of AX into DX.
5017 E8 E9 1F CALL 6000 Go to 6000 location
501A EB F1 JMP RPT Go to 500A location.
RESULT:
ADITYA ENGINEERING COLLEGE 105
MICROPROCESSORS LAB MANUAL ECE Dept.
2. PORT A AS INPUT PORT AND PORT B AS OUT PUT PORT.
ALGORITHM:
Step 1: Start
Step 2: Move the control word address 0FF40 to register DX
Step 3: Move 90 to AL register.
Step 4: Locate the contents in AL register to DX register using port out.
Step 5: Move 55 to AL register.
Step 6: Initialized port A address ie.,, 0FF40 to DX register.
Step 7: Locate the contents in AL register to DX register using port IN.
Step 8: Complement the contents of AL register.
Step 9: Initialize port B address ie,,.0FF42 to DX register.
Step 10: Locate the contents in AL register to DX register using port “out”.
Step 11: Go step 5.
Step 12: Stop.
ADITYA ENGINEERING COLLEGE 106
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize the control word register
FLOW CHART
Move the data 90h into AL register &Locate the contents in AL to DX register using port
out
Move the value 55h into AL register
1
Initialize port A address
Locate the contents of AL register to DX register using port out
Complement the contents of AL register
2
107
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
Stop
2
Locate the contents in AL register into DX register using port out
Initialize port B address
Jump
108
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
MOV DX, 0FF46
MOV AX, 90
OUT DX, AX
RPT: MOV AL, 55
MOV DX, 0FF40
IN AX, DX
NOT AX
MOV DX, 0FF42
OUT DX, AX
JMP RPT
ADITYA ENGINEERING COLLEGE 109
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Physical address Label Hex code Mnemonic
Op code operands
Comments
Segment address
Effective address
0000 4000 BA 46 FF MOV DX , FF46
Move FF46 to DX register
5003 B8 90 00 MOV AX, 0090 Load AX with 90
5006 EF OUT DX , AX Move AX content to DX
5007 Rpt B8 55 00 MOV AX , 0055 Move 55 to AX register.
500A BA 40 FF MOV DX , 0FF40
Move 0FF40 to DX register.
500D EF IN AX,DX Move DX content to AX
5011 FD D0 NOT AX Complement the AX register
5013 BA 42 FF MOV DX ,0FF42
Initialize the port B address.
5016 EF OUT DX , AX Move the contents of AX into DX.
501A EB F1 JMP RPT Go to 500A location.
RESULT:
VIVA-VOCE QUESTIONS
72. How data can be transferred in programmed I/O?
73. What is the difference between machine language and assembly language?
74. Expand USART?
75. What are the signals required for memory read operation?
76. What are the signals required for memory write operation?
77. Why 8086 uses hexadecimal number system?
78. On which data stepper motor works?
79. How the stepper motor can be interfaced to 8086 microprocessor?
80. Write the syntax for 32-bit division operation?
81. Give an example for relative based indexed addressing mode?
ADITYA ENGINEERING COLLEGE 110
MICROPROCESSORS LAB MANUAL ECE Dept.
3.1 a) DIGITAL TO ANALOG CONVERTER
GENERATION OF WAVE FORMS:
AIM: program to generate the following wave forms:• Triangular wave forms• Saw tooth wave forms• Square wave • Sine wave
REGISTERS USED: general purpose registers: AL, DX, and CX
PORTS USED: out (port-B)
CONNECTION:J4 of ESA 86/88 to J1 DAC interface.
DESCRIPTIONS: As can be from the circuit only 17 lines from the connector are used totally. The port A and port B of 8255 programmable peripheral interface are used as output ports. The digital inputs to the DAC’s are provided through the port A and port B of 8255.the analog outputs of the DAC’s are connected to the inverting inputs of op-amps µA741 which acts as current to voltage converters. The out puts from the op- amps are connected to points marked Xout and Yout at which the wave forms are observed on a CRO. (port A is used to control Xout port B is used to control Yout).the difference voltage for the DAC’s is derived from an on-board voltage regulator µA 723 .it generates a voltage of about 8V.the offset balancing of the op-amps is done by making use of the two 10k pots provided. The output wave forms are observed at Xout and Yout on an oscillator.THEORY:BASIC DAC TECHNIQUE:
Vo = K VFS (d1 .2-1 + d2 . 2-2 + . . . . . . . .+dn . 2-n )Where d1 = MSB, d2 = LSBVFS = Full scale reading / out put voltageK --- Conversion factor is adjusted to ‘unity’.D/A converters consist of ‘n’ bit binary word ‘D’and is combined with a reference voltage VR to give an analog output. The out put can be either voltage or currentOut put voltage Vo = K VFS (d1 .2-1 + d2. 2-2 + . . . . . . . . +dn. 2-n)MSB weight = ½ VFS if d1 = 1 and all are zero’s, K = 1.LSB weight = VFS/2n if dn = 1 and all are zero’s, K = 1
DUAL DAC INTERFACE: • This program generates a square wave or a Triangular wave at points Xout or Yout of
interface. The waveforms may be observed on an oscilloscope.• This program can be executed in STAND-ALONE MODE or SERIAL MODE of operation.• The program starts at memory location 3000H
ADITYA ENGINEERING COLLEGE 111
MICROPROCESSORS LAB MANUAL ECE Dept.ALGORITHM: (FOR TRIANGULAR WAVE):
Step 1: Start
Step 2: Initialize the control word register
Step 3: Move 80 to AL register.
Step 4: Locate the contents in AL register to DX register using port out.
Step 5: Move 00FF to CX register.
Step 6: Move 00 to AL register.
Step 7: Initialize the port A address.
Step 8 : Locate the contents of AL to DX register.
Step 9: Increment the value in AL by one.
Step 10: Locate AL contents to DX register.
Step 11: Decrement the value of CX register by one and move to step 6 if CX not equal to zero.
Step 11: Other wise move 00FF to CX register.
Step 12: Decrement the value of AL by one.
Step 13: Locate the contents in AL register to DX register.
Step 14: Decrement the value of CX by one and move to step 11 if CX not equal to zero.
Step 15: Otherwise move to step 5.
Step 16: Stop.
ADITYA ENGINEERING COLLEGE 112
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize the control word register
FLOW CHART
Copy the contents from AX to 80 &Locate the contents in AL to DX register using port
out Move 0FF to CX register and
1
Locate the contents of AX to DX register&
Increment the value in AX by one
Locate AX contents to DX register
Move 00 to AL register
Initialize port A address
Decrement CX & CX =0
NO
YES
2
113
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
NO
YES
Move 0FF to CX register
Decrement the value of AL
Locate the contents in AL register to DX register
Stop
Decrement CX &CX=0
Jump
2
114
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM (FOR TRIANGULAR WAVE):
MOV DX, 0FFE6
MOV AL, 80 OUT DX, AL
MOV DX, 0FFE0
MOV AX, 00
RPT: MOV CX, 0FF
L1: OUT DX, AX
INC AX
LOOP L1
MOV CX, 0FF
L2 : OUT DX,AX
DEC AX
LOOP L2
JMP RPT
ADITYA ENGINEERING COLLEGE 115
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE (FOR TRIANGULAR WAVE):
Physical address Label Hex code Mnemonic
Op code operands
Comments
Segment address
Effective address
0000 2000 BA E6 FF MOV DX , FFE6
Move FFE6 to DX register
2003 B8 80 00 MOV AX, 0080 Load AX with 80
2006 EF OUT DX , AX Move DX content to AX
2007 BA E0 FF MOV DX , FFE0 Move FFE0 to DX register
200A B8 00 00 MOV AX , 0000 Load AX with 0000
200D Rpt B9 FF 00 MOV CX , 00FF Move FF to CX register
2010 L1 EF OUT DX , AX Move contents of AX to DX
2011 40 INC AX Increment the contents of AX
2012 E2 FC LOOP L1 Loop go to 2010 location
2014 B9 FF 00 MOV CX , 00FF Move 00FF to CX register
2017 L2 EF OUT DX, AX Move the contents of AX into DX
2018 48 DEC AX Decrement to AX register
2019 E2 FC LOOP L2 Loop go to 2017 location
201B EB EA JMP RPT Jump to 200D location
RESULT:
ADITYA ENGINEERING COLLEGE 116
MICROPROCESSORS LAB MANUAL ECE Dept.
ALGORITHM (FOR SAW TOOTH WAVE):
Step 1: Start
Step 2: Move the control word address 0FFE6 to register DX
Step 3: Move 80 to AL register.
Step 4: Locate the contents in AL register to DX register using port out.
Step 5: Move 00 to AL register.
Step 6: Move 00FF to CX register.
Step 7: Locate or move 0FFE2 to DX register ie, port B address.
Step 8: Locate AL contents to DX register.
Step 9: Increment the value of AL register by one.
Step 10: Decrement the value of CX register by one and move to step 8 if CX not equal to zero.
Step 11: Otherwise move to step 5.
Step 12 Stop.
ADITYA ENGINEERING COLLEGE 117
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize the control word register
FLOW CHART
Copy the contents from AX to 80 &Locate the contents in AL to DX register using port
out Move 00 to AX register
Locate the contents of AX to DX register
Move 0FF to CX register
Initialize port B address
Decrement CX & CX =0
NO YES
Locate the contents of AX to DX register
Stop
118
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM (FOR SAW TOOTH WAVE):
MOV DX, 0FFE6
MOV AL, 80
OUT DX,AL
MOV DX, 0FFE0
MOV AX, 00
RPT: MOV CX, 0FF
L1: OUT DX, AX
INC AX
LOOP L1
MOV AX, 00
OUT DX, AX
JMP RPT
ADITYA ENGINEERING COLLEGE 119
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE (FOR SAW TOOTH WAVE):
Physical address Label Hex code Mnemonic
Op code operands
Comments
Segment address
Effective address
0000 3000 BA E6 FF MOV DX , FFE6 Move FFE6 to DX register
3003 B8 80 00 MOV AX, 0080 Load AX with 80
3006 EF OUT DX , AX Move DX content to AX
3007 BA E0 FF MOV DX , FFE0 Move FFE0 to DX register
300A B8 00 00 MOV AX , 0000 Load AX with 0000
300D Rpt B9 FF 00 MOV CX , 00FF Move FF to CX register
3010 L1 EF OUT DX , AX Move contents of AX to DX
3011 40 INC AX Increment the contents of AX
3012 E2 FC LOOP L1 Loop go to 2010 location
3014 B8 00 00 MOV AX , 0000 Move 0000 to AX register
3017 EF OUT DX, AX Move the contents of AX into DX
3018 EB F3 JMP RPT Jump to 300D location
RESULT:
ADITYA ENGINEERING COLLEGE 120
MICROPROCESSORS LAB MANUAL ECE Dept.
ALGORITHM (FOR SQUARE WAVE):
Step 1: Start
Step 2: Move the control word address 0FFE6 to register DX
Step 3: Move 80 to AL register.
Step 4: Locate the contents in AL register to DX register using port out.
Step 5: Move FF to AL register.
Step 6: Locate the contents in AL register to DX register using port out .
Step 7: Move 91 into CX register.
Step 8: Decrement the value CX by one and jump to step 8 if CX not equal to zero.
Step 9: Other wise move 00 to AL register.
Step 10: Locate the contents in AL register to DX register using port out .
Step 11: Move 91 into CX register.
Step 12: Decrement the value CX by one and jump to step 12 if CX not equal to zero.
Step 13: Jump to location step 5.
Step 14: Stop.
ADITYA ENGINEERING COLLEGE 121
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize the control word register
FLOW CHART
Copy the contents from AX to 80 &Locate the contents in AL to DX register using port
out
Locate the contents of AX to DX register
Move 0FF to AX register
Initialize port A address
Decrement CX & CX =0
NOYES
Move the data 91h into CX register
12
122
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
NOYES
Move 00h to AX register
Locate the contents in AL register to DX registerMove the data 91h into CX register
Stop
Decrement CX &CX=0
Jump
2
123
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM (FOR SQUARE WAVE):
MOV DX, 0FFE6
MOV AL, 80
OUT DX, AL
MOV DX, 0FFE0
RPT: MOV AX, 0FF
OUT DX, AX
CALL DELAY
MOV AX, 00
OUT DX, AX
CALL DELAY
JMP RPT
DELAY PROGRAM:
MOV CX, 1E
NOP
NOP
L1: LOOP L1
RET
ADITYA ENGINEERING COLLEGE 124
MICROPROCESSORS LAB MANUAL ECE Dept.CODE TABLE (FOR SQUARE WAVE):
Physical address Label Hex code Mnemonic
Op code operands
Comments
Segment address
Effective address
0000 5000 BA E6 FF MOV DX , FFE6
Move FFE6 to DX register
5003 B8 80 00 MOV AX, 0080 Load AX with 80
5006 EF OUT DX , AX Move AX content to DX
5007 BA E0 FF MOV DX , FFE0 Move FFE0 to DX register
500A Rpt B8 FF 00 MOV AX , 00FF Load AX with 00FF
500D EF OUT DX,AX Move AX content to DX
500E E8 FF EF CALL 6000
5011 B8 00 00 MOV AX , 0000 Load AX with 0000
5014 EF OUT DX , AX Move the contents of AX into DX
5015 E8 E8 FF CALL 6000
5018 E8 F0 JMP RPT Jump to 500A location
DELAY PROGRAM:
LOCATION 0000:6000
Physical addressBase adder offset adder
Label Hex codes
Mnemonics Op code Operand
comment
0000 6000 B9 1E 00 MOV CX,001E Move 001E into CX register
6003 NOP
6004 NOP
6005 C3 RET Return to main program
RESULT:
ADITYA ENGINEERING COLLEGE 125
MICROPROCESSORS LAB MANUAL ECE Dept.
ALGORITHM (FOR SINE WAVE):
Step 1: Start
Step 2: Move the control word address 0FFE6 to register DX
Step 3: Move 80 to AL register.
Step 4: Locate the contents in AL register to DX register using port out.
Step 5: Initialize the SI with 4000h location.
Step 6: Move the number 46 into the counter CX register.
Step 7: Initialize the Port A address ie. 0FFE0
Step 8: Move the contents SI into AL register.
Step 9: Locate the contents in AL register to DX register using port out..
Step 10: Increment the value of SI.
Step 11: Decrement the counter and go to Step 8 until CX =0
Step 12: Jump to location step 5.
Step 13: Stop.
ADITYA ENGINEERING COLLEGE 126
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM FOR SINE WAVE:
MOV DX, 0FFE6
MOV AL, 80
OUT DX, AL
RPT: MOV SI, 4000
MOV CL, 46
MOV DX, 0FFE0
L1: MOV AL, [SI]
OUT DX, AL
INC SI
LOOP L1
JMP RPT
ADITYA ENGINEERING COLLEGE 127
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Base address
Effective address
Label Hex code Mnemonics Operands Comments
0000 2000 BA E6 FF MOV DX, 0FFE6 ;Initialize control word register
2003 B8 80 00 MOV AL, 80 ;Load AL with 802006 EF OUT DX, AL ;Read the data from
AL register using port out
2007 RPT BE 0040 MOV SI, 4000 ;Initialize the SI with 4000 ie,LOOK-UP TABLE
200A 8B 46 00 MOV CX , 46 ;Initialize the counter with 46h
200D BA E0 FF MOV DX, 0FFE0 Initialize port A
2010 L1 B8 C6 MOV AL, [SI] ;move the number in [SI] into al register
2012 EF OUT DX, AL ;read the data from Al register using port out
2013 46 INC SI ;Increment the value of SI
2014 E2 F5 LOOP L1 ;Decrement counter and go to L1 until CX=0
2016 EB EA JMP RPT ;Jump go to rpt with out condition
ADITYA ENGINEERING COLLEGE 128
MICROPROCESSORS LAB MANUAL ECE Dept.LOOK – UP TABLE:
EFFECTIVE ADDRESS
HEX CODES
4000 7F 8A 95 A0
4004AA B5 BF C8
4008D1 D9 E0 E7
400CED F2 F7 FA
4010FC FE FF FE
4014FC FA F7 F2
4018ED E7 E0 D9
401CD1 C8 BF B5
4020AA A0 95 8A
40247F 74 69 5F
402853 49 3F 36
402C2D 25 1D 17
403010 0B 07 04
403401 00 01 04
403807 0B 10 17
403C
1D 25 2D 364040
3F 49 53 5F4044
69 74
RESULT:
ADITYA ENGINEERING COLLEGE 129
MICROPROCESSORS LAB MANUAL ECE Dept.
VIVA-VOCE QUESTIONS
82. How does the 8086 microprocessor instruction set is classified?
83. Which operation is performed by the Negate instruction?
84. What is the difference between RET and IRET instruction?
85. If AH=00, AL=0F then what is the content of AH and AL after AAA instruction?
86. What is the function of SAHF instruction?
87. What is the difference between IN and OUT instructions?
88. Which flags are affected after CMP (compare) instruction?
89. If AL=71, AH=81 then what is the content of AL after DAA instruction?
ADITYA ENGINEERING COLLEGE 130
MICROPROCESSORS LAB MANUAL ECE Dept.
3.2. KEYBOARD INTERFACING
AIM: To display a string through interfacing 8279.
REGISTERS USED: AX, BX, CX, DX, SI
PORTS USED: command port, data port
CONNECTIONS: 8279 study card P1 to J2 of ESA 86/88 study card adapter.
DESCRIPTION:8279 study card provides keyboard as well as display section. The display section features
size 8 digit seven segment displays while the keyboard connections comprises a 4x 4 matrix hex key pad and associated circuitry. The options for using shift and controls keys during key scanning are also provided. The interface has 3 connectors, P1, J1, & J4 to interface the card with ESA 86/88E trainers. Connect the 50 pin FRC connectors P1 to connector J2 to ESA 86/88E study card adapter.
INTRODUCTION:In many microprocessors-based systems, calculator keypad is used as an input device. A
calculator keypad can be interfaced to a microprocessor using a dedicated peripheral controller like INTEL 8279Akeyboard/display controller. In this case, the controller can handle the interface problems like key debounce, 2-key lock-out, N-key roll-over etc,. Further such an alternative approach, the calculator keypad interface is passive and software is used for encoding the key positions and for handling problems like key debounce, roll-over etc.
The present interface module provides a calculator style calculator keypad consisting of the key 0 to 9 , + ,- , ×,= ,% , . , C, CE and two spare keys. These 20 keys are arranged in a 3×8 matrix (the third row has only four keys). The row lines can be driven through port C and the status of column lines can be read through port A. this interface allows the user to study a number of techniques generally used in calculator keypad interfacing. User can write programs for software debouncing of key closures, two key understanding of keyboard interface. Further , user can become familiar with the arithmetic group of processor instructions by implementing the calculator functions like addition, subtraction, multiplication , diversion, percentage etc..
ADITYA ENGINEERING COLLEGE 131
MICROPROCESSORS LAB MANUAL ECE Dept.
THEORY:
• A programmable keyboard and display interfacing chip. o Scans and encodes up to a 64-key keyboard. o Controls up to a 16-digit numerical display.
• Keyboard has a built-in FIFO 8 character buffer
• The display is controlled from an internal 16x8 RAM that stores the coded display information
PIN OUT DEFINITION 8279
• A0: Selects data (0) or control/status (1) for reads and writes between micro and 8279. • BD: Output that blanks the displays. • CLK: Used internally for timing. Max is 3 MHz. • CN/ST: Control/strobe, connected to the control key on the keyboard. • CS: Chip select that enables programming, reading the keyboard, etc. • DB7-DB0: Consists of bidirectional pins that connect to data bus on micro. • IRQ: Interrupt request, becomes 1 when a key is pressed, data is available.
ADITYA ENGINEERING COLLEGE 132
MICROPROCESSORS LAB MANUAL ECE Dept.• OUT A3-A0/B3-B0: Outputs that sends data to the most significant/least significant nibble
of display. • RD (WR): Connects to micro’s IORC or RD signal, reads data/status registers. • RESET: Connects to system RESET. • RL7-RL0: Return lines are inputs used to sense key depression in the keyboard matrix. • Shift: Shift connects to Shift key on keyboard. • SL3-SL0: Scan line outputs scan both the keyboard and displays.
8279 Interfaced to the 8088
ADITYA ENGINEERING COLLEGE 133
MICROPROCESSORS LAB MANUAL ECE Dept.
Keyboard Interface of 8279
KEYBOARD INTERFACE OF 8279:
• The keyboard matrix can be any size from 2x2 to 8x8.
• Pins SL2-SL0 sequentially scan each column through a counting operation. o The 74LS138 drives 0’s on one line at a time. o The 8279 scans RL pins synchronously with the scan. o RL pins incorporate internal pull-ups, no need for external resistor pull-ups.
• Unlike the 82C55, the 8279 must be programmed first.
D7 D6 D5 Function Purpose
0 0 0 Mode set Selects the number of display positions, type of key scan…
0 0 1 Clock Programs internal clk, sets scan and debounce times.
0 1 0 Read FIFO Selects type of FIFO read and address of the read.
0 1 1 Read Display Selects type of display read and address of the read.
1 0 0 Write Display Selects type of write and the address of the write.
ADITYA ENGINEERING COLLEGE 134
MICROPROCESSORS LAB MANUAL ECE Dept.
1 0 1 Display write inhibit Allows half-bytes to be blanked.
1 1 0 Clear Clears the display or FIFO
1 1 1 End interrupt Clears the IRQ signal to the microprocessor.
o The first 3 bits of # sent to control port selects one of 8 control words.
Keyboard Interface of 8279
• First three bits given below select one of 8 control registers (opcode).
• 000DDMMM o Mode set: Opcode 000.
DD sets displays mode. MMM sets keyboard mode.
o DD field selects either: • 8- or 16-digit display • Whether new data are entered to the rightmost or leftmost display position.
DD Function
00 8-digit display with left entry
01 16-digit display with left entry
10 8-digit display with right entry
11 16-digit display with right entry
Keyboard Interface of 8279
o MMM field:
DD Function
000 Encoded keyboard with 2-key lockout
001 Decoded keyboard with 2-key lockout
010 Encoded keyboard with N-key rollover
011 Decoded keyboard with N-key rollover
100 Encoded sensor matrix
101 Decoded sensor matrix
ADITYA ENGINEERING COLLEGE 135
MICROPROCESSORS LAB MANUAL ECE Dept.
110 Strobed keyboard, encoded display scan
111 Strobed keyboard, decoded display scan
o Encoded: SL outputs are active-high, follow binary bit pattern 0-7 or 0-15. o Decoded: SL outputs are active-low (only one low at any time).
Pattern output: 1110, 1101, 1011, 0111. o Strobed: An active high pulse on the CN/ST input pin strobes data from the RL pins
into an internal FIFO for reading by micro later.
o 2-key lockout/N-key rollover: Prevents 2 keys from being recognized if pressed simultaneously/Accepts all keys pressed from 1st to last.
INTERFACE OF 8279
• 001PPPPP o The clock command word programs the internal clock driver. o The code PPPPP divides the clock input pin (CLK) to achieve the desired operating
frequency, e.g. 100KHz requires 01010 for a 1 MHz CLK input.
• 010Z0AAA o The read FIFO control word selects the address (AAA) of a keystroke from the
FIFO buffer (000 to 111). o Z selects auto-increment for the address.
• 011ZAAAA o The display read control word selects the read address of one of the display RAM
positions for reading through the data port.
• 100ZAAAA o Selects write address – Z selects auto-increment so subsequent writes go to
subsequent display positions.
INTERFACE OF 8279
• 1010WWBB o The display write inhibit control word inhibits writing to either the leftmost 4 bits of
the display (left W) or rightmost 4 bits. o BB works similarly except that they blank (turn off) half of the output pins.
• 1100CCFA o The clear control word clears the display, FIFO or both o Bit F clears FIFO and the display RAM status, and sets address pointer to 000.
If CC are 00 or 01, all display RAM locations become 00000000. If CC is 10, 00100000, if CC is 11, 11111111.
ADITYA ENGINEERING COLLEGE 136
MICROPROCESSORS LAB MANUAL ECE Dept.• 1110E000
o End of Interrupt control word is issued to clear IRQ pin in sensor matrix mode.
• 1) Clock must be programmed first. If 3.0 MHz drives CLK input, PPPPP is programmed to 30 or 11110.
INTERFACE OF 8279
• 2) Keyboard type is programmed next. o The previous example illustrates an encoded keyboard, external decoder used to
drive matrix.
• 3) Program the FIFO.
• Once done, a procedure is needed to read data from the keyboard. o To determine if a character has been typed, the FIFO status register is checked. o When this control port is addressed by the IN instruction, the contents of the FIFO
status word is copied into register AL:
INTERFACE OF 8279
• Code given in text for reading keyboard.
• Data returned from 8279 contains raw data that need to be translated to ASCII:
o Row and column number are given the rightmost 6 bits (scan/return).
o This can be converted to ASCII using the XLAT instruction with an ASCII code lookup table.
o The CT and SH indicate whether the control or shift keys were pressed.
o The Strobed Keyboard code is just the state of the RLx bits at the time a 1 was `strobed’ on the strobe input pin.
ADITYA ENGINEERING COLLEGE 137
MICROPROCESSORS LAB MANUAL ECE Dept.
ALGORITHM:
Step1: Move the value 00 to BX register.
Step2: Move the value 00 to AX register.
Step3: Move the 0FF42 to DX & out AX to DX.
Step4: Move the 90 to AL , and out value AL to DX.
Step5: Initialize counters CX with the value 08h
Step6: Move the 0ff40 to DX register and Load AL with 00
Step7: Write the value in AL register into DX register using port OUT.
Step8: Go to step 6 until equal to zero.
Step9: Move the address 2050 into SI register.
Step10: Move the value 0FF42 to DX register.
Step11: Read the value in DX register into AL register using port IN.
Step12: Add the contents of AL register with the value 07h.
Step 13: Go to step 8 if the result not equal to zero.
Step14: Get the value 40 to AL register.
Step15: Write the value in AL register into DX register using port OUT.
Step 16: move the 0ff40 to DX register.
Step 17: read the value in DX register into AL register using port IN.
Step 18: Logical AND ed the contents of AL with 01F.
Step19: Move the value of AL into BL register.
Step 20: Add the contents of SI with BX register.
Step21: Initialize data port and move the value 94 into AL register.
Step22: Write the data in AL register into DX register using port OUT.
Step 23: Initialize Command port and move the value F3 into AL register.
ADITYA ENGINEERING COLLEGE 138
MICROPROCESSORS LAB MANUAL ECE Dept.Step24: Write the value in AL register into DX register using port OUT.
Step25: Initialize the data port and move the value 95 into AL register.
Step 26: Write the value in AL register into DX register using port OUT.
Step 27: Initialize the Command port.
Step 28: Move the contents of SI into AL register.
Step29: Write the value in AL register into DX register using port OUT.
Step 30: Go to step 8.
Step31: Stop.
PROGRAM: MOV BX, 00H
MOV DX, 0FF42
MOV AL, 00
OUT DX, AL
MOV AL, 90
OUT DX, AL
MOV CX, 08
MOV AL, 00
MOV DX, 0FF40
RPT: OUT DX, AL
LOOP RPT
BACK: MOV SI, 2050
MOV DX, 0FF42
KEY: IN AL, DX
ADITYA ENGINEERING COLLEGE 139
MICROPROCESSORS LAB MANUAL ECE Dept.AND AL, 07
JZ KEY
MOV AL, 40
OUT DX, AL
MOV DX, 0FF40
IN AL, DX
AND AL, 1F
MOV BL, AL
ADD SI, BX
MOV DX, 0FF42
MOV AL, 94
OUT DX, AL
MOV DX, 0FF40
MOV AL, 0F3
OUT DX, AL
MOV DX, 0FF42
MOV AL, 95
OUT DX, AL
MOV DX, 0FF40
MOV AL, [SI]
OUT DX, AL
JMP BACK
CODE TABLE:
Physical address Label Hex code Mnemonic
Op code operands
Comments
Segment address
Effective address
0000 2000 BB 00 00 MOV BX,00 Load 00 with BX register
ADITYA ENGINEERING COLLEGE 140
MICROPROCESSORS LAB MANUAL ECE Dept.
2003 BA 42 FF MOV DX,0FF42 Initialize control port
2006 B0 00 MOV AL,00 Load 00 with Al register
2008 EE OUT DX,AL Routine to clear
2009 B0 90 MOV AL, 90 All display LEDs
200B EE OUT DX,AL
200C B9 08 00 MOV CX,08 Set the count
200F B0 00 MOV AL,00 Load 00 with AL register
2011 BA 40 FF MOV DX,0FF40 Initialize data port
2014 RPT EE OUT DX,AL Read the data from port
2015 E2 FD LOOP RPT Continuous loop
2017 BACK
BE 50 20 MOV SI, 2050 Initialize SI with 2050
201A BA 42 FF MOV DX,0FF42 Read 8279 status to check if any character is available
201D KEY EC IN AL,DX Write the data from port IN
201E 24 07 AND AL,07 Logical AND between [AL] and 07h
2020 74 FB JZ KEY Jump if condition
2022 B0 40 MOV AL,40 Load AL register with 40
2024 EE OUT DX,AL Read the data from port
2025 BA 40 FF MOV DX,0FF40 Read FIFO RAM
2028 EC IN AL,DX Mask SIFT
2029 24 1F AND AL,1F AND AL with 1F
202B 8A D8 MOV BL,AL Move the contents of AL into BL
202D 03 F3 ADD SI,BX Add SI with BX
ADITYA ENGINEERING COLLEGE 141
MICROPROCESSORS LAB MANUAL ECE Dept.
202F BA 42 FF MOV DX,0FF42 Address to display 0
2032 B0 94 MOV AL,94 Load AL register with 94
2034 EE OUT DX,AL Read the data from port
2035 BA 40 FF
MOV DX,0FF40 Addressed control port
2038 B0 F3 MOV AL,F3 Move the value 0F3 into AL register
203A EE OUT DX,AL Read the data from port
203B BA 42 FF MOV DX,0FF42 Addressed data port
203E B0 95 MOV AL,95 Set 95 into AL register
2040 EE OUT DX,AL Read the data from port
2041 BA 40 FF MOV DX,0FF40 Initialize control port
2044 8A 04 MOV AL,[SI] Move the contents of SI into the AL register
2046 EE OUT DX,AL Read the data from port
2047 E9 CD FF JMP BACK Unconditional jump
INPUT DATA:
Segment address
Offset address
DATA INPUT
2050 F3 60 B5 F4
2054 66 D6 D7 70
2058 F7 76 77 C7
205C 93 E5 97 17
RESULT:
VIVA-VOCE QUESTIONS
ADITYA ENGINEERING COLLEGE 142
MICROPROCESSORS LAB MANUAL ECE Dept.90. What is the difference between opcode and operand?
91. What is the function of instruction pointer (IP) register?
92. What does assembler mean?
93. What is the difference between RCL and ROL instructions?
94. Which signal is used to restart the 8086 microprocessor?
95. What is the power supply required for 8086 microprocessor?
ADDITIONAL PROGARMS
DUAL SLOPE ANALOG TO DIGITAL CONVERTERS
AIM: To Convert digital data into Analog voltage.
INTRODUCTION:The analog to digital conversion can be done in many ways. One of the methods is the Dual
Slope method, used to achieve high noise immunity.The input voltage is integrated for a fixed time T1. Also a known reference voltage VR is
integrated for a time TX. Now the input voltage VX is given by XX TT
VV ×=
1
1
But 1
1
T
V=K (a constant)
Hence VX = K . TX I.e. the input voltage is proportional to the measured time TX. If integrated time TC is chosen as 20 m sec.the microprocessor measures time as the number of counts, namely
ADITYA ENGINEERING COLLEGE 143
MICROPROCESSORS LAB MANUAL ECE Dept.TX = NX. TC where
• NX is number of counts.• TX is counter period.By proper choice of the counter period TC scaling can be incorporated into the counter such that a software multiplication can be avoided.
THEORY: Voltage,current,temperature,pressure,time,etc, are available in analog form.ot is difficult to
process ,store or transmit the analog signal with out introducing considerable error because of the superimposition of noise as in the case of amplitude modulation. Therefore, for processing, transmission and storage purpose. It is often convenient to express these variables in digital form, it gives better accuracy system is based.
The operation of any digital communication system is based upon analog to digital and digital to analog conversion.
A/D converter requires sample and hold(S/H) circuit. The ADC output is a sequence of binary digit.D/A converter is to convert digital signal to analog signal and function of DAC is exactly opposite to that of ADC. The D/A converter is usually operated at the same frequency as the ADC.the output of D/A converter is commonly a stair case. This stair case like digital output is passed through a smoothing filter to reduce the effect of quantization noise.
ADC’s are classified broadly into two groups according to their conversion technique:1. Direct type ADC’s and2. Integrating type ADC’s.
Direct type ADC’s compare a given analog signal with the internally generated equivalent signal. This group includes:1. Flash (comparator) type converter2. Counter type converter.3. Tracking or servo converter4. Successive approximation type converter.
Integral type ADC’s perform conversion in an indirect manner by first changing the analog input signal to a linear function of time or frequency and then to a digital code .the two most widely used integrating type converters are:1. Charge balancing ADC.2. Dual slope ADC
The flash (comparator) type is expensive for high of accuracy the integrated type converter is used in application such as digital meter, panel meter and so on.
PARALLEL COMPARATOR (FLASH) A/D CONVERTER:It is simplest possible converter and the fastest and most expensive technique.
3-BIT A/D CONVERTER:Circuit consists of resistive divider network, 8 op-amp comparators and 8-5line encoder. At each node of the resistive divider, a comparison voltage is available .since all the resistors are of equal value, the voltage levels available at the nodes are equally divided between the reference voltage VR and the ground.
The purpose of circuit is to compare the analog input voltage VA with each of the voltages.
ADITYA ENGINEERING COLLEGE 144
MICROPROCESSORS LAB MANUAL ECE Dept.The circuit has the advantage of high speed as the conversion take place
simultaneously rather than sequentially. Typical conversion time is loons or less. Conversion time is limited only by the speed of the comparator and of the priority encoder by using advanced micro devices AMA 686A comparator and a T1147 priority encoder ,conversion delays of the order of 20 no’s can be obtained.
This type of ADC has the disadvantage that the number of comparators required almost doubles for each added bit. A 2-bit ADC requires 3 comparators .in general, the number of comparators required are 2n-1 where n is the desired number of bits. Hence the number of comparators approximately doubles for each added bit. Also the larger the value of n the more complex is the priority encoder.
INTEGRATING TYPE OF ADC’S: the generating type of ADC’s do not require a S/H circuit at the input. If the input changes during conversion, the ADC’s output code will be proportional to the value of the input averaged over the integration period.
DUAL SLOPE ADC:
DUAL SLOPE OR DUAL RAMP CONVERTERS:
The analog part of the circuit consists of a high input impedance buffer A1, precision integrator A2 and a voltage comparator. The converter fort integrates the analog input signal VA for a fixed duration of 2n clock periods. Then to integrate an internal reference voltage VR of opposite polarity until the integrator output is zero. The number N of clock cycles required to return the integrated period. Hence N represents the desired output code. Since VR and n are constant, the analog voltage VA is proportional to the count reading N and is independent of R,C and T.
The dual-slope ADC integrates the input signal for a fixed time, hence to provides excellent noise rejection of ac signals whose periods are integral multiples of the integration time T1.
The main disadvantage of the dual-slope ADC is the long conversion time. For instance, if 2n-T =1 / 50 is used to reject line pick-up , the conversion time will be 20 m sec.
Dual-slope converters are particularly suitable for accurate measurement of slowly varying signal, such as thermo couples and weighing scales. Dual slope ADC’s also form the basics of digital panel meters and millimeters.
Dual slope converters are available in monolithic form and are available both in microprocessors compatible and in display oriented versions.
REGISTERS USED: AX, BX, CX, DX.
PORTS USED: Port A and Port B.
ALGORITHM:
Step1: Initialize 8255 Control Word Register and Port A as O/P port and Port B as I/P port.
Step2: Load the number 02 in AL register.
Step3: Initialize Port A address and read the data from port out.
Step4: Perform NOP five times.
ADITYA ENGINEERING COLLEGE 145
MICROPROCESSORS LAB MANUAL ECE Dept.Step5: Move the number 01h into AL register.
Step6: Read the data from port out.
Step7: Load CX register with 1000h.
Step8: Continue the loop if CX is not equal to zero.
Step9: Load AL with 04 and read the data from port out.
Step10: Initialized port A with 0FFE0 and initialized BX register with 0000h.
Step11: Initialized port B with 0FFE2 and write the data from register AL using port IN.
Step12: Logical AND operation AL register with 01h value.
Step13: Jump the corresponding condition to specify in instruction.
Step14: After the increment the BL register jump step 11.
Step15: Move the contents of BL register into the AL register.
Step16: Initialize SI with 3000h and move the value in AL register into the SI location.
Step 17: Load AL register with 02h
Step 18: Initialize port A and read the data from port out.
Step19: Get the value 03h into BX register.
Step20: Initialize CX with 0FFFFh and continue the loop until CX is equal to zero.
Step21: Decrement the value of BX register and jump step 20 if BX equal to zero.
Step22: Jump step 2 Unconditional
Step23: Stop.
PROGRAM:MOV DX, 0FFE6
MOV AL, 82
OUT DX, AL
ADITYA ENGINEERING COLLEGE 146
MICROPROCESSORS LAB MANUAL ECE Dept.START: MOV AL, 02H
MOV DX, 0FFE0
OUT DX, AL
NOP
NOP
NOP
NOP
NOP
MOV AX, 01
OUT DX, AL
MOV CX, 1000H
L2: LOOP L1
MOV AL, 04H
OUT DX, AL
MOV DX, 0FFE0
MOV BL, 00H
L1: MOV DX, 0FFE2
IN AX, DX
AND AL, 01
JE DISP
INC BL
JMP L1
DISP: MOV AL, BL
ADITYA ENGINEERING COLLEGE 147
MICROPROCESSORS LAB MANUAL ECE Dept.MOV SI, 3000H
MOV [SI], AL
MOV AL, 02H
MOV DX, 0FFE0
OUT DX, AL
MOV BX, 20
DELAY: MOV CX, 0FFFF
$: LOOP $
JNZ DELAY
JMP START
CODE TABLE:
Physical address Label Hex code
Mnemonic
Op code operands
Comments
Segment address
Effective address
0000 4000 BA E6 FF MOV DX,0FFE6 Initialize the Control word
register4003 B0 82 MOV AL,82 Port A as output &
port B as input4004 EE OUT DX,AL
4006 START B0 02 MOV AL,02 Reset integrator
4008 BA E0 FF MOV DX,0FFE0 Addressed port A ie initializes.
400B EE OUT DX,AL Read the data from port out
400C 90 NOPNo operation
4011 90 NOP
4014 90 NOP
4015 90 NOP
4018 90 NOP
ADITYA ENGINEERING COLLEGE 148
MICROPROCESSORS LAB MANUAL ECE Dept.
401A B8 01 00 MOV AX,01 Load AX with 01h
401C EE OUT DX,AL Read the data
401D B9 00 10 MOV CX, 1000H Set the count with 1000h
4020 L1 E2 FE LOOP L1 Continuous loop
4022 B0 04 MOV AL,04H Load AL with 04number
4025 EE OUT DX,AL Read the data
4026 BA E0 FF MOV DX,0FFE0 Initialized port A addressed
4028 B3 00 MOV BL,00 Clear BL register
402A L2 BA E2 FF MOV DX,0FFE2 Initialize port B
402C EC IN AL,DX Write the data from port IN
402E 24 01 AND AL, 01H AND ed operation between AL and 01
4030 74 04 JE DISP Jump conditionally4033 FE C3 INC BL Increment value of
BL4035 EB F4 JMP L2 Jump
Unconditionally4037 DSP 8A C3 MOV AL,BL Move the contents
from AL into BL403A B8 00 30 MOV SI,3000 Initialize SI with
3000h403B MOV [SI],AL Move the value in
AL register into contents of SI
403E B0 02 MOV AL,02 Load AL with the value 02h
4041 BA E0 FF MOV DX,0FFE0 Initialize port A
4043 EE OUT DX,AL Read the data from port out
4044 BB 20 00 MOV BX,20 Set the 20h in BX register
4046 DY B9 FF FF MOV CX,0FFFH Set the count with 0FFFFh value into
CX register4049 L3 F2 EE LOOP L3 Continuous loop
ADITYA ENGINEERING COLLEGE 149
MICROPROCESSORS LAB MANUAL ECE Dept.404B 4B DEC BX Decrement the
value of BX register
404C 75 F8 JNZ DY Jump Conditionally
404E EB AD JMP START Jump Unconditionally.
RESULT:
STEPPER MOTOR INTERFACING
AIM: program to design a stepper motor to rotate shaft of a 4 phase stepper motor in clockwise 15 rotations.
REGISTERS USED: General purpose registers: AL , DX , CX
PORTS USED: Port B, port C (out)
CONNECTIONS: J4 of ESA 86/88E to J1 of stepper motor.OPERATING PRINCIPLE OF PERMANENT MAGNET STEPPER MOTOR:
ADITYA ENGINEERING COLLEGE 150
MICROPROCESSORS LAB MANUAL ECE Dept.
It consists of two stator windings A,B and a motor having two magnetic poles N and S. when a voltage +v is applied to stator winding A, a magnetic field Fa is generated. The rotor positions itself such that its poles lock with corresponding stator poles.
With the winding ‘A’ excited as before ,winding ‘b’ is now to Fa. the resulting magnetic field F makes an angle of 450. the rotor consequently moves through 450 in anti clockwise direction,again to cause locking of rotor poles with corresponding stator poles.
While winding ‘B’ has voltage +V applied to it, winding ‘A’ is switched off. The rotor then moves through a further 450 in anti-clockwise direction to aligne itself with stator field Fb. with voltage +V on winding B, a voltage –V is applied to winding A. then the stator magnetic field has two components Fa , Fb and their resultant F makes an angle of 1350 position.
In this way it can be seen that ,as the pattern of excitation of the state of winding is changed, the rotor moves successively through450 steps. And completes one full revolution in anti clock-wise direction. A practical PM stepper motor will have 1.80 step angle and 50 tooth on it’s rotor;there are 8 main poles on the stator, each having five tooth in the pole face. The step angle is given by
A = 360 / (N * K) degrees
Where N = number of rotor tooth.
K = execution sequence factor.
PM stepper motors have three modes of excitation i,e..
• Single phase mode
• Two phase mode
• Hybrid mode
Single phase mode: in this mode only one of the motor winding is excited at a time. There are four steps in the sequence, the excitation sequence factor K=2 ,so that step angle is 900.
Two phase mode: Here both stators phase are excited at a time. There are four steps in the excitation sequence, K = 2 and the step angle is 900. However, the rotor positions in the two phase mode are 450 way from those in single phase mode.
ADITYA ENGINEERING COLLEGE 151
MICROPROCESSORS LAB MANUAL ECE Dept.Hybrid mode: this is a combination of single and two phase modes. There are 8 steps in excitation sequence=2 and step angle = 450. a voltage +V is applied to a stator winding during some steps, which voltage V is applied during certain other steps. This requires a bipolar regulated power supply capable of yielding +V,-V and zero outputs and a air of SPDT switches, which is quite cumbersome. Consequently each of the two stator windings is split into two sections A1-A2 , B1-B2. these sections are wound differentially. These winding sections can now be excited from a univocal regulated power supply through switcher S1 to S4. this type of construction is called bipolar winding construction. Bipolar windingesults in reduced winding inductance and consequently improved torque stepping rate.Description: the stepper motor interfaces uses four transistor pairs (SL 100 and 2N 3055) in a Darlington pair configuration. Each Darlington pair is used to excite the particular winding of the motor connected to 4 pin connector on the interface. The inputs to these transistors are from the 8255 PPI I/O lines of the microprocessor kit or from digital I/O card plugged in the PC. “port A” lower nibble PA0 , PA1, PA2 , PA3 are the four lines brought out to the 26 pin FRC male connector(J1) on the interface module. The freewheeling diodes across each winding protect transistors from switching transients.Theory:
A motor used for moving things in small increments is known as stepper motor. Stepper motor rotate from one fixed position to next position rather than continuous rotation as in case of other ac or dc motor stepper motors are used in printers to advance the paper from one position to advance the paper from one position to another in steps. They are also used to position the read/write head on the desired track of a floppy disk. To rotate the shaft the stepper motor a sequence of pulses are applied to the windings in a predefined sequence. The number of pulses required for one complete rotation per pulse is given by 3600/NT. where “NT” is the number of teeth on rotot. Generally the stepper motor is available with 10 to 300 rotation. They are available with two phase and four phase common field connections.
Instead of rotating smoothly around and around as most motors, stepper motors rotate or step one fixed position to next. Common step size range from 0.90 to 300. it is stepped from one position to next by changing the currents through the fields in the motor.
The two common field connections are referred to as two phase and four phase. The drive circuitry is simpler in 4 phase stepper. The figure shows a circuitry that can interface a small 4 stepper motor to four microcomputer port lines.
The 7406 buffers are inverting , so. A high on ah output port pin turns on current to a winding. The purpose of clamp diodes across each winging is to save transistors from inductive kick. Resistors R1 and R2 are current limiting resistors.Typical parameters of stepper motor:1. Operating voltage - 12 volts2. Current rating - 1.2 Amp3. Step angle - 1.80
4. Step for revolution - 200(No. of teeth on rotor)5. Torque - 3 kg/cmWorking of stepper motor:
Suppose that SW1 and SW2 are turned ON. Turning OFF SW2 and turning ON SW4 cause the motor to rotate one step of 1.80 clockwise. Changing to SW4 and SW3 ON will cause the motor to rotate 1.80 clockwise another. Changing SW3 and SW2 ON will cause another step. To step the motor in counter clock wise direction simply work through the switch sequence in the reverse direction.
The switch pattern for changing from one step to another step in clockwise direction is simply rotated right one position. For counter clockwise direction rotated left one position.
ALGORITHM:
ADITYA ENGINEERING COLLEGE 152
MICROPROCESSORS LAB MANUAL ECE Dept.
Step 1: Start
Step 2: move the control word address 0FFE6 to register DX
Step 3: move 80 to AL register.
Step 4: locate the contents in AL register to DX register using port out.
Step 5: move port A address ie.,,0FFE0 to DX register.
Step 6: move 11 to AL register.
Step 7: locate the contents in AL register to DX register using port out.
Step 8: move 300 to CX register.
Step 9: repeat step 8 until the content in CX register becomes equal to zero.
Step 10: Rotate carry left through bit.
Step 11: jump to location / step 7.
Step 12: stop.
ADITYA ENGINEERING COLLEGE 153
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
Start
Initialize the control word register
FLOW CHART
Copy the contents from AX to 80 &Locate the contents in AL to DX register using port
out
Move the data 11h into AL register &Locate the contents in AL to DX register using port
out
Initialize port A address
1
Load CX register with 300
2
154
MICROPROCESSORS LAB MANUAL ECE Dept.
ADITYA ENGINEERING COLLEGE
1
NO YES
Stop
Decrement CX &CX=0
Jump
2
Rotate carry left through bit
155
MICROPROCESSORS LAB MANUAL ECE Dept.
PROGRAM:
MOV DX, 0FFE6
MOV AX, 80
RPT: OUT DX, AX
MOV DX, 0FFE0
MOV AX, 0011
RPT: OUT DX, AX
MOV CX, 0300
L1: LOOP L1
RCL AL, 01H
JMP RPT
ADITYA ENGINEERING COLLEGE 156
MICROPROCESSORS LAB MANUAL ECE Dept.
CODE TABLE:
Physical address Label Hex code Mnemonic
Op code operands
Comments
Segment address
Effective address
0000 5000 BA E6 FF Mov DX , FFE6 Move FFE6 to DX register
5003 B8 80 00 Mov AX, 0080 Load AX with 80
5006 EF Out DX , AX Move AX content to DX
5007 BA E0 FF Mov DX , FFE0 Move FFE0 to DX register
500A Rpt B8 FF 00 Mov AX , 00FF Load AX with 00FF
500D EF Out DX,AX Move AX content to DX
500E E8 FF EF Call 6000
5011 B8 00 00 Mov AX , 0000 Load AX with 0000
5014 EF Out DX , AX Move the contents of AX into DX
5015 E8 E8 FF Call 6000
5018 E8 F0 Jmp Rpt Jump to 500A location
RESULT:
ADITYA ENGINEERING COLLEGE 157
top related