Chinaunix首页 | 论坛 | 博客
  • 博客访问: 212912
  • 博文数量: 70
  • 博客积分: 2050
  • 博客等级: 大尉
  • 技术积分: 700
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-15 21:42
文章分类

全部博文(70)

文章存档

2013年(1)

2011年(5)

2010年(3)

2009年(9)

2008年(17)

2007年(6)

2006年(29)

我的朋友

分类: C/C++

2008-10-07 16:21:33

好久没弄过汇编,就这么个破程序,弄了我个把小时。对比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) |
给主人留下些什么吧!~~