好久没弄过汇编,就这么个破程序,弄了我个把小时。对比C程序优化编译结果,只有15%的性能提升,失败
.section .text
.global AllocateBitmapID
.type AllocateBitmapID, @function
AllocateBitmapID:
pushl %ecx
pushl %edi
movl 12(%esp), %edi
movl $1048576, %ecx
xorl %eax, %eax
repz scasl
movl $0xffffffff, %eax
jz quit
subl $1048575, %ecx
negl %ecx
sall $5, %ecx
movl -4(%edi), %eax
bsfl %eax, %eax
orl %ecx, %eax
pushl %eax
movl %eax, %ecx
movl $1, %eax
sall %cl, %eax
notl %eax
andl %eax, -4(%edi)
popl %eax
quit:
popl %edi
popl %ecx
ret
阅读(770) | 评论(0) | 转发(0) |