Beruflich Dokumente
Kultur Dokumente
INTRODUCTION TO 8085
INTEL 8085 is one of the most popular 8-bit microprocessor capable of addressing 64 KB of
memory and its architecture is simple. The device has 40 pins, requires +5 V power supply and
can operate with 3MHz single phase clock.
ALU (Arithmetic Logic Unit):
The 8085A has a simple 8-bit ALU and it works in coordination with the accumulator,
temporary registers, 5 flags and arithmetic and logic circuits. ALU has the capability of
performing several mathematical and logical operations. The temporary registers are used to hold
the data during an arithmetic and logic operation. The result is stored in the accumulator and the
flags are set or reset according to the result of the operation. The flags are affected by the
arithmetic and logic operation. They are as follows:
Sign flag: After the execution of the arithmetic - logic operation if the bit D7 of the result is 1,
the sign flag is set. This flag is used with signed numbers. If it is 1, it is a negative number and if
it is 0, it is a positive number.
Zero flag: The zero flag is set if the ALU operation results in zero. This flag is modified by the
result in the accumulator as well as in other registers.
Auxillary carry flag: In an arithmetic operation when a carry is generated by digit D3 and
passed on to D4, the auxillary flag is set.
Parity flag: After arithmetic logic operation, if the result has an even number of 1s the flag is
set. If it has odd number of 1s it is reset.
Carry flag: If an arithmetic operation results in a carry, the carry flag is set. The carry flag also
serves as a borrow flag for subtraction.
Timing and control unit:
This unit synchronizes all the microprocessor operation with a clock and generates the control
signals necessary for communication between the microprocessor and peripherals. The control
signals RD (read) and WR (write) indicate the availability of data on the data bus.
Instruction register and decoder
The instruction register and decoder are part of the ALU. When an instruction is fetched from
memory it is loaded in the instruction register. The decoder decodes the instruction and
establishes the sequence of events to follow.
Register array
The 8085 has six general purpose registers to store 8-bit data during program execution. These
registers are identified as B, C, D, E, H and L. they can be combined as BC, DE and HL to
perform 16-bit operation.
Accumulator
Accumulator is an 8-bit register that is part of the ALU. This register is used to store 8-bit data
and to perform arithmetic and logic operation. The result of an operation is stored in the
accumulator.
Program counter
The program counter is a 16-bit register used to point to the memory address of the next
instruction to be executed.
Stack pointer
It is a 16-bit register which points to the memory location in R/W memory, called the Stack.
Communication lines
8085 microprocessor performs data transfer operations using three communication lines called
buses. They are address bus, data bus and control bus.
Ex.no:1
Date:
AIM:
a) To write an Assembly Language program to add two 8 bit numbers and store sum at
memory location 4500 and carry at 4501.
b) To write an Assembly Language program to Subtract two 8 bit numbers and store
difference at memory location 4500 and carry at 4501.
APPARATUS REQUIRED:
1. Microprocessor kit 8085
2. Power Supply(+ 5V)
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.
9.
FLOW CHART:
ADDRESS
4100
MNEMONICS
LABEL
MVI C,00
OPCODE
COMMENTS
0E,00
4102
MVI A,09
3E,09
4104
MVI B,05
06,05
4106
ADD B/SUB B
80/90
4107
JNC Loop
D2,0B,41
410A
INR C
0C
carry.
Increment
reg C
STA 4500
32,00,45
410E
MOV A,C
79
410F
STA 4501
32,01,45
4112
HLT
76
410B
Loop
PROGRAM:
PROGRAM:
OUTPUT
Data : A = 09
B = 05
Result :
Addition=0E
5
Subtraction=04
RESULT:
a)Thus an ALP was written to add 8 bit numbers and output was stored stored at 4500 &
carry at 4501.
b) Thus an ALP was written to Subtract two 8 bit numbers and output was stored stored
at 4500 & carry at 4501.
Ex.no:1
Date:
8 BIT MULTIPLICATION
AIM:
To write an Assembly Language program to multiply two 8 bit numbers store at
consecutive memory locations.
APPARATUS REQUIRED:
1. Microprocessor kit 8085
2. Power Supply(+ 5V)
ALGORITHM:
LOGIC: Multiplication can be done by repeated addition.
1. Clear Register A.
2. Load the datas to multiplied to B register and C register.
3. Clear the D register for carry.
4. Add B register data with A.
5. If no carry exists decrement C else increment D and do steps in sequence.
6. If C is not equal to zero do repeat addition else store output at 1000.
7. If carry exists move D to A and store at 1001.
8. Halt the operation.
FLOW CHART:
PROGRAM:
ADDRESS
MNEMONICS
OPCODE
COMMENTS
MVI C,00
0E,00
8002
MVI A,00
3E,00
register
Move immediate data 00 to A reg
8004
MVI B,05
06,05
8006
MVI D,04
16,04
ADD D
82
8009
JNC L1
D2,0D,80
Jump if no carry to L1
800C
INR C
0C
Increment Cregister
DCR B
05
Decrement B register
800E
JNZ L2
C2,08,80
Jump if no zero to L2
8011
STA 1000
32,00,C0
8014
MOV A,C
79
8015
STA 1001
32,01,C0
8000
8008
800D
LABEL
L2
L1
8018
HLT
76
OUTPUT
RESULT:
Thus an ALP was written to multiply two 8 bit data and output was stored at 1000 and
carry at 1001.
Ex.no:1
8 BIT DIVISION
Date:
AIM:
To write an ALP to divide two 8-bit datas numbers and store the result in memory.
APPARATUS REQUIRED:
1. Microprocessor kit 8085
2. Power Supply(+ 5V)
ALGORITHM:
LOGIC: Division is done using the method Repeated subtraction.
1. Clear the carry register D.
2. Load the data to be divided to A and B register.
3. Compare B register data with A.
4. If carry exists increment carry register H.Subtract B with A and do successive steps
and jump to 8006.
5. Else store output at 8700.
6. Move carry into B to A and store at 8701.
7. Halt the operation.
FLOWCHART:
8
PROGRAM:
ADDRES
MNEMONICS
OPCODE
COMMENTS
8000
MVI H,00
26,00
8002
MVI A,08
3E,08
8004
MVI B,02
06,02
CMP B
B8
8007
JC L1
DA,0F,80
800A
SUB B
90
800B
INR H
24
Increment Hregister.
800C
JMP L2
C3,06,80
Jump to L2.
STA A010
32,10,A0
MOV A,H
7C
8006
800F
8012
L2
L1
8013
STA A011
32,11,A0
8016
HLT
76
OUTPUT
RESULT:
Thus an ALP was written to divide two 8-bit datas using repeated subtraction method
and executed using 8085 p kits and the output was stored at 8010 and carry at A011.
Ex.no:2
Date:
AIM:
a) To write an Assembly Language program to Perform 16 bit addition and store output
and carry.
b) To write an Assembly Language program to Perform 16 bit Subtraction and store output
and carry.
APPARATUS REQUIRED:
1. Microprocessor kit 8085
2. Power Supply(+ 5V)
ALGORITHM:
a) ADDITION (16 bit)
10
1.
2.
3.
4.
5.
Clear D register for Carry and load 16 bit data to HL and BCregister pair.
And perform addition.
If no carry store output at 9000,9002.
If carry exist increment carry then store the output and carry.
Halt the operation.
Clear H register for Carry and get 16 bit data at BC and DEregister pair .
And perform addition.
If no carry store output at 9000,9002.
If carry exist increment carry then store the output and carry.
Halt the operation.
FLOW CHART:
PROGRAM:
16-Bit Addition
ADDRESS
MNEMONICS
OPCODE
COMMENTS
16,00
8000
MVI D,00
8002
LXI H,0502
21,02,05
8005
LXI B,0704
01,04,07
8008
DAD B
09
Do addition process
8009
JNC L1
D2,0D,80
800C
INR D
14
Increment Carry.
11
800D
L1
SHLD 9000
22,00,90
Store HL at 9000
8010
MOV A,D
7A
8011
STA 9002
32,02,90
76
OPCODE
COMMENTS
8014
OUTPUT
HLT
Data : HL= 0502
BC=0704
Result : HL=0C06
PROGRAM:
16-Bit Subtraction:
ADDRESS
MNEMONICS
12
8000
MVI H,00
26,00
8002
LXI B,0502
01,02,05
8005
LXI D,0301
11,03,01
8008
MOV A,C
79
8009
SUB E
93
800A
STA 9000
32,00,90
800D
MOV A,B
78
Move B to A
800E
SBB D
9A
Subtract D,A,CY
800F
JNC L1
D2,13,80
Jump if C0 to 8013
8012
INR H
24
Increment H Register
STA 9001
32,01,90
Store A to 9001
8016
MOV A,H
7C
8017
STA 9002
32,02,90
801A
HLT
76
8013
L1
OUTPUT
Data : BC= 0502
DE=0301
Result : 9000=01
9002=02
RESULT:
a)Thus an ALP program was written to perform 16-bit addition and executed in 8085p
using special instructions and output was stored.
b)Thus an ALP program was written to perform 16-bit Subtraction and executed in
instructionsELEMENTS
and output was
stored.
Ex.8085p
no: 3 using special LARGEST
IN AN
ARRAY &
SMALLEST NUMBER IN AN ARRAY
Date:
AIM:
To write an ALP to find largest element and smallest element in an array.
APPARATUS REQUIRED:
13
FLOW CHART:
14
PROGRAM:
15
ADDRESS
MNEMONICS
OPCODE
COMMENTS
16,03
8000
MVI D,04
8002
LXI H,8500
21,00,85
8005
MOV A,M
7E
Move M to A
INX H
23
Increment H reg
8007
MOV B,M
46
Move M to B
8008
CMP B
B8
Compare B with A
8009
JNC L1(Largest
D2,0D,80
JC L1(Smallest No)
DA,0D,80
MOV A,M
7E
Move memory to A
DCR D
15
Decrement D reg
800E
JNZ L2
C2,06,80
8011
STA 9000
32,00,90
8014
HLT
76
8006
L2
800C
800D
L1
OUTPUT
Ex.no:3(A)
Date: 23-12-2011
AIM:
To find the smallest element in an array.
ALGORITHM:
16
IS[A] <
[HL]?
[A] [HL]
FLOW CHART:
[B] [B]-1
IS[B] =
0?
17 [A]
[8105]
STOP
PROGRAM:
ADDRESS
OPCODE
8001
21
LABEL
MNEMONICS
OPERAND
LXI
H,8100
8002
COMMENTS
Initialize HL reg. to
8100H
8003
18
8004
06
MVI
B,04
8006
7E
MOV
A,M
8007
23
INX
Increment HL reg. to
point next memory
location
8008
8E
CMP
Compare M & A
8009
DA
JC
LOOP
If A is lesser than M
then go to loop
800C
7E
MOV
A,M
800D
05
DCR
800E
C2
JNZ
LOOP1
32
STA
8105
76
HLT
8005
LOOP1
800A
800B
LOOP
800F
Decrement B reg
If B is not Zero go to
loop1
8010
8011
8012
8013
8014
19
OUTPUT
RESULT:
Thus the smallest number in the given array is found out.
Ex.no:4
ASCENDING ORDER
Date: 23-12-2011
AIM:
To sort the given number in the ascending order using 8085 microprocessor.
ALGORITHM:
1. Get the numbers to be sorted from the memory locations.
20
2. Compare the first two numbers and if the first number is larger than second then I
interchange the number.
3. If the first number is smaller, go to step 4
4. Repeat steps 2 and 3 until the numbers are in required order
START
[B] 04H
[HL]
[8100H]
[C] 04H
[A] [HL]
[HL [HL] + 1
IS [A] <
[HL]?
[D] [HL]
FLOWCHART:
[HL] [A]
[HL] [HL] - 1
[HL] [D]
[HL] [HL] + 1
[C] [C] 01 H
21
A
IS[C] =
0?
[B] [B]-1
IS[B] =
0?
STOP
22
PROGRAM:
ADDRESS
OPCODE
8000
06
LABEL
MNEMONICS
OPERAND
MVI
B,04
LXI
H,8100
Initialize HL reg. to
8001
8002
21
LOOP 3
23
COMMENTS
8003
8100H
8004
8005
0E
MVI
C,04
MOV
A,M
8006
8007
7C
LOOP2
8008
23
INX
Increment HL reg. to
point next memory
location
8009
8E
CMP
Compare M & A
800A
DA
JC
LOOP1
If A is less than M
then go to loop1
800D
56
MOV
D,M
800E
77
MOV
M,A
800F
28
DCX
8010
72
MOV
M,D
8011
23
INX
Increment HL pair
8012
0D
DCR
Decrement C reg
8013
C2
JNZ
LOOP2
8016
05
DCR
8017
C2
JNZ
LOOP3
800B
800C
LOOP1
8014
Decrement HL pair
Transfer data from D
to M
If C is not zero go to
loop2
8015
8018
24
Decrement B reg
If B is not Zero go to
loop3
8019
801A
76
HLT
OUTPUT:
DESCENDING ORDER
AIM:
To sort the given number in the descending order using 8085 microprocessor.
ALGORITHM:
1. Get the numbers to be sorted from the memory locations.
2. Compare the first two numbers and if the first number is smaller than second then I
interchange the number.
3. If the first number is larger, go to step 4
4. Repeat steps 2 and 3 until the numbers are in required order
25
FLOWCHART:
26
PROGRAM:
MEMORY ADDRES
OPCODES
LABEL
MNEMONICS
OPERANDS
START
MVI
B,00
LXI
H,4150
sssssssS
4100
06
4101
00
4102
21
4103
50
4104
41
4105
4E
MOV
C,M
4106
0D
DCR
27
4107
23
INX
4108
7E
LOOP
MOV
A,M
4100
06
START
MVI
B,00
4101
00
4102
21
LXI
H,4150
4103
50
4104
41
4105
4E
MOV
C,M
4106
0D
DCR
4107
23
INX
4108
7E
LOOP
MOV
A,M
4100
06
START
MVI
B,00
4101
00
4102
21
LXI
H,4150
4103
50
4104
41
4105
4E
MOV
C,M
4106
0D
DCR
4107
23
INX
4108
7E
MOV
A,M
LOOP
4109
23
INX
410A
BE
CMP
410B
D2
JNZ
28
LOOP1
410C
15
410D
41
410E
56
MOV
410F
77
MOV
M,A
4110
2B
DCX
4111
72
MOV
M,D
4112
23
INX
4113
06
MVI
B,01H
4114
01
4115
0D
4116
C2
4117
08
4118
41
4119
05
DCR
411A
CA
JZ
411B
00
411C
41
411D
76
HLT
4109
23
INX
410A
BE
CMP
410B
D2
JNZ
410C
15
410D
41
410E
56
MOV
410F
77
MOV
M,A
4110
2B
DCX
4111
72
MOV
M,D
4112
23
INX
LOOP1
DCR
JNZ
29
D,M
C
LOOP
B
START
LOOP1
D,M
4113
06
MVI
4114
01
4115
0D
4116
C2
4117
08
4118
41
4119
05
DCR
411A
CA
JZ
411B
00
411C
41
411D
76
LOOP1
B,01H
DCR
JNZ
LOOP
B
START
HLT
OUTPUT:
Ex. no: 5
Parallel communication between 2 p Kits using 8255
Date: 27-12-2011
AIM
To write an ALP to Interface parallel communication between two micro processor kits
using 8255.
ALGORITHM
30
PROGRAM: TRANSMITTER
MEMORY
OPCODES LABEL
ADDRESS
4100
4101
4102
4103
4104
4105
3E
82
D3
43
3E
3F
31
MNEMONICS
OPERANDS
MVI
A,82H
OUT
43H
MVI
A,3FH
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
411A
411B
411C
411D
411E
411F
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
412A
412B
412C
412D
D3
40
DB
41
D6
3F
C2
08
41
42
08
21
00
45
7E
D3
40
CD
20
41
23
41
C2
14
41
CF
06
05
1E
FF
1D
C2
24
41
FE
CB
C2
22
41
C9
LOOP
OUT
40H
IN
41
SU
I 3FH
JNZ
LOOP
MVI
C,08H
LXI
H,4500
MOV
OUT
A,M
40H
CALL
INX
DELAY
H
DCR
JNZ
RST 1
DELAY
MVI
B,05H
D1
MVI
E,0FFH
D2
DCR
JNZ
SD2
D1
DCR
JNZ
D2
RET
RECEIVER
MEMORY OPCODES
ADDRESS
4100
3E
LABEL
MNEMONICS
MVI
32
OPERANDS
A,90H
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
411A
411B
411C
411D
411E
411F
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
412A
412B
412C
412D
412E
90
D3
43
DB
40
D6
3F
C2
04
41
3E
3F
D3
41
42
08
CD
23
41
21
00
45
DB
40
77
CD
23
41
23
41
C2
17
41
43
06
05
1E
FF
1D
C2
27
41
05
C2
25
41
CHECK:
L1:
OUT
43H
IN
40H
SUI
3FH
JNZ
CHECK
MVI
A,3FH
OUT
41H
MVI
C,08H
CALL
DELAY
LXI
H,4500H
IN
40H
MVI
CALL
INX
M,A
DELAY
H
DCR
JNZ L1
DELAY:
RST 1
MVI
B,05H
D1:
MVI
E,FFH
D2:
DCR
JNZ
E
D2
DCR
JNZ
B
D1
33
412F
4130
C9
C9
RET
RET
RESULT:
Thus a parallel communication between two microprocessor kits is obtained.
Ex. no: 6
Serial communication between 2 p Kits using 8251
Date: 27-12-2011
AIM
To write an ALP to Interface parallel communication between two micro processor kits
using 8255.
ALGORITHM
34
PROGERAM:
SERIAL TRANSMISSION USING 8085:
TRANSMITTER:
MEMORY
OPCODES MNEMONICS
ADDRESS
4100
21
LXI
4101
00
4102
45
4103
3E
MVI
4104
36
35
OPERANDS
H,4500
A,36
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
410A
4111
4112
4113
4114
4115
4116
4117
4118
4119
411A
411B
411C
411D
411E
411F
4120
4121
4122
4123
4124
4125
D3
0B
3E
40
D3
08
3E
01
D3
08
0E
05
DB
05
E6
04
CA
11
41
7E
D3
04
23
FE
3F
C2
0F
41
0D
C2
11
41
CF
OUT
0B
MVI
A,40
OUT
08
MVI
A,01
OUT
08
MVI
C,05
IN
05
ANI
04
JZ
4111
MOV
OUT
A,M
04
INX
CPI
H
3F
JNZ
410F
DCR
JNZ
C
4111
RST 1
RECEIVER:
MEMORY
ADDRESS
4100
4101
4102
4103
4104
4105
OPCODES
21
00
45
3E
36
D3
MNEMONICS
OPERANDS
LXI
H,4500
MVI
A,36
OUT
0B
36
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
411A
411B
411C
412D
411E
412F
4120
4121
4122
4123
4124
4125
4126
0B
3E
40
D3
08
3E
01
D3
08
0E
05
DB
05
E6
02
CA
11
41
DB
04
77
23
FE
3F
C2
0F
41
0D
C2
11
41
CF
CF
MVI
A,40
OUT
08
MVI
A,01
OUT
08
MVI
C,05
IN
05
ANI
02
JZ
4111
IN
04
MOV
INX
CPI
M,A
H
3F
JNZ
410F
DCR
JNZ
C
4111
RST 1
RST 1
RESULT:
Thus a serial communication between two micro processor kit is obtained.
37
8085 INTERFACING
KEYBOARD AND DISPLAY
CONTROLLER - 8279
2) Three Input modes such as Scanned Keyboard Mode, Scanned Sensor Mode and Strobed
Input Entry Mode.
3) Two Output modes such as 8 or 16 character multiplexed displays, right entry or left entry
display formats.
4) Clock Prescaler.
5) Programmable Scan Timing.
6) 2 Key lockout or N-key Roll-over with contact debounce.
7) Auto Increment facility for easy programming.
CIRCUIT DESCRIPTION:
The keyboard section consists of 16 keys, besides two keys for CNTL (Control) and
SHFT (Shift). The keyboard is arranged as two rows of eight keys each. With this keyboard it is
possible to enter 64 different key codes.
Keyboard and display is configured in the encoded mode. In the encoded mode, a binary
count sequence is put on the scan lines SL0-SL3. These lines must be externally decoded to
provide the scan lines for keyboard and display. A 3 to 8 decoder 74LS138 (U3) is provided for
this purpose. The S0-S1 output lines of this decoder are connected to the two rows of the
keyboard.
Display is a 6 digit, multiplexed display. The decoded outputs S0-S5 of the 74LS138
(U3) are used to drive the cathodes of the seven segment display. The output port lines A0-A3,
B0-B3 drive the anodes of the seven segment display.
___
IRQ output line is connected to RST 5.5 of 8085.
The 8279 is designed specifically to connect to any 8 bit microprocessor bus directly.
This allows the CPU to do some other work other than scanning the keyboard and refreshing the
display. The CPU can program the operating modes for 8279. 8279 uses the CS, A0, RD and
WR lines to control data flow to and from various internal registers and buffers, as given in the
following table.
39
Segment Definition:
Segment definitions of the seven segment display are shown below:
Table below shows the correspondence between the data bus and output port bits of 8279. Also,
the segment relationship with these are given:
D0 bit of the byte sent to the display RAM corresponds to B0 and D7 of the byte sent to the
display RAM corresponds A3. In order to light up a segment the corresponding bit of data
written into the display RAM should be a "0".
Ex. no: 1
Date: 3-1-2012
AIM:
To initialize 8279 controller and to display the character "A" in the first digit of the
display.
ALGORITHM:
40
1. Display/Keyboard mode set word and clear word take care of basic initialization of 8279.
2. However, before sending codes to the display RAM, a write display RAM control word
should be sent.
3. Then, write the data to be displayed, to the data register.
PROGRAM:
ADDRESS
OPCODE
MNEMONICS OPERAND
COMMENT
4100
3E
MVI
A,00
Mode &
display set
4101
00
4102
D3
OUT
4103
C2
CNT
4104
3E
MVI
A,CC
Clear display
4105
CC
4106
D3
OUT
4107
C2
CNT
4108
3E
MVI
A,90
Write display
RAM
4109
90
410A
D3
OUT
410B
C2
CNT
410C
3E
MVI
A,88
Display "A"
410D
88
410E
D3
OUT
411F
C0
DAT
4110
3E
MVI
A,FF
4111
FF
4112
D3
OUT
4113
C0
DAT
4114
D3
OUT
4115
C0
DAT
4116
D3
OUT
4117
C0
DAT
4118
D3
OUT
4119
C0
DAT
411A
D3
OUT
41
411B
C0
DAT
411C
76
HLT
RESULT:
The above programs from the address specified and execute it.
Ex.no:1(A)
Date: 3-1-2012
ROLLING DISPLAY
AIM:
To display the rolling message 'HELP US' in the display using 8279 microcontroller .
ALGOROTHM:
1. The initialization of 8279
2. Then, the data is fetched from address 412CH and displayed in the first digit of the
display.
42
3. The next data is displayed in the second digit of the display, since in the command word
for 'write display RAM' the Auto Increment flag is set.
4. A time delay is given between successive digits for a lively display.
FLOWCHART:
SET UP
POINTER
INITIALIZE THE COUNTER
DELAY
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT
4100
21
START LXI
H,POINTER Set pointer =
412CH
4101
4102
4103
2C
41
16
4104
4105
4106
4107
0F
3E
10
D3
MVI
D,0FH
MVI
A,10H
OUT
43
Initialize
counter
display
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
4116
4117
C2
3E
CC
D3
C2
3E
90
D3
C2
7E
D3
C0
CD
1F
41
23
4118
LOP
CNT
MVI
A,OCCH
OUT
CNT
MVI
A,90H
OUT
CNT
MOV
OUT
DAT
CALL
DELAY
A,M
INX
15
DCR
4119
C2
JNZ
LOP
411A
411B
411C
411D
411E
411F
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
412A
11
41
C3
00
41
O6
A0
OE
FF
0D
C2
23
41
05
C2
21
41
JMP
START
DELAY MVI
B,OAOH
LOP1
MVI
C,OFFH
LOP2
JNZ
DCR
LOP
C
2
B
LOP1
DCR
JNZ
44
Write display
Increment the
pointer
Decrement the
counter
Jump if nonzero to display
the next chr.
412B
C9
RET
OUTPUT:
4400
4404
4408
440C
FF
FF
98
FF
FF
FF
68
IC
FF
FF
7C
29
FF
FF
C8
FF
DELAY SUBROUTINE
4500
4502
4504
4505
4507
4509
7C
7D
00
DD
DC
22
A0
FF
FD
F9
MOV R4,#A0
LOOP2 : MOV R5,#FF
LOOP1 : NOP
DJNZ R5,LOOP1
DJNZ R4,LOOP2
RET
RESULT:
The above programs from the address specified and execute it.
45
46
PORT B: One 8-bit data output latch/buffer and one 8-bit data input buffer. Port B can function
as input or output port in two modes.
PORT C: One 8-bit output latch/buffer and one 8-bit data input buffer (no latch for input). Port
C can function as a simple input or output port. This port can be divided into two 4-bit ports,
which in turn can function as simple input or output port. In addition the port C lines can be used
for the control signal outputs and status signal inputs in conjunction with port A and Port B.
GROUP A AND GROUP B CONTROLS
The three ports of 8255 have been divided into two groups: Group A and Group B.
Group A contains port A (PA0 - PA7) and port C higher order lines (PC4 - PC7).
Group B contains Port B (PB0 - PB7) and port C lower order lines (PC0 - PC3).
The ports are configured as input or output by the command word.
CIRCUIT IMPLEMENTAYION
The 24 I/O lines of the 8255 are terminated at a 26 pin header. This is our standard
Dio-bus.
The design provides all the hardware needed to configure 8255 in mode-0, mode-1 and
mode-2. Eight to configure 8255 in mode-0, mode-1 and 8 bit data set by the SPDT
switches, can be read by the CPU through the port A.
Eight LEDs are connected to port B configuring it as an output port. The output operation
of 8255 can be explained using these 8 LEDs in detail. Port C has multiacting as STB,
IBF, OBF and INTR lines in mode-1 and 2. In our circuit design, 5 LEDs are connected
to PC0, PC1, PC3, PC5, PC4 and PC6.
Ex. no:3
Date:3.1.2012
8255
FOR PORT-A AS INPUT PORT IN MODE-1
AIM:
The process involving INTR & RD signals will be explained later in the chapter
"Experimenting with 8255".
ALGORITHM:
1. With this configuration, PC4 of port C acts as strobe input and PC5 acts as IBFA output.
47
2. Referring to Figure 2-1C, it can be seen that, on giving a strobe pulse (STBA), the IBFA
goes high.
3. This can be explained with the following simple program.
PROGRAM:
ADDRESS OPCODE LABEL
4100
3E
MVI
4101
B0
4102
D3
OUT
4103
C6
0C6H
4104
76
HLT
START
A,B0
Initialize port
as Input port in
mode-1
RESULT:
The above programs from the address specified and execute it.
Ex. no:3A
Date:3.1.12
8255
FOR PORT-B AS OUTPUT PORT IN MODE-2
AIM:
To initialize Port A as an Input port in mode-0, and port B as output port in Mode-1.
ALGORITHM:
1. In this configuration, the lines PC2 of port C acts as STBB input and PCI acts as IBFB
output.
48
2. From the following example, it can be seen that on applying a STBB signal, the IBFB
goes high.
3. Press the Int 0 switch which generates STBB signal. See the IBFB control signal going
high visually (The corresponding LED glows).
PROGRAM:
ADDRESS OPCODE LABEL
4100
3E
START
4101
4102
4103
4104
C0
D3
C6
3E
4105
4106
4107
4108
45
D3
C0
76
OUT
0C6H
Port in mode-2.
MVI
A,45
Write Data 45
to Port B
OUT
0C0H
HLT
RESULT:
The above programs from the address specified and execute it.
49
8-BIT DIGITAL TO
ANALOG CONVERTER
INTERFACE
50
VBMB-002 contains two D/A converters using DAC0800. Using this add-on card you can learn
in detail how to interface D/A converters with microprocessors. This card also consists of a
comparator which can be used along with the D/A converter.
Ex.no:4
Date: 7-1-2012
AIM:
51
2. With 00 (Hex) as input to DAC 2, the analog output is -5V. Similarly with FF (Hex) as
input the output is +5V.
3. Outputting digital data 00 and FF at regular intervals, to DAC2, results in a square wave
of amplitude 15 Volts.
PROGRAM:
ADDRESS
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
411A
411B
411C
411D
OPCODE
3E
00
D3
C8
CD
11
41
3E
FF
D3
C8
CD
11
41
C3
00
11
06
05
0E
FF
0D
C2
15
41
05
C2
13
41
C9
LABEL
START
MNEMONICS OPERAND
MVI
A,00H
OUT
0C8H
CALL
DELAY
MVI
A,0FF
OUT
0C8H
CALL
DELAY
JMP
START
MVI
B,05
MVI
C,0FF
DCR
JNZ
C
L2
DCR
JNZ
B
L1
RET
52
RESULT:
Execute the program and using a CRO, verify that the waveform at the
DAC2 output is a square-wave. Modify the frequency of the square-wave,
by varying the time delay.
53
picture. Thus an Analog to Digital Converter is an electronic circuit that converts the analog or
continuous signal to digital or discrete form.
This manual explains about our add-on card VBMB-003. This card consists of a 16 Channel A to
D converter using two ADC 0809 ICs form National Semiconductor Devices FAC. Following
chapters will acquaint you with the basic principles of A to D converters, the IC ADC 0809,
interfacing ADC 0809 with Microprocessor.
Ex.no:3
Date: 7-1-2012
AIM:
Initiating the analog to digital conversion process by means of software.
ALGORITHM:
1.
2.
3.
4.
PROGRAM:
ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT
Select Channel
4100
3E
START MVI
A,10
0 and Make
4101
4102
4103
4104
10
D3
C8
3E
4105
4106
4107
4108
18
D3
C8
3E
OUT
0C8H
ALE Low
MVI
A,18
Make ALE
High
OUT
0C8H
MVI
A,01
56
SOC Signal
High
4109
410A
410B
410C
410D
410E
411F
01
D3
D0
AF
AF
AF
3E
4110
4111
4112
4113
00
D3
D0
76
OUT
0D0H
XRA
XRA
XRA
MVI
A
A
A
A,00
OUT
0D0H
DELAY
SOC Signal
Low
HLT
RESULT:
which converts the analog input at Channel 0 and displays the output with the
LEDs.
Ex. no: 4(A)
ADC CONVERTER
Date:7-1-2012
AIM:
The following programs initiate the conversion process, checks the EOC pin of ADC
0809 as to whether the conversion is over and then inputs the data to the processor
ALGORITHM:
1.
2.
3.
4.
PROGRAM:
ADDRESS OPCODE LABEL
4100
3E
4101
4102
4103
4104
10
D3
C8
3E
4105
4106
4107
4108
18
D3
C8
3E
4109
410A
410B
410C
410D
410E
410F
01
D3
D0
AF
AF
AF
3E
4110
4111
4112
4113
00
D3
D0
DB
4114
4115
4116
4117
4118
4119
411A
411B
411C
D8
E6
01
FE
01
C2
13
41
DB
411D
411E
411F
C0
32
50
START
LOP
MVI
A,10
Select
Channel
0and Make
OUT
0C8H
ALE Low
MVI
A,18
MAHE ALE
HIGH
OUT
0C8H
MVI
A,01
OUT
0D0H
XRA
XRA
XRA
MVI
A
A
A
A,00
OUT
0D0H
IN
0D8H
ANI
01
CPI
01
JNZ
LOP
IN
0C0H
STA
4150H
58
SOC Signal
High
DELAY
SOC Signal
Low
Check
EOC
for
Read
Data
From ADC
4120
4121
41
76
HLT
RESULT:
The above programs from the address specified and execute it.
59
8259 INTERRUPT
60
The 8259 is designed to minimize the software and real time overhead in handling
multilevel priority interrupts. It has several modes, permitting optimization for a variety of
system requirements.
CIRCUIT IMPLEMENTATION:
Design of this interrupt controller interface is quite simple. The 8259 interacts with the CPU by
D0-D7 , , , ,A0 ,I CS RD WR NT, INTA. Description of the rest of pins of 8259 are given below.
-CASO-CAS2 - Cascade lines (pin 12, pin 13 and pin 15).
-Private 8259 bus to control a multiple 8259 structure. These pins are left free.
-SP/EN - Slave program/Enable buffer (Pin 16).
-In buffered mode , it can be used to control buffer transceivers (EN) . In other modes, indicates
whether a master (SP=1) or a slave (SP=0) 8259. It is pulled high using a 3.3 k resistor.
-IRO-IR& - INTERRUPT REQUESTS.
In VBMB-007 these pins are connected to the switch settings so that interrupt requests can be
given manually. These interrupt request are also terminated at a 10 pin connector.
A latch 74LS273 (U3) is provided on-board, which transfers the status of the data bus to glow the
LEDS. This is meant for demonstration purposes.
Ex. no: 5
Date: 7-1-2012
8259 INTERRUPT
AIM:
To initialize 8259 with the following specifications.
ALGORITHM:
* ICW4 needed
* Single 8259
* Interval of 4
* Edge triggered mode
* A7 A6 A5 = 0 0 0
* Interrupt service routine address for IRO:5000H
61
* 8085 mode
* Normal EOI
* Non buffered mode (Since we are not using buffers)
* Not special fully nested mode
* Mask all interrupts except IR0
PROGRAM:
62
ADDRESS
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
OPCODE LABEL
3E
START
17
D3
C0
3E
50
D3
C2
3E
00
D3
C2
3E
FE
D3
C2
76
MNEMONICS OPERAND
MVI
A,17
OUT
0C0H
MVI
A,50
OUT
0C2H
MVI
A,00
OUT
0C2H
MVI
A,FE
OUT
0C2H
HLT
RESULT:
The above programs from the address specified and execute it.
63
8259 INTERRUPT
Ex.no:5(A)
Date: 7-1-2012
AIM:
To program the 8259 in special mask mode.
ALGORITHM:
1. The CPU jumps to 5000H and executes the program there.
2. Normally, since no EOI command is given 8259 will not accept further interrupts.
3. However due to special mask mode 8259 will accept interrupt only at IR1, since only IR1
is enabled at that location.
4. You may verify this.
PROGRAM:
ADDRESS
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
411F
4110
4111
4112
OPCODE
3E
17
D3
C0
3E
50
D3
C2
3E
00
D3
C2
3E
00
D3
C2
3E
68
D3
LABEL
START
64
MNEMONICS OPERAND
MVI
A,17
OUT
0C0H
MVI
A,50
OUT
0C2H
MVI
A,00
OUT
0C2H
MVI
A,00
OUT
0C2H
MVI
A,68
OUT
0C0H
4113
4114
C0
76
HLT
RESULT:
The above programs from the address specified and execute it.
65
The timer section contains only the chip 8253. The main features of the timer Intel 8253 are as
follows:
1. Three independent 16-bit counters
2. Input clock from DC to 2 MHz
3. Programmable counter modes
4. Count binary or BCD
The control signals with which the 8253 interfaces with the CPU are CS, RD, WR, A1, A2. The
basic operations performed by 8253 are determined by these control signals and are illustrated
in the table given below.
continuous serial data stream for transmission. Simultaneously, it can receive serial data streams
and convert the minto parallel data characters for the CPU. The CPU can read the status of the
USART at any time. These include data transmission errors and control signals.
The main features of 8251A are,
1. Both Synchronous and Asynchronous operation,
2. False Start Bit Detection,
3. Automatic Break Detect and Handling,
4. Clock rate - 1, 16 or 64 times Baud rate,
5. Error Detection - Parity, Overrun and Framing Errors,
6. Break Character Generation.
The control pins with which the 8251A communicates with the CPU are the RESET, CLK,
WR, RD, CS, C/D, DO-D7.
Ex. no: 6
Date: 11-1-2012
AIM:
The program that follows initializes channel 0 in mode 5 and also triggers GATE 0.
Connect CLK 0 to debounce circuit.
ALGORITHM:
1. After giving six clock pulses, you can see using CRO.
2. The initially high output goes low.
4. The output (OUT 0 pin) goes high on the next clock pulse.
PROGRAM:
ADDRESS OPCODE LABEL
4100
4101
4102
4103
4104
3E
1A
D3
CE
3E
MVI
A,1A
OUT
0CE
MVI
A,05
4105
4106
4107
4108
4109
410A
05
D3
C8
D3
D0
76
OUT
OC8
OUT
0D0
HLT
RESULT:
The above programs from the address specified and execute it.
Ex.no:6
8253 in mode 5
Load LSB of
count
Trigger Gate 0
Date:11-1-2012
AIM:
To initiate 8253 and 8251 and to check the transmission and reception of a character.
ALGORITHM:
1. The program first initializes.
2. The 8253 to give an output clock frequency of 150 KHz at channel 0 which will give a
9600 baud rate of 8251.
3. Then the 8251 is also initialized with data 4E and 37.
PROGRAM:
ADDRESS OPCODE LABEL
4100
3E
START
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
36
D3
CE
3E
0A
D3
C8
3E
00
D3
C2
3E
4E
D3
C2
3E
37
D3
C2
3E
41
OUT
0CEH
MVI
A,OA
OUT
0C8H
MVI
A,00
OUT
0C8H
MVI
A,4E
OUT
0C2H
MVI
A,37
Command
OUT
0C2H
Instruction
MVI
A,41
70
4116
4117
4118
D3
C0
CF
OUT
0C0H
RST
OUTPUT:
4200
4202
4205
DB
32
CF
C0
50
IN
41
0C0H
STA 4150
RST 1
RESULT:
The above programs from the address specified and execute it.
71
STEPPER MOTOR
&
DC MOTOR INTERFACE
72
73
Ex.no:7
Date: 11-1-2012
AIM:
To run a stepper motor at different speed in two directions.
ALGORITHM:
1. A motor in which the rotor is able to assume only discrete stationary angular position is a
stepper motor.
2. The rotary motion occurs in a stepwise manner from one equilibrium position to the next.
PROGRAM:
ADDRESS
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
4116
OPCODE
21
1A
41
06
04
7E
D3
C0
11
03
03
00
1B
7B
B2
C2
0B
41
23
05
CZ
05
41
LABEL
START
REPT
DELAY
74
MNEMONICS
LXI
OPERAND
H,LOOK UP
MVI
B,04
MOV
OUT
A,M
0C0H
LXI
D,0303H
NOP
DCX
MOV
ORA
JNZ
D
A,E
D
DELAY
INX
DCR
JNZ
H
B
REPT
4117
4118
4119
411A
411B
411C
411D
C3
00
41
09
03
06
0C
JMP
LOOK UP DB
START
09 05 06 0A
RESULT:
The stepper motor rotates. Speed can be varied by varying the count at DE pair. Direction
can be varied by entering the data in the look-up table in the reverse order.
75
AIM:
To run Stepper Motor in both Forward and Reverse directions with delay.
ALGORITHM:
1) Enter the above program starting from location 1000 onwards.
2) Execute the program after connecting the stepper motor in port 1.
3) Now you can see that the stepper motor runs in forward and reverse direction
IS B =
0 ?
76
PROGRAM:
77
ADDRESS
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
411A
411B
411C
411D
411E
411F
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
412A
412B
412C
412D
OPCODE
0E
20
21
3F
41
CD
21
41
0D
C2
02
41
CD
35
41
0E
20
21
43
41
CD
21
41
0D
C2
11
41
CD
35
41
C3
00
41
06
04
7E
D3
C0
11
03
03
1B
7B
B2
C2
29
LABEL
START
MNEMONICS OPERAND
MVI
C,20H
FORWARD LXI
H,FORLOOK
CALL
RATATE
DCR
JNZ
C
FORWARD
CALL
STOP
MVI
C,20H
LXI
H,REVLOOK
CALL
ROTATE
DCR
JNZ
C
REVES
CALL
STOP
JMP
START
ROTATE
MVI
B,04H
REPT
MOV
OUT
A,M
0C0H
LXI
D,0303H
DCX
MOV
ORA
JNZ
D
A,E
D
LOOP1
REVES
LOOP1
78
RESULT:
Execute the program. Now you can see that the stepper motor runs in forward direction
and reverse direction continuously with a delay.
SPEED OF DC MOTOR
Ex. no: 8
Date: 24-1-2012
AIM:
To set the speed of DC motor and read the count value from channel 0 of the counter.
ALGORITHM;
1.
2.
3.
4.
5.
6.
PROGRAM:
ADDRESS
4100
4101
4102
4103
4104
4105
4106
LABEL
MNEMONIC OPERAND
MVI
A,0FFH
OUT
0C0H
MVI
OUT
0D8H
4108
CALL
DELAY
4109
410A
410B
MVI
A,3OH
4107
410C
79
410D
410E
410F
4110
4111
4112
4113
OUT
0CEH
MVI
A,0FFH
OUT
0C8H
CE
3E
FF
D3
0C8H
C8
D3
OUT
4114
D3
C8
4115
4116
4117
4118
4119
411A
411B
411C
411D
411E
411F
4120
4121
4122
MVI
A,00
OUT
0D00H
3E
00
D3
CALL
DELAY
D0
CD
MVI
A,00
OUT
0D8H
2B
41
3E
00
D3
IN
0C8H
D8
DB
MEMI
C8
32
STA
4123
4124
4125
4126
4127
4128
4129
412A
MVI
A,00
STA
MEMI+1
HLT
00
45
3E
00
32
01
45
76
DELAY
MVI
C,03
80
0E
TIMER
CONTROL
PORT
MAX DATA
TIMER CHO
PORT(LSB)
TIMER CHO
PORT(MSB)
ENABLING
GATE FOR 1
SECOND
MAKE GATE
HIGH
DELAY FOR
ONE SECOND
MAKE GATE
LOW
DATA INPUT
DATA IN
FROM CHO
DATA STORED
ON MEMI
412C
412D
412E
412F
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
413A
413B
LO2
LXI
H,0A3C3H
LOOP
DCX
MVI
ORA
JNZ
H
A,L
H
LOOP
DCR
JNZ
C
LO2
RET
END
03
21
C3
A3
2B
7D
B4
C2
30
41
0D
C2
2D
41
C9
RESULT:
The decremented value is stored in memory location 4500H and 4501H.
81
8086 PROGRAMMING
82
Introduction to 8086
The 8086 is a 16-bit microprocessor chip designed by Intel between early 1976
and mid-1978, when it was released. The 8086 gave rise to the x86 architecture of Intel's future
processors. The Intel 8088, released in 1979, was a slightly modified chip with an external 8-bit
data bus.
8086 has a 20 bit address bus can access up to 220 memory locations ( 1 MB) . It can
support up to 64K I/O ports. It provides 14, 16-bit registers. It has multiplexed address and data
bus AD0- AD15 and A16 A19. It requires single phase clock with 33% duty cycle to provide
internal timing. 8086 is designed to operate in two modes, Minimum and Maximum. It can
prefetches up to 6 instruction bytes from memory and queues them in order to speed up
instruction execution. It requires +5V power supply. A 40 pin dual in line package.
Minimum and Maximum Modes:
The minimum mode is selected by applying logic 1 to the MN / MX# input pin. This is a single
microprocessor configuration.
The maximum mode is selected by applying logic 0 to the MN / MX# input pin. This is a multi
micro processors configuration.
Internal Registers of 8086:
The 8086 has four groups of the user accessible internal registers. They are the instruction
pointer, four data registers, four pointer and index register, four segment registers.
The 8086 has a total of fourteen 16-bit registers including a 16 bit register called the status
register, with 9 of bits implemented for status and control flags. Most of the registers contain
data/instruction offsets within 64 KB memory segment. There are four different 64 KB segments
for instructions, stack, data and extra data. To specify where in 1 MB of processor memory these
4 segments are located the processor uses four segment registers:
Code segment:
It is a 16-bit register containing address of 64 KB segment with processor instructions. The
processor uses CS segment for all accesses to instructions referenced by instruction pointer (IP)
register. CS register cannot be changed directly. The CS register is automatically updated during
far jump, far call and far return instructions.
Stack segment:
It is a 16-bit register containing address of 64KB segment with program stack. By default, the
Processor assumes that all data referenced by the stack pointer (SP) and base pointer (BP)
registers is located in the stack segment. SS register can be changed directly using POP
instruction.
Data segment
It is a 16-bit register containing address of 64KB segment with program data. By default, the
Processor assumes that all data referenced by general registers (AX, BX, CX, DX) and index
register (SI, DI) is located in the data segment. DS register can be changed
directly using POP and LDS instructions.
83
Extra segment:
It is a 16-bit register containing address of 64KB segment, usually with program data.
By default, the processor assumes that the DI register references the ES segment in string
manipulation instructions. ES register can be changed directly using POP and LES instructions.
It is possible to change default segments used by general and index registers by prefixing
instructions with a CS, SS, DS or ES prefix.
General Registers of the 8086 Microprocessor:
It can be used for arithmetic and logic operations. The general registers are:
Accumulator:
This register consists of two 8-bit registers AL and AH, which can be combined together
and used as a 16- bit register AX. AL in this case contains the low-order byte of the word, and
AH contains the high-order byte. Accumulator can be used for I/O operations and string
manipulation.
Base register:
It consists of two 8-bit registers BL and BH, which can be combined together and used as
a 16-bit register BX. BL in this case contains the low-order byte of the word, and BH contains
the high-order byte. BX register usually contains a data pointer used for based, based indexed or
register indirect addressing.
Count register:
It consists of two 8-bit registers CL and CH, which can be combined together and used as
a 16-bit register CX. When combined, CL register contains the low-order byte of the word, and
CH contains the high order byte. Count register can be used in Loop, shift/rotate instructions and
as a counter in string manipulation,.
Data register:
It consists of two 8-bit registers DL and DH, which can be combined together and used as a
16-bit register DX. When combined, DL register contains the low-order byte of the word, and
DH contains the high order byte. Data register can be used as a port number in I/O operations. In
integer 32-bit multiply and divide instruction the DX register contains high-order word of the
initial or resulting number.
Stack Pointer
It is a 16-bit register pointing to program stack
.
Base Pointer:
It is a 16-bit register pointing to data in stack segment. BP register is usually used for
based, based indexed or register indirect addressing.
Source Index:
It is a 16-bit register. SI is used for indexed, based indexed and register indirect addressing,
as well as a source data addresses in string manipulation instructions.
Internal
Destination Index:
It is a 16-bit register. DI is used for indexed, based indexed and register indirect addressing,
a well as a destination data address in string manipulation instructions.
84
Other registers:
Instruction Pointer (IP) is a 16-bit register.
Flags are a 16-bit register containing 9 one bit flags.
Overflow Flag (OF) - set if the result is too large positive number, or is too small negative
number to fit into destination operand.
Direction Flag - if set then string manipulation instructions will auto-decrement index
registers. If cleared then the index registers will be auto-incremented.
Interrupt-enable Flag (IF) - setting this bit enables maskable interrupts.
Single-step Flag (TF) - if set then single-step interrupt will occur after the next instruction.
Sign Flag (SF) - set if the most significant bit of the result is set.
Zero Flag (ZF) - set if the result is zero.
Auxiliary carry Flag (AF) - set if there was a carry from or borrow to bits 0-3 in the AL
register.
Parity Flag (PF) - set if parity (the number of "1" bits) in the low-order byte of the result is
even.
Carry Flag (CF) - set if there was a carry from or borrow to the most significant bit during
last result calculation.
Addressing Modes:
Implied - the data value/data address is implicitly associated with the instruction.
Register - references the data in a register or in a register pair.
Immediate - the data is provided in the instruction.
Direct - the instruction operand specifies the memory address where data is located.
Register indirect - instruction specifies a register containing an address, where data is located.
Indexed:- 8-bit or 16-bit instruction operand is added to the contents of an index register (SI or
DI), the resulting value is a pointer to location where data resides.
Based Indexed:- the contents of a base register (BX or BP) is added to the contents of an index
register (SI or DI), the resulting value is a pointer to location where data resides.
Based Indexed with displacement:- 8-bit or 16-bit instruction operand is added to the contents
of a base register (BX or BP) and index register (SI or DI), the resulting value is a pointer to
location where data resides.
85
ADDITION
To write an Assembly Language Program (ALP) for performing the addition operation of
two byte numbers.
ALGORITHM:
a)
a)
b)
c)
d)
e)
PROGRAM:
MEMORY
ADDRESS
OPCODES
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C
MNEMONICS OPERANDS
8B
06
00
11
03
06
02
11
89
06
00
12
F4
MOV
AX,[1100]
ADD
AX,[1102]
MOV
[1200],AX
HLT
OUTPUT:
Data-1: 1100 = 1234
Data-2: 1102 = 5678
Result: 1200 = 68AC
RESULT:
Thus the 8086 assembly language program to add two 16 bit numbers was successfully
executed and verified
86
SUBTRACTION
AIM:
To write an Assembly Language Program (ALP) for performing the subtraction operation
of two byte numbers.
ALGORITHM:
1.
2.
3.
4.
5.
6.
PROGRAM:
MEMORY
ADDRESS
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C
OPCODES
MNEMONICS
8B
06
00
11
03
06
02
11
89
06
00
12
F4
OPERANDS
MOV
AX,[1100]
SUB
AX,[1102]
MOV
[1200],AX
HLT
OUTPUT:
Data-1: 1100 = 4343
Data-2: 1102 = 2121
Result:
1200 =.2222
RESULT:
Thus the 8086 assembly language program to subtract two 16 bit numbers was
successfully executed and verified
87
MULTIPLICATION
AIM:
To write an Assembly Language Program (ALP) for performing the multiplication
operation of 16-bit numbers.
ALGORITHM:
a)
b)
c)
d)
e)
f)
PROGRAM:
MEMORY
ADDRESS
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C
100D
100E
100F
1010
1011
1012
OPCODES
MNEMONICS
8B
06
00
11
8B
1E
02
11
F7
E3
89
16
00
12
89
06
02
12
F4
MOV
AX,[1100]
MOV
BX,[1102]
MUL
BX
MOV
[1200],DX
MOV
[1202],AX
HLT
88
OPERANDS
OUTPUT:
Data-1: 1100 = FEDC
Data-2: 1102 = BA98
Result: 1200 = B9C3
1202 = 2AA0
RESULT:
Thus the 8086 assembly language program to multiplication of two 16 bit numbers was
successfully executed and verified.
89
DIVISION
AIM:
To write an Assembly Language Program (ALP) for performing the division operation of 16-bit
numbers
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
PROGRAM:
MEMORY
ADDRESS
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C
100D
100E
100F
1010
1011
1012
1013
1014
1015
OPCODES
MNEMONICS
8B
16
00
11
8B
06
02
11
8B
0E
04
11
F7
F1
89
06
00
12
89
16
02
12
90
OPERANDS
MOV
DX,[1100]
MOV
AX,[1102]
MOV
CX,[1104]
DIV
CX
MOV
[1200],AX
MOV
[1202],DX
1016
OUTPUT:
Dividend:
Divisor:
Result:
F4
HLT
1100 = 0000
1102 = FFFF
1104 = FFFF
1200 = 0001
1202 = 0000.
RESULT:
Thus the 8086 assembly language program to division of two 16 bit numbers was
successfully executed and verified
91
Ex. no: 2
Date: 7-2-2012
LINEAR SEARCH
AIM:
To write 8086 ALP to find the desired (enter) element in the array starting from 1200H.
ALGORITHM:
1.
2.
3.
4.
5.
PROGRAM
MEMORY
ADDRESS
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C
100D
100E
100F
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
OPCODE
BE
00
12
BF
00
15
8A
0C
46
8A
04
46
3A
04
74
09
46
FE
C9
75
F7
B0
FF
88
04
8A
MNEMONICS
MOV SI,1200H
MOV DI,1500H
MOV CL,[SI]
INC SI
MOV AL,[SI]
LOOP:
INC SI
CMP AL,[SI]
JZ END
INC SI
DEC CL
JNZ LOOP
MOV AL,0FFH
MOV [SI],AL
END:
92
MOV BL,[SI]
101A
101B
101C
101D
101E
101F
1C
88
1D
CD
02
F4
MOV [DI],BL
INT 02H
HLT
OUTPUT:
1200 = 04H (LENGTH 0F ARRAY)
1201 = 35H
1202 = 18H
1203 = 36H
1204 = 54H
1205 = 72H
Note: The element which one we want to search is stored at location 1201h & The number of
elements in an array is stored at location 1200h.
Result:
1. If the elment which one we want to search is in an array, then it will be store at the
location [1500H] i.e 35 is stored
2. If the element which one we want of search is not in an array, then FFFFH will be
stored at location 1500h to indicate ERROR condition.
RESULT:
93
Thus the program finding the desired element using 8086 was executed and verified.
Ex. no: 3(A)
ASCENDING ORDER
Date: 7-2-2012
AIM:
To write an Assembly Language Program (ALP) to sort a given array in ascending
order.
ALGORITHM:
1. Load the array count in two registers C1 and C2.
2. Get the first two numbers.
3. Compare the numbers and exchange if necessary so that the two numbers are in
ascending order.
4. Decrement C2.
5. Get the third number from the array and repeat the process until C2 is 0.
6. Decrement C1 and repeat the process until C1 is 0.
PROGRAM:
INSERTION SORT: (ASCENDING)
MEMORY
ADDRESS
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
100A
100B
100C
100D
100E
100F
1010
1011
1012
1013
OPCODES LABEL
B3
00
BE
00
12
8A
0C
FE
C9
46
8A
04
46
3A
04
72
0A
8A
14
88
04
MNEMONICS OPERANDS
START
94
MOV
BL,00
MOV
SI,1200H
MOV
CL,[SI]
DEC
CL
INC SI
MOV
AL,[SI]
INC
CMP
SI
AL,[SI]
JC
LOOP1
MOV
DL,[SI]
MOV
[SI],AL
1015
1016
1017
1018
1019
101A
101B
101C
101D
101E
101F
1020
1021
1022
1023
4E
88
14
46
B3
01
FE
C9
75
EB
FE
CB
74
DD
F4
DEC
MOV
SI
[SI],DL
INC
MOV
SI
BL,01
DEC
CL
JNZ
LOOP
ZEC
JZ
START
HLT
OUTPUT:
1200 = 05 (LENGTH 0F ARRAY)
1201 = 2A
1202 = B5
1203 = FF
1204 = 34
1205 = D1
Result:
1200 = 2A
1201 = 34
1202 = B5
1203 = D1
1204 = FF.
RESULT
Thus the program for arranging the number in ascending order using 8086 was executed
and verified
95
DESCENDING ORDER
AIM:
To write an Assembly Language Program (ALP) to sort a given array in descending
order.
ALGORITHM:
a. Load the array count in two registers C1 and C2.
b. Get the first two numbers.
c. Compare the numbers and exchange if necessary so that the two numbers are in descending
order.
d. Decrement C2.
e. Get the third number from the array and repeat the process until C2 is 0.
f. Decrement C1 and repeat the process until C1 is 0.
PROGRAM
SELECTION SORT
MEMORY ADDRESS
1000
1002
1005
1007
1009
100A
100C
100D
100F
1011
1013
1015
1016
1018
1019
LABEL
START:
OPCODES
B3
00
BE
00
12
8A
0C
FE
C9
46
8A
04
46
3A
04
73
0A
8A
14
88
04
4E
88
14
46
B3
96
MNEMONICS
MOV
OPERANDS
BL,00
MOV
SI,1200H
MOV
CL,[SI]
DEC
CL
INC
MOV
SI
AL,[SI]
INC
CMP
SI
AL,[SI]
JNC
LOOP1
MOV
DL,[SI]
MOV
[SI],AL
DEC
MOV
SI
[SI],DL
INC
MOV
SI
BL,01
101B
LOOP1:
101D
101F
1021
1023
01
FE
C9
75
EB
FE
CB
74
DD
F4
DEC
CL
JNZ
LOOP
DEC
BL
JZ
START
HLT
OUTPUT:
1200 = 05 (LENGTH 0F ARRAY)
1201 = 2A
1202 = B5
1203 = FF
1204 = 34
1205 = D1
Result:
1200 = FF
1201 = D1
1202 = B5
1203 = 34
1204 = 2A.
RESULT
Thus the program for arranging the number in descending order using 8086 was executed
and verified
Ex. no: 4
STRING MANIPULATION
97
Date: 7-2-2012
AIM:
To write an ALP to compare two strings using 8086 microcontroller kit.
ALGORITHM
1. Clear the data segment register.
2. Load the data in to the register.
3. Compare the value in the register.
4. Store the result in the corresponding memory location.
5. Stop the program.
PROGRAM
COMPARE STRING PROGRAM
ORG 1000H
LEA SI,[1200]
LEA DI,[1300]
MOV CX,0003H
CLD
REPE CMPSB
JNZ NOTEQUAL
MOV AL,01
MOV [1400],AL
HLT
NOTEQUAL: MOV AL,00
MOV [1400],AL
HLT
OUTPUT:
CONDITION 1: (SAME STRING IN DATA1 AND DATA2)
1ST INPUT
1200:11
1201:22
1202:33
2ND INPUT
1300:11
1301:22
1302:33
OUTPUT:
1400:01
CONDITION 2: (DIFFERENT STRING IN DATA1 AND DATA2)
98
1ST INPUT:
1200:11
1201:22
1202:33
2ND INPUT:
1300:44
1301:55
1302:66
OUTPUT:
1400:00
RESULT:
Thus the program to perform string manipulation by using 8086 was executed and
verified.
99
Ex. no: 5
Date: 14-2-2012
AIM:
To write the program to display 24 hours digital clock in serial mode. Execute the
program from 1000H to change MIN, HOURS. Change the data in location 1009H & 1007H
respectively by using 8086.
DIGITAL CLOCK PROGRAM FOR MICRO-86/88LCD R:2 KIT:
store time value in memory location 1500- SECONDS
1501- MINUTES
1502- HOURS
MEMORY
ADDRESS
1000
1003
1006
1006
1008
100A
100C
100C
100E
1010
1012
1014
1014
1015
1016
1017
1018
101A
101C
101E
1020
1022
1024
1026
1029
102B
102D
OPCODE
MNEMONICS
E8 0060
E8 0051
START:
CALL
CALL
CONVERT
DISPLAY
MOV
OUT
MOV
AL,0B0H
16H,AL
CL,07H
MOV
OUT
MOV
OUT
AL,88H
14H,AL
AL,80H
14H,AL
MOV
OUT
AL,80H
16H,AL
DELAY:
B0 B0
E6 16
B1 07
S2:
B0 88
E6 14
B0 80
E6 14
S1:
90
90
90
90
E4 14
8A D0
E4 14
0A C2
75 F2
FE C9
75 E6
BE 1500
8A 04
FE C0
88 04
;
;
NOP
NOP
NOP
NOP
IN AL,14H
MOV
DL,AL
IN AL,14H
OR AL,DL
JNZ S1
DEC
CL
JNZ S2
MOV
SI,1500H
MOV
AL,[SI]
INC AL
MOV
[SI],AL
100
102F
1031
1033
1035
1037
1038
103A
103C
103E
1040
1042
1044
1046
1047
1049
104B
104D
104F
1051
1053
1055
1057
1057
1059
105C
105E
1060
1062
1063
1063
1066
1069
106B
106D
106F
1071
1073
1075
1078
1079
107B
107C
107E
3C 3C
75 CD
B0 00
88 04
46
8A 04
FE C0
88 04
3C 3C
75 BE
B0 00
88 04
46
8A 04
FE C0
88 04
3C 18
75 AF
B0 00
88 04
EB A9
CMP
AL,3CH
JNZ START
MOV
AL,00H
MOV
[SI],AL
INC
SI
MOV
AL,[SI]
INC AL
MOV
[SI],AL
CMP
AL,3CH
JNZ START
MOV
AL,0
MOV
[SI],AL
INC
SI
MOV
AL,[SI]
INC AL
MOV
[SI],AL
CMP
AL,18H
JNZ START
MOV
AL,0
MOV
[SI],AL
JMP START
DISPLAY:
B4 06
BA 1600
B5 01
B1 00
CD 05
C3
MOV
MOV
MOV
MOV
INT 5
RET
AH,06H
DX,1600H
CH,01H
CL,0H
BE 1500
BB 1608
B0 24
88 07
MOV
MOV
MOV
MOV
SI,1500H
BX,1608H
AL,24H
[BX],AL
8A 04
B4 00
B6 0A
F6 F6
80 C4 30
4B
88 27
4B
04 30
88 07
MOV
MOV
MOV
DIV DH
ADD
DEC
MOV
DEC
ADD
MOV
AL,[SI]
AH,0
DH,0AH
CONVERT:
101
AH,30H
BX
[BX],AH
BX
AL,30H
[BX],AL
;SECONDS
1080
1081
1083
1085
4B
B0 3A
88 07
4B
DEC
MOV
MOV
DEC
BX
AL,3AH
[BX],AL
BX
1086
1087
1089
108B
108D
108F
1092
1094
1095
1097
1099
109A
109C
109E
46
8A 04
B4 00
B6 0A
F6 F6
80 C4 30
88 27
4B
04 30
88 07
4B
B0 3A
88 07
4B
INC
MOV
MOV
MOV
DIV DH
ADD
MOV
DEC
ADD
MOV
DEC
MOV
MOV
DEC
SI
;MINUTES
AL,[SI]
AH,0
DH,0AH
109F
10A0
10A2
10A4
10A6
10A8
10AB
10AD
10AE
10B0
10B2
10B3
10B3
10B5
10B7
10B9
46
8A 04
B4 00
B6 0A
F6 F6
80 C4 30
88 27
4B
04 30
88 07
C3
INC
MOV
MOV
MOV
DIV DH
ADD
MOV
DEC
ADD
MOV
RET
SI
;HOURS
AL,[SI]
AH,0
DH,0AH
AH,30H
[BX],AH
BX
AL,30H
[BX],AL
BX
AL,3AH
[BX],AL
BX
AH,30H
[BX],AH
BX
AL,30H
[BX],AL
GETC:
E4 02
24 FF
3C F0
75 F8
IN AL,02H
AND AL,0FFH
CMP AL,0F0H
JNE GETC
RESULT
Thus the program was executed and displayed 24 hours digital clock. The minutes and
hours could be changed
102
8051 -MICRO
CONTROLLER
INTRODUCTION
103
104
The 8051 have 4K of code memory implemented as on-chip Read Only Memory (ROM). The
8051 have 128 bytes of internal Random Access Memory (RAM). The 8051 has two
timer/counters, a serial port, 4 general purpose parallel input/output ports, and interrupt control
logic with five sources of interrupts. Besides internal RAM, the 8051 have various Special
Function Registers (SFR), which are the control and data registers for on-chip facilities. The
SFRs also include the accumulator, the B register, and the Program Status Word (PSW), which
contains the CPU flags. Programming the various internal hardware facilities of the 8051 is
achieved by placing the appropriate control words into the corresponding SFRs.
8051 PROGRAMMING
105
8 BIT ADDITION
ALGORITHM:
1. Clear Program Status Word.
2. Select Register bank by giving proper values to RS1 & RS0 of PSW.
3. Load accumulator A with any desired 8-bit data.
4. Load the register R 0 with the second 8- bit data.
5. Add these two 8-bit numbers.
6. Store the result.
7. Stop the program.
FLOW CHART:
START
Clear PSW
Select Register
Bank
Load A and R 0
with 8- bit
datas
Add A & R 0
Store the sum
STOP
PROGRAM
106
CLR
HEX
CODE
C3
4101
MOV
A, data1
74,data1
4103
ADDC
A, # data 2
24,data2
4105
MOV
90,45,00
4108
MOVX
DPTR, #
4500H
@ DPTR, A
SJMP
L1
80,FE
4109
LABEL
L1
MNEMONIC OPERAND
F0
COMMENTS
Clear CY Flag
RESULT:
Thus the 8051 ALP for addition of two 8 bit numbers is executed.
8 BIT SUBTRACTION
107
Date: 14-2-2012
AIM:
To perform subtraction of two 8 bit data and store the result in memory.
ALGORITHM:
a.
b.
c.
d.
e.
f.
FLOWCHART:
START
CLEAR CARRY
FLAG
GET IST
OPERAND IN
ACCR
SUBTRACT THE
2ND OPERAND
FROM ACCR
N
IS
CF=1
Y
INCREMENT
THE BORROW
REGISTER
STORE
RESULT IN
MEMORY
STOP
108
PROGRAM
8 Bit Subtraction (Immediate Addressing)
ADDRESS
MNEMONIC
OPERAND
COMMENTS
HEX
CODE
C3
4100
CLR
4101
MOV
A, # data1
74, data1
4103
SUBB
A, # data2
94,data2
4105
MOV
DPTR, # 4500
90,45,00
4108
MOVX
@ DPTR, A
F0
SJMP
L1
80,FE
Store data1 in
accumulator
Subtract data2 from
data1
Initialize memory
location
Store the difference
in memory location
Stop
4109
LABEL
L1
RESULT:
Thus the 8051 ALP for subtraction of two 8 bit numbers is executed.
109
Clear CY flag
8 BIT MULTIPLICATION
AIM:
To perform multiplication of two 8 bit data and store the result in memory.
ALGORITHM:
a.
b.
c.
d.
FLOWCHART:
START
GET MULTIPLIER IN
ACCR
GET MULTIPLICAND IN B
REG
MULTIPLY A WITH B
STORE RESULT IN
MEMORY
STOP
PROGRAM
110
8 Bit Multiplication
MEMORY ADDRESS
4100
4102
4105
4106
4109
410A
410B
410D
410E
OPCODES
74 0A
75 F0 88
A4
90 45 00
F0
A3
E5 F0
F0
80 FE
MNEMONICS
MOV A,#0A
MOV B,#88
MUL AB
MOV DPTR,#4500
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
HERE: SJMP HERE
INPUT:
4101 = 0A
4104 = 88
RESULT:
4500 = 50 (LSB)
4501 = 05 (MSB)
RESULT
Thus the 8051 ALP for multiplication of two 8 bit numbers is executed.
8 BIT DIVISION
111
Date: 18-2-2012
AIM:
To perform division of two 8 bit data and store the result in memory.
ALGORITHM:
1.
2.
3.
4.
FLOWCHART:
START
GET DIVIDEND IN
ACCR
GET DIVISOR IN B
REG
DIVIDE A BY B
STORE
QUOTIENT &
REMAINDER IN
MEMORY
STOP
112
PROGRAM
8 Bit Division
ADDRESS LABEL MNEMONIC
OPERAND
4100
MOV
A, # data1
HEX
CODE
74,data1
COMMENTS
4102
MOV
B, # data2
75,data2
Store data1 in
accumulator
Store data2 in B reg
4104
DIV
A,B
84
Divide
4015
MOV
DPTR, # 4500H
90,45,00
4018
MOVX
@ DPTR, A
F0
Initialize memory
location
Store remainder
4109
INC
DPTR
A3
410A
MOV
A,B
E5,F0
Go to next memory
location
Store quotient
410C
410D
STOP
MOV
@ DPTR, A
F0
SJMP
STOP
80,FE
RESULT:
113
Stop
Thus the 8051 ALP for division of two 8 bit numbers is executed.
Ex. no: 1(E)
Date: 18-2-2012
AIM:
To write an ALP to perform logical and bit manipulation operations using 8051 microcontroller.
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.
PROGRAM
1. SETTING BITS IN AN 8-BIT NUMBER:
MEMORY
ADDRESS
4100
4102
4104
4107
4108
OPCODES
MNEMONICS
74 2F
44 45
90 45 00
F0
80 FE
MOV A,#2FH
ORL A,#45H
MOV DPTR,#4500H
MOVX @DPTR,A
HERE: SJMP HERE
INPUT:
4101 = 2F
4103 = 45
RESULT:
4500 = 6F.
114
OPCODES
MNEMONICS
74 87
54 7E
90 45 00
F0
80 FE
MOV A,#87H
ANL A,#7EH
MOV DPTR,#4500H
MOVX @DPTR,A
HERE: SJMP HERE
INPUT:
4101 = 87
4103 = 7E
Result:
4500 = 06.
RESULT:
115
AIM
To verify the Timer, Interrupts & UART operations using 8051.
ON BOARD TIMER AND INTERRUPT USING MICRO-51EB
TIMER OVERFLOW
4100
75
89
20
4103
75
A8
88
MOV IE,#88H;
TIMER1 OVERFLOW
4106
76
8D
00
MOV TH1,#00H;
INTERRUPT IS ENABLED
4109
75
8B
00
MOV TL1,#00H;
410C
D2
8E
4111
30
8F
4113
C2
8E
SETB TR1;
FD L1:JNB TF1,L1;
CLR TR1;
4115
L2:SJMP L2;
5030
74
12
MOV A,#12H
5032
24
12
ADD A,#12H
5035
90
45
5038
F0
5039
80
00
MOV DPTR,#4500H
MOVX @DPTR,A
FE
116
75
89
00
MOV TMOD,#20h
4103
75
8D
FD
MOV TH1,#FD h
4106
75
8b
00
MOV TL1,#00h
4109
75
88
40
MOV TCON,#40h
410C
75
98
58
MOV SCON,#58h
410F
75
99
54
MOV SBUF,#54h
4112
30
98
FD
4115
C2
98
CLR SCON.0
4117
E5
99
MOV A,SBUF
4119
90
45
4122
F0
411C
80
00
MOV DPTR,#4500h
MOVX @DPTR,A
FE
RESULT:
Thus the program to verify Timer, Interrupts & UART operations in 8051 microcontroller
was successfully executed.
117
AIM:
To write an ALP for interfacing with pc by using 8051
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
PROGRAM:
ADDRESS
4100
CLR
HEX
CODE
C3
4101
MOV
A, data1
74,data1
4103
ADDC
A, # data 2
24,data2
4105
MOV
90,45,00
4108
MOVX
DPTR, #
4500H
@ DPTR, A
SJMP
L1
80,FE
4109
LABEL
L1
MNEMONIC OPERAND
F0
COMMENTS
Clear CY Flag
RESULT:
Thus the program for interfacing with pc by using 8051 was successfully executed and
verified.
118
EXTRA PROGRAMS
USING 8085, 8086, 8051
119
Ex. no: 1
Date:28.2.12
AIM:
To stimulate the blinking of the signaling lights or ON-OFF control of light emitting
diodes.
ALGORITHM:
PROGRAM:
ADDRESS
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
410A
410B
410C
410D
410E
410F
4110
4111
4112
4113
4114
4115
4116
LABEL
START
LOOP1
MNEMONIC
LXI
OPERAND
H,DATA
MVI
C,OC
MOV
OUT
A,M
CNT
INX
MOV
OUT
H
A,M
APRT
INX
MOV
OUT
H
A,M
BART
CALL
DELAY
INX
DCR
JMP
H
C
LOOP1
120
HEX CODE
21
00
45
0E
0C
23
D3
0F
23
7E
D3
0C
23
7E
D3
0D
CD
1B
41
23
OD
C2
09
4117
4118
4119
411A
411B
411C
411D
411E
411F
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
412A
412B
412C
JMP
START
DELAY
PUSH
MVI
B
A,0A
LOOP3
LXI
D,FFFFF
LOOP2
DCX
MOV
ORA
JNZ
D
A,D
E
LOOP2
DCR
JNZ
C
LOOP3
POP
RET
121
41
C3
00
41
C5
0E
0A
11
FF
FF
1B
7A
B3
C2
21
41
0D
C2
1E
41
C1
C9
RESULT:
The outputs are the inputs to buffers 7406 whose outputs drive the LEDs.
122
123
Ex. no:2
Date: 28.2.12
124
AIM
To interface a LCD with 8051 micro controller to send letters M, D, and E to the
LCD using C
PROGRAM
#include <reg51.h>
sfr ldata = 0x90; //P1=LCD data pins
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
sbit busy = P1^7;
void main(){
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
lcdcmd(0x06);
lcdcmd(0x86); //line 1, position 6
lcdcmd(M);
lcdcmd(D);
lcdcmd(E);
}
RESULT:
Thus the LCD interface with 8051 is obtained.
Ex. no: 3
Date:28-2-2012
125
AIM:
To run a stepper motor for required angle within 460, which is equivalent to 256 steps.
PROGRAM:
PORT1
1000
1000
1000 B3 45
1002 BF 1B 10
1005 B1 04
1007 8A 05
1009 E6 C0
100B FE CB
100D 74 0B
100F BA 1010
1012 4A
1013 75 FD
1015 47
1016 E2 EF
1018 EB E8
101A F4
101B
101B 09 05 06 0A
EQU
ORG
0C0H
1000H
BEGIN:
MOV BL,45H
START: MOV DI,OFFSET TABLE
MOV CL,04
REPT: MOV AL,[DI]
OUT PORT1,AL
DEC BL
JZ END
MOV DX,1010H
DELAY: DEC DX
JNZ DELAY
INC DI
LOOP REPT
JMP START
END: HLT
TABLE:
DB
9.5,6,0AH
RESULT:
Enter the above program and execute it. By converting the required step in decimal to hex
and entering the hex data at 1001 the motor rotates for so much steps and then stops.
Ex. no:4
Date:28-2-2012
THROW OF A DICE
126
AIM:
To simulate THROW OF A DICE using 8085 interrupts.
ALGORITHM:
STEP 1: Initialize the interrupt system by proper data.
STEP 2: Write the interrupt service routine at proper location (memory location)
STEP 3: Interrupt service routine is a program for dice simulation (counting from 0-6).
STEP 4: Loop the program control in a continuous mode.
STEP 5: Terminating point.
PROGRAM:
START: MVI A,0BH
SIM
EI
CAR: MVI A,01H
RPT: INR A
CPI 06H
JNZ RPT
JMP CAR
INRTS: DI
PUSH PSW
CALL UPDDT
POP PSW
EI
RETRN: RET
FFB1: C3 0F F0
RESULT
Press the Vect intr button in the keyboard, for each pressing a display will be there in
the display field (data field). I t displays from 00 to 06.
127
VIVA QUESTIONS
128
EC1304-Microprocessor And
Microcontroller
Laboratory
VIVA QUESTIONS
1.What is Microprocessor ?
It is a program controlled semiconductor device (IC}, which fetches, decode and
executes instructions.
2. What are the basic units of a microprocessor ?
The basic units or blocks of a microprocessor are ALU, an array of registers and control unit.
3.What is Software and Hardware?
The Software is a set of instructions or commands needed for performing a specific task by a
programmable device or a computing machine.
The Hardware refers to the components or devices used to form computing machine in which
the software can be run and tested. Without software the Hardware is an idle machine.
4. What is assembly language?
The language in which the mnemonics (short -hand form of instructions) are used to write a
program is called assembly language. The manufacturers of microprocessor give the mnemonics.
5. What are machine language and assembly language programs?
The software developed using 1's and 0's are called machine language, programs. The
software developed using mnemonics are called assembly language programs.
6. What is the drawback in machine language and assembly language, programs?
The machine language and assembly language programs are machine dependent. The
programs developed using these languages for a particular machine cannot be directly run on
another machine .
7. Define bit, byte and word.
A digit of the binary number or code is called bit. Also, the bit is the fundamental storage unit
of computer memory. The 8-bit (8-digit) binary number or code is called byte and 16-bit
binary number or code is called word.
8. What is a bus?
Bus is a group of conducting lines that carries data, address and control signals.
9. Why data bus is bi-directional?
The microprocessor has to fetch (read) the data from memory or input device for
processing and after processing, it has to store the data to memory or output device. Hence the
data bus is bi-directional.
129
2. AL 8-bit Accumulator
3. BX Base Register
4. CX Count Register
5. DX .Data Register
19. What is pipelined architecture?
In pipelined architecture the processor will have number of functional units and the execution
time of functional units are overlapped. Each functional unit works independently most of the
time.
20. What are the functional units available in 8086 architecture?
The bus interface unit and execution unit are the two functional units available in 8086
architecture.
21. List the segment registers of 8086.
The segment registers of 8086 are Code segment, Data segment, Stack segment and Extra
segment registers.
22. Define machine cycle.
Machine cycle is defined as the time required to complete one operation of accessing
memory, I/O, or acknowledging an external request. This cycle may consist of three to six Tstates.
23. Define T-State.
T-State is defined as one subdivision of the operation performed in one clock period.
These subdivisions are internal states synchronized with the system clock, and each T-State is
precisely equal to one clock period.
24. List the components of microprocessor (single board microcomputer) based system.
The microprocessor based system consist of microprocessor as CPU, semiconductor
memories like EPROM and RAM, input device, output device and interfacing devices.
25. Why interfacing is needed for 1/0 devices?
Generally I/O devices are slow devices. Therefore the speed of I/O devices does not
match with the speed of microprocessor. And so an interface is provided between system bus and
I/O devices.
26. What is the difference between CPU bus and system bus?
The CPU bus has multiplexed lines but the system bus has separate lines for each signal.
27..What does memory-mapping mean?
The memory mapping is the process of interfacing memories to microprocessor and
allocating addresses to each memory locations.
28..What is interrupt 1/0?
131
If the 1/0 device initiate the data transfer through interrupt then the 1/0 is called interrupt
driven 1/0.
29. Why EPROM is mapped at the beginning of memory space in 8085 system?
In 8085 microprocessor, after a reset, the program counter will have OOOOH address. If
the monitor program is stored from this address then after a reset, it will be executed
automatically. The monitor program is a permanent program and stored in EPROM memory. If
EPROM memory is mapped at the beginning of memory space, i.e., at OOOOH, then the
monitor program will be executed automatically after a reset.
30. What is the need for system clock and how it is generated in 8085?
The system clock is necessary for synchronizing various internal operations or devices
in the microprocessor and to synchronize the microprocessor with other peripherals in the
system.
31.What is DMA?
The direct data transfer between I/O device and memory is called DMA.
32. What is the need for Port?
The I/O devices are generally slow devices and their timing characteristics do not match
with processor timings. Hence the I/O devices are connected to system bus through the ports.
33.What is a port?
The port is a buffered I/O, which is used to hold the data transmitted from the microprocessor to
I/O device or vice-versa.
34.Give some examples of port devices used in 8085 microprocessor based system?
The various INTEL I/O port devices used in 8085 microprocessor based system are 8212, 8155,
8156, 8255, 8355 and 8755.
35. Write a short note on INTEL 8255?
The INTEL 8255 is a I/O port device consisting of 3 numbers of 8 bit parallel I/O ports. The
ports can be programmed to function either as a input port or as a output port in different
operating modes. It requires 4 internal addresses and has one logic LOW chip select pin.
36.What is the drawback in memory mapped I/0?
When I/O devices are memory mapped, some of the addresses are allotted to I/O devices and so
the full address space cannot be used for addressing memory (i.e., physical memory address
space will be reduced). Hence memory mapping is useful only for small systems, where the
memory requirement is less.
37. How DMA is initiated?
When the I/O device needs a DMA transfer, it will send a DMA request signal to DMA
controller. The DMA controller in turn sends a HOLD request to the processor. When the
processor receives a HOLD request, it will drive its tri-stated pins to high impedance state at the
end of current instruction execution and send an acknowledge signal to DMA controller. Now the
DMA controller will perform DMA transfer.
132
133
The status signals can be used by the system designer to track the internal operations of the
processor. Also, it can be used for memory expansion (by providing separate memory banks for
program & data and selecting the bank using status signals).
48. How the 8085 processor differentiates a memory access (read/write) and 1/0 access
(read/write)?
The memory access and 1/0 access is differentiated using 10 I M signal. The 8085
processor asserts 10 I M low for memory read/write operation and 10 I M is asserted high for 1/0
read/write operation.
49. When the 8085 processor checks for an interrupt?
In the second T -state of the last machine cycle of every instruction, the 8085 processor
checks whether an interrupt request is made or not.
50. What is interrupt acknowledge cycle?
The interrupt acknowledge cycle is a machine cycle executed by 8085 processor to get the
address of the interrupt service routine in-order to service the interrupt device.
51. How the interrupts are affected by system reset?
Whenever the processor or system is resetted , all the interrupts except TRAP are disabled.
fu order to enable the interrupts, El instruction has to be executed after a reset.
52. What is Software interrupts?
The Software interrupts are program instructions. These instructions are inserted at
desired locations in a program. While running a program, if software interrupt instruction is
encountered then the processor executes an interrupt service routine.
53. What is Hardware interrupt?
If an interrupt is initiated in a processor by an appropriate signal at the interrupt pin, then
the interrupt is called Hardware interrupt.
54. What is the difference between Hardware and Software interrupt?
The Software interrupt is initiated by the main program, but the Hardware interrupt is
initiated by an external device. In 8085, the Software interrupt cannot be disabled or masked but
the Hardware interrupt except TRAP can be disabled or masked.
55. What is Vectored and Non- Vectored interrupt?
When an interrupt is accepted, if the processor control branches to a specific address defined
by the manufacturer then the interrupt is called vectored interrupt. In Non-vectored interrupt
there is no specific address for storing the interrupt service routine. Hence the interrupted device
should give the address of the interrupt service routine.
56. List the Software and Hardware interrupts of 8085?
Software interrupts: RST 0, RSTl, RST 2, RST 3, RST 4, RST 5, RST 6 and RST 7.
Hardware interrupts: TRAP, RST 7.5, RST 6.5, RST 5.5 and INTR.
57. What is TRAP?
134
The TRAP is non-maskable interrupt of8085. It is not disabled by processor reset or after
reorganization of interrupt.
58. Whether HOLD has higher priority than TRAP or not?
The interrupts including TRAP are recognized only if the HOLD is not valid, hence
TRAP has lower priority than HOLD.
59. What is masking and why it is required?
Masking is preventing the interrupt from disturbing the current program execution. When
the processor is performing an important job (process) and if the process should not be
interrupted then all the interrupts should be masked or disabled. In processor with multiple
'interrupts, the lower priority interrupt can be masked so as to prevent it from interrupting, the
execution of interrupt service routine of higher priority interrupt.
60. When the 8085 processor accept hardware interrupt?
The processor keeps on checking the interrupt pins at the second T-state of last Machine
cycle of every instruction. If the processor finds a valid interrupt signal and if the interrupt is
unmasked and enabled then the processor accepts the interrupt. The acceptance of the interrupt is
acknowledged by sending an OOA signal to the interrupted device.
61. When the 8085 processor will disable the interrupt system?
The interrupts of 8085 except TRAP are disabled after anyone of the following operations
1. Executing El instruction.
2. System or processor reset.
3. After reorganization (acceptance) of an interrupt.
62. What is the function performed by Dl instruction?
The function of Dl instruction is to enable the disabled interrupt system.
63. What is the function performed by El instruction?
The El instruction can be used to enable the interrupts after disabling.
64. How the vector address is generated for the INTR interrupt of 8085?
For the interrupt INTR, the interrupting device has to place either RST opcode or CALL
opcode followed by l6-bit address. I~RST opcode is placed then the corresponding vector
address is generated by the processor. In case of CALL opcode the given l6-bit address will be
the vector address.
65. How clock signals are generated in 8085 and what is the frequency of the internal clock?
The 8085 has the clock generation circuit on the chip but an external quartz crystal or L C
circuit or RC circuit should be connected at the pins XI and X2. The maximum internal clock
frequency of 8085A is 3.03 MHz.
66. What happens to the 8085 processor when it is resetted?
When the 8085 processor is resetted it execute the first instruction at the OOOOH location.
The 8085 resets (clears) instruction register, interrupt mask bits and other registers.
135
138
In display devices, the process of sending display codes to 7 segment LEDs to display the
LEDs one by one is called scanning ( or multiplexed display). The scan time is the time taken to
display all the 7-segment LEDs one by one, starting from first LED and coming back
to the first LED again.
97. What are the internal devices of a typical DAC?
The internal devices of a DAC are R/2R resistive network, an internal latch and current to
voltage converting amplifier.
98. What is settling or conversion time in DAC?
The time taken by the DAC to convert a given digital data to corresponding analog signal is
called conversion time.
99. What are the different types of ADC?
The different types of ADC are successive approximation ADC, counter type ADC flash
type ADC, integrator converters and voltageto- frequency converters.
100. Define stack
Stack is a sequence of RAM memory locations defined by the programmer.
101. What is program counter? How is it useful in program execution?
The program counter keeps track of program execution. To execute a program the starting
address of the program is loaded in program counter. The PC sends out an address to fetch a byte
of instruction from memory and increments its content automatically.
102. How the microprocessor is synchronized with peripherals?
The timing and control unit synchronizes all the microprocessor operations with clock
and generates control signals necessary for communication between the microprocessor and
peripherals.
103. What is a minimum system and how it is formed in 8085?
A minimum system is one which is formed using minimum number of IC chips, The 8085
based minimum system is formed using 8155,8355 and 8755.
104. What is mean by microcontroller
A device which contains the microprocessor with integrated peripherals like memory,
serial ports, parallel ports, timer/counter, interrupt controller, data acquisition interfaces like
ADC,DAC is called microcontroller.
105.List the features of 8051 microcontroller?
The features are
*single_supply +5 volt operation using HMOS technology.
*4096 bytes program memory on chip(not on 8031)
*128 data memory on chip.
*Four register banks.
*Two multiple mode,16-bit timer/counter.
*Extensive boolean processing capabilities.
139
140