C161U
System Programming
Preliminary Data Sheet
413
02.2000
PRELIMINARY
PRE
LI
M
INAR
Y
- E
XCE
RP
T
-
ALU. Multiple bit rotate and logic instructions allow easy masking and extracting of
portions of floating point numbers.
To decrease the time required to perform floating point operations, two hardware
features have been implemented in the CPU core. First, the PRIOR instruction aids in
normalizing floating point numbers by indicating the position of the first set bit in a GPR.
This result can the be used to rotate the floating point result accordingly. The second
feature aids in properly rounding the result of normalized floating point numbers through
the overflow (V) flag in the PSW. This flag is set when a one is shifted out of the carry bit
during shift right operations. The overflow flag and the carry flag are then used to round
the floating point result based on the desired rounding algorithm.
21.7
Trap/Interrupt Entry and Exit
Interrupt routines are entered when a requesting interrupt has a priority higher than the
current CPU priority level. Traps are entered regardless of the current CPU priority.
When either a trap or interrupt routine is entered, the state of the machine is preserved
on the system stack and a branch to the appropriate trap/interrupt vector is made.
All trap and interrupt routines require the use of the RETI (return from interrupt)
instruction to exit from the called routine. This instruction restores the system state from
the system stack and then branches back to the location where the trap or interrupt
occurred.
21.8
Unseparable Instruction Sequences
The instructions of the C161U are very efficient (most instructions execute in one
machine cycle) and even the multiplication and division are interruptable in order to
minimize the response latency to interrupt requests (internal and external). In many
microcontroller applications this is vital.
Some special occasions, however, require certain code sequences (eg. semaphore
handling) to be uninterruptable to function properly. This can be provided by inhibiting
interrupts during the respective code sequence by disabling and enabling them before
and after the sequence. The necessary overhead may be reduced by means of the
ATOMIC instruction which allows locking 1...4 instructions to an unseparable code
sequence, during which the interrupt system (standard interrupts and PEC requests)
and Class A Traps (NMI, stack overflow/underflow) are disabled. A Class B Trap
(illegal opcode, illegal bus access, etc.), however, will interrupt the atomic sequence,
since it indicates a severe hardware problem. The interrupt inhibit caused by an ATOMIC
instruction gets active immediately, ie. no other instruction will enter the pipeline except
the one that follows the ATOMIC instruction, and no interrupt request will be serviced in
between. All instructions requiring multiple cycles or hold states are regarded as one
instruction in this sense (eg. MUL is one instruction). Any instruction type can be used
within an unseparable code sequence.