Chinaunix首页 | 论坛 | 博客
  • 博客访问: 267140
  • 博文数量: 107
  • 博客积分: 305
  • 博客等级: 二等列兵
  • 技术积分: 417
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-22 09:42
文章分类

全部博文(107)

文章存档

2014年(3)

2013年(41)

2012年(34)

2011年(28)

2008年(1)

分类:

2011-07-25 19:43:23

Referrence:
1. GCC DOC: C Extensions::Extended Asm::
2. HOWTO: 

Base Inline: asm("assembly code");
Extended Asm:
asm ( assembler template 
 : output operands /* optional */ 
 : input operands /* optional */ 
 : list of clobbered registers /* optional */ 
 );

Operands = "ConstraintModifiers-Constraint"(Operand-Expr), Another, ...

Clobbered register: 
registers that may be modified in this inline asm instructions, or "memory" indicates that our instruction modifies memory in a unpredictable fashion, and will cause GCC to not keep memory values cached in registers across the assembler instruction. 

Constraint Modifiers: 
= + &
Constraint: 
m r g 0-9 and so on. Constrains tells where the operands come from, and where to put the operands.

__asm__ equals to asm key word.
__volatile__ equals to volatile key word. 
When it decorates variables, it means that the var can be modified by some external program routine.And when it decorates routines just like here, following the asm key word, it tells gcc to not do any optimization on these instuctions. I think it's the difference with "memory" clobber string.



阅读(940) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~