Carzy (Assembly Builder)
Carzy is a built-in low-level assembly and code generation module that comes with LightVM. It provides helpers for assembly text, symbols, memory sections (text, data, rodata), I/O constants, and architecture-specific instructions.
How Carzy Works
Carzy uses a two-tier architecture: the Core Assembly Engine (AsmBuilder) manages text formatting and a string buffer, while the Architecture-Specific Builder (AArch64Builder) wraps it with instruction helpers. These builders emit assembly text without validating instructions or operands.
- Core Assembly Buffer (
AsmBuilder): Writes directly to aStringbuffer using thewrite!andwriteln!macros and thestd::fmt::Writetrait.build()returns the text, andwrite_to_file()writes it to a file. - Allocation Name Sanitization:
AsmBuilder::alloc()replaces characters that are neither alphanumeric nor underscores with_in allocation names.label(),global(), andsymbol_type()write names as supplied. - Global I/O Constant Injection: Emits constants for a newline, the text
16, object/array markers, and ANSI screen-clearing sequences. - Architecture Instruction Helpers:
AArch64Builderprovides methods such asmov,add,sub,ldr,str, andretto format instruction text. - Memory Section Management: Emits
.text,.data, and.section .rodatadirectives. - String Escaping:
alloc()escapes backslashes, quotes, newlines, carriage returns, and tabs forPrimitiveTypes::Strvalues.
INFO
You can find how to use Carzy on the Compile Method page.