Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Something with meaningful restrictions such as register count and RAM that you'll hit quickly when hand-coding assembler is a super IMHO useful teaching tool. 16 registers is luxurious!


The 16 registers in RV32EC [1] on the CH32V003 is not a lot using the standard ABI once you take out the zero register, return address, stack pointer, globals pointer, and thread pointer [2] you're left with 11 registers, allocated as 6 function argument / local variable registers (caller cave), 2 callee save registers, and 3 temporary registers.

Empirically you need up to 20% more instructions executed vs the 32 register RV2I, which is also similar to what Intel reports with their new "APX" x86 extension giving 32 GPRs.

The 2k RAM also concentrates the mind more so than a 6502 or Z80 with 64k RAM.

[1] you can ignore the "C" for simplicity if you want

[2] which arguably you're not going to use for that purpose so it's effectively available too, most usefully as a 3rd callee save register.


For a teaching tool, you can get the best of both worlds by simply restricting RISC-V to fewer registers. Something like: "Write this in RISC-V assembly, but only use registers 0..3, and 31 for the return address."


rv32e and rv64e have 16 registers rather than 32.

Maybe use these.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: