annotate docs/ccguide/asm.appendix @ 2538:f87ec0b216c8

Enabled automatic string detection in the disassembler.
author lothan
date Tue, 11 May 2010 05:45:21 +0000
parents 06e11c941478
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
1 <appendix>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
2 <title>Relocating Macro Assembler Reference</title>
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
3 <para>
468
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
4 This appendix gives a summary of the operation of the "Relocating
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
5 Macro Assembler" (named c.asm as distributed with the C Compiler).
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
6 This appendix and the example assembly source files supplied with
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
7 the C compiler should provide the basic information on how to use the
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
8 "Relocating Macro Assembler" to create relocatable-object format
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
9 files (ROF). It is further assumed that you are familiar with the
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
10 6809 instruction set and mnemonics. See the Microware Relocating
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
11 Assembler Manual for a more detailed description. The main function
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
12 of this appendix is to enable the reader to understand the output
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
13 produced by c.asm. The Relocating Macro Assembler allows programs
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
14 to be compiled separately and then linked together, and it also
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
15 allows macros to be defined within programs.
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
16 </para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
17 <para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
18 Differences between the Relocating Macro Assembler (RMA) and the
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
19 Microware Interactive Assembler (MIA):
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
20 </para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
21 <blockquote>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
22 <para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
23 RMA does not have an interactive mode. Only a disk file is
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
24 allowed as input.
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
25 </para>
468
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
26 <para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
27 RMA output is an ROF file. The ROF file must be processed by
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
28 the linker to produce an executable OS9 memory module. The
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
29 layout of the ROF file is described later.
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
30 </para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
31 <para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
32 RMA has a number of new directives to control the placement of
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
33 code and data in the executable module. Since RMA does not
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
34 produce memory modules, the MIA directives "mod" and "emod" are
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
35 not present. Instead, new directives PSECT and VSECT control
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
36 the allocation of code and data areas by the linker.
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
37 </para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
38 <para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
39 RMA has no equivalent to the MIA "setdp" directive. Data (and
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
40 DP) allocation is handled by the linker.
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
41 </para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
42 </blockquote>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
43 <section>
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
44 <title>Symbolic Names</title>
468
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
45 <para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
46 A symbolic name is valid if it consists of from one to nine
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
47 uppercase or lowercase characters, decimal digits or the characters
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
48 "$", "_", "." or "@". RMA does not fold lowercase letters to
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
49 uppercase. The names "Hi.you" and "HI.YOU" are distinct names.
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
50 </para>
60b821f18853 A little here and there.
roug
parents: 466
diff changeset
51 </section>
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
52
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
53 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
54 <title>Label field</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
55 <para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
56 If a symbolic name in the label field of a source statement is
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
57 followed by a <quote>:</quote> (colon), the name will be known
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
58 <emphasis>globally</emphasis> (by all modules linked together).
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
59 If no colon appears, the name will be known only in the PSECT
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
60 in which it was defined. PSECT will be described later.
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
61 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
62 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
63
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
64 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
65 <title>Undefined names</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
66 <para>
651
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
67 If a symbolic name is used in an expression and hasn't been defined,
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
68 RMA assumes the name is external to the PSECT. RMA will record
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
69 information about the reference so the linker can adjust the operand
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
70 accordingly. External names cannot appear in operand expressions
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
71 for assembler directives.
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
72 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
73 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
74
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
75 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
76 <title>Listing format</title>
651
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
77 <programlisting>
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
78 00098 0032 59 + rolb
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
79 00117 0045=17ffb8 label lbsr _dmove Comment
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
80 ^ ^ ^^ ^ ^ ^ ^ ^
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
81 | | || | | | | Start of comment
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
82 | | || | | | Start of operand
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
83 | | || | | Start of mnemonic
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
84 | | || | Start of label
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
85 | | || A "+" indicates a line generated by a macro
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
86 | | || expansion.
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
87 | | |Start of object code bytes.
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
88 | | An "=" here indicates that the operand contains an
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
89 | | external reference.
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
90 | Location counter value
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
91 Line number.
ac4142f99b21 Appendix C is finished
roug
parents: 633
diff changeset
92 </programlisting>
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
93 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
94
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
95 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
96 <title>Section Location Counters</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
97 <para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
98 Each section contains the following location counters:
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
99 </para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
100 <variablelist termlength="5">
06e11c941478 Completely finished
roug
parents: 651
diff changeset
101 <varlistentry><term>PSECT</term>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
102 <listitem><literallayout>instruction location counter</literallayout>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
103 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
104 </varlistentry>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
105 <varlistentry><term>VSECT</term>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
106 <listitem><literallayout>initialized direct page location counter
06e11c941478 Completely finished
roug
parents: 651
diff changeset
107 non-initialized direct page location counter
06e11c941478 Completely finished
roug
parents: 651
diff changeset
108 initialized data location counter
06e11c941478 Completely finished
roug
parents: 651
diff changeset
109 non-initialized data location counter</literallayout>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
110 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
111 </varlistentry>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
112 <varlistentry><term>CSECT</term>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
113 <listitem><literallayout>base offset counter</literallayout>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
114 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
115 </varlistentry>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
116 </variablelist>
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
117 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
118
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
119 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
120 <title>Section Directives</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
121 <para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
122 RMA contains 3 section directives. PSECT indicates to the linker
06e11c941478 Completely finished
roug
parents: 651
diff changeset
123 the beginning of a relocatable-object-format file (<acronym>ROF</acronym>) and
06e11c941478 Completely finished
roug
parents: 651
diff changeset
124 initializes the instruction and data location counters and assembles
06e11c941478 Completely finished
roug
parents: 651
diff changeset
125 code into the <acronym>ROF</acronym> object code area. VSECT causes RMA to change to
06e11c941478 Completely finished
roug
parents: 651
diff changeset
126 the data location counters and place any generated code into the
06e11c941478 Completely finished
roug
parents: 651
diff changeset
127 appropiate <acronym>ROF</acronym> data area. CSECT initializes a base value for
06e11c941478 Completely finished
roug
parents: 651
diff changeset
128 assigning offsets to symbols. The end of these sections is indicated by the
06e11c941478 Completely finished
roug
parents: 651
diff changeset
129 ENDSECT directive.
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
130 </para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
131 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
132 The source statements placed in a particular section cause the
06e11c941478 Completely finished
roug
parents: 651
diff changeset
133 linker to perform a function appropiate for the statement.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
134 Therefore, the mnemonics allowed within a section are restricted as
06e11c941478 Completely finished
roug
parents: 651
diff changeset
135 follows:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
136 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
137 <itemizedlist>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
138 <listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
139 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
140 The mnemonics are allowed inside or outside any section: nam,
06e11c941478 Completely finished
roug
parents: 651
diff changeset
141 opt, ttl, pag, spc, use, fail, rept, endr, ifeq, ifne, iflt,
06e11c941478 Completely finished
roug
parents: 651
diff changeset
142 ifle, ifge, ifgt, ifpl, endc, else, equ, set, macro, endm,
06e11c941478 Completely finished
roug
parents: 651
diff changeset
143 csect, and endsect.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
144 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
145 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
146 <listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
147 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
148 Within a CSECT: rmb
06e11c941478 Completely finished
roug
parents: 651
diff changeset
149 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
150 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
151 <listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
152 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
153 Within a PSECT: any 6809 instruction mnemonic, fcc, fdb,fcs,
06e11c941478 Completely finished
roug
parents: 651
diff changeset
154 fcb, rzb, vsect, endsect, os9 and end.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
155 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
156 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
157 <listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
158 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
159 Within a VSECT: rmb, fcc, fdb, fcs, fcb, rzb and endsect.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
160 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
161 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
162 </itemizedlist>
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
163 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
164 <title>PSECT Directive</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
165 <para>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
166 The main difference between PSECT and MOD is that MOD sets up
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
167 information for OS-9 and PSECT sets up information for the
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
168 linker (c.link in the C compiler).
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
169 </para>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
170 <informalexample>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
171 <para>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
172 PSECT {name,typelang,attrrev,edition,stacksize,entrypoint}
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
173 </para>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
174 <informaltable frame="none">
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
175 <tgroup cols="2">
633
14e792902588 Convert to Docbook XML format
roug
parents: 563
diff changeset
176 <colspec colwidth="0.8in"/>
14e792902588 Convert to Docbook XML format
roug
parents: 563
diff changeset
177 <colspec colwidth="3.2in"/>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
178 <tbody>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
179 <row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
180 <entry>name</entry>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
181 <entry>Up to 20 bytes (any printable character except space
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
182 or comma) for a name to be used by the linker to
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
183 identify this PSECT. This name need not be distinct
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
184 from all other PSECTs linked together, but it helps
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
185 to identify PSECTs the linker has a problem with if
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
186 the names are different.</entry>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
187 </row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
188 <row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
189 <entry>typelang</entry>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
190 <entry>byte expression for the executable module type/language
06e11c941478 Completely finished
roug
parents: 651
diff changeset
191 byte. If this PSECT is not a "mainline"
06e11c941478 Completely finished
roug
parents: 651
diff changeset
192 (a module that has been designed to be forked to) module
06e11c941478 Completely finished
roug
parents: 651
diff changeset
193 this byte must be zero.</entry>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
194 </row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
195 <row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
196 <entry>attrrev</entry>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
197 <entry>byte expression for executable module attribute/revision byte.</entry>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
198 </row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
199 <row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
200 <entry>edition</entry>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
201 <entry>byte expression for executable module edition byte.</entry>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
202 </row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
203 <row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
204 <entry>stacksize</entry>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
205 <entry>word expression estimating the amount of stack storage
06e11c941478 Completely finished
roug
parents: 651
diff changeset
206 required by this psect. The linker totals this
06e11c941478 Completely finished
roug
parents: 651
diff changeset
207 value in all PSECTs to appear in the executable module and
06e11c941478 Completely finished
roug
parents: 651
diff changeset
208 adds this value to any data storage requirement
06e11c941478 Completely finished
roug
parents: 651
diff changeset
209 for the entire program.</entry>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
210 </row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
211 <row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
212 <entry>entrypoint</entry>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
213 <entry>word expression entrypoint offset for this PSECT.
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
214 If the PSECT is not a mainline odule, this should
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
215 be set to zero.</entry>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
216 </row>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
217 </tbody>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
218 </tgroup>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
219 </informaltable>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
220 </informalexample>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
221 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
222 PSECT must have either no operand list or an operand list
06e11c941478 Completely finished
roug
parents: 651
diff changeset
223 containing a name and five expressions. If no operand list is
06e11c941478 Completely finished
roug
parents: 651
diff changeset
224 provided, the PSECT name defaults to "program" and all other
06e11c941478 Completely finished
roug
parents: 651
diff changeset
225 expressions to zero. The can only be one PSECT per assembly
06e11c941478 Completely finished
roug
parents: 651
diff changeset
226 language file.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
227 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
228 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
229 The PSECT directive initializes all counter orgs and marks the
06e11c941478 Completely finished
roug
parents: 651
diff changeset
230 start of the program module. No VSECT data reservations or
06e11c941478 Completely finished
roug
parents: 651
diff changeset
231 object code may appear before or after the PSECT/ENDSECT block.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
232 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
233 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
234 Example:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
235 <programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
236 psect myprog,Prgrm+Objct,Reent+1,Edit,0,progent
06e11c941478 Completely finished
roug
parents: 651
diff changeset
237 psect another_prog,0,0,0,0,0
06e11c941478 Completely finished
roug
parents: 651
diff changeset
238 </programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
239 </para>
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
240 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
241
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
242 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
243 <title>VSECT Directive</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
244 <para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
245 VSECT {DP}
06e11c941478 Completely finished
roug
parents: 651
diff changeset
246 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
247 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
248 The VSECT directive causes RMA to change to the data location
06e11c941478 Completely finished
roug
parents: 651
diff changeset
249 counters. If DP appears after VSECT, the direct page counters are
06e11c941478 Completely finished
roug
parents: 651
diff changeset
250 used, otherwise the non-direct page data is used. The RMB directive
06e11c941478 Completely finished
roug
parents: 651
diff changeset
251 within this section reserves the specified number of bytes in the
06e11c941478 Completely finished
roug
parents: 651
diff changeset
252 appropiate uninitialized data section. The fcc, fdb, fcs, fcb and
06e11c941478 Completely finished
roug
parents: 651
diff changeset
253 rzb (reserve zeroed bytes) directives place data into the
06e11c941478 Completely finished
roug
parents: 651
diff changeset
254 appropiate initialized data section. If an operand for fdb or fcb
06e11c941478 Completely finished
roug
parents: 651
diff changeset
255 contains an external reference, this information is placed in the
06e11c941478 Completely finished
roug
parents: 651
diff changeset
256 external reference part of the ROF to be adjusted at link or
06e11c941478 Completely finished
roug
parents: 651
diff changeset
257 execution time. ENDSECT marks the end of the VSECT block. Any
06e11c941478 Completely finished
roug
parents: 651
diff changeset
258 number of VSECT blocks can appear within a PSECT. Note, however,
06e11c941478 Completely finished
roug
parents: 651
diff changeset
259 that the data location counters maintain their values between one
06e11c941478 Completely finished
roug
parents: 651
diff changeset
260 VSECT block and the next. Since the linker handles the actual data
06e11c941478 Completely finished
roug
parents: 651
diff changeset
261 allocation, there is no facility provided to adjust the data
06e11c941478 Completely finished
roug
parents: 651
diff changeset
262 location counters.
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
263 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
264 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
265
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
266 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
267 <title>CSECT Directive</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
268 <para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
269 CSECT {expression}
06e11c941478 Completely finished
roug
parents: 651
diff changeset
270 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
271 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
272 The CSECT directive provides a means for assigning consecutive
06e11c941478 Completely finished
roug
parents: 651
diff changeset
273 offsets to labels without resorting to EQUs. If the expression is
06e11c941478 Completely finished
roug
parents: 651
diff changeset
274 present, the CSECT base counter is set to that value, otherwise it
06e11c941478 Completely finished
roug
parents: 651
diff changeset
275 is set to zero.
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
276 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
277 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
278
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
279 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
280 <title>RZB statement</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
281 <para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
282 RZB &lt;expression&gt;
06e11c941478 Completely finished
roug
parents: 651
diff changeset
283 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
284 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
285 The reserve zeroed bytes pseudo-instruction generates sequences of
06e11c941478 Completely finished
roug
parents: 651
diff changeset
286 zero bytes in the code or initialized data sections, the number of
06e11c941478 Completely finished
roug
parents: 651
diff changeset
287 which is specified by the expression.
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
288 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
289 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
290 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
291
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
292 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
293 <title>Comparison Between Assembly Programs for the Microware Interactive Assember
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
294 and the Relocating Macro Assembler</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
295 <para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
296 The following two program examples simply fork a BASIC09. The
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
297 purpose of the examples are to show some of the differences in the
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
298 new relocating assembler. The differences are apparent.
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
299 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
300 <programlisting>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
301 * this program forks a basic09
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
302 ifp1
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
303 use ..../defs/os9defs.a
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
304 endc
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
305
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
306 PRGRM equ $10
06e11c941478 Completely finished
roug
parents: 651
diff changeset
307 OBJCT equ $01
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
308
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
309 stk equ 200
06e11c941478 Completely finished
roug
parents: 651
diff changeset
310 psect rmatest,$11,$81,0,stk,entry
06e11c941478 Completely finished
roug
parents: 651
diff changeset
311
06e11c941478 Completely finished
roug
parents: 651
diff changeset
312 name fcs /basic09/
06e11c941478 Completely finished
roug
parents: 651
diff changeset
313 prm fcb $D
06e11c941478 Completely finished
roug
parents: 651
diff changeset
314 prmsize equ *-prm
06e11c941478 Completely finished
roug
parents: 651
diff changeset
315
06e11c941478 Completely finished
roug
parents: 651
diff changeset
316 entry leax name,pcr
06e11c941478 Completely finished
roug
parents: 651
diff changeset
317 leau prm,pcr
06e11c941478 Completely finished
roug
parents: 651
diff changeset
318 ldy #prmsize
06e11c941478 Completely finished
roug
parents: 651
diff changeset
319 lda #PRGRM+OBJCT
06e11c941478 Completely finished
roug
parents: 651
diff changeset
320 clrb
06e11c941478 Completely finished
roug
parents: 651
diff changeset
321 os9 F$FORK
06e11c941478 Completely finished
roug
parents: 651
diff changeset
322 os9 F$WAIT
06e11c941478 Completely finished
roug
parents: 651
diff changeset
323 os9 F$EXIT
06e11c941478 Completely finished
roug
parents: 651
diff changeset
324 endsect
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
325 </programlisting>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
326 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
327 <title>Macro Interactive Assembler Source</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
328 <programlisting>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
329 ifp1
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
330 use defsfile
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
331 endc
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
332
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
333 mod siz,prnam,type,revs,start,size
06e11c941478 Completely finished
roug
parents: 651
diff changeset
334 prnam fcs /testshell/
06e11c941478 Completely finished
roug
parents: 651
diff changeset
335 type set prgm+objct
06e11c941478 Completely finished
roug
parents: 651
diff changeset
336 revs set reent+1
06e11c941478 Completely finished
roug
parents: 651
diff changeset
337
06e11c941478 Completely finished
roug
parents: 651
diff changeset
338 rmb 250
06e11c941478 Completely finished
roug
parents: 651
diff changeset
339 rmb 200
06e11c941478 Completely finished
roug
parents: 651
diff changeset
340 name fcs /basic09/
06e11c941478 Completely finished
roug
parents: 651
diff changeset
341 prm fcb $D
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
342 prmsize equ *-prm
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
343 size equ .
06e11c941478 Completely finished
roug
parents: 651
diff changeset
344 start equ *
06e11c941478 Completely finished
roug
parents: 651
diff changeset
345 leax name,pcr
06e11c941478 Completely finished
roug
parents: 651
diff changeset
346 leau prm,pcr
06e11c941478 Completely finished
roug
parents: 651
diff changeset
347 ldy #prmsize
06e11c941478 Completely finished
roug
parents: 651
diff changeset
348 lda #PRGRM+OBJCT
06e11c941478 Completely finished
roug
parents: 651
diff changeset
349 clrb
06e11c941478 Completely finished
roug
parents: 651
diff changeset
350 os9 F$FORK
06e11c941478 Completely finished
roug
parents: 651
diff changeset
351 os9 F$WAIT
06e11c941478 Completely finished
roug
parents: 651
diff changeset
352 os9 F$EXIT
06e11c941478 Completely finished
roug
parents: 651
diff changeset
353 emod
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
354 siz equ
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
355 </programlisting>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
356 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
357 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
358
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
359 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
360 <title>Introduction to Macros</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
361 <para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
362 In programming applications it is frequently necessary to use a
06e11c941478 Completely finished
roug
parents: 651
diff changeset
363 repeated sequence or pattern of instructions in many different
06e11c941478 Completely finished
roug
parents: 651
diff changeset
364 places in a program. For example, suppose a group of program
06e11c941478 Completely finished
roug
parents: 651
diff changeset
365 statements creates a file a number of times throughout the program.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
366 The code might look like the following statements:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
367 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
368 <screen>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
369 leax name,pcr
06e11c941478 Completely finished
roug
parents: 651
diff changeset
370 lda $02
06e11c941478 Completely finished
roug
parents: 651
diff changeset
371 ldb $03
06e11c941478 Completely finished
roug
parents: 651
diff changeset
372 os9 I$CREATE
06e11c941478 Completely finished
roug
parents: 651
diff changeset
373 </screen>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
374 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
375 The sequence must be replicated each time that a new file is
06e11c941478 Completely finished
roug
parents: 651
diff changeset
376 created. A macro assembler eliminates the need for coding duplicate
06e11c941478 Completely finished
roug
parents: 651
diff changeset
377 statement patterns by allowing the programmer to define macro
06e11c941478 Completely finished
roug
parents: 651
diff changeset
378 instructions that are equivalent to longer code sequences.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
379 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
380 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
381 When a macro is called, it is the same as calling a subrouting to
06e11c941478 Completely finished
roug
parents: 651
diff changeset
382 perform a defined function. A macro produces in-line code that is
06e11c941478 Completely finished
roug
parents: 651
diff changeset
383 inserted into the normal flow of the program beginning at the
06e11c941478 Completely finished
roug
parents: 651
diff changeset
384 location of the macro call. The statements that may be generated by
06e11c941478 Completely finished
roug
parents: 651
diff changeset
385 a macro are generally unrestricted, and the statements may contain
06e11c941478 Completely finished
roug
parents: 651
diff changeset
386 substitutable arguments.
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
387 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
388 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
389
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
390 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
391 <title>Operations</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
392
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
393 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
394 <title>Macro Definition</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
395 <para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
396 A macro definition consists of three sections:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
397 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
398 <screen>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
399 &lt;Label&gt; MACRO /* macro header */
06e11c941478 Completely finished
roug
parents: 651
diff changeset
400 . /* &lt;Label&gt; is the name of the macro */
06e11c941478 Completely finished
roug
parents: 651
diff changeset
401 .
06e11c941478 Completely finished
roug
parents: 651
diff changeset
402 body /* macro body */
06e11c941478 Completely finished
roug
parents: 651
diff changeset
403 .
06e11c941478 Completely finished
roug
parents: 651
diff changeset
404 .
06e11c941478 Completely finished
roug
parents: 651
diff changeset
405 ENDM /* macro terminator */
06e11c941478 Completely finished
roug
parents: 651
diff changeset
406 </screen>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
407 <orderedlist numeration="arabic" spacing="compact">
06e11c941478 Completely finished
roug
parents: 651
diff changeset
408 <listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
409 <para>The macro header - assigns a name to the macro</para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
410 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
411 <listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
412 <para>The body - contains the macro statements</para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
413 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
414 <listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
415 <para>The terminator - indicates the end of the macro</para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
416 </listitem>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
417 </orderedlist>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
418 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
419 A macro can have up to nine arguments (\1 to \9) in the operand
06e11c941478 Completely finished
roug
parents: 651
diff changeset
420 fields. The arguments are used to refer to symbols, registers, etc.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
421 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
422 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
423 The following macro below could represent the file creation pattern:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
424 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
425 <programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
426 CREATE MACRO
06e11c941478 Completely finished
roug
parents: 651
diff changeset
427 leax \1,pcr
06e11c941478 Completely finished
roug
parents: 651
diff changeset
428 lda $\2
06e11c941478 Completely finished
roug
parents: 651
diff changeset
429 ldb $\3
06e11c941478 Completely finished
roug
parents: 651
diff changeset
430 os9 I$CREATE
06e11c941478 Completely finished
roug
parents: 651
diff changeset
431 ENDM
06e11c941478 Completely finished
roug
parents: 651
diff changeset
432 </programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
433 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
434 Calls can be made to create files with different names, access
06e11c941478 Completely finished
roug
parents: 651
diff changeset
435 modes, and attributes as follows:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
436 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
437 <programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
438 CREATE name2,02,03
06e11c941478 Completely finished
roug
parents: 651
diff changeset
439 CREATE name3,01,02
06e11c941478 Completely finished
roug
parents: 651
diff changeset
440 </programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
441 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
442 The above macro calls will produce the following in-line code:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
443 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
444 <programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
445 leax name2, pcr
06e11c941478 Completely finished
roug
parents: 651
diff changeset
446 lda $02
06e11c941478 Completely finished
roug
parents: 651
diff changeset
447 ldb $03
06e11c941478 Completely finished
roug
parents: 651
diff changeset
448 os9 I$CREATE
06e11c941478 Completely finished
roug
parents: 651
diff changeset
449
06e11c941478 Completely finished
roug
parents: 651
diff changeset
450 leax name3, pcr
06e11c941478 Completely finished
roug
parents: 651
diff changeset
451 lda $01
06e11c941478 Completely finished
roug
parents: 651
diff changeset
452 ldb $02
06e11c941478 Completely finished
roug
parents: 651
diff changeset
453 os9 I$CREATE
06e11c941478 Completely finished
roug
parents: 651
diff changeset
454 </programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
455 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
456 If an argument has multiple parts, for example if d1,d2 is to be
06e11c941478 Completely finished
roug
parents: 651
diff changeset
457 passed to the macro called frud, it must be passed in double quotes.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
458 For example:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
459 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
460 <programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
461 frud "0,s","2,s"
06e11c941478 Completely finished
roug
parents: 651
diff changeset
462 </programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
463 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
464 If frud looks like the following macro:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
465 <programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
466 frud MACRO
06e11c941478 Completely finished
roug
parents: 651
diff changeset
467 \@ leau \1
06e11c941478 Completely finished
roug
parents: 651
diff changeset
468 ldd \2
06e11c941478 Completely finished
roug
parents: 651
diff changeset
469 beq \@
06e11c941478 Completely finished
roug
parents: 651
diff changeset
470 ENDM
06e11c941478 Completely finished
roug
parents: 651
diff changeset
471 </programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
472 The previous call to frud would expand the macro as follows:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
473 <programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
474 @xxx leau 0,s
06e11c941478 Completely finished
roug
parents: 651
diff changeset
475 ldd 2,s
06e11c941478 Completely finished
roug
parents: 651
diff changeset
476 beq @xxx
06e11c941478 Completely finished
roug
parents: 651
diff changeset
477 </programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
478 Where "\@" is a label, and "xxx" would be replaced
06e11c941478 Completely finished
roug
parents: 651
diff changeset
479 by a three digit number.
06e11c941478 Completely finished
roug
parents: 651
diff changeset
480 </para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
481 <para>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
482 An argument may be declared null by leaving it blank in the macro
06e11c941478 Completely finished
roug
parents: 651
diff changeset
483 call. For example, if the macro instruction was "ldd \1ZZ\2", then
06e11c941478 Completely finished
roug
parents: 651
diff changeset
484 the call to the macro with arguments AA,BB would expand the
06e11c941478 Completely finished
roug
parents: 651
diff changeset
485 instruction to "ldd AAZZBB", and the call with argument ,BB will
06e11c941478 Completely finished
roug
parents: 651
diff changeset
486 expand it to "ldd ZZBB".
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
487 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
488 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
489
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
490 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
491 <title>Nested Macro Calls</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
492 <para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
493 Macro calls may be nested, that is, the body of a macro definition
06e11c941478 Completely finished
roug
parents: 651
diff changeset
494 may contain a call to another macro. For example, the macro prepw
06e11c941478 Completely finished
roug
parents: 651
diff changeset
495 could be defined as follows:
06e11c941478 Completely finished
roug
parents: 651
diff changeset
496 <programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
497 prepw MACRO
06e11c941478 Completely finished
roug
parents: 651
diff changeset
498 lda \1
06e11c941478 Completely finished
roug
parents: 651
diff changeset
499 getw
06e11c941478 Completely finished
roug
parents: 651
diff changeset
500 ENDM
06e11c941478 Completely finished
roug
parents: 651
diff changeset
501 </programlisting>
06e11c941478 Completely finished
roug
parents: 651
diff changeset
502 Getw is a macro call. The code to getw is substituted in-line at
06e11c941478 Completely finished
roug
parents: 651
diff changeset
503 expansion time. However, the definition of a new macro within
06e11c941478 Completely finished
roug
parents: 651
diff changeset
504 another is not permitted. Macro calls may be nested up to eight deep.
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
505 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
506 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
507
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
508 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
509 <title>Labels</title>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
510 <para>
552
fcb97f0ba24b All diagnostics added.
roug
parents: 530
diff changeset
511 Sometimes it is necessary to use labels within a macro. Labels are
fcb97f0ba24b All diagnostics added.
roug
parents: 530
diff changeset
512 specified by <quote>\@</quote>. Each time the macro is called, a unique label
fcb97f0ba24b All diagnostics added.
roug
parents: 530
diff changeset
513 will be generated to avoid multiple definition errors. Within the
fcb97f0ba24b All diagnostics added.
roug
parents: 530
diff changeset
514 expanded code <quote>\@</quote> will take on the form <quote>@xxx</quote>, where xxx
fcb97f0ba24b All diagnostics added.
roug
parents: 530
diff changeset
515 will be a decimal number between 000 to 999.
fcb97f0ba24b All diagnostics added.
roug
parents: 530
diff changeset
516 </para>
fcb97f0ba24b All diagnostics added.
roug
parents: 530
diff changeset
517 <para>
653
06e11c941478 Completely finished
roug
parents: 651
diff changeset
518 More than one label may be specified in a macro by the addition of
06e11c941478 Completely finished
roug
parents: 651
diff changeset
519 an extra character(s). For example, if two different labels are
06e11c941478 Completely finished
roug
parents: 651
diff changeset
520 required in a macro, they can be specified by "\@A" and "\@B". In
06e11c941478 Completely finished
roug
parents: 651
diff changeset
521 the first expansion of te macro, the labels would be "@001A" and
06e11c941478 Completely finished
roug
parents: 651
diff changeset
522 "@001B", and in the second expansion they would be "@002A" and
06e11c941478 Completely finished
roug
parents: 651
diff changeset
523 "@002B". The extra characters may be appended before the "\" or
06e11c941478 Completely finished
roug
parents: 651
diff changeset
524 after the "@".
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
525 </para>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
526 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
527
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
528 <section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
529 <title>Additional Pseudo-Instructions</title>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
530 <variablelist>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
531 <varlistentry><term>\n</term>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
532 <listitem>
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
533 <para>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
534 will return the number of arguments passed to the macro.
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
535 </para>
563
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
536 </listitem>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
537 </varlistentry>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
538
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
539 <varlistentry><term>\L&lt;num&gt;</term>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
540 <listitem>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
541 <para>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
542 will return the length of the ith argument
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
543 that is specified by &lt;num&gt;.
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
544 </para>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
545 </listitem>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
546 </varlistentry>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
547
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
548 <varlistentry><term>FAIL</term>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
549 <listitem>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
550 <para>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
551 Causes an error to be generated.
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
552 </para>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
553 </listitem>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
554 </varlistentry>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
555
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
556 <varlistentry><term>REPT &lt;num&gt;</term>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
557 <listitem>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
558 <para>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
559 will repeat an instruction or group of instructions &lt;num&gt; times.
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
560 ENDR terminates REPT.
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
561 </para>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
562 </listitem>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
563 </varlistentry>
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
564
e1be1b610076 Several functions ready.
roug
parents: 552
diff changeset
565 </variablelist>
530
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
566 </section>
c43b678c0055 Mainly section structures added.
roug
parents: 468
diff changeset
567 </section>
466
bea58398bb15 Skeletons for the C Compiler User's Guide, 1983
roug
parents:
diff changeset
568 </appendix>