Best register usage

Matthew Dillon dillon at apollo.backplane.com
Wed Sep 28 09:09:04 PDT 2005


:A couple of questions...
:
:first, I understand that BSD is C based, so system calls are expected to
:respect (and preserve) esi, edi, and ebx.
:
:second, I understand that the string instructions work on esi and edi.
:
:Aside from that, what reasons are there for choosing one register over another
:for indirect addressing?  Is there compelling reason to keep addresses in esi
:and/or edi?  What about calls?  Is it better to 'call' a subroutine from a
:particular register, other than preservation of ebx/esi/edi?
:
:jcm

    It no longer matters.  The x86 architecture has 8 registers
    (eax,ebx,ecx,edx,esi,edi,ebp,esp) and except for esp they are all
    treated pretty much the same once the instruction has been decoded by
    the cpu.  Certain instructions, of course, still use implied (fixed)
    registers that cannot be changed, like the loop and string instructions.

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Users mailing list