morph/test.mclang
2025-06-23 19:12:17 +03:00

42 lines
493 B
Plaintext

// vim: ft=mclang :
sizeof(...)
struct Foo do
bar i32;
baz i64;
end
export "C" fn square with i32 returns i32 do
dup *
end
const SYS_write 1 end
fn sc_write with isize ptr isize returns isize do
SYS_write syscall3
end
5 square .
const i32 sizeof(i32) end
memory ptr sizeof(i32) end
// Reads smaller than the default size would get truncated
ptr 69 write32
ptr read32 .
0 while dup 10 > do
"Hello: " .
dup .
"\n" .
1 +
done
if 5 2 > do
else
done