Instruction Set Topic Notes Unit - 2
Instruction Set Topic Notes Unit - 2
Add the contents of the register B to the contents of the accumulator ADD B
The above instructions are 1-byte instructions performing three different tasks.
In the first instruction, both operand registers are specified.
In the second instruction, operand B is specified and the accumulator is assumed.
Similarly, in the third instruction, the accumulator is assumed to be the implicit
operand.
These instructions are stored in an 8-bit binary format in memory; each requires one
memory location.
The 2-byte or 2-word Instruction set of 8085
In a 2-byte instruction, the 1st-byte specifies the opcode and the 2nd-byte specifies the
operand.
MVI B, 05
IN 01 etc.
For 2-byte Instruction:
Task Opcode Operand Task
Load an 8-bit data byte in the accumulator MVI A, Data 1st byte, data 2nd byte
Assume the data byte is 32H. The assembly language instruction is written as:
Mnemonics: MVI A, 32H
This instruction would require two memory locations to store n memory.
The 3-byte or 3-word Instruction set of 8085
In a 3-byte instruction, the 1st byte specifies the opcode and the following two bytes
specify the 16-bit address such that the 2nd byte is a low-order address and the 3rd
byte is a high-order address.
LXI H, 2400H
LDA 2500H
JMP 2085H etc.
Transfer the program sequence to the memory C3 is 1st byte, 85 2nd byte, and
JMP 2085 H
location 2085H 20 3rd byte.
⇒RETURN Instruction:
It is used at the end of the subroutine to return to the main program.
When the RET instruction is executed at the end of the subroutine, the memory
address stored on the stack is retrieved, and the sequence of execution is resumed in
the main program.
Unconditional RET Instructions:
It will change the program sequence from the subroutine to the main program.
1-byte instruction
Implicit addressing mode
3 MC
10 T-states
No flags are affected.
Conditional RET Instructions:
In this case, the sequence of the program returns to the main program if the condition
is met and at this time it requires 3 MC and 12 T-States.
If the condition is not met then the sequence of the program is continued in the
subroutine and it requires 1-MC and 6 T-states.
In this instruction, all flags are used except the AC flag.
5. Stack, I/O, and Machine Control Group Instruction set of 8085
The stack in an 8085 microprocessor is a group of memory locations in the R/W memory
that is used for the temporary storage of binary information during the execution of the
program.
PUSH, POP, SPHL, and XHTL are examples of instructions for stack groups.
IN, and OUT are examples of I/O groups.
NOP, EI, D, SIM, RIM, and HLT are examples of machine control groups.
ADDRESSING MODES
Every instruction of a program has to operate on a data. The method of specifying the
data to be operated by the instruction is called Addressing. The 8085 supports the
following five
TYPES OF ADDRESSING MODES
There are 5 types of addressing modes -
➢Immediate Addressing Mode (IAM)
➢Direct Addressing Mode (DAM)
➢ Register Direct Addressing Mode (RDAM)
➢ Register Indirect Addressing Mode (RIAM)
➢ Implicit Addressing Mode (IPAM)
Immediate Addressing Mode
If 8/16 bit data required for executing the instruction is
directly given along with instruction then such type of
instructions are called Immediate Addressing Mode
instructions. In most of the Immediate Addressing Mode
Instruction, the last alphabet is ‘I’.
For Example:
MVI A,75H (for 8- bit number)
LXI B,4565H (for 16- bit number)
Direct Addressing Mode
If 8/16 bit data required for executing the instruction is present
in memory location and the address of that memory location is
given along with instruction then such type of instructions are
called Direct Addressing Mode instruction.
For Example:
LDA 1575H
Load accumulator from the given address data
STA 4565H
Store accumulator at given address
Register Direct Addressing Mode
If 8/16 bit data required for executing the instruction present in register(for
8-bit)/ register pair(for 16-bit) and the name of the register / register pair is
given along with instruction then such type of instructions are called
Register Direct Addressing Mode instruction.
➢ For Example –
MOV C, D
Move data from register D to Register C
Register Indirect Addressing Mode
➢If 8/16 bit data required for executing the instruction present in
memory location and the address of that memory location is
present in register pair and the name of that register pair is given
along with instruction then such type of instructions are called
Register Indirect Addressing mode instruction .
➢For Example :
LDAX B
Load accumulator from the register pair address data.
STAX D
Store accumulator at given register address
Implicit Addressing Mode
➢ If the address of source of data as well as the destination of result is
fixed, then there is no need to give the operand in the instruction
and such type of instructions are known as Implicit Addressing
Mode instruction.
➢For Example:
CMA complement accumulator
CMC complement Carry Flag
STC Set Carry Flag
RAL Rotate Accumulator Left with Carry
RLC Rotate Accumulator Left without Carry
Subroutine in 8085
A subroutine is a sequence of program instructions that perform a specific task,
packaged as a unit.
This unit can then be used in programs wherever that particular task have to be
performed.
A subroutine is often coded so that it can be started (called) several times and from
several places during one execution of the program, including from other subroutines,
and then branch back (return) to the next instruction after the call, once the
subroutine's task is done.
It is implemented by using Call and Return instructions.
The different types of subroutine instructions are
1.Unconditional Call instruction - CALL address is the format for unconditional call
instruction. After execution of this instruction program control is transferred to a sub-
routine whose starting address is specified in the instruction. Value of PC (Program
Counter) is transferred to the memory stack and value of SP (Stack Pointer) is
decremented by 2
2. Conditional Call instruction - In these instructions program control is transferred to
subroutine and value of PC is pushed into stack only if condition is satisfied.
INSTRUCTION COMMENT
Advantages of Subroutine -
1. Decomposing a complex programming task into simpler steps.
2. Reducing duplicate code within a program.
3. Enabling reuse of code across multiple programs.
4. Improving tractability or makes debugging of a program easy.
The 8085 microprocessor provides a set of instructions that can be used to manipulate the
stack. These instructions include:
1. PUSH: This instruction is used to push a register or memory location onto the stack.
The contents of the register or memory location are first copied to the memory
location pointed to by the stack pointer, and then the stack pointer is decremented.
2. POP: This instruction is used to pop the topmost item from the stack. The contents of
the memory location pointed to by the stack pointer are first copied to the register or
memory location specified in the instruction, and then the stack pointer is
incremented.