Find the longest run in a list of words
Online version: https://fpga.labsland.com/altera/computer-organization/lab-02/part-02/
Debugger setup
CPUlator simulatorRISC-V · DE1-SoC Nios V computer, simulated in your browser. No board or sign-in needed.
- Get the sourceDownload
ones.s - Open the simulatorOpen CPUlator
Complete ones in ones.s. It receives one 32-bit word in a0 and returns its longest run of ones in a0. The caller examines ten nonzero words and stops at the zero sentinel. Register s0 contains the largest result seen so far.
Trace the call boundary
Stop at ones on the first word. Predict its return before stepping out. Continue until s0 changes; record the input, the returned count and the new maximum. Check one word with the longest run at a boundary and one with its longest run in the middle.
Put 0xffffffff at the end of the data, just before the sentinel. After running that case, place the sentinel first. Submit the final s0 for both runs and explain why scanning bytes in memory order could accidentally merge runs from different words.
Adapted from FPGAcademy Computer Organization 24.1 · Lab 2, II. Original LabsLand assembly and worksheet. MIT
