-
Rust연습❤️] Hello from asm__assembly코드 연습코딩Coding/Rust연습 2022. 7. 3. 00:41728x90
Rust Playground에서는 잘 실행 된다.
인텔 cpu칩인가 보다 ㅠㅠ
You can try this example on the playground
.)
use std::arch::asm; #[feature(asm)] fn main() { let buf = "Hello from asm!\n"; let ret: i32; unsafe { asm!( "syscall", in("rax") 1, // syscall number in("rdi") 1, // fd in("rsi") buf.as_ptr(), in("rdx") buf.len(), out("rcx") _, // clobbered by syscalls out("r11") _, // clobbered by syscalls lateout("rax") ret, ); } println!("write returned: {}", ret); }
결과
Compiling playground v0.0.1 (/playground) warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> src/main.rs:3:1 | 3 | #[feature(asm)] | ^^^^^^^^^^^^^^^ | = note: `#[warn(unused_attributes)]` on by default warning: `playground` (bin "playground") generated 1 warning Finished release [optimized] target(s) in 1.40s Running `target/release/playground` Standard Output Hello from asm! write returned: 16
반응형'코딩Coding > Rust연습' 카테고리의 다른 글
러스트연습❤️ 뭔가 제자리에서 출력되는거 (0) 2022.08.13 Rust연습❤️“rust spinning rod animation in text” Code Answer (0) 2022.08.13 Rust연습❤️Processing 0~100%올라가는 프린트 ㅎㅎ (0) 2022.08.13 Rust연습❤️HashMap, Arc, Mutex, thread연습 (0) 2022.08.13 Rust연습❤️] Displaying raw pointers (0) 2022.07.03 Rust연습❤️내 컴퓨터에 병렬 실행 가능한 코어수 알아보기available_parallelism (0) 2022.06.29 Rust – Fibonacci using Recursion and Iteration (0) 2022.06.26 Rust연습❤️) Collect & Vec 조합 Closure활용 (0) 2022.06.23