3.3.7.3 How Do I Access C Objects from Assembly Code?
Most C objects are accessible from assembly code. There is a mapping between the symbols used in the C source and those used in the assembly code generated from this source. Your assembly should access the assembly-equivalent symbols which are detailed in 20.1 Mixing Assembly Language and C Variables and Functions.
Instruct the assembler that the symbol is defined elsewhere by using the
.global
assembler directive. This is the assembly equivalent of a C
declaration, although no type information is present. This directive is not needed and
should not be used if the symbol is defined in the same module as your assembly code.
Any C variable accessed from assembly code will be treated as if it were
qualified volatile
(see 9.9.2 Volatile Type Qualifier). Specifying the
volatile
qualifier in C code is preferred as it makes it clear that
external code may access the object.