anybody can tell me about the best use of registers i mean the fastes in differend situation.
All registers are equally fast to access but 'esp' can sometimes generate a larger opcode (in for example mov eax, i think).
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)
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)
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).
the Win32 calling convention lets you modify eax, ecx, edx (ebx, esi, edi, esp, ebp must be saved/restored).
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
That's true - mov was a bad example.
mov -> cmp, add etc.
mov -> cmp, add etc.
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 :)
thx PPL
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'.
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 ?
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: