免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 964 | 回复: 0
打印 上一主题 下一主题

clobbered register 说明 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-13 11:07 |只看该作者 |倒序浏览

                                Please refer to
gcc inline asm
the following is only explain for clobber parameter.
24.6.1 The Clobber Parameter
One of the dangers of intermixing assembly language and a compiled language such as Ada is
that the compiler needs to be aware of which registers are being used by the assembly code.
In some cases, such as the earlier examples, the constraint string is sufficient to
indicate register usage (e.g. "a" for the eax register).  But more generally, the
compiler needs an explicit identification of the registers that are used by the Inline
Assembly statements.
   
Using a register that the compiler doesn't know about
could be a side effect of an instruction (like mull
storing its result in both eax and edx).
It can also arise from explicit register usage in your
assembly code; for example:
     Asm ("movl %0, %%ebx" & LF & HT &
          "movl %%ebx, %1",
          Inputs  => Unsigned_32'Asm_Input  ("g", Var_In),
          Outputs => Unsigned_32'Asm_Output ("=g", Var_Out));
   where the compiler (since it does not analyze the Asm template string)
does not know you are using the ebx register.
   
In such cases you need to supply the Clobber parameter to Asm,
to identify the registers that will be used by your assembly code:
     Asm ("movl %0, %%ebx" & LF & HT &
          "movl %%ebx, %1",
          Inputs  => Unsigned_32'Asm_Input  ("g", Var_In),
          Outputs => Unsigned_32'Asm_Output ("=g", Var_Out),
          Clobber => "ebx");
   
The Clobber parameter is a static string expression specifying the
register(s) you are using.  Note that register names are not prefixed by a percent sign.
Also, if more than one register is used then their names are separated by commas; e.g., "eax, ebx"
   
The Clobber parameter has several additional uses:
     
  • Use the "register" name cc to indicate that flags might have changed -- I think "cc" maybe is CPSR in ARM, is that correct?
  • Use the "register" name memory if you changed a memory location
            
                   
                   
                   
                   
                   
                   
                   

    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/101219/showart_2147321.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP