MPMC Unit 1
MPMC Unit 1
Microprocessor Architecture
Basic Concepts of Microprocessors
• Microcomputer: a computer with a microprocessor as its
CPU. Includes memory, I/O etc.
• This can be the monitor, a paper from the printer, a simple LED or many
other forms.
Functional blocks of computer
Computer is a system which process information.
1. Input unit: Responsible for inputting
information (code / data) eg. Keyboard,
Memory Unit
stylus etc.
• It is abbreviated as μp
Features of 8085 μp
• It is a 8 bit microprocessor.
• Six 8-bit general purpose register arranged in pairs: BC, DE, HL.
• A 16 bit program counter (PC), A 16 bit stack pointer (SP)
• Data bus is a group of 8 lines AD0 – AD7.
• It has 16-bit address buses A0-A15. The first 8 lines of address bus and 8
lines of data bus are multiplexed AD0 – AD7.
• 8085 μp can address up to 64 KB (216= 65536 bytes) memory.
• It is enclosed with 40 pins DIP (Dual in line package).
• It requires a signal +5V power supply and operates at 3 MHZ single
phase clock.
Bus architecture of 8085 μp
System Bus
• System bus is a collection of wires carrying information within a
computer system.
• Example:
a) 8-bit μP will have a data bus of 8 wires
b) 32-bit μP will have a data bus with 32 wires
Control Bus
• Control bus consists of wires, carrying signals from CPU to external
devices or from external devices to CPU.
• The number of wires present in the control bus varies from one μP to
another.
• Examples are Memory read , Memory write, I/O read, I/O write.
The 8085 Programming Model
Registers
• The 8085 has six general-purpose registers to store
8-bit data;
• B,C,D,E,H, and L
• They can be combined as register pairs –
• BC, DE, and HL – to perform some 16-bit operations.
Reg B D7 D6 D5 D4 D3 D2 D1 D0 Reg C D7 D6 D5 D4 D3 D2 D1 D0
Reg D D7 D6 D5 D4 D3 D2 D1 D0 Reg E D7 D6 D5 D4 D3 D2 D1 D0
Reg H D7 D6 D5 D4 D3 D2 D1 D0 Reg L D7 D6 D5 D4 D3 D2 D1 D0
Accumulator
The accumulator is an 8-bit register that is a part of arithmetic/logic unit
(ALU).
This register is used to store 8-bit data and to perform arithmetic and
logical operations.
D7 D6 D5 D4 D3 D2 D1 D0
Result= 0 0 0 1 0 0 1 0
S= 0
D7 D6 D5 D4 D3 D2 D1 D0
Result= 1 0 0 0 1 0 0 0
S= 1
Example: 1
1 1 1
1 0 0 0 1 0 1 1
+ 1 1 0 0 1 0 0 1
1 0 1 0 1 0 1 0 0
CY = 1
P=0
AC = 1
Z=0
S=0
Example: 2
0 1 1 0 0 0 1 1
- 1 0 0 0 1 0 0 0
1 1
1 1 1 0 1 1 0 1 1
CY = 1
P=1
AC = 1
Z=0
S=1
Program Counter (PC)
• This 16-bit register deals with sequencing the execution of instructions.
This register is a memory pointer.
• Memory locations have 16-bit addresses, and that is why this is a 16-bit
register.
• Initial Value of PC = 0000H
PCH PCL
RST 6.5
RST 7.5
RST 5.5
INTA’
TRAP
SID
INTR
SOD
Instruction
ACC Reg (8) Temp Reg (8) Flag Reg (8) B Reg (8) C Reg (8)
Register
D Reg (8) E Reg (8)
H Reg (8) L Reg (8)
Instruction
Stack Pointer (16)
Decoder
and Program Counter (16)
ALU
Machine Increment / Decrement
Cycle Address Latch (16)
Encoder
X1 X2 +5V GND
CLK READY WR’ RD’ ALE S0 S1 IO/M’ HOLD HLDA RESETIN’ RESETOUT A8-A15 AD0-AD7
OUT
The ALU
• In addition to the arithmetic & logic circuits, the ALU includes
the accumulator, which is part of every arithmetic & logic
operation.
F F F B (H)
F F F C (H)
F F F D (H)
F F F E (H)
F F F F (H)
Memory and Address
• The memory map is a picture representation of the address range and
shows where the different memory chips are located within the address
range.
0000
EPROM Address Range of EPROM Chip
3FFF
4400
RAM 1 Address Range of 1st RAM Chip
5FFF
6000
Address Range
F7FF
FFFF
Memory and Address
• To execute a program the user enters its instructions in binary
format into the memory.
Separated by ALE
ALE is High : AD7-AD0 Add Bus
ALE is Low : AD7-AD0 Data Bus
Pin Configuration of 8085 …
Status & Control Signals
ALE (30):
• It is an Address Latch Enable signal.
Used for demultiplexing of address
and data lines.
• It is a positive going pulse generated
when a new operation is started by the
microprocessor (during first T-State).
• When the pulse goes high, it indicates
address.
• When the pulse goes down it
indicates data.
Pin Configuration of 8085 …
Status & Control Signals
S0 (29), S1 (33):
• These are status signals.
• These signals are used to identify the
type of current operation.
• They distinguish the various types of
operations such as halt, reading,
instruction fetching or writing.
Pin Configuration of 8085 …
Status & Control Signals
IO/𝐌ഥ (34)
• This signal is used to differentiate
between IO and Memory operations.
• When it is high indicates IO operation
• When it is low then it indicates
memory operation.
Pin Configuration of 8085 …
ഥ
IO/𝐌 S1 S0 Operation
0 1 1 Opcode fetch
0 1 0 Memory read
0 0 1 Memory write
1 1 0 I/O read
1 0 1 I/O write
1 1 1 Interrupt acknowledge
0 0 0 Halt
Pin Configuration of 8085 …
Status & Control Signals
𝐑𝐃 (32)
• It is a signal to control READ
operation.
• When it is low the selected memory
or input-output device is read.
Pin Configuration of 8085 …
Status & Control Signals
𝐖𝐑 (31)
• It is a signal to control WRITE
operation.
• When it goes low the data on the data
bus is written into the selected
memory or I/O location.
Pin Configuration of 8085 …
Status & Control Signals
READY (35)
• It senses whether a peripheral is ready
to transfer data or not.
• If READY is high(1) the peripheral is
ready.
• If it is low(0) the microprocessor
waits till it goes high.
• It is useful for interfacing low speed
devices.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
𝐑𝐄𝐒𝐄𝐓 𝐈𝐍 (36)
• When the signal on this pin is low(0),
the program-counter is set to zero, the
buses are tristated and the
microprocessor unit is reset.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
RESET OUT (3)
• This signal indicates that the MPU is
being reset.
• The signal can be used to reset other
devices.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
HOLD (39)
• It indicates that another device is
requesting the use of the address and
data bus.
• Having received HOLD request the
microprocessor relinquishes the use of
the buses as soon as the current machine
cycle is completed.
• Internal processing may continue.
• After the removal of the HOLD signal
the processor regains the bus.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
HLDA (38)
• It is a signal which indicates that the
hold request has been received after
the removal of a HOLD request, the
HLDA goes low.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
HOLD(39) and HLDA (38)
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
• The 8085 has five interrupt signals
that can be used to interrupt a
program execution.
1. TRAP
2. RST 7.5
3. RST 6.5
4. RST 5.5
5. INTR
• The microprocessor acknowledges
Interrupt Request by INTA signal.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
TRAP (6)
• It is a non-maskable interrupt, having
the highest priority among all
interrupts.
• By default, it is enabled until it gets
acknowledged. In case of failure, it
executes as ISR and sends the data to
backup memory.
• This interrupt transfers the control to
the location 0024H.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
RST 7.5 (7)
• It is a maskable interrupt, having the
second highest priority among all
interrupts.
• When this interrupt is executed, the
processor saves the content of the PC
register into the stack and branches to
003CH address.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
RST 6.5 (8)
• It is a maskable interrupt, having the
third highest priority among all
interrupts.
• When this interrupt is executed, the
processor saves the content of the PC
register into the stack and branches to
0034H address.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
RST 5.5 (9)
• It is a maskable interrupt.
• When this interrupt is executed, the
processor saves the content of the PC
register into the stack and branches to
002CH address.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
INTR (10)
• It is a maskable interrupt, having the
lowest priority among all interrupts.
• It can be disabled by resetting the
microprocessor.
• When INTR signal goes high, the
following events can occur
1. The microprocessor checks the
status of INTR signal during the
execution of each instruction.
Pin Configuration of 8085 …
Externally Started (Initiated) and
Interrupt Signals
INTR (10)
2. When the INTR signal is high, then
the microprocessor completes its
current instruction and sends active
low interrupt acknowledge signal.
VSS (20)
• VSS is a ground pin
Pin Configuration of 8085 …
Power Supply & Clock Frequency.
X1 (1) and X2 (2)
• X1, X2 terminals that are associated
with the exterior oscillator for
generating the required as well as
appropriate operation of a clock.
Pin Configuration of 8085 …
Power Supply & Clock Frequency.
X1 (1) and X2 (2)
Pin Configuration of 8085 …
Power Supply & Clock Frequency.
X1 (1) and X2 (2)
Pin Configuration of 8085 …
Power Supply & Clock Frequency.
CLK OUT (37)
• Sometimes it is compulsory to
generate output clock signal from
8085 microprocessors so that it can be
used in favor of other peripherals or
else other digital integrated circuits.
• This is offered with CLK OUT pin.
Its frequency is continually similar
because the frequency at which the
microprocessor works.
Pin Configuration of 8085 …
Generation of Control Signals
ഥ
IO/𝐌
𝐌𝐄𝐌𝐑
𝐑𝐃
8085 𝐌𝐄𝐌𝐖
𝐖𝐑
𝐈𝐎𝐑
𝐈𝐎𝐖
Demultiplexing of AD7-AD0
A15 - A8 A15 - A8
ALE
8085
AD7 – AD0 Latch A7 – A0
D7 – D0
Demultiplexing of AD7-AD0
Generation of Control Signals and
Demultiplexing of AD7-AD0
The 8085 organization an example
• Putting all of the concepts together, we get:
Chip Selection
A15- A10 Circuit
8085
A15-A8 CS
ALE
A9-A0 1K Byte
AD7-AD0 Latch Memory
A7- A0
Chip
WR RD IO/M D7- D0
RD WR
The three cycle instruction execution model
• To execute a program,
• the microprocessor Reads each instruction from memory,
• Interprets it, then
• Executes it.
• To use the right names for the cycles:
• The microprocessor fetches each instruction,
• Decodes it, then
• Executes it.
• This sequence is continued until all instructions are performed.
Machine Language
• The number of bits that form the word of a microprocessor is fixed for
that particular processor.
• These bits define a maximum number of combinations.
• For example an 8-bit microprocessor can have at most 28 = 256
different combinations.
• However, in most microprocessors, not all of these combinations are
used.
• Certain patterns are chosen and assigned specific meanings.
• Each of these patterns forms an instruction for the microprocessor.
• The complete set of patterns makes up the microprocessor’s machine
language.
The 8085 Machine Language
• The 8085 (from Intel) is an 8-bit microprocessor.
• The 8085 uses a total of 246 bit patterns to form its instruction set.
• These 246 patterns represent only 74 instructions.
• The reason for the difference is that some (actually most) instructions
have multiple different formats.
• Because it is very difficult to enter the bit patterns correctly, they are
usually entered in hexadecimal instead of binary.
• For example, the combination 0011 1100 which translates into
increment the number in the register called the accumulator, is
usually entered as 3C.
Assembly Language
• Entering the instructions using hexadecimal is quite easier than entering
the binary combinations.
• Example 2:
• 1000 0000, translates to 80 H
• Its mnemonic is ADD B.
• Add register B to the accumulator and keep the result in the
accumulator.
Assembly Language
• It is important to remember that a machine language and its
associated assembly language are completely machine
dependent.
• In other words, they are not transferable from one
microprocessor to a different one.
• For example, Motorola has an 8-bit microprocessor called the
6800.
• The 8085 machine language is very different from that of the
6800; so is the assembly language.
• A program written for the 8085 cannot be executed on the 6800
and vice versa.
Assembling The Program
• How does assembly language get translated into machine
language?
• There are two ways:
• Hand assembly: The programmer translates each
assembly language instruction into its equivalent
hexadecimal code (machine language). Then the
hexadecimal code is entered into memory.
20 H 05 H 05 H 05 H
Reg B Reg C Reg B Reg C
Data Transfer Instructions . . .
Instruction: MOV R, M
Explanation: Move the content of memory to register
Byte: 1 Byte
Operation Performed: [R] ← [M] / [R] ← [[H-L]]
Addressing Mode: Register Indirect
Flags Affected: None
T-States / Machine Cycles: 7 / 2 (Fetch, Mem Rd)
Example: MOV B, M
Before Execution After Execution
2504 H 05 H
A5 H 25 H 05 H 2505 H 21 H 21 H
B H L 2506 H 32 H B
Data Transfer Instructions . . .
Instruction: MOV M, R
Explanation: Move the content of register to memory
Byte: 1 Byte
Operation Performed: [M] ← [R] / [[H-L]] ← [R]
Addressing Mode: Register Indirect
Flags Affected: None
T-States / Machine Cycles: 7 / 2 (Fetch, Mem Rd)
Example: MOV M, C
Before Execution After Execution
2504 H 05 H 2504 H 05 H
21 H 25 H 05 H 2505 H 00 H 2505 H 21 H 21 H
C H L 2506 H 32 H 2506 H 32 H C
Data Transfer Instructions . . .
Instruction: MVI R, data(8)
Explanation: Move immediate data to register
Byte: 2 Byte
Operation Performed: [R] ← data(8)
Addressing Mode: Immediate, Register
Flags Affected: None
T-States / Machine Cycles: 7 / 2 (Fetch, Mem Rd)
Example: MVI D, A2H
Before Execution After Execution
A2 H 21 H A2 H A2 H
Data D Data D
Data Transfer Instructions . . .
Instruction: MVI M, data(8)
Explanation: Move immediate data to memory
Byte: 2 Byte
Operation Performed: [M] ← data(8) / [[H-L]] ← data(8)
Addressing Mode: Immediate, Register Indirect
Flags Affected: None
T-States / Machine Cycles: 10 / 3 (Fetch, Mem Rd, Memory Wr)
Example: MVI M, B4H
Before Execution After Execution
2504 H 05 H 2504 H 05 H
B4 H 25 H 05 H 2505 H 00 H 2505 H B4 H B4 H
Data H L 2506 H 32 H 2506 H 32 H Data
Data Transfer Instructions . . .
Instruction: LXI RP , data(16)
Explanation: Load Register pair immediate
Byte: 3 Byte
Operation Performed: [RP] ← data(16), [RH] ←8 MSBs, [RL] ←8 LSBs
Addressing Mode: Immediate
Flags Affected: None
T-States / Machine Cycles: 10 / 3 (Fetch, Mem Rd, Mem Rd)
Example: LXI H, 3240H
Before Execution After Execution
25 H 05 H 32 H 40 H
H L H L
Data Transfer Instructions . . .
Instruction: LDA addr(16)
Explanation: Load Accumulator direct
Byte: 3 Byte
Operation Performed: [A] ← [addr(16)]
Addressing Mode: Direct
Flags Affected: None
T-States / Machine Cycles: 13 / 4 (Fetch, Mem Rd, Mem Rd, Mem Rd)
Example: LDA 2034H
Before Execution After Execution
2033 H 05 H
C1 H
2034 H 23 H 23 H
A 2035 H 32 H A
Data Transfer Instructions . . .
Instruction: STA addr(16)
Explanation: Store Accumulator direct
Byte: 3 Byte
Operation Performed: [addr(16)] ← [A]
Addressing Mode: Direct
Flags Affected: None
T-States / Machine Cycles: 13 / 4 (Fetch, Mem Rd, Mem Rd, Mem Wr)
Example: STA 2034H
Before Execution After Execution
2033 H 05 H 2033 H 05 H
C1 H 2034 H 23 H 2034 H C1 H C1 H
A 2035 H 32 H 2035 H 32 H A
Data Transfer Instructions . . .
Instruction: LHLD addr(16)
Explanation: Load H-L pair direct
Byte: 3 Byte
Operation Performed: [L] ←[addr(16)], [H] ← [addr(16) + 1 ]
Addressing Mode: Direct
Flags Affected: None
T-States / Machine Cycles: 16 / 5 (Fetch, Mem Rd, Mem Rd, Mem Rd, Mem Rd)
Example: LHLD 2034H
Before Execution After Execution
2033 H 05 H 2033 H 05 H 32 H 21 H
A2 H C1 H 2034 H 21 H 2034 H 21 H
H L 2035 H 32 H 2035 H 32 H
H L
Data Transfer Instructions . . .
Instruction: SHLD addr(16)
Explanation: Store H-L pair direct
Byte: 3 Byte
Operation Performed: [addr(16)] ←[L], [addr(16) +1] ← [H]
Addressing Mode: Direct
Flags Affected: None
T-States / Machine Cycles: 16 / 5 (Fetch, Mem Rd, Mem Rd, Mem Wr, Mem Wr)
Example: SHLD 2034H
Before Execution After Execution
A2 H C1 H 2033 H 05 H A2 H C1 H 05 H 2033 H
H L 2034 H 21 H C1 H 2034 H
2035 H 32 H A2 H 2035 H
H L
Data Transfer Instructions . . .
Instruction: LDAX RP (Valid for B-C and D-E pair only)
Explanation: Load accumulator indirect
Byte: 1 Byte
Operation Performed: [A] ←[[RP]]
Addressing Mode: Register Indirect
Flags Affected: None
T-States / Machine Cycles: 7 / 2 (Fetch, Mem Rd)
Example: LDAX B
Before Execution After Execution
20 H C4 H 20C3 H 05 H 20C3 H 05 H
B C 20C4 H 23 H 20C4 H 23 H 23 H
20C5 H 32 H 20C5 H 32 H
F5 H A A
Data Transfer Instructions . . .
Instruction: STAX RP (Valid for B-C and D-E pair only)
Explanation: Store accumulator indirect
Byte: 1 Byte
Operation Performed: [[RP]] ← [A]
Addressing Mode: Register Indirect
Flags Affected: None
T-States / Machine Cycles: 7 / 2 (Fetch, Mem Wr)
Example: STAX D
Before Execution After Execution
25 H 04 H 2503 H 05 H 2503 H 05 H
D E 2504 H C1 H 2504 H E5 H E5 H
2505 H 32 H 2505 H 32 H
E5 H A A
Data Transfer Instructions . . .
Instruction: XCHG (Valid for H-L and D-E pair only)
Explanation: Change the contents of H-L with D-E pair
Byte: 1 Byte
Operation Performed: [H-L] ↔ [D-E]
Addressing Mode: Register
Flags Affected: None
T-States / Machine Cycles: 4 / 1 (Fetch)
Example: XCHG
Before Execution After Execution
25 H 04 H F2 H 4E H F2 H 4E H 25 H 04 H
H L D E H L D E
Arithmetic Instructions
• The instructions of this group perform arithmetic
operations such as addition, subtraction, increment
or decrement of the content of a register or a
memory.
Arithmetic Instructions
Instruction : ADD R
Explanation : Add register to accumulator
Byte : 1Byte
Operation Performed : [A] ← [A] + [R]
Addressing Mode : Register
Flags Affected : All
T-States / Machine Cycles : 4 /1 (Fetch)
Example : ADD E
Before Execution After Execution
05 H 04 H 05 H 09 H
E A E A
Arithmetic Instructions
Instruction : ADD M
Explanation : Add memory to accumulator
Byte : 1 Byte
Operation Performed : [A] ← [A] + [[H-L]]
Addressing Mode : Register indirect
Flags Affected : All
T-States / Machine Cycles : 7 / 2 (Fetch, Mem Rd)
Example : ADD M
Before Execution After Execution
25 H 04 H 2503 H 05 H 2503 H 05 H
2504 H 08 H 2504 H 08 H 0F H
H L
2505 H 32 H 2505 H 32 H A
07 H A
Arithmetic Instructions . . .
Instruction : ADC R
Explanation : Add register with carry to accumulator
Byte : 1 Byte
Operation Performed : [A] ← [A] + [R] + [CS]
Addressing Mode : Register
Flags Affected : All
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : ADC E
Before Execution After Execution
05 H 04 H 01 H 05 H 0A H 00 H
E A CS E A CS
Arithmetic Instructions
Instruction : ADC M
Explanation : : Add memory with carry to accumulator
Byte : 1 Byte
Operation Performed : [A] ← [A] + [[H-L]] + [CS]
Addressing Mode : Register indirect
Flags Affected : All
T-States / Machine Cycles : 7 / 2 (Fetch, Mem Rd)
Example : ADC M
Before Execution After Execution
25 H 04 H 2503 H 05 H 2503 H 05 H
2504 H 08 H 2504 H 08 H A 10 H CS 00 H
H L
2505 H 32 H 2505 H 32 H
A 07 H CS 01 H
Arithmetic Instructions
Instruction : ADI data(8)
Explanation : Add immediate data to accumulator
Byte : 2 Byte
Operation Performed : [A] ← [A] + data(8)
Addressing Mode : Immediate
Flags Affected : All
T-States / Machine Cycles : 7 /2 (Fetch, Mem Rd)
Example : ADI 05 H
Before Execution After Execution
05 H 04 H 05 H 09 H
data A data A
Arithmetic Instructions
Instruction : ACI data(8)
Explanation : Add immediate data to accumulator with carry
Byte : 2 Byte
Operation Performed : [A] ← [A] + data(8) + [CS]
Addressing Mode : Immediate
Flags Affected : All
T-States / Machine Cycles : 7 /2 (Fetch, Mem Rd)
Example : ACI 05 H
Before Execution After Execution
05 H 04 H 01 H 05 H 0A H 00 H
data A CS data A CS
Arithmetic Instructions . . .
Instruction : DAD RP
Explanation : Add register pair to H-L pair
Byte : 1 Byte
Operation Performed : [H-L] ←[H-L] + [RP]
Addressing Mode : Register
Flags Affected : CS
T-States / Machine Cycles : 10 / 3 (Fetch, Bus Idle, Bus Idle)
Example : DAD B
Before Execution After Execution
05 H 04 H 02 H 04 H 07 H 08 H 02 H 04 H
H L B C H L B C
Arithmetic Instructions . . .
Instruction : DAD SP
Explanation : Add stack pointer to H-L pair
Byte : 1 Byte
Operation Performed : [H-L] ←[H-L] + [SP]
Addressing Mode : Register
Flags Affected : CS
T-States / Machine Cycles : 10 / 3 (Fetch, Bus Idle, Bus Idle)
Example : DAD SP
Before Execution After Execution
05 H 40 H 05 H 04 H 0A H 44 H 05 H 04 H
05 H 02 H 03 H 02 H
A B A B
Arithmetic Instructions . . .
Instruction : SUB M
Explanation : Subtract memory from accumulator
Byte : 1 Byte
Operation Performed : [A] ← [A] - [[H-L]]
Addressing Mode : Register Indirect
Flags Affected : All
T-States / Machine Cycles : 7 / 2 (Fetch, Mem Rd)
Example : SUB M
Before Execution After Execution
20 H C4 H 20C3 H 65 H 20 H C4 H 20C3 H 65 H
H L 20C4 H 05 H H L 20C4 H 05 H
20C5 H 32 H 20C5 H 32 H
A F5 H A F0 H
Arithmetic Instructions . . .
Instruction : SBB R
Explanation : Subtract register from accumulator with borrow
Byte : 1 Byte
Operation Performed : [A] ← [A] - [R] - [CS]
Addressing Mode : Register
Flags Affected : All
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : SBB B
Before Execution After Execution
05 H 02 H 01 H 02 H 02 H 00 H
A B CS A B CS
Arithmetic Instructions . . .
Instruction : SBB M
Explanation : Subtract register from accumulator with Borrow
Byte : 1 Byte
Operation Performed : [A] ← [A] - [[H-L]] - [CS]
Addressing Mode : Register
Flags Affected : All
T-States / Machine Cycles : 7 / 2 (Fetch, Mem Rd)
Example : SBB M
Before Execution After Execution
20 H C4 H 20C3 H 65 H 20 H C4 H 20C3 H 65 H
H L 20C4 H 05 H H L 20C4 H 05 H
20C5 H 32 H 20C5 H 32 H
A F6 H CS 01 H A F0 H CS 00 H
Arithmetic Instructions . . .
Instruction : SUI data(8)
Explanation : Subtract immediate data from accumulator
Byte : 2 Byte
Operation Performed : [A] ← [A] - data(8)
Addressing Mode : Immediate
Flags Affected : All
T-States / Machine Cycles : 7 / 2 (Fetch, Mem Rd)
Example : SUI 02H
Before Execution After Execution
05 H 02 H 03 H 02 H
A data A data
Arithmetic Instructions . . .
Instruction : SBI data(8)
Explanation : Subtract immediate data from accumulator with borrow
Byte : 2 Byte
Operation Performed : [A] ← [A] - data(8) - [CS]
Addressing Mode : Immediate
Flags Affected : All
T-States / Machine Cycles : 7 / 2 (Fetch, Mem Rd)
Example : SBI 02H
Before Execution After Execution
05 H 02 H 01 H 02 H 02 H 00 H
A data CS A data CS
Arithmetic Instructions . . .
Instruction : INR R
Explanation : Increment register content by 1
Byte : 1 Byte
Operation Performed : [R] ← [R] + 1
Addressing Mode : Register
Flags Affected : All except CS
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : INR A
Before Execution After Execution
05 H 06 H
A A
Arithmetic Instructions . . .
Instruction : INR M
Explanation : Increment memory content by 1
Byte : 1 Byte
Operation Performed : [[H-L]] ← [[H-L]] + 1
Addressing Mode : Register Indirect
Flags Affected : All except CS
T-States / Machine Cycles : 10 / 3 (Fetch, Mem Rd, Mem Wr)
Example : INR M
Before Execution After Execution
20 H C4 H 20C3 H 65 H 20 H C4 H 20C3 H 65 H
H L 20C4 H 05 H H L 20C4 H 06 H
20C5 H 32 H 20C5 H 32 H
CS 00 H CS 00 H
Arithmetic Instructions . . .
Instruction : DCR R
Explanation : Decrement register content by 1
Byte : 1 Byte
Operation Performed : [R] ← [R] - 1
Addressing Mode : Register
Flags Affected : All except CS
T-States / Machine Cycles : 4 / 1 (Fetch, Mem Rd)
Example : DCR A
Before Execution After Execution
05 H 04 H
A A
Arithmetic Instructions . . .
Instruction : DCR M
Explanation : Decrement memory content by 1
Byte : 1 Byte
Operation Performed : [[H-L]] ← [[H-L]] - 1
Addressing Mode : Register Indirect
Flags Affected : All except CS
T-States / Machine Cycles : 10 / 3 (Fetch, Mem Rd, Mem Wr)
Example : DCR M
Before Execution After Execution
20 H C4 H 20C3 H 65 H 20 H C4 H 20C3 H 65 H
H L 20C4 H 05 H H L 20C4 H 04 H
20C5 H 32 H 20C5 H 32 H
CS 00 H CS 00 H
Arithmetic Instructions . . .
Instruction : INX RP
Explanation : Increment register pair
Byte : 1 Byte
Operation Performed : [RP] ←[RP] + 1
Addressing Mode : Register
Flags Affected : None
T-States / Machine Cycles : 6 / 1 (Fetch)
Example : INX H
Before Execution After Execution
20 H C4 H 20 H C5 H
H L H L
Arithmetic Instructions . . .
Instruction : DCX RP
Explanation : Decrement register pair
Byte : 1 Byte
Operation Performed : [RP] ←[RP] - 1
Addressing Mode : Register
Flags Affected : None
T-States / Machine Cycles : 6 / 1 (Fetch)
Example : DCX H
Before Execution After Execution
20 H C4 H 20 H C3 H
H L H L
Arithmetic Instructions . . .
Instruction : DAA
Explanation : Decimal adjust accumulator
Byte : 1 Byte
Operation Performed : [A](10) ← [A] (H)
Addressing Mode : Implicit
Flags Affected : All
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : DAA
Arithmetic Instructions . . .
Programming Examples
Place 05H in register B.
Address Mnemonics Hex Code Comment
2000, 2001 MVI B, 05H 06H, 05H Get 05H in Register B
2002 HLT 76H Stop
CS 0 CS 1
Logical Instructions …
Instruction : STC
Explanation : Set carry status
Byte : 1 Byte
Operation Performed : [CS] ← 1
Addressing Mode :
Flags Affected : Only Carry
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : STC
Before Execution After Execution
CS 0 CS 1
CS 1 CS 1
Arithmetic Instructions . . .
Instruction : CMP R
Explanation : Compare register with accumulator
Byte : 1 Byte
Operation Performed : [A] - [R]
Addressing Mode : Register
Flags Affected : All
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : CMP B
Before Execution After Execution
05 H 02 H 05 H 02 H
A B A B
Arithmetic Instructions . . .
Instruction : CMP M
Explanation : Compare memory with accumulator
Byte : 1 Byte
Operation Performed : [A] - [[H-L]]
Addressing Mode : Register Indirect
Flags Affected : All
T-States / Machine Cycles : 7 / 2 (Fetch, Mem Rd)
Example : CMP M
Before Execution After Execution
20 H C4 H 20C3 H 65 H 20 H C4 H 20C3 H 65 H
H L 20C4 H 05 H H L 20C4 H 05 H
20C5 H 32 H 20C5 H 32 H
A F5 H A F0 H
Arithmetic Instructions . . .
Instruction : CPI data(8)
Explanation : Compare immediate data with accumulator
Byte : 2 Byte
Operation Performed : [A] - data(8)
Addressing Mode : Immediate
Flags Affected : All
T-States / Machine Cycles : 7 / 2 (Fetch, Mem Rd)
Example : CPI 02H
Before Execution After Execution
05 H 02 H 05 H 02 H
A data A data
Logical Instructions . . .
Instruction : RLC
Explanation : Rotate accumulator left
Byte : 1 Byte
Operation Performed : [An+1] ←[An], [A0] ←[A7], [CS] ←[A7]
Addressing Mode : Implicit
Flags Affected : Only Carry
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : RLC
Before Execution After Execution
CS A7 A6 A5 A4 A3 A2 A1 A0 CS A7 A6 A5 A4 A3 A2 A1 A0
0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 0 1 1
Logical Instructions . . .
Instruction : RRC
Explanation : Rotate accumulator right
Byte : 1 Byte
Operation Performed : [An] ←[An+1], [A7] ←[A0], [CS] ←[A0],
Addressing Mode : Implicit
Flags Affected : Only Carry
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : RRC
Before Execution After Execution
CS A7 A6 A5 A4 A3 A2 A1 A0 CS A7 A6 A5 A4 A3 A2 A1 A0
0 1 0 1 1 1 0 0 1 1 1 1 0 1 1 1 0 0
Logical Instructions . . .
Instruction : RAL
Explanation : Rotate accumulator left through carry
Byte : 1 Byte
Operation Performed : [An+1] ←[An], [CS] ←[A7], [A0] ←[CS]
Addressing Mode : Implicit
Flags Affected : Only Carry
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : RAL
Before Execution After Execution
CS A7 A6 A5 A4 A3 A2 A1 A0 CS A7 A6 A5 A4 A3 A2 A1 A0
0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 0 1 0
Logical Instructions . . .
Instruction : RAR
Explanation : Rotate accumulator right through carry
Byte : 1 Byte
Operation Performed : [An] ←[An+1], [CS] ←[A0], [A7] ←[CS]
Addressing Mode : Implicit
Flags Affected : Only Carry
T-States / Machine Cycles : 4 / 1 (Fetch)
Example : RAR
Before Execution After Execution
CS A7 A6 A5 A4 A3 A2 A1 A0 CS A7 A6 A5 A4 A3 A2 A1 A0
0 1 0 1 1 1 0 0 1 1 0 1 0 1 1 1 0 0
Branch Control Instructions
• The instruction in this group changes the normal sequence of
the program
• There are two types of branch control instructions.
• Unconditional: It transfer the program to the specified
address (label) unconditionally (without checking any
condition).
• Conditional: It transfer the program to the specified address
(label) when a certain condition is satisfied.
Branch Control Instructions . . .
Instruction : JMP addr (label)
Explanation : Jump to the instruction specified by the addr (label)
Byte : 3 Byte
Operation Performed : [PC] ← addr (Label)
Addressing Mode : Immediate
Flags Affected : None
T-States / Machine Cycles : 10 / 3 (Fetch, Mem Rd, Mem Rd)
Example : JMP 2900H
F2 2097
42 2098
X 2099
Stack, I/O and Machine Instructions . . .
Instruction : PUSH PSW
Explanation : Push processor status word to stack
Byte : 1 Byte
Operation Performed : [[SP] - 1] ← [A], [[SP] - 2] ← [PSW], [SP] ← [SP] - 2
Addressing Mode : Register (source) / Register Indirect (destination)
Flags Affected : None A Flag
T-States / Machine Cycles : 12 / 3
12 80
Example : PUSH PSW
FFFB
FFFC
FFFD 80
FFFE 12
FFFF
Stack, I/O and Machine Instructions . . .
Instruction : POP RP
Explanation : Pop the content of stack to register pair
Byte : 1 Byte
Operation Performed : [RL] ← [[ SP ]], [RH] ← [[SP] + 1], [SP] ← [SP] + 2
Addressing Mode : Register Indirect (source) / Register (destination)
8085 Register
Flags Affected : None A F
B C
T-States / Machine Cycles : 10 / 3 D E
H 42 F2 L
Example : POP H SP 2099
MEMORY
F2 2097
42 2098
X 2099
Stack, I/O and Machine Instructions . . .
Instruction : POP PSW
Explanation : Pop content of stack to processor status word
Byte : 1 Byte
Operation Performed : [PSW] ← [[SP]], [A] ← [[SP] + 1], [SP] ← [SP] + 2
Addressing Mode : Register Indirect (source) / Register (destination)
Flags Affected : None A FLAG
T-States / Machine Cycles : 10 / 3 12 80
www.themeart.com
The PUSH Instruction
2000 LXI SP,2099H Load the stack pointer register with the addre
ss 2099.
2003 LXI H ,42F2H Loads data in the HL register pair.
www.themeart.com
PUSH H
⚫ The stack pointer is decremented by one to 2098 H
, and the contents of the h register are copied to
memory location 2098H. 8085 Register
F
A
⚫ The stack pointer register is again B C
D E
decremented by one to 2097H,and H 42 F2 L
SP 2097
the contents of the L register are
Memory
copied to memory location 2097H.
⚫ The contents of the register pair F2 2097
42 2098
HL are not destroyed ; however X 2099
www.themeart.com
PUSH PSW Register Pair
⚫ PUSH PSW (1 Byte Instruction) A Flag
➢ Decrement SP
➢ Copy the contents of 12 80
register A to the memory
location pointed to by SP
➢ Decrement SP
➢ Copy the contents of
Flag register to the memory FFFB
FFFC
location pointed to by SP
FFFD 80
FFFE 12
FFFF
www.themeart.com
Pop PSW Register Pair
⚫ POP PSW (1 Byte Instruction)
A FLAG
➢ Copy the contents of the memory location pointed to by the SP to Flag
12 80
register
➢ Increment SP
www.themeart.com
Subroutines
⚫ A subroutine is group of instruction written sepa
rately from the main program to perform a func
tion that occurs repeatedly in the main program
.
➢ When a main program calls a subroutine the pro
gram execution is transferred to the subroutine
after the completion of the subroutine ,the prog
ram execution returns to the main program.
➢ The microprocessor uses the stack to store the r
eturn address of the subroutine.
www.themeart.com
Subroutines
⚫ The 8085 has two instructions for dealing
with subroutines.
– The CALL instruction is used to redirect
program execution to the subroutine.
– The RET instruction is used to return to t
he main program at the end of the subro
utine .
www.themeart.com
The CALL instruction
⚫ CALL ,16 bit
➢ Call subroutine in conditionally located at
the memory address specified by the 16
bit operand.
➢ This instruction places the address of the
next instruction on the stack and transfer
the program execution to the subroutine
address.
www.themeart.com
The RET instruction
➢ Return unconditionally from the subrouti
ne.
➢ This instruction locates the return addre
ss on the top of the stack and transfers t
he program execution back to the calling
program.
www.themeart.com
General characteristics of CALL &
RTE instruction
1. The CALL instructions are 3-byte instruc
tion; the second byte specifies the low
order byte ,and the third byte specifies
the high order byte of the subroutine
address.
2. The return instruction are 1-byte instruc
tions.
3. A CALL instruction must be used in
conjunction with a return instruction in
the subroutine .
www.themeart.com
Necessary steps to implement a
subroutine