Terminal output prints a byte through a memory-mapped register at 0xFFFFFF00. A program can write the character A using an ordinary store:
.equ term_out, 0xFFFFFF00 .section my_code ld $65, %r1 st %r1, term_out halt .end
The callback converts the stored value to char, writes it to standard output, and flushes the stream. This makes the character visible without waiting for a newline or buffered-output threshold.
The store's operand names the address. It does not point to an allocated data word that must be declared with .word; the emulator recognizes the address and performs the device action.
Run the linked program with ./emulator program.hex. The -terminal flag starts input handling and is not needed for this output-only example. After the character, the emulator also prints its normal halt report.
Interrupt handlers can use the same register for diagnostics or echoing input. Preserve any working registers whose values the interrupted program expects to survive.
Source: emulator.c.