Hello World Walkthrough
Here is a step-by-step walkthrough of writing and compiling your first native AzLang program using the real SDK syntax.
1. Writing main.az
Create a file named main.az:
enum FD
Stdin
Stdout
Stderr
@link("./sdk/src/write.s")
op write(FD fd, const str val, const int size): void
@link("./sdk/src/exit.s")
op exit(const int val): void
write(Stdout, "Hello World from AzLang!\n", 25)
exit(0)
Deconstructing the Code:
enum FD: Defines standard file descriptors (Stdin=0,Stdout=1,Stderr=2). Enum variants are inlined as immediates — no lookup table exists at runtime.@link(...): Points at a fasm assembly source containing a syscall stub that performs a direct Linuxsyscallinstruction. The source is included straight into the generated assembly — there is nothing to pre-compile.op write(...): Declares a callable operation function signature and parameter types.write(...)&exit(...): Calls the operations natively without libc overhead. The string length25accounts for the\nescape, which is resolved to a single newline byte at emission time.
2. Compiling with AzCLI
Compile main.az using azcli:
azcli build main.az
The AzLang pipeline will:
- Parse
main.azinto an AST. - Validate symbols and types.
- Emit a single assembly file (
main.asm) containing the program code, its string data, andincludedirectives forwrite.sandexit.s. - Invoke
fasm, which assembles and links that file directly into the standalone binarymainin one pass.
The only external tool required is fasm. There is no
qbe, noas, noldand no object files.
Run the resulting executable:
./main
# Output:
# Hello World from AzLang!
Check the binary size:
ls -l main
# 180 bytes
A complete, functional ELF executable in 180 bytes!