Chinaunix首页 | 论坛 | 博客
  • 博客访问: 807696
  • 博文数量: 118
  • 博客积分: 2067
  • 博客等级: 大尉
  • 技术积分: 1751
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-17 14:27
文章存档

2016年(1)

2013年(1)

2012年(3)

2011年(26)

2010年(47)

2009年(40)

分类: LINUX

2010-01-13 11:07:28

Please refer to

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:

  1. Use the "register" name cc to indicate that flags might have changed -- I think "cc" maybe is CPSR in ARM, is that correct?
  2. Use the "register" name memory if you changed a memory location
阅读(3510) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~