Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created April 27, 2018 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/54a5b6c95c1352139b9896b7aade1f2e to your computer and use it in GitHub Desktop.
Save rust-play/54a5b6c95c1352139b9896b7aade1f2e to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
#![feature(asm)]
fn main() {
unsafe { sched_part_2_thunk(0) };
}
unsafe fn sched_part_2_thunk(rsp: usize) -> ! {
asm!{
"
movq $0, %rsp
movq $0, %rbp
jmp $1
"
: /* no outputs */
: "r"(rsp), "i"(main)
: "rbp", "rsp", "memory"
: "volatile"
};
unreachable!();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment