zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

test_global_assembly.zig (380B) - Raw


      1 const std = @import("std");
      2 const expect = std.testing.expect;
      3 
      4 comptime {
      5     asm (
      6         \\.global my_func;
      7         \\.type my_func, @function;
      8         \\my_func:
      9         \\  lea (%rdi,%rsi,1),%eax
     10         \\  retq
     11     );
     12 }
     13 
     14 extern fn my_func(a: i32, b: i32) i32;
     15 
     16 test "global assembly" {
     17     try expect(my_func(12, 34) == 46);
     18 }
     19 
     20 // test
     21 // target=x86_64-linux
     22 // llvm=true