Here is a little tidbit before jumping into the details. The 64-bit processor has three operating modes:
64-bit Mode: 64-bit code/data running under a 64-bit OS
Compatibility Mode: 32-bit code/data running under a 64-bit OS
Legacy Mode: 32-bit code/data running under a 32-bit OS
These various operating modes give a nice upgrade methodology as well as extend the life of a large portion of pre-existing software as it has the ability to run under the new hardware and operating systems. Additional instructions and hardware have been added to the 32-bit hardware base to enhance its functionality while moving forward into the 64-bit world. I am not going to hype the technology here, as the manufacturers are doing a pretty good job themselves . My job with this book is to help you learn to program in assembly code for 32/64-bit processors. If you are already up to speed with 32-bit, it will help with your transition to the 64-bit machine. At the time of writing this book the new 64-bit operating systems were XP 64 and Linux 64.
At this point you are probably wondering to yourself, "My, this is a small section on the topic for 64-bit processors. Wasn't 64-bit 80x86 in the title?" From this book's point of view its only interest is the hardware capabilities of the instruction set and that means software, not the infrastructure of the hardware. But keep in mind that in 64-bit mode the data size becomes 2 64 .
2 64 bits are used to store a pretty big number.
A 32-bit unsigned number is 04,294,967,295. That is approximately 4.2 GB.
A 64-bit unsigned number is 018,446,744,073,709,551,615. That is approximately 18.4 exabytes.
Add computer memory and video memory to get your computer's maximum limit of memory. 64-bit is much higher than 32-bit and should be enough for a couple years of expansion.
That is almost too big most of the time.
for (uint i = 0; i < 7; i++)
For example, in this C for-loop snippet three bits were needed to represent the loop, thus 61 bits are wasted ! (Well, not really, but you may begin to see my point.) The advantage to registers that are 64 bits in size is not only can you store a value twice as big as a 32-bit register, but you can address memory that is twice the size. That drastically increases the amount of memory your application can access. Applications can be much bigger ! Which means that you can put larger memory sticks into your computers so your computer can run even hotter. ( That meant heat, not necessarily speed! ) For network applications that is good. But what the chip manufacturers realized is that sometimes those extra bits for size were needed for size of data but mostly not. So this is where things get cool: The default is 32-bit data! The processor stack, however, is still 64 bits.
The topic of 64-bit mode is spread throughout this book. Almost every instruction has a difference when used while in 64-bit mode. Some have been invalidated and thus do not exist anymore. Some have been renamed to help differentiate between 32-bit and 64-bit modes. The one thing to keep in mind is that most use a new 64-bit data addressing scheme involving a REX prefix, which will be discussed later in this chapter. The neat thing is some scalar operations that used to be done with MMX registers can now be done with the general-purpose registers. Instructions that used MMX registers such as PAND, POR, or XOR can now be done alternatively, using 64-bit general-purpose registers in 64-bit mode, thus minimizing the use of MMX registers and alleviating their associated dependency issues.
The goal is to preferably use XMM (SSE) registers or general-purpose registers instead.
So do not feel swizzled! 64 bit is discussed throughout this book!