Professional Documents
Culture Documents
The instruction set is the collection of all groups of instructions. Each instruction
has two parts:
The first part is the task to be performed. This is known as operation code (opcode).
The second part is data to be operated on, called operands.
Generally, instructions are stored in the memory devices. Before execution of any
instruction, the microprocessor locates the memory location and fetches the
operational code through a data bus. Then the decoder decodes the instruction and
performs the specified function.
Instruction Set and Addressing Modes
Generally, the following addressing modes are used in the 8085 microprocessor :
1. Immediate addressing
2. Register addressing
3. Direct addressing
4. Indirect addressing
Instruction Set and Addressing Modes
Direct Addressing
In this addressing mode, the address of the operand always exists within the
instruction.
This mode can be used to read data from output devices and store it in the
accumulator or write the data, content of the accumulator to the output devices.
In the instruction IN 00H, the address of an I/O port is 00H where the data is
available. From this location, data is to be read and stored in the accumulator.
Similarly, the content of the accumulator can be sent to the output port address 01H
using OUT 01H instruction.
Instruction Set and Addressing Modes
Register Addressing
In the register addressing mode, one of the registers A, B, C, D, E, H and L can be
used as source of operands. Consequently, data is provided through the registers.
For example, the instruction MOV A, M means that move the contents of the
content of the memory location whose address is stored in H and L register pair, in
the accumulator.
The instruction LDAX B is also another example. In this instruction, load the
accumulator with the byte of data that is specified by the address in the B and C
register pair.
Instruction Set and Addressing Modes
Immediate Addressing
In the immediate addressing mode, the operand or data is present within the
instruction. Load the immediate data to the destination, which is given in the
instruction.
The immediate instructions use the accumulator as an implied operand. The MVI
(move immediate) instruction can move its immediate data to any of the working
registers. For example, the instruction MVI D, FFH moves the hexadecimal data
FFH to the D register.
The LXI instruction (load register pair immediate) uses 16-bit immediate data. This
instruction is generally used to load addresses into a register pair.
Instruction Set and Addressing Modes
Implicit Addressing
The addressing mode of certain instructions can be implied by the instruction’s
function. Actually, these instructions work on the content of the accumulator and
there is no need of the address of the operand.
Instruction Set
An instruction is a command applied to the microprocessor to perform a specific
function.
The instruction set of a microprocessor means the entire group of instructions.
Generally, instructions have been classified into the following five functional
groups.
Data transfer group
Arithmetic group
Logical group
Branch control group
I/O and machine control group
Data-Transfer Group
Instruction Set
Data transfer group
The data-transfer instructions copy data from a source to a destination without
modifying the contents of the source.
The term data transfer has been used for copying data.
The data transfer can be possible between registers or between memories or
between memory and registers or between I/O ports and the accumulator.
Instruction Set
Data transfer group
Examples
MOV Move
MVI Move immediate
LDA Load accumulator directly from memory
STA Store accumulator directly in memory
LHLD Load H and L registers directly from memory
SHLD Store H and L registers directly in memory
An ‘X’ in the name of a data-transfer instruction means that the data transfer
operation is performed with a register pair.
LXI Load register pair with 16-bit immediate data
LDAX Load accumulator from memory whose address is in a register pair
STAX Store the content of the accumulator in memory whose address is in the
register pair
XCHG Exchange H and L with D and E
XTHL Exchange top of stack with H and L
Instruction Set
Arithmetic Group
The arithmetic instructions perform arithmetic operations such as addition,
subtraction, increment, and decrement data in registers or memory.
Addition: The contents of a register or the contents of a memory location or any 8-
bit number can be added to the contents of the accumulator. After addition, the sum
is stored in the accumulator.
Subtraction: An 8-bit number or the contents of a register or the contents of a
memory location can be subtracted from the contents of the accumulator. After
subtraction, the result will be stored in the accumulator.
Increment / Decrement:
The content of a register or a memory location, 8-bit data can be incremented or
decremented by 1.
In the same way, the contents of a register pair H-L or B-C or D-E (16-bit data) can
be incremented or decremented by 1.
The increment and decrement operations can also be performed in a memory
location.
Instruction Set
Arithmetic Group
Examples
ADD Add to accumulator
ADI Add immediate 8-bit data to accumulator
ADC Add to accumulator using carry flag
ACI Add immediate data to accumulator with carry
SUB Subtract from accumulator
SUI Subtract immediate data from accumulator
SBB Subtract from accumulator with borrow (carry) flag
SBI Subtract immediate from accumulator with borrow (carry) flag
INR Increment specified 8-bit data or byte by one
DCR Decrement specified 8-bit data or byte by one
INX Increment register pair by one
DCX Decrement register pair by one
DAD Double register addition: Add content of register pair to H-L register pair
Instruction Set
Logical Group
This group of instructions performs various logical operations such as AND, OR,
Exclusive-OR, Rotate, Compare, and Complement with the contents of the
accumulator.
Rotate: Each bit of the accumulator can be shifted either left or right by one bit.
Jump: Jump instructions are generally conditional jump and unconditional jump
types. Conditional jump instructions always test certain conditions such as Zero or
Carry flag and then change the program execution sequence once the condition
arises. On the other hand, when conditions are not used in the instruction set, the
instruction is called unconditional jump.
Call and Return, and Restart :These instructions can also change the sequence of
a program execution by calling a subroutine or returning from a subroutine. Like
Jump instructions, Call instructions are conditional call and unconditional call.
Conditional call instructions test all condition flags.
The unconditional branch control instructions are as follows:
JMP Jump
CALL Call
RET Return
Instruction Set
Stack I/O and Machine Control Group
These instructions can perform various functions related to stack and input/output
ports and machine control.
The following instructions are related with the Stack and/or Stack Pointer:
PUSH Push two bytes of data onto the stack
POP Pop two Bytes of data off the stack
XTHL Exchange top of stack with H and L
SPHL Move content of H and L to stack pointer
In the first instruction, MOV B, A both operand registers are specified in A and B
registers.
In the second instruction ADD C, one operand is specified in the C register and the
other operand is in the accumulator, which is assumed.
These instructions are one-byte long and each instruction requires only one memory
location.
Instruction and Data Formats
Two-byte or 2-word instructions
In a two-byte instruction, the first byte specifies the operation code and the second
byte states the operand.
The source operand is an 8-bit data immediately subsequently the opcode
The above instructions are 2-byte instructions. This instruction would require two
consecutive memory locations to store in memory.
Instruction and Data Formats
Three-byte or 3-word instructions
In a three-byte instruction, the first byte specifies the operation code (opcode), and
the following two bytes stand for the 16-bit address.
It may be noted that the second byte will be the lower-order address and the third
byte will be the higher-order address.
These instructions are three-byte instructions which consist of one opcode and two
data bytes.
Instruction and Data Formats
Opcode Format
Instruction and Data Formats
Opcode Format
Instruction and Data Formats
Data Format
Instruction and Data Formats
Data Format
Assembly Language Programming
A Program is a set of instructions arranged in the specific sequence to do the
specific task.
The process of writing the set of instructions which tells the microprocessor what to
do is called programming.
In other words, we can say that programming is the process of telling the processor
exactly how to solve a problem.
3
Arithmetic Operations
Flags Concepts and Cautions
1
Arithmetic Operations
Flags Concepts and Cautions
Arithmetic Operations
Flags Concepts and Cautions
Arithmetic Operations
Flags Concepts and Cautions
Arithmetic Operations
Flags Concepts and Cautions
Arithmetic Operations
Flags Concepts and Cautions
Arithmetic Operations
Subtraction
The 8085 performs subtraction by using 2’s complement
Arithmetic Operations
10s complement method
Arithmetic Operations
10s complement method
Arithmetic Operations
10s complement method
Arithmetic Operations
Arithmetic Operations
Arithmetic Operations
Arithmetic Operations
Arithmetic Operations
Arithmetic Operations
Logic Operations
Logic Operations
Logic Operations
Logic AND
Simple AND gate has two inputs and one output, while the instruction ANA
simulates eight AND gates .
An interrupt is a process where an external device can get the attention of the
microprocessor.
The microprocessor can scan
the interrupt pin on every
machine cycle.
When the interrupt signal is
present, microprocessor
suspends its present operation
after storing the current status
in the microprocessor so that
the microprocessor can restart
the suspended work again
from where it left.
Interrupts of 8085 Microprocessor
An interrupt is considered to be an emergency signal which may be serviced. The
microprocessor may respond to it as soon as possible.
When the microprocessor receives an interrupt signal, it suspends the currently
executing program and jumps to an Interrupt Service Routine (ISR) to respond to the
incoming interrupt. Each interrupt will most probably have its own ISR
Interrupts of 8085 Microprocessor
Responding to an interrupt may be immediate or delayed depending on whether the
interrupt is maskable or nonmaskable and whether interrupts are being masked or
not.
There are two different ways of redirecting the execution to the ISR depending on
whether the interrupt is vectored or nonvectored.
In a vectored interrupt, the address of the subroutine is already known to the
microprocessor.
In case of a nonvectored interrupt, the I/O devices will have to supply the address of
the subroutine to the microprocessor.
Interrupts of 8085 Microprocessor
Classification of Interrupts
Interrupts can be classified into two types: maskable interrupts and nonmaskable
interrupts.
The maskable interrupts can be delayed or rejected but the nonmaskable interrupts
cannot be delayed or rejected.
Interrupts can also be classified into vectored and nonvectored interrupts. In vectored
interrupts, the address of the service routine is hard-wired but in nonvectored
interrupts, the address of the service routine needs to be supplied externally by the
device
Interrupts of 8085 Microprocessor
When a device interrupts, it actually wants the microprocessor to give a service,
which is equivalent to asking the microprocessor to call a subroutine.
This subroutine is known as Interrupt Service Routine (ISR).
– The microprocessor checks the INTR line one clock cycle before the last T-state of
each instruction.
– The interrupt process is Asynchronous.
– The INTR must remain active long enough to allow for the longest instruction.
– The longest instruction for the 8085 is the conditional CALL instruction which
requires 18 T-states.
TRAP is the only non-maskable interrupt.It does not need to be enabled because it
cannot be disabled.
However, TRAP has lower priority than the HLD signal used for DMA.
Interrupts of 8085 Microprocessor
Interrupts of 8085 Microprocessor
Internal Interrupt Priority
However, TRAP has lower priority than the HLD signal used for DMA.
Stack
LIFO
The order of PUSHs and POPs must be opposite of each other in order to retrieve
information back into its original location.
PUSH B
PUSH D
...
POP D
POP B
Stack
The PSW Register Pair
• The 8085 recognizes one additional register pair called the PSW (Program Status
Word).
– This register pair is made up of the Accumulator and the Flags registers.
•It is possible to push the PSW onto the stack, do whatever operations are needed,
then POP it off of the stack.
– The result is that the contents of the Accumulator and the status of the Flags are
returned to what they were before the operations were executed.
Subroutine
Some operations/functions are repeatedly performed in a main program like
multiplication, division, and time delay between two operations, etc.,
Groups of instructions are written to perform these operations and these groups of
instructions are known as subroutines, which are called by the main program
whenever required.
The microprocessor uses the stack to store the return address of the subroutine.
For example, generally, subroutine are written for sine, cosine, logarithms, square
root, time delay, and multiplication functions in 8085 microprocessors.
InAssemblylanguage,asubroutinecanexistanywhereinthecode.
Subroutine
A subroutine is implemented with two associated instructions, namely, Call and
Return.
Call is used to call a subroutine and the Call instruction is written in the main
program.
Return is used to return from the subroutine and the Return instruction is written in
the subroutine to return to the main program.
When a subroutine is called, the contents of the program counter are stored on the
stack, and the program execution is transferred to the subroutine address.
When the Return instruction is executed at the end of the subroutine, the memory
address stored in the stack is retrieved and the sequence of execution is resumed in
the main program.
Subroutine
in previous example
Subroutine
Restart, Conditional Call and Return
Restart, Conditional Call and Return
Restart, Conditional Call and Return
Nesting
Nesting