Saturday, 5 May 2012

8085 Branch, Stack related and Machine control instructions


Branch operations:

unconditional branch
JMP 16-bit
This instruction causes PC to load with the 16-bit address specified in the instruction unconditionally. So the Processor jumps for executing from the address location specified in the instruction.

Conditional jump instructions:
This instructions jumps to the specified location in the instruction depending on the certain conditions indicated by flags. Except AC(auxiliary carry) remaining flags are used for decision making in these conditional branch instructions

1.JC 16-bit ; jump if carry(if CY=1)
2.JNC 16-bit ; jump if no carry(if CY=0)
3.JZ 16-bit ;jump if zero(if Z=1)
4.JNZ 16-bit ; jump if no zero(if Z=0)
5.JP 16-bit ; jump if positive(if S=0)
6.JM 16-bit ; jump if minus(if S=1)
7.JPE 16-bit ; jump on even parity(if P=1)
8.JPO 16-bit ; jump on odd parity(if P=0)



unconditional CALL instruction:
Subroutines can be implemented using CALL instruction. Subroutines are a way for code reuse. When it is required to perform certain operations more frequently then those operations can be written as a subroutine. Whenever those operations are required simply call the subroutine.
CALL 16-bit
This instruction causes processor to start executing from the specified location in the instruction. When this instruction is executed processor stores the PC content on the stack and decrements the stack pointer by 2. It loads PC with 16-bit address specified in the instruction.

Unconditional RET instruction:
This instruction is used to return from the subroutine. When this instruction is executed by the processor it copies the top of stack into PC and increments the stack pointer by 2.

Conditional CALL instruction:
This instruction calls the subroutine depending on the certain conditions indicated by flags.
CC – call subroutine if CY=1(Call if carry)
CNC – call subroutine if CY=0(call if no carry)
CZ – call subroutine if Z=1(call if zero)
CNZ – call subroutine if Z=0(call if no zero)
CM – call subroutine if S=1(call if minus)
CP – call subroutine if S=0(call if plus)
CPE – call subroutine if P=1(call if even parity)
CPO – call subroutine if P=0(call if odd parity)

Conditional RET instruction:
This instruction returns from the subroutine depending certain conditions indicated by flags.
RC – return if CY=1(Return on carry)
RNC – return if CY=0(return on no carry)
RZ – return if Z=0(return on zero)
RNZ - return if Z=1(return on no zero)
RM – return if S=1(return on minus)
RP – return if S=0(return on plus)
RPE – return if P=1(return on even parity)
RPO – return if P=0(return on odd parity)

Restart instructions:
RST n
These instructions are like software interrupts to 8085. When these instructions are executed processor vectors(jumps) to a specific location called restart location. The following list gives restart location for different RST instructions.
'n' value -- Vector location
RST 0 -- 0000H
RST 1 -- 0008H
RST 2 -- 0010H
RST 3 -- 0018H
RST 4 -- 0020H
RST 5 -- 0028H
RST 6 -- 0030H
RST 7 -- 0038H
To get the vector location 'n' value is multiplied by 8 and the result is converted to hexadecimal notation. For example RST 3 instruction, multiply 3*8=24. 24 in hexadecimal notation is 18H. So vector address is 0018H.

Stack related instructions:
PUSH instruction:
PUSH Rp
This instruction stores the content of register pair Rp(16-bit) into stack. Stack is Last in first out data structure.
Example:
PUSH B; push BC pair on to stack
PUSH D; push DE pair on to stack
PUSH H; push HL pair on to stack
PUSH PSW; push PSW(Accumulator+Flag register) on to stack
When this instruction is executed by the processor first it decrements SP by 1 and stores higher byte of the specified register pair, Then it again decrements SP by 1 and stores lower byte of the specified register pair. SP always points to top of stack.
8085 Maintains a stack which grows downwards .i.e. Higher address to lower address. And SP points to already stored location.

POP instruction:
POP Rp
This instruction is used to retrieve data from stack. i.e. Is 16-bit data from top of stack is stored in the specified register pair.
Example:
POP B; store data from top of stack in BC pair
POP D; store data from top of stack in DE pair
POP H; store data from top of stack in HL pair
POP PSW; store data from top of stack in Accumulator and Flag register
When this instruction is executed by the processor, it copies a byte from top of stack into lower byte of register pair and increments SP by 1, Then it again copies a byte from top of stack into higher byte of the register pair specified in the instruction and increments SP by 1.

Machine control instructions:
HLT instruction – Halt
When this instruction is executed by the processor it stops executing and enters into wait state. Address and data bus of the processor are kept in high impedance state.

NOP instruction – No operation
This instructions performs nothing except wasting processor time. This instruction is used for writing delays.

EI instruction- Enable interrupts
This instruction is used to enable the interrupts

DI instruction- disable interrupts
This instruction is used to disable the interrupts


Back                                             Contents                                               Next

No comments:

Post a Comment