Lab 1

Reuse string routines for two instrument labels

Debugger setup

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

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

Complete slen and srev in labels.s. The first takes a string address in a0 and returns the byte count in a0, excluding the terminating zero. The second takes the first and last character addresses in a0 and a1, both inclusive. The caller already handles an empty label.

Follow two calls

Set a breakpoint at slen. For SCOPE, predict the returned length and the address of its final character before letting the caller compute it. At srev, compare the actual pointers with your prediction. Continue and repeat with VGA2. Inspect first, second and empty in Memory before and after execution. Each label starts on its own 16-byte boundary.

Hand in the two subroutines, the original and final byte rows, and the value of the guard after the empty label. If the caller passed the address of the terminator as the last character, what would a C program see at the start of the resulting string?

Adapted from FPGAcademy · Computer Organization 24.1 · Lab 1, V. Original LabsLand assembly and worksheet. MIT

Run a signed maximum on a physical Nios V board