Microprocessor
Program counter and Stack pointer
• Program Counter :
• Program Counter holds the address value of the
memory to the next instruction that is to be
executed. It is a 16-bit register.
• For Example: Suppose current value of Program
Counter : [PC] = 4000H
• (It means that next executing instruction is at
location [Link] fetching,program Counter(PC)
always increments
• by +1 for fetching of next instruction.)
Stack pointer
• Stack Pointer :
• It works like a stack. In stack, the content of the register is
stored that is later used in the program. It is a 16-bit
special register. The stack pointer is part of memory but it
is part of Stack operations, unlike random memory access.
Stack pointer works in a continuous and contiguous part
of the memory. whereas Program Counter(PC) works in
random memory locations. This pointer is very useful in
stack-related operations like PUSH, POP, and nested CALL
requests initiated by Microprocessor. It reserves the
address of the most recent stack entry.
Status of Flags In MP
• Sign Flag (S) – After any operation if the MSB (B(7)) of the result is 1, it
indicates the number is negative and the sign flag becomes set, i.e. 1. If
the MSB is 0, it indicates the number is positive and the sign flag becomes
reset i.e. 0. from 00H to 7F, sign flag is 0 from 80H to FF, sign flag is 1 1-
MSB is 1 (negative) 0- MSB is 0 (positive) Example: MVI A 30 (load 30H in
register A) MVI B 40 (load 40H in register B) SUB B (A = A – B) These set of
instructions will set the sign flag to 1 as 30 – 40 is a negative number. MVI
A 40 (load 40H in register A) MVI B 30 (load 30H in register B) SUB B (A = A
– B) These set of instructions will reset the sign flag to 0 as 40 – 30 is a
positive number.
• Zero Flag (Z) – After any arithmetical or logical operation if the result is 0
(00)H, the zero flag becomes set i.e. 1, otherwise it becomes reset i.e. 0.
00H zero flags is 1. from 01H to FFH zero flag is 0 1- zero-result 0- non-zero
result Example: MVI A 10 (load 10H in register A) SUB A (A = A – A) These
set of instructions will set the zero flag to 1 as 10H – 10H is 00H
Status of Flags In MP
• Auxiliary Carry Flag (AC) – This flag is used in the BCD number system(0-9). If
after any arithmetic or logical operation D(3) generates any carry and passes it
on to D(4) this flag becomes set i.e. 1, otherwise, it becomes reset i.e. 0. This is
the only flag register that is not accessible by the programmer 1-carry out from
bit 3 on addition or borrows into bit 3 on subtraction 0-otherwise Example: MVI
A 2BH (load 2BH in register A) MVI 39H (load 39H in register B) ADD B (A = A +
B) These set of instructions will set the auxiliary carry flag to 1, as on adding 2B
and 39, the addition of lower-order nibbles B and 9 will generate a carry.
• Parity Flag (P) – If after any arithmetic or logical operation the result has even
parity, an even number of 1 bit, the parity register becomes set i.e. 1, otherwise
it becomes reset i.e. 0. 1-accumulator has an even number of 1 bits 0-
accumulator has odd parity Example: MVI A 05 (load 05H in register A) This
instruction will set the parity flag to 1 as the BCD code of 05H is 00000101,
which contains an even number of ones i.e. 2.
Status of Flags In MP
• Carry Flag (CY) – Carry is generated when performing n bit
operations and the result is more than n bits, then this flag
becomes set i.e. 1, otherwise, it becomes reset i.e. 0. During
subtraction (A-B), if A>B it becomes reset, and if (A<B) it becomes
set. Carry flag is also called the borrow flag. 1-carry out from MSB
bit on addition or borrow into MSB bit on subtraction 0-no carry
out or borrow into MSB bit.
• Example: MVI A 30 (load 30H in register A) MVI B 40 (load 40H in
register B) SUB B (A = A – B) These set of instructions will set the
carry flag to 1 as 30 – 40 generates a carry/borrow. MVI A 40 (load
40H in register A) MVI B 30 (load 30H in register B) SUB B (A = A –
B) These set of instructions will reset the sign flag to 0 as 40 – 30
does not generate any carry/borrow.
• A 15H and B = BEh, then find A+B=?
And also find the flags.
Opcodes of Register Pair
What does Mov and MVI mean and where to
apply move and move immediate ?
Instruction cycle in 8085 microprocessor
• Time required to execute and fetch an entire instruction is
called instruction cycle. It consists:
• Fetch cycle – The next instruction is fetched by the address stored
in program counter (PC) and then stored in the instruction register.
• Decode instruction – Decoder interprets the encoded instruction
from instruction register.
• Reading effective address – The address given in instruction is
read from main memory and required data is fetched. The
effective address depends on direct addressing mode or indirect
addressing mode.
• Execution cycle – consists memory read (MR), memory write
(MW), input output read (IOR) and input output write (IOW)
Timing Diagram of 8085
• The time required by the microprocessor to
complete an operation of accessing memory or
input/output devices is called machine cycle.
• One time period of frequency of microprocessor is
called t-state.
• A t-state is measured from the falling edge of one
clock pulse to the falling edge of the next clock
pulse.
Fetch cycle takes four t-states and execution cycle
takes three t-states.
Instruction Cycle and Timing Diagram
Instruction Cycle and Timing Diagram
• 05 – lower bit of address where opcode is stored. Multiplexed
address and data bus AD0-AD7 are used.
• 20 – higher bit of address where opcode is stored. Multiplexed
address and data bus AD8-AD15 are used.
• ALE – Provides signal for multiplexed address and data bus. If
signal is high or 1, multiplexed address and data bus will be
used as address bus.
• To fetch lower bit of address, signal is 1 so that multiplexed bus
can act as address bus.
• If signal is low or 0, multiplexed bus will be used as data bus.
When lower bit of address is fetched then it will act as data bus
as the signal is low
Instruction Cycle and Timing Diagram
• RD (low active) – If signal is high or 1, no data is
read by microprocessor. If signal is low or 0, data is
read by microprocessor.
• WR (low active) – If signal is high or 1, no data is
written by microprocessor. If signal is low or 0, data
is written by microprocessor.
• IO/M (low active) and S1, S0 – If signal is high or 1,
operation is performing on input output. If signal is
low or 0, operation is performing on memory.
Status of symbols in timing diagram
Machine cycle and T states
THANK YOU