291
The effects of each instruction are:
The SETUSR instruction puts the processor into the User Mode by pushing the correct
value into the SU register.
PUSH SU
and POP SU push and pop the single-byte SU register on/off the SP stack.
SURES
pops the current processor mode off the SU register, returning it to the previous
mode.
IDET
causes an interrupt if executed in the User Mode, and does nothing in System
Mode. It is intended to be placed in system-level code and trap any execution of that
code while in the User Mode.
RDMODE
returns the current mode in the carry flag (0 for System Mode, 1 for User Mode).
SYSCALL
is essentially a new RST instruction, and was added to allow User Mode
access to the System Mode without using one of the existing RST instructions. It will
put the processor into the System Mode and execute code in the corresponding
interrupt-vector table entry.
SCALL
is another RST instruction that vectors to the same address as SYSCALL. The
difference is that it also pushes the value of the SU register as well as the return address
onto the stack.
SRET
is the companion instruction to SCALL; it expects both SU and the return address
to be on the stack.
SETSYSP
and SETUSRP are support functions for handing user mode interrupts.
pushes a 16-bit compare value onto the stack and enters user mode. SETSYSP pops a
16-bit value off the stack and compares it to the provided value; a system mode viola-
tion interrupt occurs if they do not match. These two instructions provide protection for
User Mode interrupts by checking for both main stack and SU stack mismatches when
the User Mode handler returns.
27.3.6 System Mode Violation Interrupt
The following steps describe how to set up the System Mode Violation interrupt.
1. Write the vector to the interrupt service routine to the internal interrupt table.
2. Enable the system/user mode by writing to EDMR.
3. The interrupt request is cleared automatically when handled.
A sample interrupt handler is shown below.
sysmode_isr::
push af
; handle the system mode violation here
pop af
sures
ipres
ret