8 64-bit mode coding guidelines, Introduction, Coding rules affecting 64-bit mode – Intel ARCHITECTURE IA-32 User Manual

Page 409: Chapter 8, Bit mode coding guidelines

Advertising
background image

8-1

8

64-bit Mode Coding
Guidelines

Introduction

This chapter describes coding guidelines for application software
written to run in 64-bit mode. These guidelines should be considered as
an addendum to the coding guidelines described in Chapter 2 through 7.
Software that runs in either compatibility mode or legacy non-64-bit
modes should follow the guidelines described in Chapter 2 through 7.

Coding Rules Affecting 64-bit Mode

Use Legacy 32-Bit Instructions When The Data Size Is 32 Bits

64-bit mode makes 16 general purpose 64-bit registers available to
applications. If application data size is 32 bits, however, there is no need
to use 64-bit registers or 64-bit arithmetic.

The default operand size for most instructions is 32 bits. The behavior
of those instructions is to make the upper 32 bits all zeros. For example,
when zeroing out a register, the following two instruction streams do the
same thing but the 32-bit version saves one instruction byte:

32-bit version

xor eax, eax ;Performs xor on lower

;32bits and zeros the upper 32 bits.

64-bit version

xor rax, rax

;Performs xor on all 64 bits.

Advertising