anybody can tell me about the best use of registers i mean the fastes in differend situation.
Posted on 2002-12-09 06:01:37 by drakoforma
All registers are equally fast to access but 'esp' can sometimes generate a larger opcode (in for example mov eax, i think).
Posted on 2002-12-09 06:51:13 by gliptic
eax has been optimized for size and speed if I'm not wrong in arithmetical operations :


add eax, 401000

05 00 10 40 00 ; 5 bytes

add ecx, 401000

81 C1 00 10 40 00 ; 6 bytes

cmp eax, 12345

3D 45 23 01 00 ; 5 bytes

cmp ecx, 12345

81 F9 45 23 01 00 ; 6 bytes

[...]

However, "cmp eax, 12" and "cmp ecx, 12" are equal lengh because when an 8 bits displacement follows the opcode it isn't optimised like the above (32 bits displacement)
Posted on 2002-12-09 07:53:32 by Axial
ALU ops on eax often have a smaller encoding (e.g. mov eax, 1234 doesn't require a ModR/M byte);
the Win32 calling convention lets you modify eax, ecx, edx (ebx, esi, edi, esp, ebp must be saved/restored).
Posted on 2002-12-09 07:54:31 by Jan Wassenberg

ALU ops on eax often have a smaller encoding (e.g. mov eax, 1234 doesn't require a ModR/M byte);


none of the -type ops require a ModR/M byte
Posted on 2002-12-09 10:15:27 by longer
That's true - mov was a bad example.
mov -> cmp, add etc.
Posted on 2002-12-09 11:31:36 by Jan Wassenberg

anybody can tell me about the best use of registers i mean the fastes in differend situation.


I think you mean the frequently used registers:eax,ebx,ecx,edx,edi,esi,ebp :)
Posted on 2002-12-09 12:40:39 by Vortex
thx PPL
Posted on 2002-12-10 06:36:16 by drakoforma
Different registers are supposed to have different uses and sometimes when the appropiate registers are used with certain opcodes, the resulting size would be smaller. For example, xchg ebx, ecx takes 2 bytes, while xchg eax,ecx takes 1 byte. This is due to the fact that xchg opcode is optmised (well sort of) to be used with the eax and ax. I could give other examples, such as the opcode 'and'.
Posted on 2002-12-11 07:25:22 by roticv

Different registers are supposed to have different uses and sometimes when the appropiate registers are used with certain opcodes, the resulting size would be smaller. For example, xchg ebx, ecx takes 2 bytes, while xchg eax,ecx takes 1 byte. This is due to the fact that xchg opcode is optmised (well sort of) to be used with the eax and ax. I could give other examples, such as the opcode 'and'.




I was looking for that wher can i find more about this ?
Posted on 2002-12-11 07:37:28 by drakoforma
Have a look into the intel instruction doument. I have attached a printscreen of it. Hope you will get what is on the image :rolleyes:
Posted on 2002-12-11 08:03:20 by roticv