Lab 4

Trace a byte from the stack to the terminal

Debugger setup

CPUlator simulatorRISC-V · DE1-SoC Nios V computer, simulated in your browser. No board or sign-in needed.

  1. Get the sourceDownload digit.s
  2. Open the simulatorOpen CPUlator

The DE1-SoC model has a JTAG UART. The program sends a prefix, a hexadecimal digit and a newline. Predict the line for 0x0b. In CPUlator choose Compile and Load, then Continue. Stop once the line appears in the JTAG UART terminal.

Restart and set a breakpoint on the call to uart_byte inside uart_string. Record sp, ra and s0 on entry to uart_string and again after its return. Locate the saved return address in the stack frame. Explain why the routine must save it before calling another routine.

Repeat with 0x09, 0x0a and 0x0f. Hand in the three output lines and a short trace of one nested return. Which bits in the UART control register tell the program it can write?

Adapted from FPGAcademy Computer Organization 24.1 · Lab 4, Part I. LabsLand wrote the assembly and worksheet. MIT

Run a signed maximum on a physical Nios V board