We're looking for your comments on how to best organize the wiki's content.

INT

From 0x10c Wiki
Jump to: navigation, search

INT (Interrupt) is one of the Special opcodes in the DCPU-16 specification. It triggers an interrupt from the software.

Contents

[edit] Usage

 INT arg1

If the IA register has been set to a non-zero value, INT will trigger an interrupt from software. First, interrupt queueing will be turned on. Then, first the PC and then the A registers are pushed to the stack. Finally, the PC is set to IA, and A is set to arg1.

If the IA register is zero, the interrupt will be ignored, although the instruction still takes four clock cycles.

[edit] Returning from an interrupt

The RFI instruction should be used to return from an interrupt.

[edit] Example

SET ia, myISR   ; interrupts will be handled by myISR (Interrupt Service Routine), below
SET a, 1
INT a
ADD a, 2
:end
SET pc, end
 
:myISR
SET b, 1
ADD b, a
RFI a   ; continues execution at ADD a, 2

[edit] Processing

In binary machine code, this Special opcode's five-bit representation is: 0b0 1000 (0x08)

The instruction has a takes four cycles to execute, plus any additional cycles necessary to evaluate the argument.

[edit] References

Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox