AVR Assembly language :: Assembly

AVR Assembly language

AVR Assembly Language

Each asm statement is devided by colons into (up to) four parts:

  1. The assembler instructions, defined as a single string constant:
  2. A list of output operands, separated by commas. Our example uses just one:
  3. A comma separated list of input operands. Again our example uses one operand only:

    "I" (_SFR_IO_ADDR(PORTD))

  4. 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

AVR Microcontroller Assembly Language Programming Tutorial 2
AVR Microcontroller Assembly Language Programming Tutorial 2
AVR Microcontroller Assembly Language Programming Tutorial 1
AVR Microcontroller Assembly Language Programming Tutorial 1

Copyright © . All Rights Reserved