CHENNAI INSTITUTE OF TECHNOLOGY Sarathy Nagar, Pudupedu

advertisement
MT6411 - Microprocessor Laboratory
CHENNAI INSTITUTE OF TECHNOLOGY
Sarathy Nagar, Pudupedu, Chennai– 600 069.
DEPARTMENT OF MECHATRONICS ENGINEERING
MT6411 – MICROPROCESSOR LABORATORY
LABORATORY MANUAL
\
1
MT6411 - Microprocessor Laboratory
LIST OF EXEPRIMENTS
Sl.No.
Name of the Experiments
Page No.
Introduction to 8085 Microprocessor
3
1
Addition of 2 - 8 bit numbers
11
2
Subtraction of 2 – 8 bit numbers
14
3
Addition of 2 - 16 numbers
17
5
8 – bit Multiplication
21
6
8 – bit Division
24
7
To a arrange a series of numbers in Ascending order
27
8
To a arrange a series of numbers in Descending order
30
9
Analog to Digital Conversion
33
10
Decimal Addition of 8-bit numbers
36
11
Hexadecimal to Decimal & Decimal to Hexadecimal Conversion
37
12
Stepper motor Controller
44
2
MT6411 - Microprocessor Laboratory
INTRODUCTION TO MICROPROCESSOR 8085
Aim
To study the microprocessor 8085
Architecture of 8085 Microprocessor
a) General purpose register
It is an 8 bit register i.e. B,C,D,E,H,L. The combination of 8 bit register is known as
register pair, which can hold 16 bit data. The HL pair is used to act as memory pointer is
accessible to program.
b) Accumulator
It is an 8 bit register which hold one of the data to be processed by ALU and stored
the result of the operation.
c) Program counter (PC)
It is a 16 bit pointer which maintain the address of a byte entered to line stack.
d) Stack pointer (Sp)
It is a 16 bit special purpose register which is used to hold line memory address for
line next instruction to be executed.
e) Arithmetic and logical unit
It carries out arithmetic and logical operation by 8 bit address it uses the accumulator
content as input the ALU result is stored back into accumulator.
f) Temporary register
It is an 8 bit register associated with ALU hold data, entering an operation, used by
the microprocessor and not accessible to programs.
g) Flags
Flag register is a group of fire, individual flip flops line content of line flag register
will change after execution of arithmetic and logic operation. The line states flags are
i)
Carry flag (C)
ii)
Parity flag (P)
iii)
Zero flag (Z)
iv)
Auxiliary carry flag (AC)
v)
Sign flag (S)
h) Timing and control unit
Synchronous all microprocessor, operation with the clock and generator and control
signal from it necessary to communicate between controller and peripherals.
i) Instruction register and decoder
Instruction is fetched from line memory and stored in line instruction register decoder
the stored information.
j) Register Array
These are used to store 8 bit data during execution of some instruction.
3
MT6411 - Microprocessor Laboratory
PIN Description
Address Bus
1.
The pins Ao – A15 denote the address bus.
2.
They are used for most significant bit
Address / Data Bus
1.
AD0 – AD7 constitutes the address / Data bus
2.
These pins are used for least significant bit
ALE : (Address Latch Enable)
1.
The signal goes high during the first clock cycle and enables the lower order
address bits.
IO / M
1.
This distinguishes whether the address is for memory or input.
2.
When this pins go high, the address is for an I/O device.
S0 –
S0 and S1 are status signal which provides different status and functions.
S1
RD
1.
2.
This is an active low signal
This signal is used to control READ operation of the microprocessor.
WR
1.
2.
WR is also an active low signal
Controls the write operation of the microprocessor.
HOLD
1.
This indicates if any other device is requesting the use of address and data bus.
HLDA
1.
2.
HLDA is the acknowledgement signal for HOLD
It indicates whether the hold signal is received or not.
INTR
1.
2.
INTE is an interrupt request signal
IT can be enabled or disabled by using software
INTA
1.
2.
Whenever the microprocessor receives interrupt signal
It has to be acknowledged.
RST 5.5, 6.5, 7.5
1.
These are nothing but the restart interrupts
2.
They insert an internal restart junction automatically.
4
MT6411 - Microprocessor Laboratory
TRAP
1.
2.
Trap is the only non-maskable interrupt
It cannot be enabled (or) disabled using program.
RESET IN
1.
This pin resets the program counter to 0 to 1 and results interrupt enable and
HLDA flip flops.
X1,
These are the terminals which are connected to external oscillator to produce the
X2
necessary and suitable clock operation.
SID
This pin provides serial input data
SOD
This pin provides serial output data
VCC and VSS
1.
VCC is +5V supply pin
2.
VSS is ground pin
Specifications
1. Processors
Intel 8085 at E144 MHz clock
2. Memory
Monitor RAM:
0000 – IFFF
EPROM Expansion: 2000 – 3FFF’s
0000 – FFF
System RAM:
4000 – 5FFF
Monitor data area
4100 – 5FFF
RAM Expansion
6000 – BFFF
3. Input / Output
Parallel: A8 TTL input timer with 2 number of 32-55 only input timer available in -85 EBI.
Serial: Only one number RS 232-C, Compatible, crucial interface using 8281A
Timer: 3 channel -16 bit programmable units, using 8253 channel ‘0’ used for no band late.
Clock generator. Channel ‘1’ is used for single stopping used program.
Display: 6 digit – 7 segment LED display with filter 4 digit for adder display and 2 digit for
data display.
Key board: 21 keys, soft keyboard including common keys and hexa decimal keys.
RES: Reset keys allow to terminate any present activity and retain to  - 85 its on initialize
state.
5
MT6411 - Microprocessor Laboratory
INT: Maskable interrupt connect to CPU’s RST 7.5 interrupt
DEC: Decrement the adder by 1
EXEC: Execute line particular value after selecting address through go command.
NEXT: Increment the address by 1 and then display its content.
Key Functions:
E
0
SUB
RD
1
i. Hex entry key ‘0’
ii. Substituting memory content where “next” key is paused immediately
after 1, take used to st cutting address.
iii. Register key ‘E’
i)
ii)
Hex code entry (1)
Register key ‘D’
i)
ii)
iii)
Hex code entry ‘2’
Retricre data from data ‘memory’ to data top
Register key ‘C’
i)
ii)
iii)
Hex code entry ‘3’
Retricre data from memory to top
Register key ‘B’
i)
ii)
iii)
Hex key entry ‘C’
Block search from byte
Register key ‘F’
i)
ii)
iii)
Hex key entry ‘5’
Fill block of RAM memory with desired data
Register key ‘A’
i)
ii)
iii)
Hex key entry ‘6’
TN/Tl used for sending (or) receiving
Register key ‘H’
i)
ii)
Hex key entry ‘7’
Register key ‘H’
REG
C
2
TN
B
3
TR
F
4
BLOC
A
5
FILL
L
6
SER
H
7
F2
6
MT6411 - Microprocessor Laboratory
i)
ii)
Register key ‘S’
Register key ‘I’
SNG
i)
ii)
iii)
Hex key entry ‘A’
Function key F3
Register key “ph”
PH
i)
ii)
Hex key entry “y”
Signal step program (instruction by instruction)
i)
ii)
iii)
Hex key entry “c”
Much a block of memory from a linear block
Register key “SH”
i)
ii)
Hex key D
Compare 2 memory block
i)
ii)
iii)
Hex key entry ‘B’
Check a block from flame
Register key “SPL”
i)
ii)
Hex key ‘E’
Insert by test into memory (RAM)
i)
ii)
Hex key ‘F’
Delete byte from memory RAM
I
8
G0
PL
9
A
F3
C
SH
MOV
D
CMP
B
SL
BC
E
INS
F
DEL
System Power Consumption
Micro BSEB2
+5V @ 1Amp
+12V @ 200 mA
- 12V @ 100 mA
MICRO SSEB
+5V@ 800 mA
7
MT6411 - Microprocessor Laboratory
Power Supply Specification
MICRO SSEM
230V, AC @ 80 Hz
+5V @ 600 mA
Key Function
8
MT6411 - Microprocessor Laboratory
IC’s Used
8085
8253
8255
8279
8251
2764
6264
7414
7432
7409
7400
7404
74373
74139
74138
-
8 bit p
programmable internal timer
programmable peripheral interface
programmable key boards / display interface
programmable communication interface
8 KV VV EPROM
8K STATIC PROM
Hex inverter
Quad 21/p OR GATE
Quad 21/p AND GATE
NAND Gate
Dual D-FF
Octal ‘D’ Latch
Dual 2 to 4 line decoder
3 to 8 line decoder
9
MT6411 - Microprocessor Laboratory
In Enter Program into Trainer Kit
1.
2.
3.
4.
5.
6.
7.
8.
Press ‘RESET’ key
Sub (key processor represent address field)
Enter the address (16 bit) and digit in hex
Press ‘NEXT’ key
Enter the data
Again press “NEXT”
Again after taking the program, are use HLT instruction
its Hex code
Press “NEXT”
How to executive program
1.
Press “RESET”
2.
Press “GO”
3.
Enter the address location in which line program was executed
4.
Press “Execute” key
Result:
Thus 8085 microprocessor was studied successfully.
10
MT6411 - Microprocessor Laboratory
ADDITION OF TWO 8-BIT NUMBERS
Aim:
To write an assembly language for adding two 8 bit numbers by using micro
processor kit.
Apparatus required:
8085 micro processor kit
(0-5V) DC battery
Algorithm:
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
Step 10
Step 11
Step 12
:
:
:
:
:
:
:
:
:
:
:
:
Start the microprocessor
Intialize the carry as ‘Zero’
Load the first 8 bit data into the accumulator
Copy the contents of accumulator into the register ‘B’
Load the second 8 bit data into the accumulator.
Add the 2 - 8 bit datas and check for carry.
Jump on if no carry
Increment carry if there is
Store the added request in accumulator
More the carry value to accumulator
Store the carry value in accumulator
Stop the program execution.
11
MT6411 - Microprocessor Laboratory
STAR
T
Intialise the carry as
zero
Load the 1st 8 bit number
Transfer the 1st number to register ‘B’
Load the 2nd 8 bit number
Transfer and Add the contents of A and B
No
Check
for
carry?
Yes
Increment carry by
one
Store the added value in accumulator
Move the contents of carry into accumulator
Store the value of carry in accumulator
END
12
MT6411 - Microprocessor Laboratory
Address
4100
4102
4105
Mnemonics
MVI C,00
LDA 4300
MOV, B,A
Hex Code
OE, 00
3A, (00, 43)
47
4106
LDA 4301
3A, (01, 43)
4109
410A
410D
ADD B
JNC
INR C
80
D2, 0E, 41
OC
STA 4302
32 (02, 43)
4111
MOV A,C
79
4112
STA 4303
32 (03, 43)
4115
HLT
76
410E
Label
Loop
Comments
Initialize the carry as zero
Load the first 8 bit data
Copy the value of 8 bit data
into register B
Load the second 8 bit data
into the accumulator
Add the hoo values
Jump on if no carry
If carry is there increment it
by one
Stone the added value in the
accumulator
More the value of carry to
the
accumulator
from
register C
Store the value of carry in
the accumulator
Stop the program execution
Input
Without carry
Input Address
4300
4301
Value
04
02
Output Address
4302
4303
Value
06
00 (carry)
Input Address
4300
4301
Value
FF
FF
Output Address
4302
4303
Value
FE
01 (carry)
Output
With carry
Calculation
(1)
1111 1111
1111 1111
--------------1111 1110
=========
F
E
Result:
The assembly language program for 8 bit addition of two numbers was executed
successfully by using 8085 micro processing kit.
13
MT6411 - Microprocessor Laboratory
SUBTRACTION OF TWO 8 BIT NUMBERS
Aim:
To write a assembly language program for subtracting 2 bit (8) numbers by using8085 micro processor kit.
Apparatus required:
8085 micro processor kit
(0-5V) DC battery
Algorithm:
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
Step 10
Step 11
Step 12
Step 13
:
:
:
:
:
:
:
:
:
:
:
:
:
Start the microprocessor
Intialize the carry as ‘Zero’
Load the first 8 bit data into the accumulator
Copy the contents of contents into the register ‘B’
Load the second 8 bit data into the accumulator.
Subtract the 2 8 bit datas and check for borrow.
Jump on if no borrow
Increment borrow if there is
2’s compliment of accumulator is found out
Store the result in the accumulator
More the borrow value from ‘c’ to accumulator
Store the borrow value in the accumulator
Stop program execution
14
MT6411 - Microprocessor Laboratory
START
Intialise the borrow as zero
Load the 1st 8 bit number
Move the 1st 8 bit data to register ‘B’
Load the 2nd 8 bit number
Subtract the two values
No
Check
for
carry?
Yes
Increment carry by one
1’s compliment of 2nd value
Add 1 to 1’s compliment for 2’s compliment
Store the value of result in accumulator
Move the carry into the accumulator
Store the value of carry in accumulator
END
15
MT6411 - Microprocessor Laboratory
Address
4100
4102
Mnemonics
MVI C,00
LDA 4300
Hex Code
OE, 00
3A, (00, 43)
4105
4106
MOV, B,A
LDA 4301
47
3A, (01, 43)
4109
410A
410D
SUB B
INC
INR C
90
D2, 0E, 41
OC
CMA
ADI, 01
2F
6, 01
4111
4114
STA 4302
MOV A,C
32,02,43
79
4115
4118
STA 4303
HLT
32,03,43
76
410E
410F
Label
Loop
Loop
Comments
Initialize the carry as zero
Load the first 8 bit data into the
accumulator
Copy the value into register ‘B’
Load the 2nd 8 bit data into
the
Subtract both the values
Jump on if no borrow
If borrow is there, increment it by
one
Compliment of 2nd data
Add one to 1’s compliment of 2nd
data
Store the result in accumulator
Moul the value of borrow into the
accumulator
Store the result in accumulator
Stop Program execution
Input
Without borrow
Input Address
4300
4301
Value
05
07
Output Address
4302
4303
Value
02
00 (borrow)
Input Address
4300
4301
Value
07
05
Output Address
4302
4303
Value
02
01 (borrow)
Output
With carry borrow
Calculation
CMA
ADJ 0.1
05 -
05 – 07
07 – 0111
1000
0001
-----1001
0101
-----1110 (-2)
Result:
The assembly language program subtraction of two 8 bit numbers was executed
successfully by using 8085 micro processing kit.
16
MT6411 - Microprocessor Laboratory
ADDITION OF TWO 16 – BIT NUMBERS
Aim:
To write an assembly language program for adding two 16 bit numbers using 8085
micro processor kit.
Apparatus required:
8085 micro processor kit
(0-5V) DC battery
Algorithm:
Step 1
Step 2
:
:
Step 3
Step 4
:
:
Step 5
Step 6
Step 7
Step 8
Step 9
:
:
:
:
:
Step 10
Step 11
Step 12
:
:
:
Start the microprocessor
Get the 1st 8 bit in ‘C’ register (LSB) and 2nd 8 bit in ‘H’
register (MSB) of 16 bit number.
Save the 1st 16 bit in ‘DE’ register pair
Similarly get the 2nd 16 bit number and store it in ‘HL’ register
pair.
Get the lower byte of 1st number into ‘L’ register
Add it with lower byte of 2nd number
tore the result in ‘L’ register
Get the higher byte of 1st number into accumulator
Add it with higher byte of 2nd number and carry of the lower
bit addition.
Store the result in ‘H’ register
Store 16 bit addition value in ‘HL’ register pair
Stop program execution
17
MT6411 - Microprocessor Laboratory
START
C = 00H
Load ‘HL’ with 1st Data
Transfer HL - DE
Load ‘HL’ with 2nd Data
DE + HL = HL
If
Cy
=0
C = C + 01
Store ‘HL’ in memory
(SUM)
Transfer C - A
Store ‘A’ in memory (Cy)
STOP
18
MT6411 - Microprocessor Laboratory
Address
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
Label
Mnemonics
MVI
C,00
LHLD
4800
XCHG
LHLD
4802
DAD
D
JNC
Ahead
450E
450A
450B
450C
450D
450E
450F
4510
4511
4512
4513
4514
4515
AHEAD
INR
SHLD
C
4804
MOV
STA
C,A
4806
HLT
Input
Without
Input Address
4800
4801
4802
4803
Value
01 (addend)
04
02 (augend)
03 (augend)
Output Address
4804
4805
4806
Value
03 (sum)
07 (sum)
00 (carry)
Output
Calculation
0000 0100 0000 0001
0000 0011 0000 0010
--------------------------------0000 0111 0000 0011
0
7
0
3
19
Hex Code
0E
00
2A
00
48
EB
2A
02
48
19
D2
0E
45
0C
22
04
48
79
32
06
48
76
Comments
C = 00H
HL – 1st No.
HL – DE
HL – 2nd No.
Double addition DE +
HL
If Cy = 0, G0 to 450E
C = C + 01
HL – 4804 (sum)
Cy – A
Cy – 4806
Stop excution
MT6411 - Microprocessor Laboratory
With carry
Calculation
Input Address
4800
4801
4802
4803
Value
FF (addend)
DE (addend)
96 (augend)
DF (augend)
Output Address
4804
4805
4806
Value
95 (sum)
BE (sum)
01 (carry)
1101 1110 1111 1111
1101 1111 1001 0101
--------------------------------1011 1110 1001 0101
B
E
9
5
Result:
The assembly language program for addition of two 16 bit numbers was executed
using 8085 micro processing kit.
20
MT6411 - Microprocessor Laboratory
MULTIPLICATION OF TWO 8 – BIT NUMBERS
Aim:
To write an assembly language for multiplying two 8 bit numbers by using 8085
micro processor kit.
Apparatus required:
8085 microprocessor kit
(0-5V) DC battery
Algorithm:
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
Step 10
Step 11
:
:
:
:
:
:
:
:
:
:
:
Step 12
Step 13
Step 14
:
:
:
Start the microprocessor
Get the 1st 8 bit numbers
Move the 1st 8it number to register ‘B’
Get the 2nd 8 bit number
Move the 2nd 8 bit number to register ‘C’
Intialise the accumulator as zero
Intialise the carry as zero
Add both register ‘B’ value as accumulator
Jump on if no carry
Increment carry by 1 if there is
Decrement the 2nd value and repeat from step 8, till the 2nd
value becomes zero.
Store the multiplied value in accumulator
Move the carry value to accumulator
Store the carry value in accumulator
21
MT6411 - Microprocessor Laboratory
START
Get the 1st 8 bit number
Move it to register ‘B’
Get the 2nd 8 bit number
Intialize the accumulator as zero & carry as zero
Add the accumulator with 1st number
No
Check for
carry?
Yes
Increment carry
Decrement 2nd number
No
2nd Number
Yes
Store the value f carry in accumulator
END
22
MT6411 - Microprocessor Laboratory
Address
4100
4103
Label
Mnemonics
LDA 4500
MOV B,A
Hex Code
3A, 00, 45
47
4104
4107
LDA 4501
MOV C,A
3A, 01, 45
4F
4108
MVI A, 00
3E, 00
410A
410C
MVI D, 00
ADD B
16, 00
80
410D
4110
4111
4112
4115
INC
INR D
DCR C
JNZ
STA 4502
D2 11, 41
14
OD
C2 0C, 41
32 02, 45
4118
MOV A,D
7A
4119
STA 4503
32,03,45
411C
HLT
76
Comments
Load the first 8 bit number
Move the 1st 8 bit data
to
Load the 2nd 16 it number
Move the 2nd 8 bit data
to
Intialise the accumulator as
zero
Intialise the carry as zero
Add the contents of ‘B’ and
accumulator
Jump if no carry
Increment carry if there is
Decrement the value ‘C’
Jump if number zero
Store
the
result
in
accumulator
Move the carry into
accumulator
Store
the
result
in
accumulator
Stop the program execution
Input
Input Address
4500
4501
Value
04
02
Output Address
4502
4503
Value
08
00
Output
Result:
The assembly language program for multiplication of two 8 bit numbers was executed
using 8085 micro processing kit.
23
MT6411 - Microprocessor Laboratory
DIVISION OF TWO 8 – BIT NUMBERS
Aim:
To write an assembly language program for dividing two 8 bit numbers using
microprocessor kit.
Apparatus required:
8085 microprocessor kit
(0-5V) DC battery
Algorithm:
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
Step 10
Step 11
Step 12
Step 13
Step 14
:
:
:
:
:
:
:
:
:
:
:
:
:
:
Start the microprocessor
Intialise the Quotient as zero
Load the 1st 8 bit data
Copy the contents of accumulator into register ‘B’
Load the 2nd 8 bit data
Compare both the values
Jump if divisor is greater than dividend
Subtract the dividend value by divisor value
Increment Quotient
Jump to step 7, till the dividend becomes zero
Store the result (Quotient) value in accumulator
Move the remainder value to accumulator
Store the result in accumulator
Stop the program execution
24
MT6411 - Microprocessor Laboratory
START
Get the divided
Intialise the Quotient as zero
Get the divisor
Compare the dividend & divisor
Add the accumulator with 1st number
No
Check
for
carry?
Increment carry
Decrement 2nd number
Dividen
d
Yes
Store the Quotient in accumulator
Move the remainder to accumulator
Store the remainder in accumulator
END
25
MT6411 - Microprocessor Laboratory
Address
4100
4102
4105
Label
Mnemonics
MVI C, 00
LDA, 4500
MOV B,A
Hex Code
0E, 00
3A 00, 45
47
LDA, 4501
CMP B
JC (LDP)
3A 01, 45
B8
DA 12,41
SUB B
90
INR C
JMP (LDP, 41)
0C
C3, 0D, 41
STA 4502
32 02,45
4115
MOV A,C
79
4116
STA 4503
32 03,45
4119
HLT
76
4106
4109
410A
410D
Loop 2
410E
410F
4112
Loop 1
Comments
Intialise Quotient as zero
Get the 1st data
Copy the 1st
data
into
Get the 2nd data
Compare the 2 values
Jump if dividend lesser than
divisor
Subtract the 1st value by
2nd
Increment Quotient (410D)
Jump to Loop 1 till the value
of dividend becomes zero
Store
the
value
in
accumulator
Move the value of remainder
to accumulator
Store the remainder value in
accumulator
Stop the program execution
Input
Input Address
4500
4501
Value
09
02
Output Address
4502
4503
Value
04 (quotient)
01 (reminder)
Output
1001
0010 – I
-----0111
0010 – II
-----0101
0010 – III
-----0011
0010 – IV
-----0001 – carry
- 04
- 01
Quotient
Carry
Result:
The assembly language program for division of two 8 bit numbers was executed using
8085 micro processing kit.
26
MT6411 - Microprocessor Laboratory
ASCENDING ORDER
Aim:
To write a program to sort given ‘n’ numbers in ascending order
Apparatus required:
8085 microprocessor kit
(0-5V) DC battery
Algorithm:
Step 1
Step 2
:
:
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
:
:
:
:
:
:
Step 9
Step 10
Step 11
Step 12
:
:
:
:
Start the microprocessor
Accumulator is loaded with number of values to sorted and it is
saved
Decrement 8 register (N-1) Repetitions)
Set ‘HL’ register pair as data array
Set ‘C’ register as counter for (N-1) repetitions
Load a data of the array in accumulator
Compare the data pointed in ‘HL’ pair
If the value of accumulator is smaller than memory, then jump
to step 10.
Otherwise exchange the contents of ‘HL’ pair and accumulator
Decrement ‘C’ register, if the of ‘C’ is not zero go to step 6
Decrement ‘B’ register, if value of ‘B’ is not zero, go step 3
Stop the program execution
27
MT6411 - Microprocessor Laboratory
START
Load the count value in accumulator and save it in register ‘B’
Decrement ‘B’ register (N1)
Load the starting address of array in ‘HL’
Decrement ‘C’ register of array in ‘HL’
Increment the data pointer
Compare the data pointed by ‘HL’ with ‘A’
No
Compa
re the
datas
A<M
C=0?
Yes
Increment carry by one
No
Yes
Decrement register ‘B’
No
B=0?
END
28
Exchange the contents of
memory pointer by ‘HL’
MT6411 - Microprocessor Laboratory
Address
4100
4103
4104
4105
4108
4109
410A
410B
410C
410D
Label
Mnemonics
LDA 4500
MOV B,A
DCR B
LXI H, 4500
MOV C,M
DCR C
INX H
MOV A,M
INX H
CMP M
Hex Code
3A, 00,45
47
05
21, 00,45
4E
0D
23
7E
23
BE
410E
JC
DA, 16, 41
4111
MOV D,M
56
4112
4113
MOV M,A
DCX H
77
2B
4114
MOV M,D
72
4115
4116
4117
411A
411B
411E
INX H
DCR C
JNZ Loop 1
DCR B
JNZ Loop 2
HLT
23
0D
C2, 0B, 41
05
C2, 05, 41
76
Loop 3
Loop 2
Loop 1
Comments
Load the number of values
Move it ‘B’ register
For (N-1) comparisons
Set the pointer for array
Count for (N-1) comparisons
For (N-1) comparisons
Increment pointer
Get one data in array ‘A’
Increment pointer
Compare
next
with
accumulator
If content less memory go
ahead
If it is greater than
interchange it
Memory content
Exchange the content of
memory pointed by ‘HL’ by
previous location
One in by ‘HL’ and previous
location
Increment pointer
Decrement ‘C’ register
Repeat until ‘C’ is zero
Decrement in ‘B’ values
Repeat till ‘B’ is zero
Stop the program execution
Input
Input Address
4500
4501
4502
4503
4504
Value
04
AB
BC
01
0A
Output Address
4500
4501
4502
4503
4504
Value
04
01
0A
AB
BC
Output Address & Value
Result:
The assembly language program for sorting numbers in ascending order was executed
by microprocessor kit.
29
MT6411 - Microprocessor Laboratory
DESCENDING ORDER
Aim:
To write a program to sort given ‘n’ numbers in descending order
Apparatus required:
8085 microprocessor kit
(0-5V) DC battery
Algorithm:
Step 1
Step 2
:
:
Step 3
Step 4
:
:
Step 5
Step 6
Step 7
Step 8
:
:
:
:
Step 9
:
Step 10
:
Step 11
:
Step 12
:
Start the microprocessor
Load the number of values into accumulator and save the
number of values in register ‘B’
Decrement register ‘B’ for (N-1) Repetitions
Set ‘HL’ register pair as data array address pointer and load the
data of array in accumulator
Set ‘C’ register as counter for (N-1) repetitions
Increment ‘HL’ pair (data address pointer)
Compare the data pointed by ‘HL’ with accumulator
If the value of accumulator is larger than memory, then jump
to step 10, otherwise next step.
Exchange the contents of memory pointed by ‘HL’ and
accumulator
Decrement ‘C’ register, if the of ‘C’ is not zero go to step 6,
otherwise next step.
Decrement ‘B’ register, if ‘B’ is not zero, go step 3, otherwise
next step.
Stop the program execution
30
MT6411 - Microprocessor Laboratory
START
Load the count value to accumulator
Save the value in ‘B’ register
Decrement ‘B’ register (N1)
Load the starting address of data array in ‘HL’ pair
Using data pointer, load the count value in ‘C’
Decrement ‘C’ register (counter for N-1)
Increment the data pointer ‘HL’ with ‘A’
Compare the data pointed at ‘HL’ with ‘A’
No
Exchange the contents
A<M
C=0?
Decrement register C
Yes
Decrement register ‘C’
No
B=0?
No
Yes
END
31
MT6411 - Microprocessor Laboratory
Address
4100
Mnemonics
LDA 4500
Hex Code
3A, 00,45
MOV B,A
DCR B
LXI H, 4500
MOV C,M
DCR C
INX H
MOV A,M
INX H
CMP M
ICE, Loop 1
47
05
21, 00,45
4E
0D
23
7E
23
BE
D2, 16,41
4111
MOV D,M
56
4112
MOV M,A
77
4113
4114
DCX H
MOV M,D
2B
72
INX H
DCR C
JNZ Loop 2
DCR B
JNZ Loop 3
23
0D
C2, 0B, 41
05
C2, 05, 41
HLT
76
4103
4104
4105
4108
4109
410A
410B
410C
410D
410E
4115
4116
4117
411A
411B
Label
Loop 3
Loop 2
Loop 1
411E
Comments
Load the number of values
in accumulator
Move it to ‘B’ register
For (N-1) comparisons
Set the pointer for array
Count for (N-1) comparisons
For (N-1) comparisons
Increment pointer
Get one data from array
Increment pointer
Compare next with number
If content ‘A’ is greater than
content of ‘HL’ pair
If it is greater than
interchange the datas
Accumulator to memory
value
Decrement memory pointer
Move the old to ‘HL’ and
previous location
Increment pointer
Decrement ‘C’ register
Repeat till ‘C’ is zero
Decrement in ‘B’ values
Jump to loop till the value of
‘B’ be
Stop the program execution
Input
Input Address
4500
4501
4502
4503
4504
Value
04
AB
BC
01
0A
Output Address
4500
4501
4502
4503
4504
Value
04
BC
AB
0A
01
Output Address & Value
Result:
The assembly language program for sorting ‘4’ numbers in descending order was
executed successfully using microprocessor kit.
32
MT6411 - Microprocessor Laboratory
ANALOG TO DIGITAL CONVERTER
Aim:
To write an assembly language program to convert analog to digital signal and to
display it in 7 segment LED display
Apparatus required:
8085 microprocessor kit
(0-5V) power supply
Algorithm:
Step 1
Step 2
:
:
Step 3
Step 4
Step 5
:
:
:
Step 6
:
Access the channel of ADC
Intialise the accumulator with start of conversion signal &
output it to the ADC
Send ‘0’ signal for ending the conversion for ADC
Get the analog value converted to display from ADC
The digital signal is separated into two nibbles and displayed in
hexadecimal from by calling service subroutine.
Go to step 1
33
MT6411 - Microprocessor Laboratory
START
Load the control word necessary for generation of ALE signal to control register
Load the control word necessary to start the conversion to control register
Get the output port specified
If the
1st
LSB
bit=1?
Get accumulator output in port specified
Transfer accumulator content to ‘B’
Mask all MSR & Store memory in location
Mask all 4 LSB & store memory in location
Load accumulator with 03 & with 08
Load the pair with address of MSR
Call the service subroutine
34
MT6411 - Microprocessor Laboratory
Memory
Location
5000
5002
5004
5006
Hex Code
Label
Mnemonics
Op code
Operand
MVI
A,10
OUT
C8
MVI
A,18
OUT
C8
5008
5009
500A
00
00
3E,10
NOP
NOP
MVI
A,10
500C
D3,C8
OUT
C8
500E
5010
5012
5013
5014
5015
5017
5019
501B
501D
5020
5022
5023
5025
5028
5029
502B
502C
502E
502F
5032
5034
5036
3E,01
D3,D0
00
00
00
3E,00
D3,D0
DB,D8
E6,01
CA,19,50
DB,C0
47
E6,0F
32,51,51
78
E6,F0
0F
0F
0F
32,50,51
3E,03
0E,08
21,50,51
MVI
OUT
NOP
NOP
NOP
MVI
OUT
IN
ANI
JZ
IN
MOV
ANI
STA
MOV
ANI
RRC
RRC
RRC
STA
MVI
MVI
LXI H
A,01
D0
5039
503C
CD,05,00
C3,0E,50
3E,10
D3,C
3E,18
D3, C8
L2
L1
CALL
JMP
A,00
D0
D8
01
L1
C0
B,A
0F
5151
A,B
F0
550
A,03
C,08
5150
0005
500E
Result:
Thus the analog to digital conversion was done microprocessor.
35
Comments
Intialise ‘a’ with 10
Output channel through
Intialise ‘A’ with 18
Output channel through
8 bit port
No operation
No operation
Intialise ‘A’ with 2nd
signal
Output channel through
8 bit port
Intialise ‘A’ with 2nd
Output through 8 bit
Get input from
B -> A
And of with ‘A’
Store in 5151
B -> A
And F0 with A
Rotate content ‘A’
Store MSB in 5150
03 -> A
08 -> C
Load ‘HL’ pair with
5150
Call device subroutine
Jump to 500E
MT6411 - Microprocessor Laboratory
DECIMAL ADDITION OF TWO 8-BIT NUMBERS
Aim: To write an assembly language program for decimal addition of two8-bit
numbers and sum is 8 bit.
Apparatus Required:
•
•
8085 Microprocessor Kit
Power
Chord
Algorithm:
Step 1: Initialise the memory location of first number in HL register pair.
Step 2: Load the first number in accumulator
Step 3: Increment the content of HL register pair to initialise the memory
location of second data
Step 4: Addition of the content of second memory location with first data
Step 5: Decimal adjustment of result
Step 6: Store the result in memory location 8002H
PROGRAM
Memory
address
8100
Machine
Codes
Labels
Mnemonics Operands Comments
21, 50, 80
LXI
H,8050
8103
7E
MOV
A,M
8104
23
INX
H
8105
86
ADD
M
8106
27
DAA
8107
810A
32, 02, 80
76
STA
HLT
8002
Load the address of first
number in H-L register
pair
Store the first number in
accumulator
Increment H-L register
pair to
locate second number
Addition of 1st and 2nd
number
Decimal Adjust
Store result in 8002H
location
Halt
RESULT :
The decimal addition of two 8-bit numbers is performed using 8085 microprocessor
where sum is 8-bit.
36
MT6411 - Microprocessor Laboratory
HEXADECIMAL TO DECIMAL CONVERSION:
AIM:
To write an assembly language program to convert hexadecimal to
decimal data using 8085-microprocessor kit.
APPARATUS REQUIRED:
•
8085 Microprocessor Kit
•
Power Chord
ALGORITHM:
Step1: Start the program.
Step2: Load data from memory to accumulator and move the data 00 to D and E
registers.
Step3: Compare the accumulator data with the data 64.
Step4: If carry=0 jump to Step 6 else jump to Step 5.
Step5: Jump to Step 10.
Step6: Subtract accumulator data by 64. Step7:
Increment the content of D register once.
Step8: If carry=0 jump to Step 6 else jump to Step 9.
Step9: Decrement the content of D register once and add data 64 with accumulator.
Step10: Subtract accumulator data by 0A and Increment E register content once.
Step11: If carry=0 jump to Step 10 and Decrement E register content once.
Step12: Add data 64 with accumulator and move it to C register.
Step13: Move E register content to accumulator.
Step14: Rotate the accumulator content 4 tines by left.
Step15: Add C register content with accumulator content.
Step16: Store data in accumulator pair to specified memory
Step17: Move D register content to accumulator
Step18: Store data in accumulator pair to specified memory.
Step19: End.
37
MT6411 - Microprocessor Laboratory
Mnemonics
Memory Label
COD
E
Instruc
tion
4100
MVI
Description
HEX
Operand
E, 00H
1E
4101
Move data 00 to E register
00
4102
MVI
D, 00H
16
4103
Move data 00 to D register
00
4014
LDA
3A
Load data from memory to
4105
00
accumulator
4106
42
4107
CPI
4200
64
4108
4109
JNC
410F
FE
Compare the accumulator data with
64
the data 64
D2
If carry=0 jump to specified memory
410A
0F
410B
41
410C
JMP
4118
C3
410D
18
410E
41
410F
Loop1
SUI
64
D6
4110
Jump to specified memory
Subtract accumulator data by 64
64
4111
INR
D
14
Increment D register content once
4112
JNC
410F
D2
If carry=0 jump to specified memory
4113
0F
4114
41
4115
DCR
D
15
Decrement D register content once
4116
ADI
64
C6
Add data 64 with accumulator
4117
4118
64
Loop2
SUI
0A
D6
4119
Subtract accumulator data by 0A
0A
411A
INR
E
1C
Increment E register content once
411B
JNC
4118
D2
If carry=0 jump to specified memory
411C
18
38
MT6411 - Microprocessor Laboratory
411D
41
411E
DCR
E
1D
Decrement E register content once
`411F
ADI
0A
C6
Add data 64 with accumulator
4120
0A
4121
MOV
C, A
4F
4122
MOV
A, E
7B
4123
RLC
Move accumulator content to C
register
Move E register content to
accumulator
07
4124
RLC
07
Rotate the accumulator content 4
tines
4125
RLC
07
by left
4126
RLC
07
Add C register content with
accumulator
4127
ADD
C
81
content
4128
STA
4500
32
Store data in accumulator pair to
4129
00
specified memory
412A
45
412B
MOV
A, D
7A
Move D register content to
accumulator
412C
STA
4501
32
Store data in accumulator pair to
412D
01
specified memory
412E
45
412F
HLT
76
Halt
OUTPUT:
INPUT DATA:
OUTPUT DATA:
4200: CE
4500:
06
4501:
02
39
MT6411 - Microprocessor Laboratory
FLOW CHART :
START
HL
8100H
A
00
B
00H
C
00H
B
B+1
A
A +1
Decimal adjust
accumulator
Is there
carry?
C
D
B
C+1
A, A
Is
A=M?
8101
8102
A, A
A
Stop
40
C
MT6411 - Microprocessor Laboratory
DECIMAL TO HEXADECIMAL
AIM:
To convert a given decimal number to hexadecimal.
ALGORITHM:
Step 1: Initialize the memory location to the data pointer.
Step 2 : Increment B register.
Step 3 : Increment accumulator by 1 and adjust it to decimal every time.
Step 4 : Compare the given decimal number with accumulator value.
Step 5 : When both matches, the equivalent hexadecimal value is in B register.
Step 6 : Store the resultant in memory location.
41
MT6411 - Microprocessor Laboratory
FLOW CHART :
START
HL
4500H
A
00
B
00H
B
B+1
A
A +1
Decimal adjust
accumulator
Is
A=M?
A
B
8101
A
Stop
42
MT6411 - Microprocessor Laboratory
ADDRESS
OPC
O
DE
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
800A
800B
800C
800D
800E
800F
8010
8011
8012
8013
LABEL
LOOP
MNEM
ONICS
OPER
AND
LXI
H,8100
Initialize HL reg. to
8100H
MVI
A,00
Initialize A register.
MVI
B,00
Initialize B register..
INR
ADI
B
01
DAA
CMP
JNZ
M
LOOP
MOV
STA
A,B
8101
HLT
INPUT
ADDRESS
COMMENTS
Increment B reg.
Increment A reg
Decimal Adjust Accumulator
Compare M & A
If acc and given number are
not equal, then go to LOOP
Transfer B reg to acc.
Store the result in a memory
location.
Stop the program
OUTPUT
DATA
8100
ADDRESS
DATA
8101
RESULT:
Thus an assembly language program to convert hexadecimal to
decimal and decimal to hexadecimal data’s was written and executed using
8085-microprocessor kit.
43
MT6411 - Microprocessor Laboratory
STEPPER MOTOR CONTROLLER
AIM:
To write a program fro inter facing stepper motor and to run the motor in
different directions and in different speeds.
ALGORITHM:
Step1: Start the program.
Step2: Load HL register pair with memory address at look up.
Step3: Move the contents of HL pair to accumulator.
Step4: Out the contents of accumulator to run the motor.
Step5: Decrease b register. If register content is not zero then rotate the motor
continuously.
Step6: If zero then move to the Seginning of the program.
Step7: Stop the process.
THEORY:
STEPPER MOTOR:
A motor in which the rotor is able to assume only discrete stationary angular
position is a Stepper Motor. The rotary motion in a stepper motor is a stepwise
manner from one equilibrium position to another.
CONSTRUCTIONAL FEATURES:
A stepper motor could be either of the reluctance type or of the permanent magnet
type (PM). A PM stepper consists of multiphase stator and two part permanent
magnet rotor. The VR stepper motor has unmagnetised rotor. PM stepper motor is the
most commonly used type. The basic two phase stepper motor consists of two pairs of
stator poles. Each of the four poles has its own winding. The excitation of any
winding generates a north pole (N), a south pole (S) gets induced at the diametrically
opposite side.
44
MT6411 - Microprocessor Laboratory
As shown in the figure the four pole structure is continuous with the stator
frame and the magnetic field passes through the cylindrical stator annular ring. The
rotor magnetic system has two end faces. The left face is permanently magnetized as
South Pole and their right face as North Pole. The South Pole structure and the North
Pole structure posses similar pole faces. The north pole structure is twisted with
respect to the south pole structure by one pole pitch.
Stepper Motor Cross-sectional View
45
In an arrangement where four stator poles and three poles of rotor poles, there exists 12 possible
positions in which a south pole of the rotor can lock with a north pole of the stator. From this it
can be rotated that the step size is
360o
=
Ns*Nr
where,
Ns is the number of stator pole pairs Nr is the
number of pairs rotor pole
Generally step size of the stepper motor depends upon NR. These stable positions can be
attained by simply energizing the winding on any one of the stator poles with a DC. There are
three different schemes available for ‘stepping’ a stepper motor. They are,
a) Wave Scheme
b) 2-Phase scheme
c) Half stepping or mixed scheme
2-PHASE SCHEME:
In this scheme any two adjacent stator windings are energized. There are two magnetic
fields active in quadrature and none of the rotor pole faces can in direct alignment with the
stator poles. A partial but symmetric alignment of the rotor poles is of course possible.
Typical equilibrium conditions of the rotor when the windings on two successive stator
poles are excited are illustrated. In Step (a) A1 and B1 are energized. The pole-face S1 tries to
align itself with the axis of A1 (N) and the pole-face S2 with B1 (N). The North Pole N3 of the
rotor finds itself in neutral zone between A1 (N) and B1 (N). S1 and S2 of the rotor position
themselves symmetrically with respect to the two stator north pole.
46
Next when B1 and A2 are energized S2 tends to align with B1 (N) and S3 with A2 (N)
of course. Again under equilibrium conditions only partial alignment is possible and N1 finds
itself in the neutral region midway between B1 (N) and A2 (N) [Step (b)]. In Step (c), A2(N)
and B2(N), respectively, with N2 in the neutral zone. Step (d) illustrates the case when A1 and
B2 are ON.
The step angle is 30ْ as in the two phase’s scheme. However the rotor is offset by 15ْ in
the two phase’s scheme with respect to the wave scheme. A total of 12 steps are required to
move the rotor by 360ْ (mechanical) Two Phases drives produce more torque than the wave
drives.
LOOK UP TABLE
Anticlockwise
Clockwise
Step A1 A2 B1 B2 A1
A2 B1
B2
1
1
0
0
1
1
0
1
0
2
0
1
0
1
0
1
1
0
3
0
1
1
0
0
1
0
1
4
1
0
1
0
1
0
0
1
Mnemonics
HEX
COD
E
Description
21
Load HL pair with memory address
4101
1A
at Look Up
4102
41
Memory Label
Instruc
tion
4100
START: LXI
4103
MVI
Operand
H, LOOK
UP
B,04
4014
4105
4106
REPT:
Move immediate the given data
04
to B register
MOV
A,M
7E
Move content of memory to Acc.
MOV
[2000], AX
03
Out the content of Accumulator
C0
to C0 port address
11
Load the data 0303H to D register
4107
4108
06
LXI
D, 0303H
4109
03
410A
03
410B
DELAY: NOP
00
47
Perform No operation
410C
DCX
D
1B
Decrement address of DE pair once
410D
MOV
A,E
7B
Move E register content to Acc.
410E
ORA
D
B2
Perform OR operation With Acc.
410F
JNZ
410B
C2
Jump on no zero to the
4110
0B
instruction at specified memory
4111
41
Address
4112
INX
H
23
Increment HL pair address once
4113
DCR
B
05
Decrement B register content once
4114
JNZ
C2
Jump on no zero to the
4115
05
instruction at specified memory
4116
41
Address
C3
Jump to the instruction at
4118
00
specified memory
4119
41
4117
JMP
411A
LOOK
START
UP
09
Data will be stored in the location
05
06
04
RESULT:
Thus the stepper motor is rotated by varying the speed using COUNT operation and
its direction is also changed using program written and executed using 8085 micro
processor kit.
48
Download