NEC PD17062 Datasheet page 117

Mos integrated circuit 4-bit single-chip microcontroller containing pll frequency synthesizer and image display controller
Table of Contents

Advertisement

11.6 INTERRUPT PROCESSING ROUTINE
An interrupt is accepted in a program area that permits interrupts regardless of the program being executed.
Therefore, to return control to the original program after interrupt processing, return the program to the
state it is in when it is not processing an interrupt.
For example, if an arithmetic operation is performed during interrupt processing, the contents of the carry
flag may differ from those before interrupt acceptance. This content change may cause a decision error in
the program to which control has returned.
A system or control register that can at least operate within the interrupt processing routine should be saved
or restored within the interrupt processing routine.
See Section 11.9 for processing that permits an interrupt while another interrupt is being processed
(multiple interrupts).
11.6.1 Save Processing
This section describes how to save the contents of registers using the interrupt routine as an example.
Only the contents of bank register and index enable flag of system registers are automatically saved by
the hardware. Use the program to save another system register as described in the example if necessary.
The PEEK and POKE instructions can be used to save or restore the contents of the system registers or other
registers as described in the example.
To save the contents of a register, a transfer instruction (LD r, LD m, ST m, or ST r) can be used in addition
to PEEK and POKE. If a transfer instruction is used to save the contents of a register when the row address
of the general-purpose register is not defined at interrupt acceptance, the data memory address is hard to
specify.
If the general-purpose register address is not defined when the transfer instruction is used to save the
contents of the general-purpose register, the address to be saved also becomes undefined. In this case, use
of the general-purpose register should be fixed at least in the interrupt permission routine.
However, because the address of the register file controlled by the PEEK or POKE instruction is specified
regardless of the contents of the general-purpose register and because addresses 40H-7FH of the register file
overlap with the bank data memory, each system register can be saved only by specifying the bank.
In the example, the PEEK or POKE instruction is used to save the contents of the window register and
general-purpose register pointer. Then, the general-purpose register is respecified to row address 07H of
BANK0 and the ST instruction is used to save another system register.
Fig. 11-4 illustrates register content saving using the PEEK and POKE instructions.
11.6.2 Restoration Processing
This section describes an example of restoration.
To restore the contents of a register, reverse the procedures for register saving explained in Section 11.6.1.
Because an interrupt is always accepted in an interrupt permitted state (EI state), the EI instruction must
be executed before the RETI instruction.
The EI instruction sets the interrupt enable flip-flop to 1 after the next RETI instruction is executed.
Therefore, control is returned to the program before an interrupt is accepted, then the program enters an
interrupt permitted state.
PD17062
117

Advertisement

Table of Contents
loading

Table of Contents