466
|
1 <chapter>
|
|
2 <title>Characteristics of Compiled Programs</title>
|
|
3
|
|
4 <section>
|
|
5 <title>The Object Code Module</title>
|
|
6 <para>
|
468
|
7 The compiler produces position-independent, reentrant 6809 code
|
|
8 in a standard OS-9 memory module format. The format of an executable
|
|
9 program module is shown below. Detailed descriptions of each
|
|
10 section of the module are given on following pages.
|
466
|
11 </para>
|
468
|
12 <informalfigure>
|
|
13 <screen>
|
|
14 Module
|
|
15 Offset
|
466
|
16
|
468
|
17 +-------------------------------+
|
|
18 ! !
|
|
19 ! Module Header !
|
|
20 ! !
|
|
21 !-------------------------------!
|
|
22 ! Execution Offset !
|
|
23 !-------------------------------!
|
|
24 ! Permanent Storage Size !
|
|
25 !-------------------------------!
|
|
26 ! Data-text Reference Count !
|
|
27 v v
|
|
28 : Data-text Reference Offsets :
|
|
29 ^ ^
|
|
30 </screen>
|
|
31 </informalfigure>
|
466
|
32 <section>
|
468
|
33 <title>Module Header</title>
|
466
|
34 <para>
|
468
|
35 This is a standard module header with the type/language byte set to
|
|
36 $11 (Program + 6809 Object Code), and the attribute/revision byte
|
|
37 set to $81 (Reentrant + 1).
|
466
|
38 </para>
|
|
39 </section>
|
530
|
40
|
|
41 <section>
|
|
42 <title>Execution Offset</title>
|
|
43 <para>
|
|
44 </para>
|
|
45 </section>
|
|
46
|
|
47 <section>
|
|
48 <title>Storage Size</title>
|
|
49 <para>
|
|
50 </para>
|
|
51 </section>
|
|
52
|
|
53 <section>
|
|
54 <title>Module Name</title>
|
|
55 <para>
|
|
56 </para>
|
|
57 </section>
|
|
58
|
|
59 <section>
|
|
60 <title>Information</title>
|
|
61 <para>
|
|
62 </para>
|
|
63 </section>
|
|
64
|
|
65 <section>
|
|
66 <title>Executable Code</title>
|
|
67 <para>
|
|
68 </para>
|
|
69 </section>
|
|
70
|
|
71 <section>
|
|
72 <title>String Literals</title>
|
|
73 <para>
|
|
74 </para>
|
|
75 </section>
|
|
76
|
|
77 <section>
|
|
78 <title>Initializing Data and its Size</title>
|
|
79 <para>
|
|
80 </para>
|
|
81 </section>
|
|
82
|
|
83 <section>
|
|
84 <title>Data References</title>
|
|
85 <para>
|
|
86 </para>
|
|
87 </section>
|
|
88 </section>
|
|
89
|
|
90 <section>
|
|
91 <title>Memory Management</title>
|
|
92 <para>
|
|
93 The C compiler and its support programs have default conditions
|
|
94 such that the average programmer need not be concerned with details
|
|
95 of memory management. However, there are situations where advanced
|
|
96 programmers may wish to tailor the storage allocation of a program
|
|
97 for special situations. The following information explains in
|
|
98 detail how a C program's data area is allocated and used.
|
|
99 </para>
|
|
100
|
|
101 <section>
|
|
102 <title>Typical C Program Memory Map</title>
|
|
103 <para>
|
|
104 </para>
|
|
105 </section>
|
|
106
|
|
107 <section>
|
|
108 <title>Compile Time Memory Allocation</title>
|
|
109 <para>
|
|
110 </para>
|
565
|
111 <para>
|
|
112 The following rules can serve as a rough guide to estimate how
|
|
113 much memory to specify:
|
|
114 </para>
|
|
115 <orderedlist>
|
|
116 <listitem><para>
|
|
117 The parameter area should be large enough for any anticipated
|
|
118 command line string.
|
|
119 </para></listitem>
|
|
120 <listitem><para>
|
|
121 The stack should not be less than 128 bytes and should take
|
|
122 into account the depth of function calling chains and any
|
|
123 recursion.
|
|
124 </para></listitem>
|
|
125 <listitem><para>
|
|
126 All function arguments and local variables occupy stack space
|
|
127 and each function entered needs 4 bytes more for the return
|
|
128 address and temporary storage of the calling function's register
|
|
129 variable.
|
|
130 </para></listitem>
|
|
131 <listitem><para>
|
|
132 Free memory is requested by the Standard Library I/O
|
|
133 functions for buffers at the rate of 256 bytes per accessed
|
|
134 file. The does not apply to the lower level service request I/O
|
|
135 functions such as "open()", "read()" or "write()" not to
|
|
136 "stderr" which is always un-buffered, but it does apply to both
|
|
137 "stdin" and "stdout" (see the Standard Library documentation).
|
|
138 </para></listitem>
|
|
139 </orderedlist>
|
|
140 <para>
|
|
141 A good method for getting a feel for how much memory is
|
|
142 needed by your program is to allow the linker to set the memory size
|
|
143 to its usually conservative value. Then, if the program runs
|
|
144 with a variety of input satisfactorily but memory is limited on the
|
|
145 system, try reducing the allocation at the next compilation. If a
|
|
146 stack overflow occurs or an "ibrk()" call returns -1, then try
|
|
147 increasing the memory next time. You cannot damage the system by
|
|
148 getting it wrong, but data may be lost if the program runs out of
|
|
149 space at a crucial time. It pays to be in error on the generous
|
|
150 side.
|
|
151 </para>
|
530
|
152 </section>
|
468
|
153 </section>
|
466
|
154 </chapter>
|