Sie sind auf Seite 1von 21

Interrupts

5/2/2014

What is an Interrupt ?
A hardware interrupt is a CPU facility which permits spurious asynchronous events to suspend program execution and instead execute a software module to service the event.
The connection to the processor which allows external devices to signal a request for service is called an interrupt pin. The software module that the processor executes in response to an interrupt is called an interrupt service routine ( ISR ). The interrupt mechanism is such that after completion of the ISR the processor returns to execution of the main program from the point at which it was interrupted.
5/2/2014 2

Interrupt Event Sequence

5/2/2014

Direct and Vectored Interrupts


With direct interrupts, the interrupting device need to provide the interrupt signal only. i.e. to assert the signal to the interrupt pin of the processor. With direct interrupts the address of the first instruction of the ISR for the particular interrupt is pre-programmed into the CPU. With vectored interrupts the interrupting device has to supply both the interrupt signal and the 16-bit address of the first instruction of the ISR. Interrupt service routines for vectored interrupts can reside anywhere in the memory map of the computer system.
5/2/2014 4

Maskable and Non-maskable Interrupts


A non-maskable interrupt will always, if asserted, interrupt the processor. There is no software mechanism to prevent the processor being interrupted by a non-maskable interrupt.

A maskable interrupt, if asserted, will only interrupt the processor if it is enabled ( unmasked ). Maskable interrupts can be enabled ( unmasked ) or disabled ( masked ) by software.
Most maskable interrupts automatically become disabled (masked) after an interrupt has occurred. It requires further software commands to re-enable maskable interrupts.

5/2/2014

Interrupt Priority
For processor with multiple interrupt input pins, the various interrupts are assigned a priority. When simultaneous interrupts occur the highest priority interrupt will be serviced before lower priority interrupts. It is possible to arrange software such that whilst a lower priority interrupt is being serviced that a higher priority interrupt can interrupt the lower priority service routine.
5/2/2014 6

8085A Interrupts

5/2/2014

Interrupt Trap RST 7.5 RST 6.5 RST 5.5 INTR

Trigger Type Rising Edge AND High Level Rising Edge High Level High Level High Level

5/2/2014

Enabling and Disabling Maskable Interrupts


The DI (disable interrupts) instruction disables all maskable interrupts. The EI (enable interrupts) instruction enables the vectored interrupt INTR and the unmasked restart interrupts RST 5.5, RST 6.5 and RST 7.5. The interrupt mask for the restart interrupts is determined by the contents of the accumulator when the SIM instruction is executed.

5/2/2014

EXAMPLE (Enable/Disable Direct Interrupt)

For example to enable RST 7.5 and RST 5.5 and disable RST6.5

MVI A, 00011010B SIM EI

;Set Interrupt Mask ;Enable Interrupt

5/2/2014

10

ORG 0000H JMP START ORG 0034H JMP ISR65 ORG 003CH JMP ISR75
START: . MVI A, 00011010B SIM EI .. .. ISR65: .. .. RET ISR75: .. .. RET
5/2/2014 11

Machine Cycles with Direct Interrupts


Since there is no requirement to supply ISR addresses with direct interrupts ( TRAP, RST 5.5, RST 6.5 & RST 7.5 ) then there is no requirement for the 8085A to execute INA machine cycles in response to such interrupts. However to provide the CPU sufficient time to process a direct interrupt a six T-state bus idle machine cycle is introduced, following recognition of the direct interrupt. During the bus idle machine cycle no control signal is asserted nor is the program counter incremented. Ready line control is ignored during the bus idle cycle. Following the bus idle cycle two memory write cycles are executed to save the current contents of the program counter on the stack. The program counter is then overwritten with the pre-programmed address for the particular interrupt source.
5/2/2014 12

Machine Cycles with Direct Interrupts

5/2/2014

13

Machine Cycles with Vectored Interrupts


The 8085A processor executes a number of machine cycles, in response to a vectored interrupt (intr), prior to execution of the first instruction of the interrupt service routine. The processor completes the execution of the current instruction. (Note : The processor only samples the interrupt inputs in the last T-state of the last machine cycle in the current instruction cycle) This has implication in system design as it means that the interrupt signal on INTR must remain in the asserted state for at least the longest instruction in the 8085A instruction set to guarantee that the processor recognises the interrupt.

5/2/2014

14

Machine Cycles with Vectored Interrupts


The processor then executes a six T-state interrupt acknowledge machine cycle ( the INTA machine cycle is similar to the opcode fetch machine cycle except that the program counter is not incremented and the INTA* control signal is asserted instead of RD*)
In response to the INTA* signal, the interrupting device need to place the opcode of an instruction onto the data bus ( called jamming ). The processor reads the opcode in the normal manner and stores it in the instruction register.

The choice of opcode is restricted as it is necessary to automatically save the contents of the program counter to enable the program to return to the point in the software where it was interrupted.
5/2/2014 15

Machine Cycles with Vectored Interrupts (CALL)


The only viable choice of 8085A instruction is either the CALL instruction or the RST n instruction. The CALL instruction is a 3-byte instruction with bytes 2 & 3 being the address of the first instruction of the subroutine ( in this case the interrupt service routine).

Following decoding of the call opcode, the processor executes a further two interrupt acknowledge machine cycles to fetch the address of the start of the ISR.
It is incumbent on the interrupting device to place the low byte of the address of the ISR onto the data bus in response to the second INTA* control signal and the high byte of the address in response to the third INTA* signal.
5/2/2014 16

Machine Cycles with Vectored Interrupts (CALL)


The execution phase of the CALL instruction can now take place. The processor firstly executes two memory write machine cycles to save the current contents of the program counter onto the stack. The address as to where in memory the contents of PC is to be saved is specified by the stack pointer register. Finally the processor overwrites the contents of the program counter with the second and third bytes of the call instruction.

The next instruction the processor will execute will be the first instruction of the ISR.

5/2/2014

17

Machine Cycles with Vectored Interrupts

5/2/2014

18

Machine Cycles with Vectored Interrupts

5/2/2014

19

Vector Interrupts (RST n)


The Restart instruction, RST n, where 0 n 7 RST n ((SP)-1) (PCH)

((SP)-2) (PCL)
((SP) (PC) (SP) 2 8*n

5/2/2014

20

Vector Interrupts (RST n)


In respond to the INTA strobe, external logic places an RST n opcode on the data bus. RST n has the following bit pattern 11NNN111 where n=NNN (3 bit binary number) and restart address is n * 8

For example if RST 1, NNN = 001 and restart address is 8


(RST 2 (address 10H), RST 3 (address 18H) etc)
5/2/2014 21

Das könnte Ihnen auch gefallen