Unit-3-8085 ALP
Unit-3-8085 ALP
1. One-byte instructions –
In 1-byte instruction, the opcode and the operand of an instruction are represented in one byte.
Example-1: Task- Copy the contents of accumulator in register B.
Mnemonic- MOV B, A
Opcode- MOV
Operand- B, A
Hex Code- 47H
Binary code- 0100 0111
Note – The length of these instructions is 8-bit; each requires one memory location. The mnemonic
is always followed by a letter (or two letters) representing the registers (such as A, B, C, D, E, H, L
and SP).
2. Two-byte instructions –
Two-byte instruction is the type of instruction in which the first 8 bits indicates the opcode and
the next 8 bits indicates the operand.
Example-1: Task- Load the hexadecimal data 32H in the accumulator.
Mnemonic- MVI A, 32H
Opcode- MVI
Operand- A, 32H
Hex Code- 3E
32
Binary code- 0011 1110
0011 0010
Note – This type of instructions need two bytes to store the binary codes. The mnemonic is always
followed by 8-bit (byte) data.
3. Three-byte instructions –
Three-byte instruction is the type of instruction in which the first 8 bits indicates the opcode
and the next two bytes specify the 16-bit address. The low-order address is represented in
second byte and the high-order address is represented in the third byte.
Example-1: Task- Load contents of memory 2050H in the accumulator.
Mnemonic- LDA 2050H
Opcode- LDA
Operand- 2050H
Hex Code- 3A
50
20
Binary code- 0011 1010
101 0
10 0
(2) Explain the addressing mode of 8085. OR What do you mean by addressing mode? Explain
diff. addressing mode for 8085 with examples.
Ans. The 8085 microprocessor has several addressing modes that are used to access memory
locations. Some of the most commonly used addressing modes in the 8085 microprocessor are:
(3)Explain the classification of instructions of 8085 on the basis of their operation OR Give
classification of 8085 instruction set with an example.
Ans. 8085 microprocessor has following types of instructions
Data Transfer Instructions
Arithmetic Instructions
Logical Instructions
Branching & Looping Instructions
Stack Instructions
I/O Instructions
Machine Control 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.
Ex: i) MOV A, B ii) LDA 4600 iii) LHLD 4200
These instructions perform the operations like: Addition, Subtract, Increment, and Decrement.
Addition:-Any 8-bit number, or the contents of register, or the contents of memory location can
be added to the contents of accumulator. The result (sum) is stored in the accumulator. No two
other 8-bit registers can be added directly. Example: The contents of register B cannot be added
directly to the contents of register C.
For example, ADD B
Subtraction: - Any 8-bit number, or the contents of register, or the contents of memory location
can be subtracted from the contents of accumulator. The result is stored in the accumulator.
Subtraction is performed in 2’s complement form. If the result is negative, it is stored in 2’s
complement form. No two other 8-bit registers can be subtracted directly. For example, SUB C
Increment and Decrement: - The 8-bit contents of a register or a memory location can be
incremented or decremented by 1.The 16-bit contents of a register pair can be incremented or
decremented by 1.Increment or decrement can be performed on any register or a memory
location. Ex: i) INR D ii) INX H
These instructions perform logical operations on data stored in registers, memory and status flags.
The logical operations are: AND, OR, XOR, Rotate, Compare, and Complement
For example, i) ORA B ii) XRA A iii) RAR
The branching instruction changes the normal sequential flow of the Program. These instructions
alter either unconditionally or conditionally.
For example, i) JZ 4200 ii) RST 7 iii) CALL 4300
I/O instructions are used for reading or writing the input output port.
For example- IN 80H, OUT 90H
Load accumulator
OUT 8-bit port address The contents of the accumulator are copied
into the I/O port specified by the operand.
Example: OUT F8H
Input data to accumulator from a port with 8-bit address
Ans.
Logical instructions in 8085 microprocessor performs the logical operations like AND, OR,
EXCLUSIVE- OR, complement, compare and rotate. The flag conditions are altered after
execution of an instruction in this group.
Explanation of
Opcode Operand Description
Instruction
Set Carry
STC none Set Carry
Example: STC
(7) Explain Rotate instruction with example.
Ans.
ROTATE Instruction: There are 4 categories of the ROTATE instruction: Rotate accumulator left
(RLC), Rotate accumulator left through carrying (RAL), Rotate accumulator right (RRC), Rotate
accumulator right through carry (RAR). Among these four instructions; two are for rotating left and
two are for rotating right. All of them are explained briefly in the following sections:
1. Rotate accumulator left (RLC) – In this instruction, each bit is shifted to the adjacent left
position. Bit D7 becomes D0. Carry flag CY is modified according to the bit D7.
For example:-
A = D7 D6 D5 D4 D3 D2 D1 D0
//before the instruction
A = 10101010; CY=0
//after 1st RLC
A = 01010101; CY=1
//after 2nd RLC
A = 10101010; CY=0
2. Rotate accumulator left through carry (RAL) – In this instruction, each bit is shifted to the
adjacent left position. Bit D7 becomes the carry bit and the carry bit is shifted into D0. Carry
flag CY is modified according to the bit D7.
For example:
A = D7 D6 D5 D4 D3 D2 D1 D0
//before the instruction
A = 10101010; CY=0
//after 1st RAL
A = 01010100; CY=1
//after 2nd RAL
A = 10101001; CY=0
3. Rotate accumulator right (RRC) – In this instruction, each bit is shifted to the adjacent right
position. Bit D7 becomes D0. Carry flag CY is modified according to the bit D0.
For example:
A = D7 D6 D5 D4 D3 D2 D1 D0
//before the instruction
A = 10000001; CY=0
//after 1st RRC
A = 11000000; CY=1
//after 2nd RRC
A = 01100000; CY=0
4. Rotate accumulator right through carry (RAR) – In this instruction, each bit is shifted to the
adjacent right position. Bit D0 becomes the carry bit and the carry bit is shifted into D7. Carry
flag CY is modified according to the bit D0.
For example:
A = D7 D6 D5 D4 D3 D2 D1 D0
//before the instruction
A = 10000001; CY=0
//after 1st RAR
A = 01000000; CY=1
//after 2nd RAR
A = 10100000; CY=0
Applications of ROTATE Instructions: The ROTATE instructions are primarily used in
arithmetic multiply and divide operations and for serial data transfer. For example:
If A is 0000 1000 = 08H
1. By rotating 08H right : A = 0000 0100 = 04H
This is equivalent to dividing by 2.
1. Jump Instructions – The jump instruction transfers the program sequence to the memory
address given in the operand based on the specified flag. Jump instructions are 2 types:
Unconditional Jump Instructions and Conditional Jump Instructions.
(a) Unconditional Jump Instructions: Transfers the program sequence to the described memory
address.
(b) Conditional Jump Instructions: Transfers the program sequence to the described memory
address only if the condition in satisfied.
3. Call Instructions – The call instruction transfers the program sequence to the memory address
given in the operand. Before transferring, the address of the next instruction after CALL is
pushed onto the stack. Call instructions are 2 types: Unconditional Call Instructions and
Conditional Call Instructions.
(a) Unconditional Call Instructions: It transfers the program sequence to the memory address
given in the operand.
(b) Conditional Call Instructions: Only if the condition is satisfied, the instructions executes.
3. Return Instructions – The return instruction transfers the program sequence from the
subroutine to the calling program. Return instructions are 2 types: Unconditional Jump Instructions
and Conditional Jump Instructions.
(a) Unconditional Return Instruction: The program sequence is transferred unconditionally from
the subroutine to the calling program.
(b) Conditional Return Instruction: The program sequence is transferred unconditionally from
the subroutine to the calling program only is the condition is satisfied.
(10) What is stack? Explain stack related instruction with example OR Give function of
stack. OR What is stack? Explain the stack operations using examples.
Ans.
The stack is a group of memory location in the R/W memory (RAM) that is used for temporary
storage of data during the execution of a program.
Address of the stack is stored into the stack pointer register.
The 8085 provide two instructions PUSH & POP for storing information on the stack and
reading it back.
a. Data in the register pairs stored on the stack by using the instruction PUSH.
b. Data is read from the stack by using the instruction POP.
c. PUSH & POP both instruction works with register pairs only.
d. The storage and retrieval of the content of registers on the stack fallows the LIFO(Last- In-First-
Out) sequence
For PUSH H
The stack pointer is decremented by one to 2098H, and the contents of the h register are copied to
memory location 2098H.The stack pointer register is again decremented by one to 2097H,and the
contents of the L register are copied to memory location 2097H.The contents of the register pair HL
are not destroyed.
For POP H
The contents of the top of the stack location shown by the stack pointer are copied in the L register
and the stack pointer register is incremented by one to 2098 H. The contents of the top of the stack
(now it is 2098H) are copied in the H register, and the stack pointer is incremented by one. The
contents of memory location 2097H and 2098 are not destroyed until some other data bytes are stored
in these location.
(11) Give Classification of 8085 Interrupts and its priorities.
Ans.
Interrupt: It means interrupting the normal execution of the microprocessor. When
microprocessor receives interrupt signal, it discontinues whatever it was executing.
It starts executing new program indicated by the interrupt signal.
Sequence of Steps Whenever There is an Interrupt
It pushes the content of PC (Program Counter) to stack.
Then loads the vector address in PC and starts executing the Interrupt Service Routine (ISR)
stored in this vector address.
At the end of ISR, a return instruction – IRET will be placed. When the IRET instructions
executed, the processors POP the content of stack to PC.
Hence the processor control returns to the main program after servicing the interrupt.
Five Hardware Interrupts in 8085
(1) TRAP
(2) RST 7.5
(3) RST 6.5
(4) RST 5.5
(5) INTR
Classification of Interrupts
(1) Maskable and Non-Maskable
(2) Vectored and Non-Vectored
(3) Edge Triggered and Level Triggered
(4) Priority Based Interrupts
Maskable Interrupts
Maskable interrupts are those interrupts which can be enabled or disabled. Enabling and
Disabling is done by software instructions. The interrupts can be masked by moving an
appropriate data to accumulator and then executing SIM instruction. (SIM - Set Interrupt
Mask).The status of maskable interrupts can be read into accumulator by executing RIM
instruction (RIM - Read Interrupt Mask).
List of Maskable Interrupts:
RST 7.5
RST 6.5
RST 5.5
INTR
-Maskable Interrupts
The interrupts which are always in enabled mode are called non maskable interrupts. These
interrupts can never be disabled by any software instruction.
TRAP is a non-maskable interrupt.
The interrupts which have fixed memory location for transfer of control from normal execution.
List of vectored interrupts:
RST 7.5
RST 6.5
RST 5.5
TRAP
The addresses to which program control goes:
-Vectored Interrupts
The interrupts which don't have fixed memory location for transfer of control from normal execution is
called Non-Vectored Interrupts. The address of the memory location is sent along with the interrupt.
INTR is a non-vectored interrupt.
The interrupts which are triggered at leading or trailing edge are called edge triggeredinterrupts.
RST 7.5 is an edge triggered interrupt. It is triggered during the leading (positive) edge.
The interrupts which are triggered at high or low level are called level triggered interrupts.RST 6.5
RST 5.5, INTR are level trigger. TRAP is edge and level triggeredinterrupt
Whenever there exists a simultaneous request at two or more pins then the pin with higher priority is
Selected by the microprocessor. Priority is considered only when there are simultaneous requests. Priority
of interrupts:
Interrupt Priority
1. Hardware and Software Interrupts – When microprocessors receive interrupt signals through
pins (hardware) of microprocessor, they are known as Hardware Interrupts.
There are 5 Hardware Interrupts in 8085 microprocessor. They are – INTR, RST 7.5, RST
6.5, RST 5.5, TRAP
Software Interrupts are those which are inserted in between the program which means these
are mnemonics of microprocessor.
There are 8 software interrupts in 8085 microprocessor. They are – RST 0, RST 1, RST 2, RST
3, RST 4, RST 5, RST 6, RST 7.
2. Vectored and Non-Vectored Interrupts – Vectored Interrupts are those which have fixed
vector address (starting address of sub-routine) and after executing these, program control is
transferred to that address.
Vector Addresses are calculated by the formula 8 * TYPE
INTERRUPT VECTOR ADDRESS
RST 5.5 2C H
RST 6.5 34 H
RST 7.5 3C H
RST 0 00 H
RST 1 08 H
RST 2 10 H
RST 3 18 H
RST 4 20 H
RST 5 28 H
RST 6 30 H
RST 7 38 H