aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/test_global_assembly.zig
blob: a5d5f3ca5f13ecc72866a8f1637a036b4df6f9a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const std = @import("std");
const expect = std.testing.expect;

comptime {
    asm (
        \\.global my_func;
        \\.type my_func, @function;
        \\my_func:
        \\  lea (%rdi,%rsi,1),%eax
        \\  retq
    );
}

extern fn my_func(a: i32, b: i32) i32;

test "global assembly" {
    try expect(my_func(12, 34) == 46);
}

// test
// target=x86_64-linux
// llvm=true