6 # The hello world program available at https://c9x.me/compile/
7 let helloWorld = writeText "hello-world.ssa" ''
8 function w $add(w %a, w %b) { # Define a function add
10 %c =w add %a, %b # Adds the 2 arguments
11 ret %c # Return the result
13 export function w $main() { # Main function
15 %r =w call $add(w 1, w 1) # Call add(1, 1)
16 call $printf(l $fmt, w %r, ...) # Show the result
19 data $fmt = { b "One and one make %d!\n", b 0 }
22 in stdenv.mkDerivation {
23 name = "qbe-test-can-run-hello-world";
26 ${qbe}/bin/qbe -o asm.s ${helloWorld}
28 ./out | grep 'One and one make 2!'