Skip to content

22.1 Inline Assembly #1755

Closed
Closed
@moremorefaito

Description

@moremorefaito

Hi, I am reading Rust by Example recently.
I think in Late output operands Section of 22.1 Inline Assembly, the code example:

use std::arch::asm;

let mut a: u64 = 4;
let b: u64 = 4;
let c: u64 = 4;
unsafe {
    asm!(
        "add {0}, {1}",
        "add {0}, {2}",
        inout(reg) a,
        in(reg) b,
        in(reg) c,
    );
}
assert_eq!(a, 12);

The inout(reg) a should be modified to inlateout(reg) a here, to make the code example in accordance with following content "but if you want optimized performance (release mode or other optimized cases), it could not work.".

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions