rust-lang / rust-playground

The Rust Playground
https://play.rust-lang.org/
Apache License 2.0
1.2k stars 203 forks source link

Assembly output syntax does not match Rust inline assembly syntax #1046

Closed RalfJung closed 5 months ago

RalfJung commented 5 months ago

Rust inline assembly expects to be written like this:

    crate::arch::asm!(
        "movntps [{mem_addr}], {a}",
        mem_addr = in(reg) mem_addr,
        a = in(xmm_reg) a,
    );

However, when dumping the output assembly on the playground, it looks like this:

    movntps %xmm0, (%rdi)

Operand order is swapped, and it's using (%name) instead of [name]. I guess one is AT&T syntax and one is Intel syntax.

Would be good if playground could be consistent with Rust's own inline asm syntax. :)

RalfJung commented 5 months ago

Turns out this is a rustc issue: https://github.com/rust-lang/rust/issues/121592

PatchMixolydic commented 5 months ago

By default, the playground outputs AT&T syntax, but you can switch to Intel syntax in the config menu: Specifically, under the "assembly" subheading

... which yields the expected output:

    movntps xmmword ptr [rdi], xmm0
RalfJung commented 5 months ago

Oh fancy, it must have been years since I last checked the config menu. :) Thanks!

shepmaster commented 5 months ago

it must have been years since I last checked the config menu

About 6.5 years... 40d88e560d8384e2db3b94ab279241319870c340