作者loveflames (人形也要做好安全措施啊)
看板ASM
标题与程式效能有关的一些东西
时间Fri Nov 30 01:25:58 2007
前面的code比较慢
後面的code比较快
做optimizing就会碰到里面的东西
这篇讲的算是比较粗浅的部份
--------------------
1.避免AGI延迟
mov ebx,1
mov edi,10000h
mov [edi],eax
mov edi,10000h
mov ebx,1
mov [edi],eax
2.避免先写後读(8-bit和16-bit视作同一个)
mov eax,dword ptr [ebp-4]
mov dword ptr [ebp-8],eax
mov ebx,dword ptr [ebp-8]
mov dword ptr [ebp-0ch],ebx
mov edx,dword ptr [ebp-0ch]
mov dword ptr [ebp-4],edx
mov eax,dword ptr [ebp-4]
mov ebx,dword ptr [ebp-8]
mov edx,dword ptr [ebp-0ch]
mov dword ptr [ebp-8],eax
mov dword ptr [ebp-0ch],ebx
mov dword ptr [ebp-4],edx
3.利用cache
mov eax,dword ptr [ebp-14h]
mov eax,dword ptr [ebp-18h]
mov eax,dword ptr [ebp-1ch]
mov eax,dword ptr [ebp-4]
mov dword ptr [ebp-8],eax
mov eax,dword ptr [ebp-8]
mov dword ptr [ebp-0ch],eax
mov eax,dword ptr [ebp-0ch]
mov dword ptr [ebp-4],eax
mov eax,dword ptr [ebp-4]
mov eax,dword ptr [ebp-8]
mov eax,dword ptr [ebp-0ch]
mov eax,dword ptr [ebp-4]
mov dword ptr [ebp-8],eax
mov eax,dword ptr [ebp-8]
mov dword ptr [ebp-0ch],eax
mov eax,dword ptr [ebp-0ch]
mov dword ptr [ebp-4],eax
4.固定周期的multicycle opcode,後面如果是不固定周期的multicycle opcode可加快
CMC
CMC
CMC
XCHG
5.少用带有prefix的指令
MOV AX,[ebp-4]
MOV BX,[ebp-4]
MOV DX,[ebp-4]
MOV EAX,[ebp-4]
MOV EBX,[ebp-4]
MOV EDX,[ebp-4]
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.134.226.149
※ 编辑: loveflames 来自: 140.134.226.149 (11/30 01:26)
※ 编辑: loveflames 来自: 140.134.226.149 (11/30 01:26)