Creating Our Own Fibers 108 } } So, in this function, we're actually creating our new stack. hello is a pointer already (a function pointer), so we can cast it directly as an u64 since all pointers on 64-bit systems will be, well, 64-bit. Then, we write this pointer to our new stack. Note We'll talk more about the stack in the next segment, but one thing we need to know now is that the stack grows downwards. If our 48-byte stack starts at index 0 and ends on index 47, index 32 will be the first index of a 16-byte offset from the start/base of our stack. Make note that we write the pointer to an offset of 16 bytes from the base of our stack. What does the line let sb_aligned = (stack_bottom as usize &! 15) as *mut u8; do? When we ask for memory like we do when creating a Vec<u8>, there is no guarantee that the memory we get is 16-byte-aligned when we get it. This line of code essentially rounds our memory address down to the nearest 16-byte-aligned address. If it's already 16 byte-aligned, it does nothing. This way, we know that we end up at a 16-byte-aligned address if we simply subtract 16 from the base of our stack. We cast the address to hello as a pointer to a u64 instead of a pointer to a u8. We want to write to position “32, 33, 34, 35, 36, 37, 38, 39”, which is the 8-byte space we need to store our u64. If we don't do this cast, we try to write a u64 only to position 32, which is not what we want. When we run the example by writing cargo run in our terminal, we get: Finished dev [unoptimized + debuginfo] target(s) in 0. 58s Running `target\debug\a-stack-swap` I LOVE WAKING UP ON A NEW STACK! Tip As we end the program in an endless loop, you'll have to exit by pressing Ctrl + C. OK, so what happened? We didn't call the function hello at any point, but it still executed. What happened is that we actually made the CPU jump over to our own stack, and since it thinks it returns from a function, it will read the address to hello and start executing the instructions it points to. We have taken the first step toward implementing a context switch.