An example we can build upon 107 Let's try to sum up what we do here with words: Move what's at the + 0x00 offset from the memory location that {compiler_chosen_general_ purpose_register} points to to the rsp register. The next line is the ret keyword, which instructs the CPU to pop a memory location off the stack and then makes an unconditional jump to that location. In effect, we have hijacked our CPU and made it return to our stack. Next up is the first non-assembly argument to the asm! macro is our input parameter: in(reg) new, When we write in(reg), we let the compiler decide on a general-purpose register to store the value of new. out(reg) means that the register is an output, so if we write out(reg) new, we need new to be mut so we can write a value to it. Y ou'll also find other versions such as inout and lateout. Options The last thing we need to introduce to get a minimal understanding of Rust's inline assembly for now is the options keyword. After the input and output parameters, you'll often see something like options(att_syntax), which specifies that the assembly is written with the AT&T syntax instead of the Intel syntax. Other options include pure, nostack, and several others. I'll refer you to the documentation for you to read about them since they're explained in detail there: https://doc. rust-lang. org/nightly/reference/inline-assembly. html#options Inline assembly is quite complex, so we'll take this step by step and introduce more details on how it works along the way through our examples. Running our example The last bit we need is the main function to run our example. I'll present the whole function and we'll walk through it step by step: fn main() { let mut ctx = Thread Context::default(); let mut stack = vec![0_u8; SSIZE as usize]; unsafe { let stack_bottom = stack. as_mut_ptr(). offset(SSIZE); let sb_aligned = (stack_bottom as usize & !15) as *mut u8; std::ptr::write(sb_aligned. offset(-16) as *mut u64, hello as u64); ctx. rsp = sb_aligned. offset(-16) as u64; gt_switch(&mut ctx);