# `illegal`

[M68K Documentation](https://asm-editor.specy.app/documentation/m68k.md) › [Instructions](https://asm-editor.specy.app/documentation/m68k/instruction.md)

Web page: https://asm-editor.specy.app/documentation/m68k/instruction/illegal

**Take illegal instruction trap**

Category: System

Raises an illegal-instruction exception through vector 4 at $10.

Used in: [Exceptions and the vector table](https://asm-editor.specy.app/learn/courses/m68k/talking-to-the-outside-world/exceptions-and-the-vector-table.md) (M68K assembly)

## Flags

| Flag | Effect |
| --- | --- |
| X | not changed |
| N | not changed |
| Z | not changed |
| V | not changed |
| C | not changed |

## Forms

- `illegal`

## Description

Programs can use it to mark code that must never execute.

The exception saves the address of `illegal` itself. A handler that resumes at the next instruction must add 2 to the saved address before `rte`. Without a handler, the program ends at `illegal`. See [writing a handler](https://asm-editor.specy.app/documentation/m68k/exceptions/handlers.md).

## Example

```m68k
* --- Step past an illegal instruction ---
move.l #skip, $10 ; vector 4 is at $10
moveq #1, d0
illegal ; skip runs
moveq #2, d0 ; and the program carries on here
bra END

skip:
    addq.l #2, 2(sp) ; the saved address is the illegal's own: step past it
    rte

END:
```
