raz / test / list / Listing.raz

26 lines · 402 B · raw · history · last change 264716cb

1module Listing;
2(* raz -S: each line of source, and the instructions made for it *)
3import SYSTEM;
4
5var total: I64;
6
7proc twice(x: I64): I64;
8code
9 lea rax, [rdi + rdi];
10 ret;
11end twice;
12
13proc add(a, b: I64): I64;
14begin
15 return a + b * 2;
16end add;
17
18proc main*;
19var i: I64;
20begin
21 for i := 1 to 3 do
22 if i # 2 then total := add(total, twice(i)); end;
23 end;
24end main;
25
26end Listing.