nx_smoke_nxasm_demo2.nx source
↩ module page · 22 lines · 1196 B
1// Same as smoke_nxasm_demo.nx but with the full directive header
2// nxc2 emits. Expect 72 still (directives don't emit code).
3// nx_safety_envelope:
4// intended_use: AUTO_APPLIED -- primitive-specific tuning queued
5// sil_target: SIL1
6// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail]
7// verdict: NOT_YET_EVALUATED
8
9import "nx_syscalls.nx"
10import "nxasm_v2.nx"
11
12func main() -> i64 {
13 let s: *u8 = "# Auto-generated\n .option nopic\n .attribute arch, \"rv64i2p1_m2p0\"\n .attribute unaligned_access, 0\n .attribute stack_align, 16\n\n .text\n .globl main\n .type main, @function\nmain:\n addi sp, sp, -48\n sd ra, 40(sp)\n li a0, 30\n li a7, 93\n ecall\n ld ra, 40(sp)\n addi sp, sp, 48\n ret\n .size main, .-main\n"
14 var sl: i64 = 0
15 while s[sl] != 0 { sl = sl + 1 }
16 let out: *u8 = alloc(512)
17 let n: i64 = assemble(s, sl, out, 512)
18 if n == -1 { return __syscall(93, 200, 0, 0, 0, 0, 0) }
19 if n == -2 { return __syscall(93, 201, 0, 0, 0, 0, 0) }
20 if n == -3 { return __syscall(93, 202, 0, 0, 0, 0, 0) }
21 return __syscall(93, n & 0xFF, 0, 0, 0, 0, 0)
22}