The CPU and the operating system 15 However, a syscall is not the only way we interact with our operating system, as we'll see in the following section. The CPU and the operating system Does the CPU cooperate with the operating system? If you had asked me this question when I first thought I understood how programs work, I would most likely have answered no. We run programs on the CPU and we can do whatever we want if we know how to do it. Now, first of all, I wouldn't have thought this through, but unless you learn how CPUs and operating systems work together, it's not easy to know for sure. What started to make me think I was very wrong was a segment of code that looked like what you're about to see. If you think inline assembly in Rust looks foreign and confusing, don't worry just yet. We'll go through a proper introduction to inline assembly a little later in this book. I'll make sure to go through each of the following lines until you get more comfortable with the syntax: Repository reference: ch01/ac-assembly-dereference/src/main. rs fn main() { let t = 100; let t_ptr: *const usize = &t; let x = dereference(t_ptr); println!("{}", x); } fn dereference(ptr: *const usize)-> usize { let mut res: usize; unsafe { asm!("mov {0}, [{1}]", out(reg) res, in(reg) ptr) }; res } What you've just looked at is a dereference function written in assembly. The mov {0}, [{1}] line needs some explanation. {0} and {1} are templates that tell the compiler that we're referring to the registers that out(reg) and in(reg) represent. The number is just an index, so if we had more inputs or outputs they would be numbered {2}, {3}, and so on. Since we only specify reg and not a specific register, we let the compiler choose what registers it wants to use. The mov instruction instructs the CPU to take the first 8 bytes (if we're on a 64-bit machine) it gets when reading the memory location that {1} points to and place that in the register represented by {0}. The [] brackets will instruct the CPU to treat the data in that register as a memory address, 