You are on page 1of 43

Mechatronics

MME205: Advanced Microprocessor and


Microcontroller
Lecture #3: Organization of 8085 II

Prepared by:
Dr. Ahmed Hassan M. Hassan
Associate Professor
dr.ahmed@mashreq.edu.sd

www.mashreq.edu.sd
Main Contents
Architecture
 Internal Register Organization and Pin Configuration
 Instruction Set of 8085
 addressing modes
 instruction machine cycles with states and timing
diagram.
 8085 assembly language programming
 Examples
Introduction

Microprocessor-based system
 Based on the design of the ALU and decoding unit, the
microprocessor manufacturer provides instruction set for
every microprocessor.

 The instruction set consists of both machine code and


mnemonics.

 An instruction is a binary pattern designed inside a


microprocessor to perform a specific function.

 The entire group of instructions that a microprocessor


supports is called instruction set.

 Microprocessor instructions can be classified based on the


parameters such functionality, length and operand
addressing.
Classification based on functionality:
 Data transfer operations: This group of instructions copies
data from source to destination. The content of the source is not
altered.

 Arithmetic operations: Instructions of this group perform


operations like addition, subtraction, increment & decrement. One
of the data used in arithmetic operation is stored in accumulator and
the result is also stored in accumulator.

 Logical operations: Logical operations include AND, OR,


EXOR, NOT. The operations like AND, OR and EXOR uses
two operands, one is stored in accumulator and other can be any
register or memory location. The result is stored in accumulator.
NOT operation requires single operand, which is stored in
accumulator.
 Branching operations: Instructions in this group can be used to
transfer program sequence from one memory location to another
either conditionally or unconditionally.

 Machine control operations: Instruction in this group control


execution of other instructions and control operations like interrupt,
halt etc.
Classification based on length:
 One-byte instructions: Instruction having one byte in machine
code.

 Two-byte instructions: Instruction having two byte in machine code.


 Three-byte instructions: Instruction having three byte in
machine code.
1.Data Transfer Instructions

 These instructions move data between registers, or


between memory and registers.

 These instructions copy data from source to


destination (without changing the original data ).
MOV-Copy from source to destination
Opcode Operand
Rd, Rs
MOV M, Rs
Rd, M
 This instruction copies the contents of the source
register into the destination register. (contents of
the source register are not altered)
 If one of the operands is a memory location, its
location is specified by the contents of the HL
registers.
 Example: MOV B, C or MOV B, M
BEFORE EXECUTION AFTER EXECUTION

A 20 B MOV B,A A 20 B 20
A F A F
B 30 C MOV M,B B 30 C
D E D E
H 20 L 50 H 20 L 50 30

A F A F
B C B C 40
MOV C,M
D E D E
H 20 L 50 40 H 20 L 50 40
MVI-Move immediate 8-bit
Opcode Operand

MVI Rd,
Data
M, Data
 The 8-bit data is stored in the destination register or
memory.
 If the operand is a memory location, its location is
specified by the contents of the H-L registers.

 Example: MVI B, 60H or MVI M, 40H


BEFORE EXECUTION AFTER EXECUTION

A F A F
B C MVI B,60H B 60 C
D E D E
H L H L

BEFORE EXECUTION AFTER EXECUTION

204FH 204F

HL=2050 HL=2050 40
MVI M,40H
2051H 2051H
LDA-Load accumulator
Opcode Operand

LDA 16-bit address

 The contents of a memory location, specified by a 16- bit


address in the operand, are copied to the accumulator.
 The contents of the source are not altered.

 Example: LDA 2000H


BEFORE EXECUTION AFTER EXECUTION

A A 30
LDA
2000H 30 2000H 2000H 30
LDAX-Load accumulator indirect
Opcode Operand
LD A X B/D Register Pair

 The contents of the designated register pair point to a memory


location.
 This instruction copies the contents of that memory location into
the accumulator.
 The contents of either the register pair or the memory location are
not altered.
 Example: LDAX D
BEFORE EXECUTION AFTEREXECUTION

A F A 80 F
B C 2030H 80 LDAX D B C 2030H 80
D 20 E 30 D 20 E 30
LXI-Load register pair immediate
O pcode O perand

LXI Reg. pair, 16-bit data

 This instruction loads 16-bit data in the register


pair.
 Example: LXI H, 2030 H
BEFORE EXECUTION AFTEREXECUTION

A F A 80 F
B C 2030H 30 LXI H, B C 9030H 50
2030
H L
2031H 90 H 90 L 30
Assignment (1):

 LHLD-Load H and L registers direct


 STA-Store accumulator direct
 STAX-Store accumulator indirect
 SHLD-Store H and L registers direct
 XCHG-Exchange H and L with D and E
 SPHL-Copy H and L registers to the stack pointer
 XTHL-Exchange H and L with top of stack
 PUSH-Push register pair onto stack
 POP- Pop stack to register pair
 IN- Copy data to accumulator from a port with 8-bit address
 OUT- Copy data from accumulator to a port with 8-bit address
2.Arithmetic Instructions
These instructions perform the operations like:
Addition

Subtract

Increment Assignment (2):

Decrement
Addition
 Any 8-bit number, or the contents of register, or the contents
of memory location can be added to the contents of
accumulator. The result (sum) is stored in the accumulator.

 No two other 8-bit registers can be added directly.

 Example: The contents of register B cannot be added directly


to the contents of register C.
AD D
Opcode Operand Description
ADD R M Add register or memory to
accumulator

 The contents of register or memory are added to the


contents of accumulator.

 The result is stored in accumulator.

 If the operand is memory location, its address is specified


by H-L pair.

 Example: ADD B or ADD M


Before Execution After Execution

A 04
A 09
B C
ADD C B C 05
05
A=A+C D E
D E
H L
H L
04+05=09
Before Execution After Execution

A 04 ADD M A 14
B C A=A+M B C
D E D E
H 20 L 50 10
10 H 20 L 50

2050 04+10=14 2050


AD C
Opcode Operand Description
ADC R Add register or memory to
M accumulator with carry

 The contents of register or memory and Carry Flag (CY) are


added to the contents of accumulator.
 The result is stored in accumulator.
 If the operand is memory location, its address is specified by
H-L pair.
 All flags are modified to reflect the result of the addition.

 Example: ADC B or ADC M


Before Execution After Execution

CY 01
A
A 56
50
ADCC B C 20
B C 05 A=A+C+CY D E
D E H L
H L

50+05+01=56
Before Execution After Execution

CY 1
ADCM A 37 2050H 30
A 06 2050H 30
A=A+M+CY
H 20 L 50 H 20 L 50
06+1+30=37
AD I
Opcode Operand Description
ADI 8-bit data Add immediate to accumulator

 The 8-bit data is added to the contents of


accumulator.

 The result is stored in accumulator.

 All flags are modified to reflect the result of


the addition.

 Example: ADI 45 H
Before Execution After Execution

A 03 ADI 05H A 08
A=A+DATA(8)

03+05=08
AC I
Opcode Operand Description
ACI 8-bit data Add immediate to
accumulator with carry
 The 8-bit data and the Carry Flag (CY) are added to the
contents of accumulator.

 The result is stored in accumulator.

 All flags are modified to reflect the result of the addition.

 Example: ACI 45 H
Before Execution After Execution

CY 1 A 26
ACI 20H
A 05 A=A+DATA (8)+CY
05+20+1=26
DAD
Opcode Operand Description
DAD Reg. pair Add register pair to H-L pair

 The 16-bit contents of the register pair are added to the


contents of H-L pair.

 The result is stored in H-L pair.


 If the result is larger than 16 bits, then CY is set.
 No other flags are changed.

 Example: D A D B or DAD D
Before Execution After Execution

D 12 E 34 D 12 E 34
H 23 L 45 DAD D H 35 L 79

1234
2345 +
DAD D  HL=HL+DE
-------
3579 or
DAD B  HL=HL+BC
Increment / Decrement

 The 8-bit contents of a register or a memory location can be


incremented or decremented by 1.

 The 16-bit contents of a register pair can be incremented or


decremented by 1.

 Increment or decrement can be performed on any register or


a memory location.
IN R
Opcode Operand Description
INR R Increment register or
M memory by 1

 The contents of register or memory location are incremented


by 1.

 The result is stored in the same place.

 If the operand is a memory location, its address is specified by


the contents of H-L pair.

 Example: INR B or INR M


Before Execution After Execution

A A
B 10 C INR B B 11 C
D E D E
R=R+1 H L
H L

10+1=11
Before Execution After Execution

INR M
H
20
L
50 2050H 10 H
20
L
50
11 2050H
M=M+1
10+1=11
IN X
Opcode Operand Description
INX R Increment register pair by 1

 The contents of register pair are incremented by 1.

 The result is stored in the same place.

 Example: INX H or INX B or INX D


Before Execution After Execution

SP SP

B C B C
INX H D E
D E
RP=RP+1
H 10 L 20 H 10 L 21

1020+1=1021
3.Logical Instructions
 These instructions perform logical operations on data
stored in registers, memory and status flags.

 The logical operations are:


 AND
 OR
 XOR
 Rotate Assignment (3):
 Compare
 Complement
AND, OR, X O R
 Any 8-bit data, or the contents of register, or memory
location can logically have:
 AND operation
 OR operation
 XOR operation
with the contents of accumulator.

 The result is stored in accumulator.


Opcode Operand Description

ANA R Logical A N D register or


M memory with accumulator

 The contents of the accumulator are logically ANDed with the


contents of register or memory.
 The result is placed in the accumulator.
 If the operand is a memory location, its address is specified by
the contents of H-L pair.
 S, Z, P are modified to reflect the result of the operation.
 CY is reset and AC is set.
 Example: ANA B or ANA M.
1010 1010=AAH
0000 1111=0FH After Execution
Before Execution
0000 1010=0AH CY 0 AC 1
CY AC

A AA A 0A
B 10
0F C ANAB B 0F C
D E A=Aand R D E
H L H L

Before Execution After Execution

0101 0101=55H
CY AC 1011 0011=B3H CY 0 AC 1

0001 0001=11H
A 55 2050H A 11 2050H B3
B3
H 20 L 50 ANAM H 20 L 50
A=Aand M
Opcode Operand Description
ANI 8-bit data Logical A N D immediate with
accumulator

 The contents of the accumulator are logically ANDed


with the 8-bit data.
 The result is placed in the accumulator.
 S, Z, P are modified to reflect the result.
 CY is reset, AC is set.
 Example: ANI 86H.
1011 0011=B3H
0011 1111=3FH

0011 0011=33H

Before Execution After Execution

CY AC ANI 3FH CY 0 AC 1

A B3 A=A and DATA(8) A 33

You might also like