trap

Affected Flags

X
N
Z
V
C
-
-
-
-
-

Operands

Op 1
Im

Raises the trap exception selected by the operand. In this editor, trap #15 enters the simulator’s service handler; put its decimal task number in D0.B (for example, task 13 prints a NUL-terminated string). These tasks are separate from CPU exception handling. See the trap tasks reference for each task’s register inputs and results.

TaskDescription
0Print string pointed by a1 with length read in d1.w, null terminated with max of 255, then prints a new line.
1Print string pointed by a1 with length read in d1.w, null terminated with max of 255.
2Read a line, writes its first 79 characters at the address of a1 with a null and their count to d1.l.
3Print signed number at d1.
4Read a line and convert it to a number in d1.l, as C's atoi does: 12abc is 12, a line with no number is 0.
5Read one key into d1.b, without waiting for Enter; Enter is $0D.
6Print character at d1.
7Check for keyboard input, writes 1 or 0 to d1.b.
8Get the time in hundredths of a second since the run started, writes to d1.
9Terminate.
11Set or get the text cursor, or clear the screen with d1.w = $FF00.
12Turn the echo of what is typed off with d1.b = 0, on with anything else.
13Prints null terminated string pointed by a1 then prints new line, errors if string is longer than 16kb, to prevent infinite loops.
14Prints null terminated string pointed by a1, errors if string is longer than 16kb, to prevent infinite loops.
15Prints unsigned number at d1 in base (from 2 to 36) specified in d2.b, in upper case
16Hide (d1.b = 0) or show (1) the input prompt, turn the line feed after Enter off (2) or on (3).
17Prints the null terminated string at a1, then the signed number in d1.
18Prints the null terminated string at a1, then reads a number into d1.
19Reads the state of up to four keys given in d1.l, or the last keys pressed and released with d1.l = 0.
20Print the signed number in d1 right justified in a field d2.b columns wide; a negative d2.b left justifies it.
23Delay for the number of hundredths of a second in d1.
24Enable or disable the simulator shortcut keys; accepted and ignored.
33Set or get the screen size, or set the window mode.
50-59Files: close all, open, create, read, write, position, close, delete, the file dialog and whether a file exists.
61Read the mouse: flags in d0, y:x in d1.
80-96Graphics: colors, pixels, lines, rectangles, ellipses, flood fill, drawing modes, double buffering, text and the pen position.
* --- Trap #15 invokes I/O based on d0 ---
move #4, d0
trap #15 ; read input

move #3, d0
trap #15 ; print input

move #6, d0
move #32, d1
trap #15 ; print character (space)