AVR Assembly language
Each asm statement is devided by colons into (up to) four parts:
- The assembler instructions, defined as a single string constant:
- A list of output operands, separated by commas. Our example uses just one:
- A comma separated list of input operands. Again our example uses one operand only:
"I" (_SFR_IO_ADDR(PORTD))
- Clobbered registers, left empty in our example.
You can write assembler instructions in much the same way as you would write assembler programs. However, registers and constants are used in a different way if they refer to expressions of your C program. The connection between registers and C operands is specified in the second and third part of the asm instruction, the list of input and output operands, respectively. The general form is
asm(code : output operand list : input operand list [: clobber list]);
In the code section, operands are referenced by a percent sign followed by a single digit. %0 refers to the first %1 to the second operand and so forth. From the above example:
%0 refers to "=r" (value) and
%1 refers to "I" (_SFR_IO_ADDR(PORTD)).
You might also like






