13.07.2015 Views

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 9<strong>64</strong>-BIT MODE CODING GUIDELINES9.1 INTRODUCTIONThis chapter describes coding guidelines for application software written to run in<strong>64</strong>-bit mode. Some coding recommendations applicable to <strong>64</strong>-bit mode are coveredin Chapter 3. The guidelines in this chapter should be considered as an addendum tothe coding guidelines described in Chapter 3 through Chapter 8.Software that runs in either compatibility mode or legacy non-<strong>64</strong>-bit modes shouldfollow the guidelines described in Chapter 3 through Chapter 8.9.2 CODING RULES AFFECTING <strong>64</strong>-BIT MODE9.2.1 Use Legacy <strong>32</strong>-Bit Instructions When Data Size Is <strong>32</strong> Bits<strong>64</strong>-bit mode makes 16 general purpose <strong>64</strong>-bit registers available to applications. Ifapplication data size is <strong>32</strong> bits, there is no need to use <strong>64</strong>-bit registers or <strong>64</strong>-bit arithmetic.The default oper<strong>and</strong> size for most instructions is <strong>32</strong> bits. The behavior of thoseinstructions is to make the upper <strong>32</strong> bits all zeros. For example, when zeroing out aregister, the following two instruction streams do the same thing, but the <strong>32</strong>-bitversion saves one instruction byte:<strong>32</strong>-bit version:xor eax, eax; Performs xor on lower <strong>32</strong>bits <strong>and</strong> zeroes the upper <strong>32</strong> bits.<strong>64</strong>-bit version:xor rax, rax; Performs xor on all <strong>64</strong> bits.This optimization holds true for the lower 8 general purpose registers: EAX, ECX,EBX, EDX, ESP, EBP, ESI, EDI. To access the data in registers R9-R15, the REX prefixis required. Using the <strong>32</strong>-bit form there does not reduce code size.9-1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!