Riscrithm – An intuitive RISC-V assembler and optimizer coded in Go

https://news.ycombinator.com/rss Hits: 4
Summary

The Riscrithm Developer Manual Hey there. If you're looking at this, you are probably getting your hands dirty with Riscrithm, a high-level macro-assembly dialect that compiles straight down to pure RISC-V assembly. Think of it as a bridge between the readability of a high-level language and the raw, deterministic control of bare-metal hardware. Let's dive straight into how the compiler works, the syntax rules, and what's happening under the hood. To compile your source code, you'll use the riscrithm CLI tool. The syntax is straightforward: riscrithm "source_code_file" "assembly_target_file" [-o/--optimize] Source Code: Your Riscrithm input file. Target File: The generated .s assembly file. If this file doesn't exist, the compiler will create it for you on the fly. Optimization: Pass -o or --optimize to enable the optimization sweep (more on the compiler architecture later). 2. File Structure & Globals Every Riscrithm file must declare its target section and entrypoint at the very top. These, along with macro definitions, are the only lines allowed to exist completely unindented outside of a label block. header : Sets the assembly section. For instance, header default translates to .section .text. entrypoint : Defines where the program starts. Passing entrypoint main translates to .globl main. header default entrypoint main You can define text-replacement macros using the define keyword. This is perfect for aliasing registers or creating single-line inline functions. Here are some classic developer examples: define foo = x1 define bar = x2 define baz = x3 define horseBattery = x4 define apple = 10 define orange = 20 define clearFoo = foo ^^ Whenever the parser sees foo, it swaps it with x1 before processing any actual logic. are written using the # symbol. The compiler strips out anything following a # on any line, so you can place them anywhere safely. 3. Labels, Indentation, and Raw Blocks Riscrithm is strictly scoped via indentation. Labels define your executio...

First seen: 2026-05-25 22:24

Last seen: 2026-05-26 01:26