Format an unsigned 32-bit word as decimal text
Online version: https://fpga.labsland.com/altera/computer-organization/lab-04/part-03/
Debugger setup
CPUlator simulatorRISC-V · DE1-SoC Nios V computer, simulated in your browser. No board or sign-in needed.
- Get the sourceDownload
decimal.s - Open the simulatorOpen CPUlator
Complete dec_word. The caller passes a 32-bit unsigned integer in a0. Print its base-ten digits without leading zeros. Zero itself needs one digit. Repeated unsigned division by ten yields the digits in reverse order. Design how the routine will keep them until they can be printed from left to right.
Test 0, 10, 0x00b30e04, 0x80000000 and 0xffffffff in CPUlator. For the largest value, predict the length and first and last digits before running. Compare the terminal output with an independent unsigned conversion. Explain what would change if you used signed division.
Submit the displayed values and a stack diagram for one call. Mark where the return address and any temporary digits live.
Adapted from FPGAcademy Computer Organization 24.1 · Lab 4, Part III. LabsLand wrote the assembly and worksheet. MIT
