汇编指令记录
0. lea: Load Effect Address
如: lea edi,[ebp-0D8h]
比如要算EAX*4+EBX+3,结果放入EDX:
lea edx, [ebx+eax*4+3]
1. rep stosd
Save the data in eax to memory ES:[EDI] and increase EDI by 4 and decrease ecx by 1.
所以就有了一下代码:
//QUAD(四元数) inline void Mem_Set_QUAD(void* dest, int data, int count) { //填充32未对齐的内存 _asm { mov edi, dest; mov ecx, count; mov eax, data; rep stosd } }
同理 rep stosw
inline void Mem_Set_Word(void* dest, short data, int count) { _asm { mov edi, dest mov ecx, count mov ax, data rep stosw } }
// ps:为什么要写如上的函数, 因为memset()是用单字节填充的,速度不够理想。