Table of Contents

Terminal input (ivss)

Terminal input exposes the latest host input byte at memory-mapped address 0xFFFFFF04. A handler can read that byte and echo it through the output register:

.equ term_in, 0xFFFFFF04
.equ term_out, 0xFFFFFF00
.section my_handler
handler:
    push %r1
    ld term_in, %r1
    st %r1, term_out
    pop %r1
    iret
.end

The main program must install this handler and run with -terminal. For a shared handler, check %cause before treating an event as terminal input. The snippet assumes terminal-only service.

The input callback returns Emu_TermBuffer. Reading it does not consume a queued character or clear a queue: there is one latest-byte slot, and the terminal thread overwrites it when another ordinary byte arrives.

The pending interrupt flag is cleared during delivery, separately from the register read. Slow processing can therefore observe only the newest byte after several inputs. This interface is suitable for demonstrating device access and interrupts, rather than providing buffered terminal semantics.

Source: emulator.c.