Creating Our Own Fibers 102 If we want to issue a very specific set of commands to the CPU directly, we need to write small pieces of code in assembly. Fortunately, we only need to know some very basic assembly instructions for our first mission. Specifically, we need to know how to move values to and from registers: mov rax, rsp A quick introduction to Assembly language First and foremost, Assembly language isn't particularly portable since it's the lowest level of human-readable instructions we can write to the CPU, and the instructions we write in assembly will vary from architecture to architecture. Since we will only write assembly targeting the x86-64 architecture going forward, we only need to learn a few instructions for this particular architecture. Before we go too deep into the specifics, you need to know that there are two popular dialects used in assembly: the AT&T dialect and the Intel dialect. The Intel dialect is the standard when writing inline assembly in Rust, but in Rust, we can specify that we want to use the AT&T dialect instead if we want to. Rust has its own take on how to do inline assembly that at first glance looks foreign to anyone used to inline assembly in C. It's well thought through though, and I'll spend a bit of time explaining it in more detail as we go through the code, so both readers with experience with the C-type inline assembly and readers who have no experience should be able to follow along. Note We will use the Intel dialect in our examples. Assembly has strong backward compatibility guarantees. That's why you will see that the same registers are addressed in different ways. Let's look at the rax register we used as an example as an explanation: rax # 64 bit register (8 bytes) eax # 32 low bits of the "rax" register ax # 16 low bits of the "rax" register ah # 8 high bits of the "ax" part of the "rax" register al # 8 low bits of the "ax" part of the "rax" register As you can see, this is basically like watching the history of CPUs evolve in front of us. Since most CPUs today are 64 bits, we will use the 64-bit versions in our code. The word size in the assembly also has historical reasons. It stems from the time when the CPU had 16-bit data buses, so a word is 16 bits. This is relevant because you will see many instructions suffixed with q (quad word) or l (long word). So, a movq would mean a move of 4 * 16 bits, which is 64 bits. A plain mov will use the size of the register you target on most modern assemblers. This is the one you will see most used in both AT&T and the Intel dialect when writing inline assembly, and it's the one we will use in our code.