Link: http://blog.csdn.net/pennyliang/archive/2011/03/08/6231709.aspx
According to the Convention, first explain the code.
The rdtsc function is used to obtain the machine startup timestamp. The following text comes from Intel instruction manual:
Loads the current value of the processor's time-stamp counter (a 64-bit MSR)
The edX: eax registers and also loads the ia32_tsc_aux MSR (Address
C000_0103h) into the ECX register. The edX register is loaded with the high-order
32 bits of the ia32_tsc MSR; The eax register is loaded with the low-order 32 bits
The ia32_tsc MSR; and The ECX register is loaded with the low-order 32-bits
Ia32_tsc_aux MSR. On processors that support the Intel 64 architecture, the highorder
32 bits of each of rax, RDX, and rcX are cleared.
Where = A is short for eax and = D is short for the edX register, indicating that the eax register of the command is stored in Lo, and the edx register is stored in HI. This is not hard to understand. The second blog in this series also introduced the rdtsc command.
- Static_ Inline _ unsignedLong LongRdtsc (Void)
- {
- Unsigned hi, lo;
- _ ASM _ volatile _ ("rdtsc": "= A" (LO), "= D" (HI ));
- Return(UnsignedLong Long) LO) | (unsignedLong Long) HI) <32 );
- }
The method for passing 64-bit program parameters is very different from that for 32-bit programs. It is passed through registers, m_ B _64 (to, from, qdword_cnt). Before executing this function, first, store the address pointed to by to in the RDI register, then store the address pointed to by from in the RSI register, and the qdword_cnt is stored in the RDX register. The meaning of rep movsq is: Move rcX quadwords from [RSI] to [RDI]. Therefore, you need to store qdword_cnt in the rcX register.
For details about the rep movsq/movsw/movsd/movsb command, see the Intel instruction manual.
The above memory copy method is not much different. movsq has not significantly improved compared with movsb. More methods will be introduced later, which will greatly improve the performance of memory copy, to be continued.