Skip to content

Commit

Permalink
Merge pull request #81 from kdnakt/20230607
Browse files Browse the repository at this point in the history
22-1: late output operands
  • Loading branch information
kdnakt committed Jun 10, 2023
2 parents b6fc3fd + 8fea687 commit 72afd9b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 22/22-1_late_output_operands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use std::arch::asm;

fn main() {
let mut a: u64 = 4;
let mut b: u64 = 4;
let mut c: u64 = 4;

// 消すと--releaseビルドでバグる
println!("a={}", a);
// println!("b={}", b);
// println!("c={}", c);

unsafe {
asm!(
"add {0}, {1}",
"add {0}, {2}",
inlateout(reg) a,
in(reg) b,
in(reg) c,
);
}
// assert_eq!(a, 14);

println!("a={}", a);
// println!("b={}", b);
// println!("c={}", c);
}

0 comments on commit 72afd9b

Please sign in to comment.