# `traple`

[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/traple

**Trap if less than or equal** · 68020

Category: System

Raises an exception if less than or equal, and continues normally otherwise.

68020 only: select `opt p=68020` before any code or data

## Flags

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

Reads: N, Z, V

## Forms

- `traple`
- `traple #imm` · Sizes .w .l, .w by default

## Operands

- [`#imm`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/immediate.md): An optional word or long immediate, for example `#3`. The processor ignores its value, but the handler can read it to identify the trap.

## Description

Write the condition as a suffix, as in `trapeq` for Z set or `trapvs` for V set. `trapt` always traps, and `trapf` never does. See the [condition suffix table](https://asm-editor.specy.app/documentation/m68k/condition-codes.md).

The exception uses vector 7 at `$1C`, as [trapv](https://asm-editor.specy.app/documentation/m68k/instruction/trapv.md) does. The handler’s `rte` returns to the instruction after the trap. Without a handler, a true condition ends the program there. See [writing a handler](https://asm-editor.specy.app/documentation/m68k/exceptions/handlers.md).

An optional word or long immediate can identify the trap to its handler, as in `trapeq.w #3`. The processor ignores its value. The handler can read it from the instruction bytes immediately before the saved return PC. With no operand, omit the size suffix.

## Example

```m68k
opt p=68020
* --- Send a value that must not be zero to a handler ---
move.l #was_zero, $1C ; vector 7 is at $1C
moveq #5, d0
tst.l d0
trapeq.w #1 ; d0 is not zero: nothing happens
moveq #0, d0
tst.l d0
trapeq.w #2 ; d0 is zero: was_zero runs
move.w d2, d1 ; rte comes back here: d1 = 2
bra END

was_zero:
    move.l 2(sp), a0 ; the address rte returns to, just past the trap's number
    move.w -2(a0), d2 ; the number written after the trapeq: d2 = 2
    rte

END:
```
