Atmel CAVR-4 사용자 설명서

다운로드
페이지 323
CAVR-4
Part1. Using the compiler
93
Assembler language 
interface 
When you develop an application for an embedded system, there may be 
situations where you will find it necessary to write parts of the code in 
assembler, for example, when using mechanisms in the AVR microcontroller 
that require precise timing and special instruction sequences.
This chapter describes the available methods for this, as well as some C 
alternatives, with their pros and cons. It also describes how to write functions 
in assembler language that work together with an application written in C or 
C++.
Finally, the chapter covers how you can implement support for call frame 
information in your assembler routines for use in the C-SPY Call Stack 
window.
Mixing C and assembler
The AVR IAR C/C++ Compiler provides several ways to mix C or C++ and assembler: 
Modules written entirely in assembler
Intrinsic functions (the C alternative)
Inline assembler.
It might be tempting to use simple inline assembler. However, you should carefully 
choose which method to use.
INTRINSIC FUNCTIONS
The compiler provides a small number of predefined functions that allow direct access 
to low-level processor operations without having to use the assembler language. These 
functions are known as intrinsic functions. They can be very useful in, for example, 
time-critical routines. 
An intrinsic function looks like a normal function call, but it is really a built-in function 
that the compiler recognizes. The intrinsic functions compile into inline code, either as 
a single instruction, or as a short sequence of instructions.