I am creating a code to be able to print text on the screen with the rust macro (asm!) and this is the code:
fn printmsg(string: &str) {
let length: usize = string.len();
unsafe {
asm!("syscall" :: "{rax}"(1), "{rdi}"(1), "{rsi}"(&string), "{rdx}"(length));
}
}
fn main() {
let s = "hello world!";
printmsg(s);
}
When I run the code it prints random letters...
How do I get it to print "hello world!" and not something else?