Content
II
Conditional inclusion : #ifndef.......................................................................................................... 17
Conditional inclusion : #elif.............................................................................................................. 18
Conditional inclusion : defined.......................................................................................................... 18
#undef ................................................................................................................................................ 18
File inclusion: #include..................................................................................................................... 19
LANGUAGE EXTENSIONS AND RESTRICTIONS.......................................................................................... 19
Keywords ........................................................................................................................................... 19
Memory bank ..................................................................................................................................... 19
Bit data type....................................................................................................................................... 20
Inline assembly .................................................................................................................................. 20
Interrupts ........................................................................................................................................... 21
Variables............................................................................................................................................ 22
Static Variables.................................................................................................................................. 22
Constants ........................................................................................................................................... 22
Functions ........................................................................................................................................... 22
Arrays ................................................................................................................................................ 22
Constant variables............................................................................................................................. 23
Pointer ............................................................................................................................................... 23
Initial value........................................................................................................................................ 23
Multiply/Divide/Modulus................................................................................................................... 24
Built-in Function................................................................................................................................ 25
Stack................................................................................................................................................... 26
MIXED LANGUAGE.............................................................................................................................. 28
LITTLE ENDIAN ....................................................................................................................................... 28
NAMING RULE OF FUNCTION AND PARAMETERS ...................................................................................... 28
Global variable.................................................................................................................................. 29
Local variable.................................................................................................................................... 29
Function............................................................................................................................................. 30
Function parameters.......................................................................................................................... 30
PARAMETER PASSING.............................................................................................................................. 30
RETURN VALUE....................................................................................................................................... 31
PRESERVING REGISTERS.......................................................................................................................... 31
CALLING ASSEMBLY FUNCTION FROM C PROGRAM ................................................................................. 31
CALLING C FUNCTION FROM ASSEMBLY PROGRAM................................................................................. 32
PROGRAMMING ISR WITH ASSEMBLY LANGUAGE ................................................................................... 34
PROGRAMMING WITH C LANGUAGE........................................................................................... 36
START A C PROGRAM ............................................................................................................................. 36
DEFINE THE INTERRUPT SERVICE ROUTINES........................................................................................... 37
Declare the name and address of ISR in C source file ...................................................................... 37
Define the ISR in C source file........................................................................................................... 37
Restriction.......................................................................................................................................... 37
DEFINE TABLES AND SYMBOLS IN PROGRAM MEMORY.......................................................................... 38
DEFINE VARIABLES IN DATA MEMORY................................................................................................... 40
Specify Address to a Variable............................................................................................................ 40
Access Variables in Multiple RAM Banks..........................................................................................40
Specify Variables In RAM Bank 0 (Improve the Performance)......................................................... 41
Pointer boundary............................................................................................................................... 42
Access the LCD data area.................................................................................................................. 42
MCU SPECIAL FUNCTION REGISTERS..................................................................................................... 43
Access the function registers.............................................................................................................. 43
Access the IO ports............................................................................................................................ 45
BUILT-IN FUNCTIONS .............................................................................................................................. 45
Assembly-like built-in functions......................................................................................................... 46