© 2000 Scenix Semiconductor, Inc. All rights reserved. 113 SX User’s Manual Rev. 3.1 www.scenix.com Chapter 3 Instruction Set 3.6.43    RETIW Return from Interrupt and Adjust RTCC with W Operation: RTCC = RTCC + W restore W, STATUS, FSR, and program counter from shadow registers Bits affected: STATUS register restored, which affects all bits Opcode: 0000 0000 1111 Description: Like the RETI instruction, the RETIW instruction causes a return from an interrupt
service routine. It restores the 12-bit program counter value that was saved when
the interrupt occurred. This causes the program to return to the point in the program
where the interrupt occurred.
Before it returns from the interrupt service routine, the RETIW instruction first adds
W to the Real-Time Clock Counter (RTCC). Then it restores the contents of the W,
STATUS, and FSR  registers and the program counter that  were saved when  the
interrupt occurred.
Adding W to RTCC allows the interrupt service routine to restore the RTCC to the
value it contained at the time the main program was interrupted. To use this feature,
the interrupt service routine should check the RTCC at the beginning of the routine
and again at the end of the routine, and then put the adjustment value into W before
returning from the interrupt.
Cycles: 2 in “compatible” mode (SX18/20/28AC and SX18/20/28AC75 only), or 3 in “tur-
bo” mode
Example: ... ;interrupt service routine at address 000h ... ;check RTCC ... ;check interrupt pending bits ... ;perform interrupt service ...
...
;check RTCC ... ;put adjustment value into W retiw ;return from interrupt and adjust RTCC