diff options
Diffstat (limited to 'examples/wiring.zc')
| -rw-r--r-- | examples/wiring.zc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/examples/wiring.zc b/examples/wiring.zc index d10ecf5..329659b 100644 --- a/examples/wiring.zc +++ b/examples/wiring.zc @@ -1,3 +1,6 @@ +namespace; +include rt; + // virtual enhancements: custom opcodes wired into the cpu while compiling. // the recipes run through the core's optimizer; the jit inlines the result. enhance popcount(x) micro @@ -8,11 +11,11 @@ enhance div10(x) micro "x = udiv x 10"; // becomes a multiply-high, no divide enhance hypot2(a, b) vm { 0 $ * ~ 0 $ * + }; // lifted from vm code enhance 2 minmax(a, b) micro "r2 = min a b; r1 = max a b; r0 = r2"; let lo, hi; -fn main() { - put_n(popcount(0xff00ff)); put_c(' '); - put_n(div10(12345)); put_c(' '); - put_n(hypot2(3, 4)); put_c(' '); +void main() { + rt.put_n(popcount(0xff00ff)); rt.put_c(' '); + rt.put_n(div10(12345)); rt.put_c(' '); + rt.put_n(hypot2(3, 4)); rt.put_c(' '); asm { 9 4 minmax hi ! lo ! } - put_n(lo); put_c('/'); put_n(hi); put_c(10); - return 0; -}
\ No newline at end of file + rt.put_n(lo); rt.put_c('/'); rt.put_n(hi); rt.put_c(10); + return; +} |
