Examples of inline assembly statements (IBM extension)

In the following example:
int a ;  
int b = 100 ;  
int c = 200 ;  
	asm("add %0, %1, %2" : "=r"(a) : "r"(b) , "r"(c)); 
add is the op code of the instruction, understood by the assembler. %0, %1 and %2 are the operands, which are to be substituted by the C expressions in the output/input operand fields. The output operand uses the = constraint to indicate that a modifiable operand is required; and the r constraint to indicate that a general purpose register is required. Likewise, the r in the input operands indicates that general purpose registers are required. Within these restrictions, the compiler is free to choose any registers to substitute for %0, %1, and %2.
In the following example, the % constraint modifier tells the compiler that operands a and b can be switched if the compiler thinks it can generate better code in doing so.
asm("add %0, %1, %2" : "=r"(c) : "%r"(a), "r"(b)); 
The following example illustrates the use of the symbolic names for input and output operands :
int a ;  
int b = 1, c = 2, d = 3 ;  
__asm("addc %[result],%[first],%[second]" : [result]"=r"(a) : [first]"r"(b), [second]"r"(d));