I'm not very clear about it, is there some dissertations and tutorials? THX.
Hi Eric4ever,
General purpose registers
EAX: - Accumulator. General use
EBX: - Base ...
ECX: - Count... mainly for loops...
EDX: - Displacement ...
Stack registers
EBP - Base Pointer... for stack..
ESP - Stack Pointer..
Segment registers
CS - Code Segment. This is where the instructions are ...
DS - Data Segment. This is where data can be accessed. Source Segment when dealing with string operations.
ES - Extra Segment. This segment can also be used as a data segment. Source Segment when dealing with string operations.
SS - Stack Segment. This segment is for adresses ...
Index registers
ESI - Source Index. Used by string operations as the source.
EDI - Destination Index. Used by string operations as the destination.
(BX - BX can also be used as an index register. These register are used together with the segment registers as an offset.
Regards,
Immortal_One
General purpose registers
EAX: - Accumulator. General use
EBX: - Base ...
ECX: - Count... mainly for loops...
EDX: - Displacement ...
Stack registers
EBP - Base Pointer... for stack..
ESP - Stack Pointer..
Segment registers
CS - Code Segment. This is where the instructions are ...
DS - Data Segment. This is where data can be accessed. Source Segment when dealing with string operations.
ES - Extra Segment. This segment can also be used as a data segment. Source Segment when dealing with string operations.
SS - Stack Segment. This segment is for adresses ...
Index registers
ESI - Source Index. Used by string operations as the source.
EDI - Destination Index. Used by string operations as the destination.
(BX - BX can also be used as an index register. These register are used together with the segment registers as an offset.
Regards,
Immortal_One
Honest answer : use any of the common registers for anything you want.
Just know that "some opcodes are designed to work with certain registers".
Aside from that, do whatever you want. I just want to recommend that whatever you do, you are consistant. Otherwise debugging your own code will be needlessly painful.
For myself, I tend to use esi for source, edi for target, ecx as a counter, ebx as a baseptr, eax and edx as general purpose, but if I ever need an extra register I'm happy to abuse my own rules in this regard.
For my oopasm code, I tend to use esi as pThis, but sometimes its ebx.
Ultimately, its up to you, but I recommend you avoid using eax and edx for non-accumulator purposes, since they are very "transient" ie they get trashed easily and often.
Just know that "some opcodes are designed to work with certain registers".
Aside from that, do whatever you want. I just want to recommend that whatever you do, you are consistant. Otherwise debugging your own code will be needlessly painful.
For myself, I tend to use esi for source, edi for target, ecx as a counter, ebx as a baseptr, eax and edx as general purpose, but if I ever need an extra register I'm happy to abuse my own rules in this regard.
For my oopasm code, I tend to use esi as pThis, but sometimes its ebx.
Ultimately, its up to you, but I recommend you avoid using eax and edx for non-accumulator purposes, since they are very "transient" ie they get trashed easily and often.
To put this simply: you can use every register as long as you comply with OS's and App's conventions. Windows OS requires some registers to be preserved. This means that you have to (1) Store their values, (2) use them, (3) restore their values. Such reqisters -among others- are ebx, esi, edi.
You can use ebp and esp too, as long as their values are preserved.