Instruction Timing and Execution in 8085
Instruction Timing and Execution in 8085
Execution in 8085
8085 based system
• To make a complete system, the microprocessor
needs to be interfaced with the memories and
input and output devices.
• The memories required are of two types – RAM
and ROM.
• ROM is necessary to store some amount of fixed
programs.
• These programs are executed when the system is
powered on and are essential for the system.
8085 based system Contd..
• RAM is required in any system to store temporary
programs and data.
• A particular memory location is selected from the
memory by properly issuing the address for that
memory location and issuing the control signals
discussed in the previous section.
8085 based system contd..
• The microprocessor is the master in any
microcomputer system and the microprocessor
issues the required control signals to the
peripherals.
• Each location in a memory is given a number,
called an address. The maximum number of
locations that can be addressed will depend on the
number of bits in the address.
• In general, 2^n is the number of memory locations
addressed where n is the number of bits in the
address.
MICROPROCESSOR
INSTRUCTIONS
• Every microprocessor has its own instruction set.
• Based on the design of the ALU and the decoding unit, the
microprocessor manufacturers generally list out the
instruction set for the every microprocessor.
• The instruction set consists of both the assembly language
mnemonics and the corresponding machine code.
Format of Assembly
language programs contd..
3. T3: The active low RD~ signal enabled the byte instruction,
4FH, to be placed on AD7 – AD0 and transferred to the
MPU. While RD~ high, the data bus will be in high
impedance mode. 4FH will then be placed in the
instruction register and then sent to decoder circuit.
• Instruction:
• 2000H MVI B, 43H
• Corresponding Coding:
• (Machine code is 06, and data is 43)
• Memory Location M/C code
• 2000H 06H
• 2001H 43H
MVI B, 43
• Timing diagram for STA 526AH.
(3 byte instruction)
46
The Stack
• Given that the stack grows backwards into memory, it is
customary to place the bottom of the stack at the end of
memory to keep it as far away from user programs as
possible.
• In the 8085, the stack is defined by setting the SP (Stack
Pointer) register.
47
Saving Information on the Stack
49
The POP Instruction
• POP D
• Copy the contents of the memory location pointed to by the
SP to register E
• Increment SP
• Copy the contents of the memory location pointed to by the
SP to register D
• Increment SP
D E
12 F3
FFFB
FFFC
FFFD F3 SP
FFFE 12
FFFF
50
Operation of the Stack
• During pushing, the stack operates in a “decrement then
store” style.
• The stack pointer is decremented first, then the
information is placed on the stack.
PUSH B
PUSH D
...
POP D
POP B
• Reversing the order of the POP instructions will result in the exchange of
the contents of BC and DE.
52
Subroutines
• A subroutine is a group of instructions that will be used
repeatedly in different locations of the program.
• Rather than repeat the same instructions several
times, they can be grouped into a subroutine that is
called from the different locations.
54
Subroutines
• The 8085 has two instructions for dealing with
subroutines.
• The CALL instruction is used to redirect program
execution to the subroutine.
• The RET instruction is used to return the
execution to the calling routine.
55
The CALL Instruction
• CALL 4000H
• Push the address of the instruction immediately
following the CALL onto the stack
• Load the program counter with the 16-bit address
supplied with the CALL instruction.
56
The CALL Instruction
PC 2003
FFFB
4014 ... FFFC
4015 RET FFFD 03 SP
FFFE 20
FFFF
58