32 bit optimization
来源:互联网 发布:韩国加工中心编程 编辑:程序博客网 时间:2024/05/17 00:42
(1)测试寄存器是否为0
cmp eax,00000000h ; 6 bytes
jz bribriblibli ; 2 bytes (if jz is short)
optimization:
or eax,eax ; 2 bytes
jz bribriblibli ; 2 bytes (if jz is short)
xchg eax,ecx ; 1 byte
jecxz bribriblibli ; 2 bytes (if it is short)
(2)测试寄存器是否为-1
cmp eax,0FFFFFFFFh ; 6 bytes
jz insumision ; 2 bytes (if short)
optimization:
inc eax ; 1 byte
xchg eax,ecx ; 1 byte
jecxz insumision ; 2 bytes (if short)
dec ecx ; 1 byte
inc eax ; 1 byte
jz insumision ; 2 bytes
dec eax ; 1 byte
(3)寄存器清0并传送低位字数值
xor eax,eax ; 2 bytes
mov ax,word ptr [esi+6] ; 4 bytes
optimization:
movzx eax,word ptr [esi+6] ; 4 bytes
(4) 关于push的优化
mov eax, 50h ; 5 bytes
optimization:
push 50h ; 2 bytes
pop eax ; 1 bytes
push 0 ; 2 bytes
push 0 ; 2 bytes
push 0 ; 2 bytes
push 0 ; 2 bytes
push 0 ; 2 bytes
push 0 ; 2 bytes
push 0 ; 2 bytes
optimization:
xor eax, eax ; 2 bytes
push eax ; 1 byte
push eax ; 1 byte
push eax ; 1 byte
push eax ; 1 byte
push eax ; 1 byte
push eax ; 1 byte
push eax ; 1 byte
push 7 ; 2 bytes
pop ecx ; 1 byte
_loop:
push 0 ; 2 bytes
loop _loop ; 2 bytes
(5) 操作FS寄存器相关优化
push dword ptr fs:[00000000h] ; 6 bytes
mov fs:[0],esp ; 6 bytes
[...]
pop dword ptr fs:[00000000h] ; 6 bytes
optimization:
xor eax,eax ; 2 bytes
push dword ptr fs:[eax] ; 3 bytes
mov fs:[eax],esp ; 3 bytes
[...]
pop dword ptr fs:[eax] ; 3 bytes
(6) 字符串操作
mov al/ax/eax, [esi] ; 2/3/2 bytes
inc esi ; 1 byte
optimization:
lodsb/w/d ; 1 or 2 byte
到达字符串尾部。
lea edi,[ebp+ASCIIz_variable] ; 6 bytes
@@1:
cmp byte ptr [edi],00h ; 3 bytes
inc edi ; 1 byte
jz @@2 ; 2 bytes
jmp @@1 ; 2 bytes
@@2:
inc edi ; 1 byte
optimization:
lea edi,[ebp+ASCIIz_variable] ; 6 bytes
xor al,al ; 2 bytes
@@1:
scasb ; 1 byte
jnz @@1 ; 2 bytes
(7)乘法
mov ecx,28h ; 5 bytes
mul ecx ; 2 bytes
optimization:
imul eax,eax,28h ; 3 bytes
(8)置edx寄存器为0.
xor edx, edx ; 2 bytes
optimization:
cdq ; 1 bytes
(9)交换寄存器4字节的顺序
mov eax, 00200000h ; 5 bytes
bswap eax ; 2 bytes
;eax = 00002000h now
(10)乘2、除2
shl eax, 1 ; 2 bytes
;*2
shr eax, 1 ; 2 bytes
;/2
(11)分配堆栈空间
push ebp ; 1 byte
mov ebp,esp ; 2 bytes
sub esp,20h ; 3 bytes
optimization:
enter 20h,00h ; 4 bytes
(12)压入字符串指针时尽量使用
call @f
db 'string', 0
@@:
- 32 bit optimization
- optimization
- optimization
- Optimization
- optimization
- optimization
- 12bit,24bit,32bit颜色
- 32bit
- 32bit和64bit
- sizeof 32bit 64bit
- 32bit or 64bit
- 32bit还是64bit
- 32bit和64bit的区别
- win 2008 32bit 到64bit
- 32bit应用程序转位64bit
- RCU 32bit for 64bit machine
- RHEL6 64 bit with libstdc++ 32 bit
- 32bit->64bit domino升级
- for循环效率问题整理
- openmeetings05简明安装
- Singleton Pattern 两种实现的选择
- 2009下半年,痛苦的半年。网站又被和谐了,请看图。
- 标签的用途
- 32 bit optimization
- 关于静态页面分页程序端处理思考
- MyEclipse Flex环境配置详解
- MySQL 字符串函数:字符串截取
- jQuery插件FullCalendar日程表实现可扩展Google日历功能
- JPA注释参考手册
- jquery FullCalendar日程表学习笔记(一)
- 【转】实战 Groovy: Groovy:Java 程序员的 DSL
- Symbian 随机数