Microprocessor
Microprocessor
Microprocessor
8 bit Register
Intel 8085 has 5 flags
It is also a part of the ALU
Indicates the status of the ALU operation.
ALU includes 5 flip flop, which are set or reset after an operation according to
data conditions of the result in the accumulator. The output of these flip flops
are called flags
CY (Carry) The carry flag is used for carrying and borrowing in case of addition
and subtraction operations. CY is set when an arithmetic operation
generates a carry bit, otherwise it is 0 (reset) . i.e. if the result of an
operation is a number with more than 8 bits , the accumulator can
hold only 8 bits
P (Parity) P= 1; if the result of an ALU operation has an even number of 1’s in
A; P= 0; if number of 1 is odd.
AC (Auxiliary used only in BCD operations. Similar to CY, AC= 1 if there is a carry
carry) from D3 to D4 Bit, AC= 0 if there is a no carry from D3 to D4 Bit
(not available for the user)
Z(zero) The zero flag is set if the result of an ALU operation is zero, Z = 1; if
result in A is 00H otherwise it is reset Z=0
S(Sign) If the accumulator holds a negative number after an operation, then
sign flag is set, S=1 if D7 bit of the A is 1(indicate the result is -ve)
S= 0 if D7 bit of the A is 0(indicate the result is +ve)
These flags have critical importance in the decision making process of the μp. The conditions
(set or reset) of the flags are tested through program instructions.
• Temporary Register [ W, Z, Temporary data register]
• This group of instructions copies (transfers) data from a location called source
to another location called destination.
• This operation is only a copying operation and hence data is not lost from the
source location after the operation (i.e. after the operation data is available both
at the source and destination locations)
• The various types of data transfer are :
Types Examples
Between registers Copy the contents of
register B to register D
Specific data byte to a Load 28 H into register C
register or memory location
Between a memory location Load the byte in memory
and a register location 2005 H to register
D
Between an I/O device and From an input keyboard to
the accumulator the accumulator
Data Transfer Instructions
• These instructions move data between registers, or between memory and
registers.
• These instructions copy data from source to destination.
• While copying, the contents of source are not modified.
Direct
LHLD 16 bit address of Load H and L register direct
memory location
OUT 8 bit port address Out data from accumulator to
an external port
2. Arithmetic operations
These instructions perform arithmetic operations such as addition, subtraction,
increment and decrement
• Addition
One of the operands is stored in the accumulator
The contents of a register or the contents of the memory location can be
added to the contents of the accumulator and the sum is stored in the
accumulator.
No two registers can be added directly (E.g.., B and C).
The instruction DAD is an exception; it adds 16 bit data directly in the
register pairs.
• Subtraction
Subtraction is performed through 2’s complement method.
For this, the minuend is to be stored in the accumulator. From this number,
any 8 bit number or the contents of a register or the contents of a memory
location can be subtracted and the result is stored in the accumulator
The contents of any two registers cannot be subtracted directly
• Increment/Decrement
The 8 bit contents of the accumulator or any register or a memory location
can be incremented or decremented by 1.
Similarly, the 16 bit contents of register pair (such as BC) can be
incremented or decremented by 1
These operations differ from addition and subtraction- for addition and
subtraction, the accumulator is to be involved. But increment/decrement
operation can be done without the help of the accumulator
Arithmetic Instructions
These instructions perform arithmetic operations such as addition, subtraction,
increment, and decrement.
SBI 8 bit data Subtract immediate with
borrow
3. Logical Operations
These instructions perform various logical operations with the contents of the
accumulator
• AND, OR, X-OR
Any 8 bit number or the contents of a register or the contents of a memory
location are logically ANDed, ORed or X-ORed with the contents of the
accumulator and the result is stored in the accumulator
• Rotate - Each bit in the accumulator can be shifted to left or right
• Compare- Any 8 bit number or the contents of a register or the contents of a
memory location can be checked (compared) with the contents of the
accumulator
• Complement-The contents of the accumulator can be complemented, i,.e, all 0’s
can be replaced by 1’s and vice versa
Logical Instructions
These instructions perform various logical operations with the contents of
the accumulator.
CMA No operand Complement accumulator
CMC No operand Complement carry
4. Branching Operations
This group of instructions alter the sequence of program execution either
conditionally or unconditionally
• Jump
There are conditional jumps and unconditional jumps
Conditional jumps plays critical role in decision making process in
programming. They test for a certain condition (flag status: whether zero or
carry flag is set or reset) and if the condition is met, it alters the program
sequence as specified.
The unconditional jump instruction simply alters the sequence without
having to check for a condition
• Call, Return, and Restart
These instructions change the sequence of a program either by calling a
subroutine or returning from a subroutine.
Restart instruction is to begin execution right from the beginning
Branching Instructions
This group of instructions alters the sequence of program execution either
conditionally or unconditionally.
C 48 49 4A 4B 4C 4D 4E 4F
D 50 51 52 53 54 55 56 57
E 58 59 5A 5B 5C 5D 5E 5F
H 60 61 62 63 64 65 66 67
L 68 69 6A 6B 6C 6D 6E 6F
M 70 71 72 73 74 75 76 77
A 78 79 7A 7B 7C 7D 7E 7F
22 MVI Reg,
Data
MVI M, Data
MVI B 06 H 2
MVI C 0E H 2
MVI D 16 H 2
MVI E 1E H 2
MVI H 26 H 2
MVI L 2E H 2
MVI M 36 H 2
MVI A 3E H 2
23 STA 32 H 3
24 STAX B/D
reg pair
STAX B 02 H 1
STAX D 12 H 1
25 STC 37 H 1
26 SUB B 90 H 1
SUB C 91 H 1
SUB D 92 H 1
SUB E 93 H 1
SUB H 94 H 1
SUB L 95 H 1
SUB M 96 H 1
SUB A 97 H 1
27 SUI D6 H 2
28 OUT 8 bit
port address
OUT D3 H 2
How to recognize the number of bytes in an instruction
1. A mnemonic followed by one or 2 letters that designate the registers (A, B, C, D,
E, H, L, SP) is an one-byte instruction
Eg. ADD C ,
MOV B,D, etc.
Instructions in which the registers are implicit are also one-byte instructions
Let the two decimal numbers be 05 and 10 and store the result in memory location 9000 H
Let the two decimal numbers be 05 and 10 and store the result in memory location 9000 H