#trying to use the inline assembly

1 messages · Page 1 of 1 (latest)

mortal tapir
#

Hi

im trying to use the neat BLSI instruction but I honestly never wrote assembly and I am having a hard time trying to use the inline assembly syntax.

I currently have this based on the example from the documentation but not even the movq seems to work for me.

    var bb1: u64 = 1 << 7 | 1 << 6;

    var bb2: u64 = asm ("movq %r9, %r8"
        : [ret] "={r9}" (-> u64),
        : [bb1] "{r8}" (bb1),
    );

    std.debug.print("bb1: {}\n", .{bb1});
    std.debug.print("bb2: {}\n", .{bb2});

output:

bb1: 192
bb2: 32

Thanks for any help!

tawdry pond
#

zig asm uses AT&T syntax, so the general format is
mnemonic source, destination
try movq %r8, %r9

mortal tapir
#

oh wow that really fixed it

#

what a dumb mistake. Thanks! xD

azure cliff
#

Note that inline asm is very likely to change in future, and hopefully NASM syntax will be supported as a part of that

#

gas (AT&T) syntax for x86[_64] can be... interesting