Table of Contents

Debug tracing (ivss)

Debug tracing exposes individual machine operations and register states while the emulator runs. Enable it on an existing linked image:

$ ./emulator -debug program.hex

The execution loop invokes its inspection helpers after fetching and decoding each instruction:

Emu_DebugInstr(stderr, oc, mod, ra, rb, rc, disp);
Emu_PrintRegs(stderr);

These calls occur before the decoded instruction executes. The shown program counter has already advanced past its four bytes, while other register effects of that instruction are still pending. The final halt report provides the resulting state.

Tracing is useful for distinguishing a wrong branch target from an incorrect arithmetic result, or observing the expanded instructions generated by a full-width immediate load. It also reports delivered interrupts when debugging is enabled.

The trace mixes formatted output across standard streams and includes terminal color escapes, so it is primarily an interactive inspection aid. It does not alter the source or make one assembly statement correspond to one displayed machine instruction.

Source: emulator.c.