trapf
Trap if false
Never traps, because the false condition never holds.
68020 only: select opt p=68020 before any code or data
XNZVC –––––
- Changes no flag
Forms
trapftrapfSizes .w .l, .w by default
Operands
#imm- An optional word or long immediate, for example
#3. The processor ignores its value, but the handler can read it to identify the trap. More
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.
The exception uses vector 7 at $1C, as trapv 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.
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.
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: