User`s manual

Dynamic C Users Manual digi.com 3
Table of Contents
1. Installing Dynamic C ......................................... 9
1.1 Requirements .............................................. 9
1.2 Assumptions ............................................... 9
2. Introduction to Dynamic C.............................. 11
2.1 The Nature of Dynamic C ........................ 11
2.1.1 Speed............................................ 11
2.2 Dynamic C Enhancements and Differences .
12
2.3 Rabbit and Z180 Comparison................... 14
3. Quick Tutorial ................................................... 15
3.1 Run DEMO1.C ......................................... 16
3.1.1 Single Stepping ............................ 17
3.1.2 Watch Expression......................... 17
3.1.3 Breakpoint.................................... 17
3.1.4 Editing the Program ..................... 18
3.2 Run DEMO2.C ......................................... 18
3.2.1 Watching Variables Dynamically. 18
3.3 Run DEMO3.C ......................................... 19
3.3.1 Cooperative Multitasking............. 19
3.4 Run DEMO4.C ......................................... 20
3.4.1 Trace Macros................................ 21
3.5 Summary of Features................................ 22
4. Language............................................................ 23
4.1 C Language Elements............................... 23
4.2 Punctuation Tokens................................... 24
4.3 Data........................................................... 25
4.3.1 Data Type Limits.......................... 25
4.4 Names ....................................................... 26
4.5 Macros ...................................................... 27
4.5.1 Macro Operators # and ##............ 27
4.5.2 Nested Macro Definitions ............ 28
4.5.3 Macro Restrictions ....................... 29
4.6 Numbers.................................................... 29
4.7 Strings and Character Data ....................... 30
4.7.1 String Concatenation.................... 30
4.7.2 Character Constants ..................... 31
4.8 Statements................................................. 32
4.9 Declarations .............................................. 32
4.10 Functions.................................................. 33
4.11 Prototypes................................................. 33
4.12 Type Definitions....................................... 34
4.13 Aggregate Data Types.............................. 35
4.13.1 Array .......................................... 35
4.13.2 Structure ..................................... 36
4.13.3 Union.......................................... 36
4.13.4 Composites................................. 36
4.14 Storage Classes ........................................ 37
4.15 Pointers .................................................... 37
4.16 Pointers to Functions, Indirect Calls........ 38
4.17 Argument Passing.................................... 39
4.18 Program Flow .......................................... 40
4.18.1 Loops ......................................... 40
4.18.2 Continue and Break ................... 41
4.18.3 Branching................................... 42
4.19 Function Chaining ................................... 44
4.20 Global Initialization................................. 45
4.21 Libraries................................................... 46
4.21.1 LIB.DIR ..................................... 47
4.22 Headers .................................................... 47
4.23 Modules ................................................... 47
4.23.1 The Parts of a Module................ 48
4.23.2 Module Sample Code................. 50
4.23.3 Important Notes ......................... 51
4.24 Function Description Headers ................. 52
4.25 Support Files............................................ 52
5. Multitasking with Dynamic C ........................ 53
5.1 Cooperative Multitasking ......................... 53
5.2 A Real-Time Problem............................... 54
5.2.1 Solving the Real-Time Problem
with a State Machine ......................... 55
5.3 Costatements ............................................ 56
5.3.1 Solving the Real-Time Problem
with Costatements ............................. 56
5.3.2 Costatement Syntax ..................... 57
5.3.3 Control Statements....................... 57
5.4 Advanced Costatement Topics ................. 59
5.4.1 The CoData Structure .................. 59
5.4.2 CoData Fields .............................. 60
5.4.3 Pointer to CoData Structure......... 61
5.4.4 Functions for Use With Named
Costatements ..................................... 61
5.4.5 Firsttime Functions ...................... 62
5.4.6 Shared Global Variables............... 62
5.5 Cofunctions .............................................. 62
5.5.1 Cofunction Syntax ....................... 62
5.5.2 Calling Restrictions...................... 63
5.5.3 CoData Structure.......................... 64
5.5.4 Firsttime Functions ...................... 64
5.5.5 Types of Cofunctions ................... 64
5.5.6 Types of Cofunction Calls ........... 66
5.5.7 Special Code Blocks .................... 67
5.5.8 Solving the Real-Time Problem
with Cofunctions ............................... 68