AVRStudio has two assemblers:
- Built-in Atmel AVR assembler (used in CE-2800)
- Each project consists of a single .asm file that is assembled into a single .hex file.
- Multiple .asm files could be .included into the main .asm file, but the assembler cannot link multiple assembled files into one .hex file.
- Each project consists of a single .asm file that is assembled into a single .hex file.
- GNU GCC assembler/compiler (used in CE-2810)
- Each project can consist of one or more of the following types of files:
- .s — assembly language file.
- .c — c language file.
- .cpp — C++ language file.
- A linker combines the results from the multiple source files into one .hex file.
- Each project can consist of one or more of the following types of files:
C Compiler's Register Usage
- The C compiler views registers in one of three ways:
- Temporary — registers whose value need not be preserved (R0, R18:27, R30:31)
- If calling assembly from C, there is no need for us to preserve the register(s) in the assembly function.
- If calling C from assembly, we should push the register(s) before calling the C function and pop the register(s) immediately following the return (since the C compiler doesn't attempt to preserve the register's value).
- Saved — registers whose value must be preserved (R2:17, R28:29).
- If calling assembly from C, we must push the register(s) onto the stack at the beginning of the assembly function and pop the register(s) off the stack just prior to returning from the assembly function.
- If calling C from assembly, there is no need for us to preserve the register(s) in the assembly function.
- R1 — Assumed to have a 0 in it.
- If calling assembly from C — the assembly function may use R1 but it must be cleared before returning from the function.
- If calling C from assembly — the assembly function must make sure that R1=0 before calling the C function.
- Temporary — registers whose value need not be preserved (R0, R18:27, R30:31)