Lecture 02 Data Group of Instructions

lodro-ahmed 73 views 60 slides May 26, 2021
Slide 1
Slide 1 of 60
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60

About This Presentation

This is 3rd lecture of Microprocessor Theory and Interfacing which explains 8085 microprocessor's data group of instructions in detail.


Slide Content

Presented by:
Engr Zeeshan Ahmed Lodro
Lecturer-Department of Electronics Engineering Technology
BBS University of Technology and Skill Development Khairpur Mirs
1
Lecture-2

2

❑Classification of 8085 Instructions
❑Number of Instructions in 8085
Instruction type MVI r,d8
Instruction type MOV r1,r2
Instruction type MOV r,M
Instruction type M,r
Instruction type LXI rp, d16
3

Instruction type MVI M,d8
Instruction type LDA a16
Instruction type STA a16
Instruction type XCHG
❑Addressing Modes of 8085
❑Register codes
4

Immediate addressing mode
Register addressing mode
Absolute addressing mode
Register indirect addressing mode
Implied addressing mode
Instruction Type LDAX rp
Instruction type STAX rp
Instruction type LHLD a16
Instruction type SHLD a16
5

Description No. of opcodes No. of instruction types
Data transfer instruction83 13
Arithmetic instruction62 14
Logical instruction 43 15
Stack instruction 15 9
Branch instruction 36 8
I/O instruction 2 2
Interrupt instruction5 5
Total 246 66
6

❑With 8 bits for the opcode, 2^8=256 distinct
opcodes are possible.
❑In hexadecimal, the opcodes can be from 00H
to FFH.
❑Each opcode corresponds to instruction thus
theoretically 256 instructions are possible in
the instruction set of 8085.
❑However only 246 opcodes are implemented
in 8085.
7

Of the 246 opcodes we have:
202 opcodes that are 1-byte long
18 opcodes that are 2-byte long
26 opcodes are 3 bytes long.
8

MVI is a mnemonic, which stands for ‘MoVe
Immediate’. This is an instruction to load a
register with 8-bit value. This instruction uses
immediate addressing for specifying the data.
In this instruction d8 stands for any 8-bit data
and r stands for any of the following registers.
R=A,B,C,D,E,H or L
As r can have any of seven values, there are
seven opcodes for this type of instruction. It
occupies 2 bytes in the memory.
9

❑The result of execution is shown below.
Summary:
MVI r,d8( 2-byte; MVI E,8DH; 7 opcodes)
10
RegisterBefore After
E 45 8D

MOV is a mnemonic, which stands for ‘MOVe’. This is
an instruction to load a register r1 with 8-bit value
register r2. Notice that in 8085 instructions the first
operand specifies the destination and the second the
source. This instruction uses register addressing for
specifying the data.
In this instruction r1 and r2 stands for any of the
following registers.
R=A,B,C,D,E,H or L
As r1 can have any of seven values and r2 can have
any of seven values there are 7x7=49 opcodes for this
type of instruction. It occupies 1 bytes in the memory.
11

❑The result of execution is shown below.
Summary:
MOV r1,r2( 1-byte; MOV E,H; 49 opcodes)
12
RegisterBefore After
E 45 8D
H 8D 8D

Notice that H register content is not altered
at all.
Another thing to note is that there are
instructions like MOV D,D.
This instruction moves contents of D register
to D register itself.
It is of no use anybody, such useless
instructions are provided in the instruction
set of 8085.
13

MOV is a mnemonic, which stands for ‘MOVe’.
This is an instruction to load a register r with 8-
bit value in memory location. But from which
memory location? The address of memory
location is understood to be provided in HL
register pair. This instruction uses register
indirect addressing for specifying the data. As r
can have any seven values, there are seven
opcodes for this type of instruction. It occupies
only 1-byte in memory. MOV E,M is an example
of this instruction.
14

❑The result of execution is shown below.
Summary:
MOV r,M( 1-byte; MOV E,M; 7 opcodes)
15
RegisterBefore After
E 45 8D
HL F850 F850
F850 8D 8D

Another thing to note is that there are
instructions like MOV H,M.
This instruction moves contents of a memory
location pointed by HL register pair to H
register itself.
It is of no use anybody, such useless
instructions are provided in the instruction
set of 8085.
16

This is an instruction to load memory location
with 8-bit value in register r. But which
memory location? The address of memory
location is understood to be provided in HL
register pair. This instruction uses register
indirect addressing for specifying the data. As
r can have any seven values, there are seven
opcodes for this type of instruction. It
occupies only 1-byte in memory. MOV M,E is
an example of this instruction.
17

❑The result of execution is shown below.
Summary:
MOV M,r( 1-byte; MOV M,E; 7 opcodes)
18
RegisterBefore After
E 45
HL F850
F850 8D 45

Another thing to note is that there are
instructions like MOV M,H.
This instruction moves contents of H register
to memory location pointed by HL register
pair .
It is of no use anybody, such useless
instructions are provided in the instruction
set of 8085.
19

So farwe have seen that whenever M is used in an
instruction mnemonic, we are referring to the
contents of memory location whose address is given
in HL register pair. Thus, if MOV E,M is executed,
register E receives contents of memory pointed by
HL.
Suppose we want E to receive contents of memory
location FF00H. Then we have tomake sure that HL
will have FF00H, before MOV E,M is executed. Thus
any instruction involving M like MOV E,M, should
generally be preceded by instructions to load H and L
registers with the desired memory address.
20

How to ensure that HL register pair will have
the value of FF00H?
One method is to use the following two
instructions: MVI H,FFH and MVI L,00H
These two instructions occupy a total of 4
bytes in memory. A simpler alternative is to
use the 3 byteinstruction ‘LXI H, FF00H’, of
the type LXI rp,d16.
21

LXI is a mnemonic that stands for Load
eXtendedregister Immediate. Here, a
register pair is termed as extended register. It
is an instruction that loads register pair rp
with the 16 bit data denoted as d16. this
instruction uses immediate addressing for
specifying the data. In this type ,rp stands for
any of the following register pair.
rp=BC, DE,HL
22

As rp can have any of the three values, there
are three opcodes for this type of instruction.
It occupies 3 bytes in memory.
First byte specify the opcode, next tow bytes
specify the 16 bit data.
LXI H, F850H is an example of this type of
instruction. It is a 3-byte instruction. This
result of this instruction is shown next
23

❑The result of execution is shown below.
Summary:
LXI rp,d16( 3-bytes; LXI H, F850H; 3 opcodes)
24
RegisterBefore After
HL FABCH F850H

Notice that when specifying the register pair,
we specify only the MS register in the
instruction mnemonic. The X in the
mnemonic indicates that it is a register pair,
and so if the MS register is specified the
register pair is identified.
LXI H,F850H is stored in reverse order.
Code for LXI H
50
F8
25

This is an instruction to load a memory
location pointed by HL pair with 8-bit value.
This instruction uses immediate addressing
for specifying the data.
It occupies two bytes in memory.
MVI M, 8DH is an example instruction of this
type. It is a 2 bytes in a memory.
26

❑The result of execution is shown below.
Summary:
MVI M,d8( 2-byte; MVI M,8DH; 1 opcode)
27
RegisterBefore After
HL F845
F845 AC 8D

LDA is mnemonic that stands for LoaD
Accumulator contents from memory. This is an
instruction to load accumulator with the
contents of memory location whose 16 bit
address is indicated in the instruction as 16. This
instruction uses absolute addressing for
specifying the data.
It occupies 3 bytes in memory, first byte specifies
opcode, the successive 2 bytes provide the 16 bit
address.
LDA F850H is an example instruction of this
type.
28

❑The result of execution is shown below.
Summary:
LDA a16( 3-bytes; LDA F850H, 1 opcode)
29
RegisterBefore After
F850 BCH
A 12H BCH

LDA F850H is stored in memory with F850
stored in byte reversal as shown below.
Code for LDA
50
F8
There is no instruction like LDB a16,LDC a16
etc.
30

STA is a mnemonic that stands for Store
Accumulator contents in memory. This is an
instruction to store Accumulator contents in a
memory location whose 16 bit address is
indicated in the instruction as a16. This
instruction uses absolute addressing for
specifying the destination.
It is 3 byte instruction. First byte specify the
opcode, successive 2 bytes provides the 16 bit
address.
STA F850H is example of this type.
31

❑The result of execution is shown below.
Summary:
STA a16( 3-bytes; STA F850H, 1 opcode)
32
RegisterBefore After
A 12H
F850HBCH 12H

There are no instructions in 8085 like STB
a16,STD a16 etc.
STA F80H is stored in memory with F850
stored in byte reversal as shown below.
Code for STA
50
F8
33

XCHG is a mnemonic, which stands for
eXCHanGe. This is an instruction to exchange
contents of HL pair with DE pair.
This instruction used implied addressing.
It occupies only one byte in memory.
34

❑The result of execution is shown below.
Summary:
XCHG( 1-byte; XCHG, 1 opcode)
35
RegisterBefore After
HL 1234H 5678h
DE 5678 1234H

Shown below are the sizes of few instruction
types.
MOV r1,r2 1 byte
MOV r,M1 byte
MOV r,d8 2 bytes
Let us discuss reasons
36

37
The 8085 sends out 16-bit address to access one of
the 2^16=64K locations. But for convenience, we
indicate memory address using four hexadecimal
digits. Similarly, for convenience we indicate registers
as A,B,C etc. But the microprocessor must specify
these registers using 0s and 1s only.

With only seven registers in 8085, 3 bits are
enough to specify a register. Three bitcodes
are specified in table mentioned in previous
slide.
38

Now let us see how intel has arrived at the opcode for MOV E,H.
Six bits are needed to specify the two registers E and H.
Still two bits are needed to specify the two registers E and H. Still
two bits are left in a byte. Theses two bits are needed to indicate
the code for MOV. The template chose by Intel for instruction type
MOV r1,r2 is shown in the following. Intel chose 0 1 as the code for
MOV
0 1 r1 code r2 code
From the previous table the opcode for MOV E,H will be
01 011 100=5CH
This can be verified from the opcode chart given in the previous
lecture.
Similarlythe code for MOV A,B will be:
01 111 000=78H
39

Now let us see how intel has arrived at the opcode for
MOV E,M.
How to specify M? Intel solved this problem by choosing
110, which was not used to specify any register as the code
for M.
Thus although M stands for the contents of memory
location pointed by HL pair. It has 110 as the register code.
Six bits are needed to specify E and M. The remaining two
bits in the byte indicate the code for MOV. The opcode for
MOV E,M will be
01 011 110=5EH
This can be verified from opcode chart given in previous
slide. Similarly the code for MOV A,M will be : 01 111 110
with is 7EH.
40

Now let us see how intel has arrived at the opcode for
MVI E,34H. It will be a 2-byte instruction with 34H as
the second byte. In the first byte,3 bits are needed to
specify the registers E, still 5 bits are left in the first
byte. These five bits indicate the code for MVI. The
template chosen by ‘intel for instruction type MVI r,d8
is shown below.
00 r code 110
From table:
00 011 110=1EH
This can be verified from opcode chart. Similarlythe
code for MVI M will be:
00 110 110 = 36H
41

A user would like to have the ability to access data in
different ways for some reasons of convenience.
These different ways of accessing the data is called
the addressing modes. It is very similar the way
teacher in classro0m call his particular students in one
of the following ways.
By mentioning the name of student.
By indicating the position of his seat in the class.
By indicating the features of student.
Consider the execution of following four instructions.
In each of these instructions we move 25H to the
accumulator using different addressing modes.
42

43

In the previous examples, only MVI A,25H
clearly indicates that 25H has tobe moved to
the A register. This instruction occupies two
bytes in memory as follows.
Opcode for MVI A
25H
As the data moved is immediately after the
opcode in the instruction. This kind of
addressing is called immediate addressing
mode.
44

In the previous examples, MOV A,B indicates
that contents of the B register have tobe
moved to the A register. It does not directly
say that 25H has tobe moved.
The instruction only provides the address of
the data. In the case, the address is register B,
provided in the opcode using 3 bits. This kind
of addressing where the data is specified in a
register is called Register addressing mode.
45

In the previous examples, LDA F850H indicates that
content of the memory location F850H have tobe moved
to the A register. It does not directly say that 25H has tobe
moved. This instruction only provides the address of the
data. In this case, the memory address is F850H, provided
in the instruction using 2 bytes. This kind of addressing
where the data is specified in a memory location is called
absolute addressing mode. It is called absolute addressing
because a full 16 bitmemory address is given as part of
the instruction, in comparison with register addressing
where only a 3 bitregister address is provided as part of
the instruction.
This type of addressing is sometimes called direct
addressing.
46

In the previous examples, MOV A, M indicates
that contents of the memory location pointed by
HL register pair has to be moved to A register. It
does not directly say that 25H has to be moved.
If HL content is F850H, we are not moving F850H
to accumulator.
We have to take F850H as the memory address
and so move contents of F850H.
This is an indirect way of using register pair HL.
Hence this instruction is said to use Register
indirect addressing.
47

Consider the instruction XCHG. It exchanges the
contents of HL pair with DE pair. But the
instruction mnemonic does not explicitly specify
that HL and DE are to be exchanged. In other
wordswe do no write the instruction as XCHG
HL,DE. It is just implied that we have to
exchange HL and DE. Sothis type of addressing
is called implied addressing mode. It is also
called implicit addressing mode sometimes.
These are the only addressing modes available
in 8085.
48

LDAX is a mnemonic that stands for LoaD
Accumulator from memory pointed by
eXtendedregister denoted as rp. This
instruction uses register indirect addressing
for specifying the data. It occupied only 1
byte in memory.
LDAX B is an example instruction of this type.
It is a 1-byte instruction. The result of the
execution is shown below.
49

❑The result of execution is shown below.
Summary:
LDAX rp( 1-byte; LDAX B, 2 opcodes)
50
RegisterBefore After
BC F2BCH
F2BCH DCH
A 12H DCH

Only other instruction of this type is LDAX D.
Note that LDAX H is not provided in 8085.
This is because LDAX H is the same as MOV
A, M in its function.
Also note that there are no instructions in
8085 like LDBX rp, LDCX rp etc.
51

STAX is a mnemonic that stands for Store
Accumulator contents in memory pointed by
eXtendedregister denoted as ‘rp’. This
instruction uses register indirect addressing
for specifying the destination. It occupies 1
byte in memory.
STAX B is an example instruction of this type.
It is a 1-byte instruction. The result of this
instruction is shown below with an example.
52

❑The result of execution is shown below.
Summary:
STAX rp( 1-byte; STAX B, 2 opcodes)
53
RegisterBefore After
BC F2BCH
A 12H
F2BCH DCH 12H

Only other instruction of this type is STAX D.
Note that STAX H is not provided in 8085.
This is because, STAX H is the same as MOV
M,A in its function.
Also note that there is no instruction like
STBX rp, STCX rp etc.
54

LHLD is mnemonic that stands for load HL pair
using Direct addressing from memory location
whose 16 bitaddress is denoted as 16. As HL pair
has tobe loaded, the data comes from two
consecutive locations starting at the address
a16. This instruction uses absolute addressing
for specifying the data. It occupies 3 bytes in
memory.
LHLD F2BCH is an example of instruction. It is a
3-byte instruction.
55

❑The result of execution is shown below.
Summary:
LHLD a16( 3-bytes; LHLD F2BCH, 1 opcode)
56
RegisterBefore After
F2BC DCH
F2BD ABH
H 12H ABH
L 34H DCH

SHLD is a mnemonic, which stands for Store
HL pair using Direct addressing in memory
location whose 16 bitaddress is denoted as
16. As HL pair has tobe stored, it has tobe
stored in two consecutive locations starting
at the address a16. This instruction uses
absolute addressing for specifying the
destination. It occupies 3 bytes in memory.
57

❑The result of execution is shown below.
Summary:
SHLD a16( 3-bytes; SHLD F2BCH, 1 opcode)
58
RegisterBefore After
H 12H
L 34H
F2BC DCH 34H
F2BD ABH 12H

SHLD F2BCH is stored in memory with F2BC
stored in byte reversal form.
Code for SHLD
▪BC
▪F2
Note that there are no instructions like SBCD
a16 and SDED a16.
59

60