Last active
March 26, 2022 07:27
-
-
Save kekeimiku/3ef73b6633b338d8d7e51aebeca3d5b7 to your computer and use it in GitHub Desktop.
The tiny rust-x64-helloworld experiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![no_std] | |
#![no_main] | |
use core::arch::asm; | |
#[panic_handler] | |
fn panic(_info: &core::panic::PanicInfo) -> ! { | |
loop {} | |
} | |
#[no_mangle] | |
fn _start() { | |
let h: &str = "Hello, World!\n"; | |
unsafe { | |
asm!( | |
"syscall", | |
in("rax") 1, | |
in("rdi") 1, | |
in("rsi") h.as_ptr() as u64, | |
in("rdx") h.len() as u64 | |
); | |
//exit | |
asm!( | |
"syscall", | |
in("rax") 60 | |
); | |
}; | |
} |
Author
kekeimiku
commented
Apr 24, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment