Mercurial > hg-old > index.cgi
comparison doc/manual/x487.html @ 398:7987ee447833 3.0-beta1
Added generated files for release
author | lost@l-w.ca |
---|---|
date | Fri, 23 Jul 2010 17:18:52 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
397:09fe7c40a082 | 398:7987ee447833 |
---|---|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> | |
2 <HTML | |
3 ><HEAD | |
4 ><TITLE | |
5 >Structures</TITLE | |
6 ><META | |
7 NAME="GENERATOR" | |
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK | |
9 REL="HOME" | |
10 TITLE="LW Tool Chain" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="LWASM" | |
14 HREF="c43.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="Macros" | |
17 HREF="x465.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="Object Files and Sections" | |
20 HREF="x507.html"></HEAD | |
21 ><BODY | |
22 CLASS="SECTION" | |
23 BGCOLOR="#FFFFFF" | |
24 TEXT="#000000" | |
25 LINK="#0000FF" | |
26 VLINK="#840084" | |
27 ALINK="#0000FF" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
31 SUMMARY="Header navigation table" | |
32 WIDTH="100%" | |
33 BORDER="0" | |
34 CELLPADDING="0" | |
35 CELLSPACING="0" | |
36 ><TR | |
37 ><TH | |
38 COLSPAN="3" | |
39 ALIGN="center" | |
40 >LW Tool Chain</TH | |
41 ></TR | |
42 ><TR | |
43 ><TD | |
44 WIDTH="10%" | |
45 ALIGN="left" | |
46 VALIGN="bottom" | |
47 ><A | |
48 HREF="x465.html" | |
49 ACCESSKEY="P" | |
50 >Prev</A | |
51 ></TD | |
52 ><TD | |
53 WIDTH="80%" | |
54 ALIGN="center" | |
55 VALIGN="bottom" | |
56 >Chapter 3. LWASM</TD | |
57 ><TD | |
58 WIDTH="10%" | |
59 ALIGN="right" | |
60 VALIGN="bottom" | |
61 ><A | |
62 HREF="x507.html" | |
63 ACCESSKEY="N" | |
64 >Next</A | |
65 ></TD | |
66 ></TR | |
67 ></TABLE | |
68 ><HR | |
69 ALIGN="LEFT" | |
70 WIDTH="100%"></DIV | |
71 ><DIV | |
72 CLASS="SECTION" | |
73 ><H1 | |
74 CLASS="SECTION" | |
75 ><A | |
76 NAME="AEN487" | |
77 >3.8. Structures</A | |
78 ></H1 | |
79 ><P | |
80 > Structures are used to group related data in a fixed structure. A structure | |
81 consists a number of fields, defined in sequential order and which take up | |
82 specified size. The assembler does not enforce any means of access within a | |
83 structure; it assumes that whatever you are doing, you intended to do. | |
84 There are two pseudo ops that are used for defining structures. </P | |
85 ><P | |
86 ></P | |
87 ><DIV | |
88 CLASS="VARIABLELIST" | |
89 ><DL | |
90 ><DT | |
91 ><CODE | |
92 CLASS="PARAMETER" | |
93 >structname</CODE | |
94 > STRUCT</DT | |
95 ><DD | |
96 ><P | |
97 > This directive is used to begin the definition of a structure with name | |
98 <CODE | |
99 CLASS="PARAMETER" | |
100 >structname</CODE | |
101 >. Subsequent statements all form part of | |
102 the structure definition until the end of the structure is declared. </P | |
103 ></DD | |
104 ><DT | |
105 >ENDSTRUCT</DT | |
106 ><DD | |
107 ><P | |
108 >This directive ends the definition of the structure.</P | |
109 ></DD | |
110 ></DL | |
111 ></DIV | |
112 ><P | |
113 > Within a structure definition, only reservation pseudo ops are permitted. | |
114 Anything else will cause an assembly error.</P | |
115 ><P | |
116 > Once a structure is defined, you can reserve an area of memory in the | |
117 same structure by using the structure name as the opcode. Structures can | |
118 also contain fields that are themselves structures. See the example | |
119 below.</P | |
120 ><PRE | |
121 CLASS="PROGRAMLISTING" | |
122 >tstruct2 STRUCT | |
123 f1 rmb 1 | |
124 f2 rmb 1 | |
125 ENDSTRUCT | |
126 | |
127 tstruct STRUCT | |
128 field1 rmb 2 | |
129 field2 rmb 3 | |
130 field3 tstruct2 | |
131 ENDSTRUCT | |
132 | |
133 ORG $2000 | |
134 var1 tstruct | |
135 var2 tstruct2</PRE | |
136 ><P | |
137 >Fields are referenced using a dot (.) as a separator. To refer to the | |
138 generic offset within a structure, use the structure name to the left of the | |
139 dot. If referring to a field within an actual variable, use the variable's | |
140 symbol name to the left of the dot.</P | |
141 ><P | |
142 >You can also refer to the actual size of a structure (or a variable | |
143 declared as a structure) using the special symbol sizeof{structname} where | |
144 structname will be the name of the structure or the name of the | |
145 variable.</P | |
146 ><P | |
147 >Essentially, structures are a shortcut for defining a vast number of | |
148 symbols. When a structure is defined, the assembler creates symbols for the | |
149 various fields in the form structname.fieldname as well as the appropriate | |
150 sizeof{structname} symbol. When a variable is declared as a structure, the | |
151 assembler does the same thing using the name of the variable. You will see | |
152 these symbols in the symbol table when the assembler is instructed to | |
153 provide a listing. For instance, the above listing will create the | |
154 following symbols (symbol values in parentheses): tstruct2.f1 (0), | |
155 tstruct2.f2 (1), sizeof{tstruct2} (2), tstruct.field1 (0), tstruct.field2 | |
156 (2), tstruct.field3 (5), tstruct.field3.f1 (5), tstruct.field3.f2 (6), | |
157 sizeof{tstruct.field3} (2), sizeof{tstruct} (7), var1 {$2000}, var1.field1 | |
158 {$2000}, var1.field2 {$2002}, var1.field3 {$2005}, var1.field3.f1 {$2005}, | |
159 var1.field3.f2 {$2006}, sizeof(var1.field3} (2), sizeof{var1} (7), var2 | |
160 ($2007), var2.f1 ($2007), var2.f2 ($2008), sizeof{var2} (2). </P | |
161 ></DIV | |
162 ><DIV | |
163 CLASS="NAVFOOTER" | |
164 ><HR | |
165 ALIGN="LEFT" | |
166 WIDTH="100%"><TABLE | |
167 SUMMARY="Footer navigation table" | |
168 WIDTH="100%" | |
169 BORDER="0" | |
170 CELLPADDING="0" | |
171 CELLSPACING="0" | |
172 ><TR | |
173 ><TD | |
174 WIDTH="33%" | |
175 ALIGN="left" | |
176 VALIGN="top" | |
177 ><A | |
178 HREF="x465.html" | |
179 ACCESSKEY="P" | |
180 >Prev</A | |
181 ></TD | |
182 ><TD | |
183 WIDTH="34%" | |
184 ALIGN="center" | |
185 VALIGN="top" | |
186 ><A | |
187 HREF="index.html" | |
188 ACCESSKEY="H" | |
189 >Home</A | |
190 ></TD | |
191 ><TD | |
192 WIDTH="33%" | |
193 ALIGN="right" | |
194 VALIGN="top" | |
195 ><A | |
196 HREF="x507.html" | |
197 ACCESSKEY="N" | |
198 >Next</A | |
199 ></TD | |
200 ></TR | |
201 ><TR | |
202 ><TD | |
203 WIDTH="33%" | |
204 ALIGN="left" | |
205 VALIGN="top" | |
206 >Macros</TD | |
207 ><TD | |
208 WIDTH="34%" | |
209 ALIGN="center" | |
210 VALIGN="top" | |
211 ><A | |
212 HREF="c43.html" | |
213 ACCESSKEY="U" | |
214 >Up</A | |
215 ></TD | |
216 ><TD | |
217 WIDTH="33%" | |
218 ALIGN="right" | |
219 VALIGN="top" | |
220 >Object Files and Sections</TD | |
221 ></TR | |
222 ></TABLE | |
223 ></DIV | |
224 ></BODY | |
225 ></HTML | |
226 > |