x86-32 provides a grand total of eight integer registers, a full 7 of which
are usable as integer registers!! Whatever will we do with such bounty.
Table 3 summarizes these registers.
Table 3:
Possible x86-32 registers
|
|
CALLEE |
REGISTER |
USAGE |
SAVE |
%eax |
integer return val |
NO |
%edx |
dividend reg |
NO |
%ecx |
count reg |
NO |
%ebp |
optional frame pointer |
YES |
%ebx |
local reg |
YES |
%esi |
local reg |
YES |
%edi |
local reg |
YES |
%esp |
Stack pointer |
YES |
%st |
fp return val, aliased with mmx |
NO |
%st1-7 |
scratch regs, aliased with mmx |
NO |
%mmx0-7 |
scratch MMX regs, aliased with fp stack |
NO |
%xmm0-7 |
scratch SSE/SSE2 regs |
NO |
|
Note that the MMX registers are only available on architectures possing
the MMX ISA extensions, and that the xmm registers are only available
on architectures implementing SSE or SSE2. It is also worth mentioning that
all of the integer registers with the exception of the stack pointer
(%esp) may be used as general purpose registers, in addition to their
specialized usages. Finally, please note that the MMX registers
and floating point are aliased, so they cannot be referenced at the same time.
Registers marked as CALLEE SAVE = YES must be explicitly saved by any
functions which write them. Registers marked NO are scratch registers
whose values need not be saved. EAX is used by intergral functions to
return the value, and the floating point top-of-stack, %st
returns
floating point values. EBP is documented as base pointer, but I think
most sane people just do all referencing from ESP (the stack pointer),
and utilize EBP as an additional integer register.
As for floating point registers, the x86-32 has eight of them arranged
in a pseudo-stack. A document this brief cannot explain this travesty to
you if you don't already grok it. Go read the x87 FPU description in an
assembler book, and come back when you are through crying.
Clint Whaley
2012-07-10