开发者

Why are the cpu-registers in OllyDbg not sorted alphabetically?

In OllyDbg the registers window, among other things, lists the standard cpu-registers:

EAX
ECX
EDX
EBX

Is there a particular reas开发者_StackOverflow社区on why EBX is displayed last?


This is probably the same reason that they are ordered that way in processor instructions. When specifying a 32 bit register, eax is 0, ecx is 1, edx is 2, ebx is 3, esp is 4, ebp is 5, esi is 6, and edi is 7. Intel has used this order since they started the X86 architecture.


My guess is that it's because EAX, ECX and EDX are used as scratch registers by functions both in the cdecl ,stdcall and other calling conventions, that is they are not preserved after function calls. Besided the remaining registers special use is as pointers which is documented in the Intel Developer Manual (2.36MB PDF). That's just my two cents.


Since i've been into reverse engineering with ollydbg for years, i can tell you that this is the order of importance when debugging. Eax is used everywhere because of its nature. It gets the return values, it's used a lot. Then, ecx and edx are of equal occurence i would say. Instructions like loop, repsb and the likes use ecx, while divs,muls and more use edx. Moreover, when we program in assembly, we tend to use eax,edx and ecx a lot. Esi and edi are used sometimes as well, mostly in repeat string functions or as secondary registers in some cases.

I suppose that the reason behind the order is really the way intel uses the order, but it would be really weird to have esi on top of my ollydebug registers, since eax is used everywhere. Thus, it has an ergonomic point also :D


PUSHAD is the instruction which gave me more insight for this question. It pushes the values of EAX, ECX, EDX, EBX, original ESP, EBP, ESI, and EDI to the stack. This is most probably the reason why OllyDbg sorts them in that order in the registers view. A description of PUSHAD can be found here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜