Imported Upstream version 2.9.0
[debian/cc1111] / as / doc / asxhtm.html
1 <HTML>
2 <HEAD>
3 <TITLE>ASxxxx Cross Assembler Documentation</TITLE>
4 </HEAD>
5 <BODY BGCOLOR="#C0C0C0">
6
7 <a href="../home.htm">
8 <IMG width=343 heigth=58 border = 0 SRC="welcom.gif"></a>
9
10 <H2>ASxxxx Cross Assembler Documentation</H2>
11
12 <IMG width=576 height=5 border=0 SRC="rnbow.gif">
13
14 <B><PRE>
15
16                               SDCCASxxxx Assemblers
17
18
19                                        and
20
21
22                           SDCC ASLINK Relocating Linker
23
24
25
26
27                                   Version   2.0
28                                    August 1998
29 \f
30
31                                                                   Page 2
32
33
34
35
36                                   P R E F A C E
37
38
39
40
41
42            The  ASxxxx  assemblers  were  written following the style of
43         several cross assemblers found in the Digital Equipment Corpora-
44         tion  Users  Society  (DECUS)  distribution of the C programming
45         language.  The DECUS code was provided with no documentation  as
46         to  the  input  syntax  or the output format.  Study of the code
47         revealed that the unknown author of the code  had  attempted  to
48         formulate  an assembler with attributes similiar to those of the
49         PDP-11 MACRO assembler (without macro's).  The  incomplete  code
50         from  the  DECUS C distribution has been largely rewritten, only
51         the program structure, and C source  file  organization  remains
52         relatively  unchanged.   However, I wish to thank the author for
53         his contribution to this set of assemblers.
54
55            The  ASLINK  program was written as a companion to the ASxxxx
56         assemblers, its design and implementation was not  derived  from
57         any other work.
58
59            I  would  greatly  appreciate  receiving  the  details of any
60         changes, additions, or errors pertaining to these  programs  and
61         will  attempt  to  incorporate  any  fixes  or  generally useful
62         changes in a future update to these programs.
63
64
65
66                 Alan R.  Baldwin
67                 Kent State University
68                 Physics Department
69                 Kent, Ohio 44242
70                 U.S.A.
71
72
73                 http://shop-pdp.kent.edu/ashtml/asxxxx.htm
74
75                 baldwin@shop-pdp.kent.edu
76                 tel:  (330) 672 2531
77                 fax:  (330) 672 2959
78
79
80
81                E N D   U S E R   L I C E N S E   A G R E E M E N T
82
83
84
85
86
87           This  program is free software; you can redistribute it and/or
88         modify  it under the terms of the GNU General Public License  as
89         published  by the Free Software Foundation; either version 3, or
90         (at your option) any later version.
91
92           This  program  is  distributed  in the hope that  it  will  be
93         useful,  but  WITHOUT ANY WARRANTY;  without  even  the  implied
94         warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
95         See the GNU General Public License for more details.
96
97           You  should  have  received a copy of the GNU  General  Public
98         License     along     with    this program.      If not,     see
99         <http://www.gnu.org/licenses/>.
100 \f
101
102                                                                   Page 3
103
104
105
106
107
108
109
110
111                              C O N T R I B U T O R S
112
113
114
115
116            Thanks  to  Marko  Makela  for his contribution of the AS6500
117         cross assembler.
118
119                 Marko Makela
120                 Sillitie 10 A
121                 01480 Vantaa
122                 Finland
123                 Internet: Marko.Makela@Helsinki.Fi
124                 EARN/BitNet: msmakela@finuh
125
126
127
128
129
130            Thanks  to  John  Hartman  for his contribution of the AS8051
131         cross assembler and updates to the ASxxxx and ASLINK internals.
132
133                 John L. Hartman
134                 jhartman@compuserve.com
135                 http://ourworld.compuserve.com/homepages/jhartman/
136
137
138
139
140
141            Thanks  to  G.   Osborn  for his contributions to LKS19.C and
142         LKIHX.C.
143
144                 G. Osborn
145                 gary@s-4.com
146 \f
147
148                                                                   Page 4
149
150
151
152         ASxxxx Cross Assemblers, Version 2.00, August 1998
153
154         Submitted by Alan R.  Baldwin,
155         Kent State University, Kent, Ohio
156
157         Operating System:  TSX+, RT-11, MS/DOS, PDOS
158         or other supporting K&amp;R C.
159
160         Source Langauge:  C
161
162         Abstract:
163
164            The  ASxxxx  assemblers are a series of microprocessor assem-
165         blers written in the C programming  language.   This  collection
166         contains cross assemblers for the 6800(6802/6808), 6801(hd6303),
167         6804,  6805,  68HC08,  6809,  68HC11,  68HC12,   68HC16,   8051,
168         8085(8080),  z80(hd64180),  H8/3xx, and 6500 series microproces-
169         sors.  Each  assembler  has  a  device  specific  section  which
170         includes:   (1)  device description, byte order, and file exten-
171         sion information, (2) a table of assembler  general  directives,
172         special directives, assembler mnemonics and associated operation
173         codes, (3) machine  specific  code  for  processing  the  device
174         mnemonics, addressing modes, and special directives.
175
176            The assemblers have a common device independent section which
177         handles the details of file input/output, symbol  table  genera-
178         tion,  program/data  areas,  expression  analysis, and assembler
179         directive processing.
180
181            The  assemblers  provide  the following features:  (1) alpha-
182         betized, formatted symbol table listings, (2) relocatable object
183         modules, (3) global symbols for linking object modules, (4) con-
184         ditional assembly directives, (5) reusable  local  symbols,  and
185         (6) include-file processing.
186
187            The  companion program ASLINK is a relocating linker perform-
188         ing the following functions:  (1) bind multiple  object  modules
189         into  a  single  memory  image,  (2) resolve inter-module symbol
190         references,  (3)  resolve  undefined  symbols   from   specified
191         librarys of object modules, (4) process absolute, relative, con-
192         catenated, and overlay attributes in data and program  sections,
193         (5)  perform  byte and word program-counter relative (pc or pcr)
194         addressing calculations, (6) define absolute  symbol  values  at
195         link  time, (7) define absolute area base address values at link
196         time, (8) produce Intel Hex or Motorola  S19  output  file,  (9)
197         produce  a  map  of the linked memory image, and (10) update the
198         ASxxxx assembler listing files  with  the  absolute  linked  ad-
199         dresses and data.
200
201            The  assemblers  and  linker  have  been tested using DECUS C
202         under TSX+ and RT-11, PDOS C V5.4b, and Symantec C/C++ V6.1/V7.2
203         under  DOS/Windows  3.x/95.  Complete source code and documenta-
204         tion for the assemblers and linker is included with the  distri-
205         bution.   Additionally, test code for each assembler and several
206         microprocessor monitors ( ASSIST05  for  the  6805,  MONDEB  and
207         ASSIST09  for  the  6809,  and BUFFALO 2.5 for the 6811) are in-
208         cluded as working examples of use of these assemblers.
209 \f
210
211         CHAPTER 1  THE ASSEMBLER                                     1-1
212           1.1     THE ASXXXX ASSEMBLERS                              1-1
213           1.1.1     Assembly Pass 1                                  1-2
214           1.1.2     Assembly Pass 2                                  1-2
215           1.1.3     Assembly Pass 3                                  1-2
216           1.2     SOURCE PROGRAM FORMAT                              1-3
217           1.2.1     Statement Format                                 1-3
218           1.2.1.1     Label Field                                    1-3
219           1.2.1.2     Operator Field                                 1-5
220           1.2.1.3     Operand Field                                  1-5
221           1.2.1.4     Comment Field                                  1-6
222           1.3     SYMBOLS AND EXPRESSIONS                            1-6
223           1.3.1     Character Set                                    1-6
224           1.3.2     User-Defined Symbols                            1-10
225           1.3.3     Local Symbols                                   1-11
226           1.3.4     Current Location Counter                        1-12
227           1.3.5     Numbers                                         1-14
228           1.3.6     Terms                                           1-14
229           1.3.7     Expressions                                     1-15
230           1.4     GENERAL ASSEMBLER DIRECTIVES                      1-16
231           1.4.1     .module Directive                               1-16
232           1.4.2     .title Directive                                1-17
233           1.4.3     .sbttl Directive                                1-17
234           1.4.4     .page Directive                                 1-17
235           1.4.5     .byte and .db Directives                        1-17
236           1.4.6     .word and .dw Directives                        1-18
237           1.4.7     .blkb, .blkw, and .ds Directives                1-18
238           1.4.8     .ascii Directive                                1-18
239           1.4.9     .ascis Directive                                1-19
240           1.4.10    .asciz Directive                                1-19
241           1.4.11    .radix Directive                                1-20
242           1.4.12    .even Directive                                 1-20
243           1.4.13    .odd Directive                                  1-20
244           1.4.14    .area Directive                                 1-21
245           1.4.15    .org Directive                                  1-22
246           1.4.16    .globl Directive                                1-23
247           1.4.17    .if, .else, and .endif Directives               1-23
248           1.4.18    .include Directive                              1-24
249           1.4.19    .setdp Directive                                1-25
250           1.5     INVOKING ASXXXX                                   1-27
251           1.6     ERRORS                                            1-28
252           1.7     LISTING FILE                                      1-29
253           1.8     SYMBOL TABLE FILE                                 1-30
254           1.9     OBJECT FILE                                       1-31
255
256         CHAPTER 2  THE LINKER                                        2-1
257           2.1     ASLINK RELOCATING LINKER                           2-1
258           2.2     INVOKING ASLINK                                    2-2
259           2.3     LIBRARY PATH(S) AND FILE(S)                        2-3
260           2.4     ASLINK PROCESSING                                  2-4
261           2.5     LINKER INPUT FORMAT                                2-6
262           2.5.1     Object Module Format                             2-6
263           2.5.2     Header Line                                      2-6
264           2.5.3     Module Line                                      2-7
265           2.5.4     Symbol Line                                      2-7
266           2.5.5     Area Line                                        2-7
267 \f
268
269                                                                  Page ii
270
271
272
273           2.5.6     T Line                                           2-7
274           2.5.7     R Line                                           2-8
275           2.5.8     P Line                                           2-8
276           2.6     LINKER ERROR MESSAGES                              2-9
277           2.7     INTEL HEX OUTPUT FORMAT                           2-11
278           2.8     MOTORLA S1-S9 OUTPUT FORMAT                       2-12
279
280         CHAPTER 3  BUILDING ASXXXX AND ASLINK                        3-1
281           3.1     BUILDING AN ASSEMBLER                              3-1
282           3.2     BUILDING ASLINK                                    3-2
283
284         APPENDIX A  AS6800 ASSEMBLER                                 A-1
285           A.1     6800 REGISTER SET                                  A-1
286           A.2     6800 INSTRUCTION SET                               A-1
287           A.2.1     Inherent Instructions                            A-2
288           A.2.2     Branch Instructions                              A-2
289           A.2.3     Single Operand Instructions                      A-3
290           A.2.4     Double Operand Instructions                      A-4
291           A.2.5     Jump and Jump to Subroutine Instructions         A-4
292           A.2.6     Long Register Instructions                       A-5
293
294         APPENDIX B  AS6801 ASSEMBLER                                 B-1
295           B.1     .hd6303 DIRECTIVE                                  B-1
296           B.2     6801 REGISTER SET                                  B-1
297           B.3     6801 INSTRUCTION SET                               B-1
298           B.3.1     Inherent Instructions                            B-2
299           B.3.2     Branch Instructions                              B-2
300           B.3.3     Single Operand Instructions                      B-3
301           B.3.4     Double Operand Instructions                      B-4
302           B.3.5     Jump and Jump to Subroutine Instructions         B-5
303           B.3.6     Long Register Instructions                       B-5
304           B.3.7     6303 Specific Instructions                       B-5
305
306         APPENDIX C  AS6804 ASSEMBLER                                 C-1
307           C.1     6804 REGISTER SET                                  C-1
308           C.2     6804 INSTRUCTION SET                               C-1
309           C.2.1     Inherent Instructions                            C-2
310           C.2.2     Branch Instructions                              C-2
311           C.2.3     Single Operand Instructions                      C-2
312           C.2.4     Jump and Jump to Subroutine Instructions         C-2
313           C.2.5     Bit Test Instructions                            C-2
314           C.2.6     Load Immediate data Instruction                  C-3
315           C.2.7     6804 Derived Instructions                        C-3
316
317         APPENDIX D  AS6805 ASSEMBLER                                 D-1
318           D.1     6805 REGISTER SET                                  D-1
319           D.2     6805 INSTRUCTION SET                               D-1
320           D.2.1     Control Instructions                             D-2
321           D.2.2     Bit Manipulation Instructions                    D-2
322           D.2.3     Branch Instructions                              D-2
323           D.2.4     Read-Modify-Write Instructions                   D-3
324           D.2.5     Register\Memory Instructions                     D-3
325 \f
326
327                                                                 Page iii
328
329
330
331           D.2.6     Jump and Jump to Subroutine Instructions         D-4
332
333         APPENDIX E  AS6808 ASSEMBLER                                 E-1
334           E.1     68HC08 REGISTER SET                                E-1
335           E.2     68HC08 INSTRUCTION SET                             E-1
336           E.2.1     Control Instructions                             E-2
337           E.2.2     Bit Manipulation Instructions                    E-2
338           E.2.3     Branch Instructions                              E-3
339           E.2.4     Complex Branch Instructions                      E-3
340           E.2.5     Read-Modify-Write Instructions                   E-4
341           E.2.6     Register\Memory Instructions                     E-5
342           E.2.7     Double Operand Move Instruction                  E-5
343           E.2.8     16-Bit &lt;H:X&gt; Index Register Instructions         E-5
344           E.2.9     Jump and Jump to Subroutine Instructions         E-5
345
346         APPENDIX F  AS6809 ASSEMBLER                                 F-1
347           F.1     6809 REGISTER SET                                  F-1
348           F.2     6809 INSTRUCTION SET                               F-1
349           F.2.1     Inherent Instructions                            F-3
350           F.2.2     Short Branch Instructions                        F-3
351           F.2.3     Long Branch Instructions                         F-3
352           F.2.4     Single Operand Instructions                      F-4
353           F.2.5     Double Operand Instructions                      F-5
354           F.2.6     D-register Instructions                          F-5
355           F.2.7     Index/Stack Register Instructions                F-5
356           F.2.8     Jump and Jump to Subroutine Instructions         F-6
357           F.2.9     Register - Register Instructions                 F-6
358           F.2.10    Condition Code Register Instructions             F-6
359           F.2.11    6800 Compatibility Instructions                  F-6
360
361         APPENDIX G  AS6811 ASSEMBLER                                 G-1
362           G.1     68HC11 REGISTER SET                                G-1
363           G.2     68HC11 INSTRUCTION SET                             G-1
364           G.2.1     Inherent Instructions                            G-2
365           G.2.2     Branch Instructions                              G-2
366           G.2.3     Single Operand Instructions                      G-3
367           G.2.4     Double Operand Instructions                      G-4
368           G.2.5     Bit Manupulation Instructions                    G-4
369           G.2.6     Jump and Jump to Subroutine Instructions         G-5
370           G.2.7     Long Register Instructions                       G-5
371
372         APPENDIX H  AS6812 ASSEMBLER                                 H-1
373           H.1     68HC12 REGISTER SET                                H-1
374           H.2     68HC12 INSTRUCTION SET                             H-1
375           H.2.1     Inherent Instructions                            H-3
376           H.2.2     Short Branch Instructions                        H-3
377           H.2.3     Long Branch Instructions                         H-3
378           H.2.4     Branch on Decrement, Test, or Increment          H-4
379           H.2.5     Bit Clear and Set Instructions                   H-4
380           H.2.6     Branch on Bit Clear or Set                       H-4
381           H.2.7     Single Operand Instructions                      H-5
382           H.2.8     Double Operand Instructions                      H-6
383 \f
384
385                                                                  Page iv
386
387
388
389           H.2.9     Move Instructions                                H-6
390           H.2.10    D-register Instructions                          H-6
391           H.2.11    Index/Stack Register Instructions                H-7
392           H.2.12    Jump and Jump/Call to Subroutine
393                     Instructions                                     H-7
394           H.2.13    Other Special Instructions                       H-7
395           H.2.14    Register - Register Instructions                 H-7
396           H.2.15    Condition Code Register Instructions             H-7
397           H.2.16    M68HC11 Compatibility Mode Instructions          H-8
398
399         APPENDIX I  AS6816 ASSEMBLER                                 I-1
400           I.1     68HC16 REGISTER SET                                I-1
401           I.2     68HC16 INSTRUCTION SET                             I-1
402           I.2.1     Inherent Instructions                            I-2
403           I.2.2     Push/Pull Multiple Register Instructions         I-3
404           I.2.3     Short Branch Instructions                        I-3
405           I.2.4     Long Branch Instructions                         I-3
406           I.2.5     Bit Manipulation Instructions                    I-3
407           I.2.6     Single Operand Instructions                      I-4
408           I.2.7     Double Operand Instructions                      I-5
409           I.2.8     Index/Stack Register Instructions                I-5
410           I.2.9     Jump and Jump to Subroutine Instructions         I-6
411           I.2.10    Condition Code Register Instructions             I-6
412           I.2.11    Multiply and Accumulate Instructions             I-6
413
414         APPENDIX J  ASH8 ASSEMBLER                                   J-1
415           J.1     H8/3XX REGISTER SET                                J-1
416           J.2     H8/3XX INSTRUCTION SET                             J-1
417           J.2.1     Inherent Instructions                            J-2
418           J.2.2     Branch Instructions                              J-2
419           J.2.3     Single Operand Instructions                      J-3
420           J.2.4     Double Operand Instructions                      J-4
421           J.2.5     Mov Instructions                                 J-5
422           J.2.6     Bit Manipulation Instructions                    J-6
423           J.2.7     Extended Bit Manipulation Instructions           J-7
424           J.2.8     Condition Code Instructions                      J-7
425           J.2.9     Other Instructions                               J-8
426           J.2.10    Jump and Jump to Subroutine Instructions         J-8
427
428         APPENDIX K  AS8051 ASSEMBLER                                 K-1
429           K.1     ACKNOWLEDGMENT                                     K-1
430           K.2     8051 REGISTER SET                                  K-1
431           K.3     8051 INSTRUCTION SET                               K-2
432           K.3.1     Inherent Instructions                            K-2
433           K.3.2     Move Instructions                                K-3
434           K.3.3     Single Operand Instructions                      K-3
435           K.3.4     Two Operand Instructions                         K-4
436           K.3.5     Call and Return Instructions                     K-4
437           K.3.6     Jump Instructions                                K-4
438           K.3.7     Predefined Symbols:  SFR Map                     K-5
439           K.3.8     Predefined Symbols:  SFR Bit Addresses           K-6
440           K.3.9     Predefined Symbols:  Control Bits                K-7
441 \f
442
443                                                                   Page v
444
445
446
447         APPENDIX L  AS8085 ASSEMBLER                                 L-1
448           L.1     8085 REGISTER SET                                  L-1
449           L.2     8085 INSTRUCTION SET                               L-1
450           L.2.1     Inherent Instructions                            L-2
451           L.2.2     Register/Memory/Immediate Instructions           L-2
452           L.2.3     Call and Return Instructions                     L-2
453           L.2.4     Jump Instructions                                L-2
454           L.2.5     Input/Output/Reset Instructions                  L-3
455           L.2.6     Move Instructions                                L-3
456           L.2.7     Other Instructions                               L-3
457
458         APPENDIX M  ASZ80 ASSEMBLER                                  M-1
459           M.1     .hd64 DIRECTIVE                                    M-1
460           M.2     Z80 REGISTER SET AND CONDITIONS                    M-1
461           M.3     Z80 INSTRUCTION SET                                M-2
462           M.3.1     Inherent Instructions                            M-3
463           M.3.2     Implicit Operand Instructions                    M-3
464           M.3.3     Load Instruction                                 M-4
465           M.3.4     Call/Return Instructions                         M-4
466           M.3.5     Jump and Jump to Subroutine Instructions         M-4
467           M.3.6     Bit Manipulation Instructions                    M-5
468           M.3.7     Interrupt Mode and Reset Instructions            M-5
469           M.3.8     Input and Output Instructions                    M-5
470           M.3.9     Register Pair Instructions                       M-5
471           M.3.10    HD64180 Specific Instructions                    M-6
472
473         APPENDIX N  AS6500 ASSEMBLER                                 N-1
474           N.1     ACKNOWLEDGMENT                                     N-1
475           N.2     6500 REGISTER SET                                  N-2
476           N.3     6500 INSTRUCTION SET                               N-2
477           N.3.1     Processor Specific Directives                    N-3
478           N.3.2     65xx Core Inherent Instructions                  N-3
479           N.3.3     65xx Core Branch Instructions                    N-3
480           N.3.4     65xx Core Single Operand Instructions            N-3
481           N.3.5     65xx Core Double Operand Instructions            N-4
482           N.3.6     65xx Core Jump and Jump to Subroutine
483                     Instructions                                     N-4
484           N.3.7     65xx Core Miscellaneous X and Y Register
485                     Instructions                                     N-4
486           N.3.8     65F11 and 65F12 Specific Instructions            N-5
487           N.3.9     65C00/21 and 65C29 Specific Instructions         N-5
488           N.3.10    65C02, 65C102, and 65C112 Specific
489                     Instructions                                     N-6
490 \f
491
492
493
494
495
496
497
498
499
500
501
502
503
504                                     CHAPTER 1
505
506                                   THE ASSEMBLER
507
508
509
510
511
512         1.1  THE ASXXXX ASSEMBLERS
513
514
515            The  ASxxxx  assemblers are a series of microprocessor assem-
516         blers written in the C programming language.  Each assembler has
517         a device specific section which includes:
518
519              1.  device  description, byte order, and file extension in-
520                  formation
521
522              2.  a  table  of  the assembler general directives, special
523                  device directives, assembler mnemonics  and  associated
524                  operation codes
525
526              3.  machine specific code for processing the device mnemon-
527                  ics, addressing modes, and special directives
528
529         The device specific information is detailed in the appendices.
530
531            The assemblers have a common device independent section which
532         handles the details of file input/output, symbol  table  genera-
533         tion,  program/data  areas,  expression  analysis, and assembler
534         directive processing.
535
536         The assemblers provide the following features:
537
538              1.  Command string control of assembly functions
539
540              2.  Alphabetized, formatted symbol table listing
541
542              3.  Relocatable object modules
543
544              4.  Global symbols for linking object modules
545
546              5.  Conditional assembly directives
547
548 \f
549
550         THE ASSEMBLER                                           PAGE 1-2
551         THE ASXXXX ASSEMBLERS
552
553
554              6.  Program sectioning directives
555
556
557            ASxxxx assembles one or more source files into a single relo-
558         catable ascii object file.  The output of the ASxxxx  assemblers
559         consists of an ascii relocatable object file(*.rel), an assembly
560         listing file(*.lst), and a symbol file(*.sym).
561
562
563         1.1.1  Assembly Pass 1
564
565
566            During  pass  1, ASxxxx opens all source files and performs a
567         rudimenatry assembly of each source statement.  During this pro-
568         cess  all symbol tables are built, program sections defined, and
569         number of bytes for each assembled source line is estimated.
570
571            At the end of pass 1 all undefined symbols may be made global
572         (external) using the ASxxxx switch -g, otherwise undefined  sym-
573         bols will be flagged as errors during succeeding passes.
574
575
576         1.1.2  Assembly Pass 2
577
578
579            During  pass  2  the ASxxxx assembler resolves forward refer-
580         ences and determines the number  of  bytes  for  each  assembled
581         line.   The  number  of bytes used by a particular assembler in-
582         struction may depend upon the addressing mode, whether  the  in-
583         struction allows multiple forms based upon the relative distance
584         to the addressed location, or other factors.   Pass  2  resolves
585         these cases and determines the address of all symbols.
586
587
588         1.1.3  Assembly Pass 3
589
590
591            Pass 3 by the assembler generates the listing file, the relo-
592         catable output file, and the symbol tables.  Also during pass  3
593         the errors will be reported.
594
595            The  relocatable object file is an ascii file containing sym-
596         bol references and definitions, program  area  definitions,  and
597         the  relocatable assembled code, the linker ASLINK will use this
598         information to generate an absolute load file (Motorola or Intel
599         formats).
600
601
602 \f
603
604         THE ASSEMBLER                                           PAGE 1-3
605         SOURCE PROGRAM FORMAT
606
607
608         1.2  SOURCE PROGRAM FORMAT
609
610
611
612         1.2.1  Statement Format
613
614
615            A source program is composed of assembly-language statements.
616         Each statement must be completed on one line.  A line  may  con-
617         tain a maximum of 128 characters, longer lines are truncated and
618         lost.
619
620            An  ASxxxx  assembler  statement  may  have  as  many as four
621         fields.  These fields are identified by their order  within  the
622         statement  and/or  by separating characters between fields.  The
623         general format of the ASxxxx statement is:
624
625               [label:]  Operator        Operand         [;Comment(s)]
626
627            The  label and comment fields are optional.  The operator and
628         operand fields are interdependent.  The operator field may be an
629         assembler  directive or an assembly mnemonic.  The operand field
630         may be optional or required as defined in  the  context  of  the
631         operator.
632
633            ASxxxx  interprets  and  processes source statements one at a
634         time.  Each statement causes a particular operation to  be  per-
635         formed.
636
637
638         1.2.1.1  Label Field  -
639
640            A  label is a user-defined symbol which is assigned the value
641         of the current location counter and entered into  the  user  de-
642         fined  symbol  table.   The  current location counter is used by
643         ASxxxx to assign memory addresses to the source  program  state-
644         ments as they are encountered during the assembly process.  Thus
645         a label is a means  of  symbolically  referring  to  a  specific
646         statement.
647
648            When  a program section is absolute, the value of the current
649         location counter is absolute;  its value references an  absolute
650         memory  address.   Similarly, when a program section is relocat-
651         able, the value of the current location counter is  relocatable.
652         A  relocation  bias  calculated at link time is added to the ap-
653         parent value of the current location counter  to  establish  its
654         effective  absolute  address  at  execution time.  (The user can
655         also force the linker to relocate sections defined as  absolute.
656         This may be required under special circumstances.)
657
658            If  present,  a  label  must  be  the first field in a source
659         statement and must be terminated by a colon (:).   For  example,
660 \f
661
662         THE ASSEMBLER                                           PAGE 1-4
663         SOURCE PROGRAM FORMAT
664
665
666         if  the  value  of  the  current  location  counter  is absolute
667         01F0(H), the statement:
668
669               abcd:     nop
670
671         assigns  the  value  01F0(H) to the label abcd.  If the location
672         counter value were relocatable, the final value of abcd would be
673         01F0(H)+K, where K represents the relocation bias of the program
674         section, as calculated by the linker at link time.
675
676            More  than  one label may appear within a single label field.
677         Each label so specified is assigned the same address value.  For
678         example,  if  the  value  of  the  current  location  counter is
679         1FF0(H), the multiple labels in the following statement are each
680         assigned the value 1FF0(H):
681
682               abcd:     aq:     $abc:   nop
683
684            Multiple labels may also appear on successive lines.  For ex-
685         ample, the statements
686
687               abcd:
688               aq:
689               $abc:     nop
690
691         likewise  cause  the  same value to be assigned to all three la-
692         bels.
693
694            A  double  colon  (::)  defines the label as a global symbol.
695         For example, the statement
696
697               abcd::    nop
698
699         establishes the label abcd as a global symbol.  The distinguish-
700         ing attribute of a global symbol is that it  can  be  referenced
701         from  within an object module other than the module in which the
702         symbol is defined.  References to this label  in  other  modules
703         are  resolved when the modules are linked as a composite execut-
704         able image.
705
706         The legal characters for defining labels are:
707
708                 A through Z
709                 a through z
710                 0 through 9
711                 . (Period)
712                 $ (Dollar sign)
713                 _ (underscore)
714
715            A  label  may  be  any  length,  however  only  the  first 79
716         characters are significant and, therefore must be  unique  among
717         all   labels  in  the  source  program  (not  necessarily  among
718 \f
719
720         THE ASSEMBLER                                           PAGE 1-5
721         SOURCE PROGRAM FORMAT
722
723
724         separately compiled modules).  An error code(s) (m or p) will be
725         generated  in the assembly listing if the first 79 characters in
726         two or more labels are the same.  The m code is  caused  by  the
727         redeclaration  of  the symbol or its reference by another state-
728         ment.  The p code is generated because the symbols  location  is
729         changing on each pass through the source file.
730
731            The  label  must  not  start with the characters 0-9, as this
732         designates a local symbol with special attributes described in a
733         later section.
734
735            The  label  must  not  start  with  the  sequence $$, as this
736         represents the temporary radix 16 for constants.
737
738
739         1.2.1.2  Operator Field  -
740
741            The  operator field specifies the action to be performed.  It
742         may consist of an instruction mnemonic (op code) or an assembler
743         directive.
744
745            When  the  operator is an instruction mnemonic, a machine in-
746         struction is generated and the assembler evaluates the addresses
747         of  the operands which follow.  When the operator is a directive
748         ASxxxx performs certain control actions or processing operations
749         during assembly of the source program.
750
751            Leading  and  trailing  spaces  or tabs in the operator field
752         have no significance;  such characters serve  only  to  separate
753         the operator field from the preceeding and following fields.
754
755            An operator is terminated by a space, tab or end of line.
756
757
758         1.2.1.3  Operand Field  -
759
760            When  the  operator is an instruction mnemonic (op code), the
761         operand  field  contains  program  variables  that  are  to   be
762         evaluated/manipulated by the operator.
763
764            Operands  may  be  expressions  or  symbols, depending on the
765         operator.  Multiple expressions used in the operand  fields  may
766         be  separated  by a comma.  An operand should be preceeded by an
767         operator field;  if it is not, the statement will give an  error
768         (q  or  o).   All  operands  following instruction mnemonics are
769         treated as expressions.
770
771            The operand field is terminated by a semicolon when the field
772         is followed  by  a  comment.   For  example,  in  the  following
773         statement:
774
775               label:    lda     abcd,x          ;Comment field
776 \f
777
778         THE ASSEMBLER                                           PAGE 1-6
779         SOURCE PROGRAM FORMAT
780
781
782
783         the  tab  between lda and abcd terminates the operator field and
784         defines the beginning of the operand field;  a  comma  separates
785         the operands abcd and x;  and a semicolon terminates the operand
786         field and defines the beginning of the comment field.   When  no
787         comment  field  follows,  the operand field is terminated by the
788         end of the source line.
789
790
791         1.2.1.4  Comment Field  -
792
793            The comment field begins with a semicolon and extends through
794         the end of the line.  This field is optional and may contain any
795         7-bit ascii character except null.
796
797            Comments  do not affect assembly processing or program execu-
798         tion.
799
800
801         1.3  SYMBOLS AND EXPRESSIONS
802
803
804            This  section  describes the generic components of the ASxxxx
805         assemblers:  the character set, the conventions observed in con-
806         structing  symbols,  and  the use of numbers, operators, and ex-
807         pressions.
808
809
810         1.3.1  Character Set
811
812
813            The following characters are legal in ASxxxx source programs:
814
815              1.  The  letters  A  through Z.  Both upper- and lower-case
816                  letters are acceptable.  The  assemblers,  by  default,
817                  are  not  case  sensitive,  i.e.  ABCD and abcd are the
818                  same symbols.  (The assemblers can be made case  sensi-
819                  tive by using the -z command line option.)
820
821              2.  The digits 0 through 9
822
823              3.  The  characters . (period), $ (dollar sign), and _ (un-
824                  derscore).
825
826              4.  The special characters listed in Tables 1 through 6.
827
828
829            Tables  1  through  6  describe  the various ASxxxx label and
830         field terminators, assignment operators, operand separators, as-
831         sembly, unary, binary, and radix operators.
832 \f
833
834         THE ASSEMBLER                                           PAGE 1-7
835         SYMBOLS AND EXPRESSIONS
836
837
838         Table 1         Label Terminators and Assignment Operators
839         ----------------------------------------------------------------
840
841                 :   Colon               Label terminator.
842
843                 ::  Double colon        Label  Terminator;   defines the
844                                         label as a global label.
845
846                 =   Equal sign          Direct assignment operator.
847
848                 ==  Double equal        Direct assignment operator;
849                     sign                defines  the  symbol as a global
850                                         symbol.
851
852         ----------------------------------------------------------------
853
854
855
856
857
858         Table 2         Field Terminators and Operand Separators
859         ----------------------------------------------------------------
860
861                     Tab                 Item or field terminator.
862
863                     Space               Item or field terminator.
864
865                 ,   Comma               Operand field separator.
866
867                 ;   Semicolon           Comment field indicator.
868
869         ----------------------------------------------------------------
870
871
872
873
874
875         Table 3         Assembler Operators
876         ----------------------------------------------------------------
877
878                 #   Number sign         Immediate expression indicator.
879
880                 .   Period              Current location counter.
881
882                 (   Left parenthesis    Expression delimiter.
883
884                 )   Right parenthesis   Expression delimeter.
885
886         ----------------------------------------------------------------
887 \f
888
889         THE ASSEMBLER                                           PAGE 1-8
890         SYMBOLS AND EXPRESSIONS
891
892
893
894
895
896
897
898         Table 4         Unary Operators
899         ----------------------------------------------------------------
900
901                 &lt;   Left bracket        &lt;FEDC   Produces  the lower byte
902                                                 value of the expression.
903                                                 (DC)
904
905                 &gt;   Right bracket       &gt;FEDC   Produces  the upper byte
906                                                 value of the expression.
907                                                 (FE)
908
909                 +   Plus sign           +A      Positive value of A
910
911                 -   Minus sign          -A      Produces   the  negative
912                                                 (2's complement) of A.
913
914                 ~   Tilde               ~A      Produces the 1's comple-
915                                                 ment of A.
916
917                 '   Single quote        'D      Produces  the  value  of
918                                                 the character D.
919
920                 "   Double quote        "AB     Produces the double byte
921                                                 value for AB.
922
923                 \   Backslash           '\n     Unix style characters
924                                                 \b, \f, \n, \r, \t
925                                      or '\001   or octal byte values.
926
927         ----------------------------------------------------------------
928
929
930
931
932
933 \f
934
935         THE ASSEMBLER                                           PAGE 1-9
936         SYMBOLS AND EXPRESSIONS
937
938
939         Table 5         Binary Operators
940         ----------------------------------------------------------------
941
942                 &lt;&lt;  Double          0800 &lt;&lt; 4   Produces the 4 bit
943                     Left bracket                left-shifted   value  of
944                                                 0800.  (8000)
945
946                 &gt;&gt;  Double          0800 &gt;&gt; 4   Produces the 4 bit
947                     Right bracket               right-shifted  value  of
948                                                 0800.  (0080)
949
950                 +   Plus sign       A + B       Arithmetic      Addition
951                                                 operator.
952
953                 -   Minus sign      A - B       Arithmetic   Subtraction
954                                                 operator.
955
956                 *   Asterisk        A * B       Arithmetic   Multiplica-
957                                                 tion operator.   (signed
958                                                 16-bit)
959
960                 /   Slash           A / B       Arithmetic      Division
961                                                 operator.        (signed
962                                                 16-bit quotient)
963
964                 &amp;   Ampersand       A &amp; B       Logical AND operator.
965
966                 |   Bar             A | B       Logical OR operator.
967
968                 %   Percent sign    A % B       Modulus operator.
969                                                 (16-bit value)
970
971                 ^   Up arrow or     A ^ B       EXCLUSIVE OR operator.
972                     circumflex
973
974         ----------------------------------------------------------------
975
976
977
978
979
980 \f
981
982         THE ASSEMBLER                                          PAGE 1-10
983         SYMBOLS AND EXPRESSIONS
984
985
986         Table 6         Temporary Radix Operators
987         ----------------------------------------------------------------
988
989                 $%,   0b, 0B            Binary radix operator.
990
991                 $&amp;,   0o, 0O, 0q, 0Q    Octal radix operator.
992
993                 $#,   0d, 0D            Decimal radix operator.
994
995                 $$,   0h, 0H, 0x, 0X    Hexidecimal radix operator.
996
997
998                 Potential  ambiguities arising from the use of 0b and 0d
999                 as temporary radix operators may be circumvented by pre-
1000                 ceding  all  non-prefixed  hexidecimal  numbers with 00.
1001                 Leading 0's are required in any  case  where  the  first
1002                 hexidecimal  digit is abcdef as the assembler will treat
1003                 the letter sequence as a label.
1004
1005         ----------------------------------------------------------------
1006
1007
1008
1009
1010
1011
1012
1013         1.3.2  User-Defined Symbols
1014
1015
1016            User-defined  symbols are those symbols that are equated to a
1017         specific value through a direct assignment statement  or  appear
1018         as  labels.  These symbols are added to the User Symbol Table as
1019         they are encountered during assembly.
1020
1021         The following rules govern the creation of user-defined symbols:
1022
1023              1.  Symbols  can  be  composed  of alphanumeric characters,
1024                  dollar signs ($),  periods  (.),  and  underscores  (_)
1025                  only.
1026
1027              2.  The  first  character  of a symbol must not be a number
1028                  (except in the case of local symbols).
1029
1030              3.  The  first 79 characters of a symbol must be unique.  A
1031                  symbol  can  be  written  with  more  than   79   legal
1032                  characters,  but the 80th and subsequent characters are
1033                  ignored.
1034
1035              4.  Spaces and Tabs must not be embedded within a symbol.
1036
1037
1038 \f
1039
1040         THE ASSEMBLER                                          PAGE 1-11
1041         SYMBOLS AND EXPRESSIONS
1042
1043
1044         1.3.3  Local Symbols
1045
1046
1047            Local  symbols are specially formatted symbols used as labels
1048         within a block of coding that has been delimited as a local sym-
1049         bol  block.   Local  symbols  are  of  the form n$, where n is a
1050         decimal integer from 0 to 255,  inclusive.   Examples  of  local
1051         symbols are:
1052
1053               1$
1054               27$
1055               138$
1056               244$
1057
1058            The  range  of  a local symbol block consists of those state-
1059         ments between two normally constructed  symbolic  labels.   Note
1060         that a statement of the form:
1061
1062               ALPHA = EXPRESSION
1063
1064         is a direct assignment statement but does not create a label and
1065         thus does not delimit the range of a local symbol block.
1066
1067            Note that the range of a local symbol block may extend across
1068         program areas.
1069
1070            Local symbols provide a convenient means of generating labels
1071         for branch instructions and other such references  within  local
1072         symbol  blocks.   Using local symbols reduces the possibility of
1073         symbols with multiple definitions appearing within a  user  pro-
1074         gram.   In  addition,  the  use  of local symbols differentiates
1075         entry-point labels from local labels, since local labels  cannot
1076         be referenced from outside their respective local symbol blocks.
1077         Thus, local symbols of the same name can appear in  other  local
1078         symbol blocks without conflict.  Local symbols require less sym-
1079         bol table space than normal symbols.  Their use is recommended.
1080
1081            The  use of the same local symbol within a local symbol block
1082         will generate one or both of the m or p errors.
1083 \f
1084
1085         THE ASSEMBLER                                          PAGE 1-12
1086         SYMBOLS AND EXPRESSIONS
1087
1088
1089         Example of local symbols:
1090
1091                 a:      ldx     #atable ;get table address
1092                         lda     #0d48   ;table length
1093                 1$:     clr     ,x+     ;clear
1094                         deca
1095                         bne     1$
1096
1097                 b:      ldx     #btable ;get table address
1098                         lda     #0d48   ;table length
1099                 1$:     clr     ,x+     ;clear
1100                         deca
1101                         bne     1$
1102
1103
1104         1.3.4  Current Location Counter
1105
1106
1107            The  period  (.) is the symbol for the current location coun-
1108         ter.  When used in the operand  field  of  an  instruction,  the
1109         period   represents  the  address  of  the  first  byte  of  the
1110         instruction:
1111
1112                 AS:     ldx     #.      ;The period (.) refers to
1113                                         ;the address of the ldx
1114                                         ;instruction.
1115
1116            When  used  in  the  operand field of an ASxxxx directive, it
1117         represents the address of the current byte or word:
1118
1119                 QK = 0
1120
1121                 .word   0xFFFE,.+4,QK   ;The operand .+4 in the .word
1122                                         ;directive represents a value
1123                                         ;stored in the second of the
1124                                         ;three words during assembly.
1125
1126            If  we  assume  the  current  value of the program counter is
1127         0H0200, then during assembly, ASxxxx  reserves  three  words  of
1128         storage  starting  at  location 0H0200.  The first value, a hex-
1129         idecimal constant FFFE, will be stored at location 0H0200.   The
1130         second  value  represented  by  .+4  will  be stored at location
1131         0H0202, its value will be 0H0206 ( = 0H0202  +  4).   The  third
1132         value  defined  by  the  symbol  QK  will  be placed at location
1133         0H0204.
1134
1135            At the beginning of each assembly pass, ASxxxx resets the lo-
1136         cation counter.  Normally, consecutive memory locations are  as-
1137         signed  to  each  byte  of  object code generated.  However, the
1138         value of the location counter can be changed  through  a  direct
1139         assignment statement of the following form:
1140
1141 \f
1142
1143         THE ASSEMBLER                                          PAGE 1-13
1144         SYMBOLS AND EXPRESSIONS
1145
1146
1147               . = . + expression
1148
1149
1150            The  new  location  counter can only be specified relative to
1151         the current location counter.  Neglecting to specify the current
1152         program  counter  along with the expression on the right side of
1153         the assignment operator will generate the (.) error.   (Absolute
1154         program areas may use the .org directive to specify the absolute
1155         location of the current program counter.)
1156
1157         The following coding illustrates the use of the current location
1158         counter:
1159
1160                 .area   CODE1   (ABS)   ;program area CODE1
1161                                         ;is ABSOLUTE
1162
1163                 .org    0H100           ;set location to
1164                                         ;0H100 absolute
1165
1166         num1:   ldx     #.+0H10         ;The label num1 has
1167                                         ;the value 0H100.
1168                                         ;X is loaded with
1169                                         ;0H100 + 0H10
1170
1171                 .org    0H130           ;location counter
1172                                         ;set to 0H130
1173
1174         num2:   ldy     #.              ;The label num2 has
1175                                         ;the value 0H130.
1176                                         ;Y is loaded with
1177                                         ;value 0H130.
1178
1179
1180                 .area   CODE2   (REL)   ;program area CODE2
1181                                         ;is RELOCATABLE
1182
1183                 . = . + 0H20            ;Set location counter
1184                                         ;to relocatable 0H20 of
1185                                         ;the program section.
1186
1187         num3:   .word   0               ;The label num3 has
1188                                         ;the value
1189                                         ;of relocatable 0H20.
1190
1191                 . = . + 0H40            ;will reserve 0H40
1192                                         ;bytes of storage as will
1193                 .blkb   0H40            ;or
1194                 .blkw   0H20
1195
1196            The  .blkb  and .blkw directives are the preferred methods of
1197         allocating space.
1198
1199 \f
1200
1201         THE ASSEMBLER                                          PAGE 1-14
1202         SYMBOLS AND EXPRESSIONS
1203
1204
1205         1.3.5  Numbers
1206
1207
1208            ASxxxx  assumes that all numbers in the source program are to
1209         be interpreted in decimal radix unless otherwise specified.  The
1210         .radix  directive  may  be used to specify the default as octal,
1211         decimal, or hexidecimal.  Individual numbers can  be  designated
1212         as  binary, octal, decimal, or hexidecimal through the temporary
1213         radix prefixes shown in table 6.
1214
1215            Negative  numbers  must be preceeded by a minus sign;  ASxxxx
1216         translates such numbers into two's  complement  form.   Positive
1217         numbers may (but need not) be preceeded by a plus sign.
1218
1219            Numbers are always considered to be absolute values, therefor
1220         they are never relocatable.
1221
1222
1223         1.3.6  Terms
1224
1225
1226            A  term is a component of an expression and may be one of the
1227         following:
1228
1229
1230              1.  A number.
1231
1232              2.  A symbol:
1233                  1.  A  period (.) specified in an expression causes the
1234                      current location counter to be used.
1235                  2.  A User-defined symbol.
1236                  3.  An undefined symbol is assigned a value of zero and
1237                      inserted in the User-Defined symbol table as an un-
1238                      defined symbol.
1239
1240              3.  A single quote followed by a single ascii character, or
1241                  a double quote followed by two ascii characters.
1242
1243              4.  An  expression enclosed in parenthesis.  Any expression
1244                  so enclosed is evaluated and reduced to a  single  term
1245                  before  the remainder of the expression in which it ap-
1246                  pears is evaluated.  Parenthesis, for example,  may  be
1247                  used  to  alter the left-to-right evaluation of expres-
1248                  sions, (as in A*B+C versus A*(B+C)), or to apply a  un-
1249                  ary operator to an entire expression (as in -(A+B)).
1250
1251              5.  A unary operator followed by a symbol or number.
1252
1253
1254
1255 \f
1256
1257         THE ASSEMBLER                                          PAGE 1-15
1258         SYMBOLS AND EXPRESSIONS
1259
1260
1261         1.3.7  Expressions
1262
1263
1264            Expressions  are  combinations  of  terms  joined together by
1265         binary operators.  Expressions reduce to a  16-bit  value.   The
1266         evaluation  of  an  expression includes the determination of its
1267         attributes.  A resultant expression value may be  one  of  three
1268         types  (as  described  later in this section):  relocatable, ab-
1269         solute, and external.
1270
1271         Expressions are evaluate with an operand hierarchy as follows:
1272
1273                 *       /       %       multiplication,
1274                                         division, and
1275                                         modulus first.
1276
1277                 +       -               addition and
1278                                         subtraction second.
1279
1280                 &lt;&lt;      &gt;&gt;              left shift and
1281                                         right shift third.
1282
1283                 ^                       exclusive or fourth.
1284
1285                 &amp;                       logical and fifth.
1286
1287                 |                       logical or last
1288
1289                 except that unary operators take precedence over binary
1290                 operators.
1291
1292
1293            A  missing  or  illegal  operator  terminates  the expression
1294         analysis, causing error codes (o) and/or  (q)  to  be  generated
1295         depending upon the context of the expression itself.
1296
1297            At assembly time the value of an external (global) expression
1298         is equal to the value of the absolute part of  that  expression.
1299         For  example,  the expression external+4, where 'external' is an
1300         external symbol, has the value of 4.  This expression,  however,
1301         when  evaluated  at link time takes on the resolved value of the
1302         symbol 'external', plus 4.
1303
1304            Expressions,  when  evaluated  by  ASxxxx,  are  one of three
1305         types:  relocatable, absolute, or external.  The following  dis-
1306         tinctions are important:
1307
1308              1.  An  expression is relocatable if its value is fixed re-
1309                  lative to the base address of the program area in which
1310                  it appears;  it will have an offset value added at link
1311                  time.  Terms that contain labels defined in relocatable
1312                  program   areas   will   have   a   relocatable  value;
1313 \f
1314
1315         THE ASSEMBLER                                          PAGE 1-16
1316         SYMBOLS AND EXPRESSIONS
1317
1318
1319                  similarly, a period (.) in a relocatable program  area,
1320                  representing  the value of the current program location
1321                  counter, will also have a relocatable value.
1322
1323              2.  An  expression  is  absolute if its value is fixed.  An
1324                  expression whose terms are numbers and ascii characters
1325                  will  reduce  to  an absolute value.  A relocatable ex-
1326                  pression or term minus a relocatable term,  where  both
1327                  elements  being  evaluated  belong  to the same program
1328                  area, is an absolute expression.  This is because every
1329                  term  in  a  program area has the same relocation bias.
1330                  When one term is subtracted from the other the  reloca-
1331                  tion bias is zero.
1332
1333              3.  An  expression is external (or global) if it contains a
1334                  single global reference (plus or minus an absolute  ex-
1335                  pression  value) that is not defined within the current
1336                  program.  Thus, an external  expression  is  only  par-
1337                  tially  defined following assembly and must be resolved
1338                  at link time.
1339
1340
1341
1342         1.4  GENERAL ASSEMBLER DIRECTIVES
1343
1344
1345            An  ASxxxx  directive  is placed in the operator field of the
1346         source line.  Only one directive is  allowed  per  source  line.
1347         Each  directive  may  have  a blank operand field or one or more
1348         operands.  Legal operands differ with each directive.
1349
1350
1351         1.4.1  .module Directive
1352
1353         Format:
1354
1355                 .module string
1356
1357            The .module directive causes the string to be included in the
1358         assemblers output file as an identifier for this particular  ob-
1359         ject  module.   The  string  may  be  from 1 to 79 characters in
1360         length.  Only one identifier is allowed  per  assembled  module.
1361         The  main use of this directive is to allow the linker to report
1362         a modules' use of undefined symbols.  At link time all undefined
1363         symbols  are  reported  and  the  modules  referencing  them are
1364         listed.
1365
1366
1367 \f
1368
1369         THE ASSEMBLER                                          PAGE 1-17
1370         GENERAL ASSEMBLER DIRECTIVES
1371
1372
1373         1.4.2  .title Directive
1374
1375         Format:
1376
1377                 .title  string
1378
1379            The .title directive provides a character string to be placed
1380         on the second line of each page during listing.
1381
1382
1383         1.4.3  .sbttl Directive
1384
1385         Format:
1386
1387                 .sbttl  string
1388
1389            The .sbttl directive provides a character string to be placed
1390         on the third line of each page during listing.
1391
1392
1393         1.4.4  .page Directive
1394
1395         Format:
1396
1397                 .page
1398
1399            The .page directive causes a page ejection with a new heading
1400         to be printed.  The new page occurs after the next line  of  the
1401         source  program is processed, this allows an immediately follow-
1402         ing .sbttl directive to appear  on  the  new  page.   The  .page
1403         source  line will not appear in the file listing.  Paging may be
1404         disabled by invoking the -p directive.
1405
1406
1407         1.4.5  .byte and .db Directives
1408
1409         Format:
1410
1411                 .byte   exp             ;Stores the binary value
1412                 .db     exp             ;of the expression in the
1413                                         ;next byte.
1414
1415                 .byte   exp1,exp2,expn  ;Stores the binary values
1416                 .db     exp1,exp2,expn  ;of the list of expressions
1417                                         ;in successive bytes.
1418
1419         where:  exp,    represent expressions that will be
1420                 exp1,   truncated to 8-bits of data.
1421                 .       Each expression will be calculated
1422                 .       as a 16-bit word expression,
1423                 .       the high-order byte will be truncated.
1424                 .       Multiple expressions must be
1425 \f
1426
1427         THE ASSEMBLER                                          PAGE 1-18
1428         GENERAL ASSEMBLER DIRECTIVES
1429
1430
1431                 expn    separated by commas.
1432
1433            The  .byte  or .db directives are used to generate successive
1434         bytes of binary data in the object module.
1435
1436
1437         1.4.6  .word and .dw Directives
1438
1439         Format:
1440
1441                 .word   exp             ;Stores the binary value
1442                 .dw     exp             ;of the expression in
1443                                         ;the next word.
1444
1445                 .word   exp1,exp2,expn  ;Stores the binary values
1446                 .dw     exp1,exp2,expn  ;of the list of expressions
1447                                         ;in successive words.
1448
1449         where:  exp,    represent expressions that will occupy two
1450                 exp1,   bytes of data. Each expression will be
1451                 .       calculated as a 16-bit word expression.
1452                 .       Multiple expressions must be
1453                 expn    separated by commas.
1454
1455            The  .word  or .dw directives are used to generate successive
1456         words of binary data in the object module.
1457
1458
1459         1.4.7  .blkb, .blkw, and .ds Directives
1460
1461         Format:
1462
1463                 .blkb   N       ;reserve N bytes of space
1464                 .blkw   N       ;reserve N words of space
1465                 .ds     N       ;reserve N bytes of space
1466
1467            The  .blkb  and .ds directives reserve byte blocks in the ob-
1468         ject module;  the .blkw directive reserves word blocks.
1469
1470
1471         1.4.8  .ascii Directive
1472
1473         Format:
1474
1475                 .ascii  /string/
1476
1477         where:  string  is a string of printable ascii characters.
1478
1479                 /  /    represent   the  delimiting  characters.   These
1480                         delimiters   may   be   any   paired    printing
1481                         characters,  as  long  as the characters are not
1482                         contained within  the  string  itself.   If  the
1483 \f
1484
1485         THE ASSEMBLER                                          PAGE 1-19
1486         GENERAL ASSEMBLER DIRECTIVES
1487
1488
1489                         delimiting  characters  do not match, the .ascii
1490                         directive will give the (q) error.
1491
1492         The  .ascii  directive  places  one binary byte of data for each
1493         character in the string into the object module.
1494
1495
1496         1.4.9  .ascis Directive
1497
1498         Format:
1499
1500                 .ascis  /string/
1501
1502         where:  string  is a string of printable ascii characters.
1503
1504                 /  /    represent   the  delimiting  characters.   These
1505                         delimiters   may   be   any   paired    printing
1506                         characters,  as  long  as the characters are not
1507                         contained within  the  string  itself.   If  the
1508                         delimiting  characters  do not match, the .ascis
1509                         directive will give the (q) error.
1510
1511         The  .ascis  directive  places  one binary byte of data for each
1512         character in the  string  into  the  object  module.   The  last
1513         character in the string will have the high order bit set.
1514
1515
1516         1.4.10  .asciz Directive
1517
1518         Format:
1519
1520                 .asciz  /string/
1521
1522         where:  string  is a string of printable ascii characters.
1523
1524                 /  /    represent   the  delimiting  characters.   These
1525                         delimiters   may   be   any   paired    printing
1526                         characters,  as  long  as the characters are not
1527                         contained within  the  string  itself.   If  the
1528                         delimiting  characters  do not match, the .asciz
1529                         directive will give the (q) error.
1530
1531         The  .asciz  directive  places  one binary byte of data for each
1532         character in the string into the object module.   Following  all
1533         the  character  data  a  zero  byte is inserted to terminate the
1534         character string.
1535
1536
1537 \f
1538
1539         THE ASSEMBLER                                          PAGE 1-20
1540         GENERAL ASSEMBLER DIRECTIVES
1541
1542
1543         1.4.11  .radix Directive
1544
1545         Format:
1546
1547                 .radix  character
1548
1549         where:  character  represents  a single character specifying the
1550                         default radix to be used for succeeding numbers.
1551                         The character may be any one of the following:
1552
1553                         B,b     Binary
1554
1555                         O,o     Octal
1556                         Q,q
1557
1558                         D,d     Decimal
1559                         'blank'
1560
1561                         H,h     Hexidecimal
1562                         X,x
1563
1564
1565         1.4.12  .even Directive
1566
1567         Format:
1568
1569                 .even
1570
1571            The .even directive ensures that the current location counter
1572         contains an even boundary value by adding 1 if the current loca-
1573         tion is odd.
1574
1575
1576         1.4.13  .odd Directive
1577
1578         Format:
1579
1580                 .odd
1581
1582            The  .odd directive ensures that the current location counter
1583         contains an odd boundary value by adding one if the current  lo-
1584         cation is even.
1585
1586
1587 \f
1588
1589         THE ASSEMBLER                                          PAGE 1-21
1590         GENERAL ASSEMBLER DIRECTIVES
1591
1592
1593         1.4.14  .area Directive
1594
1595         Format:
1596
1597                 .area   name    [(options)]
1598
1599         where:  name    represents the symbolic name of the program sec-
1600                         tion.   This  name  may  be  the  same  as   any
1601                         user-defined  symbol  as  the area names are in-
1602                         dependent of all symbols and labels.
1603
1604                 options specify the type of program or data area:
1605                         ABS     absolute
1606                         REL     relocatable
1607                         OVR     overlay
1608                         CON     concatenate
1609                         PAG     paged area
1610
1611
1612            The .area directive provides a means of defining and separat-
1613         ing multiple programming and data sections.   The  name  is  the
1614         area  label used by the assembler and the linker to collect code
1615         from various separately assembled modules into one section.  The
1616         name may be from 1 to 79 characters in length.
1617
1618            The options are specified within parenthesis and separated by
1619         commas as shown in the following example:
1620
1621                 .area  TEST  (REL,CON)  ;This section is relocatable
1622                                         ;and concatenated with other
1623                                         ;sections of this program area.
1624
1625                 .area  DATA  (REL,OVR)  ;This section is relocatable
1626                                         ;and overlays other sections
1627                                         ;of this program area.
1628
1629                 .area  SYS   (ABS,OVR)  ;This section is defined as
1630                                         ;absolute and overlays other
1631                                         ;sections of this program area.
1632
1633                 .area  PAGE  (PAG)      ;This is a paged section. The
1634                                         ;section must be on a 256 byte
1635                                         ;boundary and its length is
1636                                         ;checked by the linker to be
1637                                         ;no larger than 256 bytes.
1638                                         ;This is useful for direct page
1639                                         ;areas.
1640
1641 \f
1642
1643         THE ASSEMBLER                                          PAGE 1-22
1644         GENERAL ASSEMBLER DIRECTIVES
1645
1646
1647            The  default  area type is REL|CON;  i.e.  a relocatable sec-
1648         tion which is concatenated with other sections of code with  the
1649         same area name.  The ABS option indicates an absolute area.  The
1650         OVR and CON options indicate if program  sections  of  the  same
1651         name  will overlay each other (start at the same location) or be
1652         concatenated with each other (appended to each other).
1653
1654            Warning: ABS used to automatically invoke OVR and CON was not
1655         allowed  with ABS.  This  behaviour  has been changed.  Absolute
1656         sections  need an explicit  OVR flag to be overlayed  with other
1657         sections of this program area.  Overlapping  absolute areas will
1658         generate a warning unless OVR is specified.
1659
1660            Multiple  invocations  of  the  .area directive with the same
1661         name must specify the same options or leave  the  options  field
1662         blank,  this  defaults  to  the previously specified options for
1663         this program area.
1664
1665         The   ASxxxx   assemblers   automatically  provide  two  program
1666         sections:
1667
1668                 '.  .ABS.'      This dummy section contains all absolute
1669                                 symbols and their values.
1670
1671                 '_CODE'         This  is  the default program/data area.
1672                                 This program area is of type (REL,CON).
1673
1674         The  ASxxxx  assemblers  also automatically generate two symbols
1675         for each program area:
1676
1677                 's_&lt;area&gt;'      This is the starting address of the pro-
1678                                 gram area.
1679
1680                                 indent  -16  'l_&lt;area&gt;'      This is the
1681                                 length of the program area.
1682
1683         The .area names and options are never case sensitive.
1684
1685
1686         1.4.15  .org Directive
1687
1688         Format:
1689
1690                 .org    exp
1691
1692         where:  exp     is  an absolute expression that becomes the cur-
1693                         rent location counter.
1694
1695         The  .org directive is valid only in an absolute program section
1696         and will give a (q) error if used in a relocatable program area.
1697         The  .org  directive specifies that the current location counter
1698         is to become the specified absolute value.
1699
1700
1701 \f
1702
1703         THE ASSEMBLER                                          PAGE 1-23
1704         GENERAL ASSEMBLER DIRECTIVES
1705
1706
1707         1.4.16  .globl Directive
1708
1709         Format:
1710
1711                 .globl  sym1,sym2,...,symn
1712
1713         where:  sym1,           represent legal symbolic names. When
1714                 sym2,...        When multiple symbols are specified,
1715                 symn            they are separated by commas.
1716
1717            A  .globl directive may also have a label field and/or a com-
1718         ment field.
1719
1720            The  .globl directive is provided to define (and thus provide
1721         linkage to) symbols not  otherwise  defined  as  global  symbols
1722         within  a  module.   In  defining  global  symbols the directive
1723         .globl J is similar to:
1724
1725               J == expression or J::
1726
1727            Because  object  modules  are linked by global symbols, these
1728         symbols are vital to a program.  All internal symbols  appearing
1729         within  a  given program must be defined at the end of pass 1 or
1730         they will be considered undefined.  The assembly directive  (-g)
1731         can  be  be  invoked to make all undefined symbols global at the
1732         end of pass 1.
1733
1734
1735         1.4.17  .if, .else, and .endif Directives
1736
1737         Format:
1738
1739                 .if     expr
1740                 .                       ;}
1741                 .                       ;} range of true condition
1742                 .                       ;}
1743                 .else
1744                 .                       ;}
1745                 .                       ;} range of false condition
1746                 .                       ;}
1747                 .endif
1748
1749            The  conditional  assembly directives allow you to include or
1750         exclude blocks of source code during the assembly process, based
1751         on the evaluation of the condition test.
1752
1753            The  range of true condition will be processed if the expres-
1754         sion 'expr' is not zero (i.e.  true) and the range of false con-
1755         dition  will  be processed if the expression 'expr' is zero (i.e
1756         false).  The range of true condition is optional as is the .else
1757         directive  and  the range of false condition.  The following are
1758         all valid .if/.else/.endif constructions:
1759 \f
1760
1761         THE ASSEMBLER                                          PAGE 1-24
1762         GENERAL ASSEMBLER DIRECTIVES
1763
1764
1765
1766                 .if     A-4             ;evaluate A-4
1767                 .byte   1,2             ;insert bytes if A-4 is
1768                 .endif                  ;not zero
1769
1770                 .if     K+3             ;evaluate K+3
1771                 .else
1772                 .byte   3,4             ;insert bytes if K+3
1773                 .endif                  ;is zero
1774
1775                 .if     J&amp;3             ;evaluate J masked by 3
1776                 .byte   12              ;insert this byte if J&amp;3
1777                 .else                   ;is not zero
1778                 .byte   13              ;insert this byte if J&amp;3
1779                 .endif                  ;is zero
1780
1781
1782         The .if/.else/.endif directives may be nested upto 10 levels.
1783
1784            The  .page  directive  is  processed within a false condition
1785         range to allow extended textual information to  be  incorporated
1786         in  the  source  program  with  out  the need to use the comment
1787         delimiter (;):
1788
1789                 .if     0
1790
1791                 .page
1792                 This text will be bypassed during assembly
1793                 but appear in the listing file.
1794                 .
1795                 .
1796                 .
1797
1798                 .endif
1799
1800
1801         1.4.18  .include Directive
1802
1803         Format:
1804
1805                 .include        string
1806
1807         where:  string  represents  a  delimited string that is the file
1808                         specification of an ASxxxx source file.
1809
1810            The .include directive is used to insert a source file within
1811         the source file currently being assembled.  When this  directive
1812         is encountered, an implicit .page directive is issued.  When the
1813         end of the specified source file is reached, an  implicit  .page
1814         directive is issued and input continues from the previous source
1815         file.  The maximum nesting level of source files specified by  a
1816         .include directive is five.
1817 \f
1818
1819         THE ASSEMBLER                                          PAGE 1-25
1820         GENERAL ASSEMBLER DIRECTIVES
1821
1822
1823            The  total  number  of separately specified .include files is
1824         unlimited as each .include file is opened and then closed during
1825         each pass made by the assembler.
1826
1827
1828         1.4.19  .setdp Directive
1829
1830         Format:
1831
1832                 .setdp [base [,area]]
1833
1834         The  set  direct  page  directive has a common format in all the
1835         AS68xx assemblers.  The .setdp directive is used to  inform  the
1836         assembler  of  the current direct page region and the offset ad-
1837         dress within the selected area.  The normal  invocation  methods
1838         are:
1839
1840                 .area   DIRECT  (PAG)
1841                 .setdp
1842
1843                 or
1844
1845                 .setdp  0,DIRECT
1846
1847         for  all  the  68xx microprocessors (the 6804 has only the paged
1848         ram area).  The commands specify that the direct page is in area
1849         DIRECT and its offset address is 0 (the only valid value for all
1850         but the 6809 microprocessor).  Be sure to place the DIRECT  area
1851         at address 0 during linking.  When the base address and area are
1852         not specified, then zero and the current area are the  defaults.
1853         If  a  .setdp directive is not issued the assembler defaults the
1854         direct page to the area "_CODE" at offset 0.
1855
1856            The  assembler  verifies  that  any  local variable used in a
1857         direct variable reference is located in this area.  Local  vari-
1858         able  and  constant value direct access addresses are checked to
1859         be within the address range from 0 to 255.
1860
1861            External direct references are assumed by the assembler to be
1862         in the correct area and have valid  offsets.   The  linker  will
1863         check all direct page relocations to verify that they are within
1864         the correct area.
1865
1866            The  6809  microprocessor  allows the selection of the direct
1867         page to be on any 256 byte boundary by loading  the  appropriate
1868         value  into the dp register.  Typically one would like to select
1869         the page boundary at link time, one method follows:
1870 \f
1871
1872         THE ASSEMBLER                                          PAGE 1-26
1873         GENERAL ASSEMBLER DIRECTIVES
1874
1875
1876                 .area   DIRECT  (PAG)   ; define the direct page
1877                 .setdp
1878                 .
1879                 .
1880                 .
1881                 .area   PROGRAM
1882                 .
1883                 ldd     #DIRECT         ; load the direct page register
1884                 tfr     a,dp            ; for access to the direct page
1885
1886         At  link  time specify the base and global equates to locate the
1887         direct page:
1888
1889                 -b DIRECT = 0x1000
1890                 -g DIRECT = 0x1000
1891
1892         Both  the  area address and offset value must be specified (area
1893         and variable names are independent).   The  linker  will  verify
1894         that  the  relocated  direct page accesses are within the direct
1895         page.
1896         The  preceeding  sequence  could  be repeated for multiple paged
1897         areas, however an alternate method is to define a non-paged area
1898         and use the .setdp directive to specify the offset value:
1899
1900                 .area   DIRECT          ; define non-paged area
1901                 .
1902                 .
1903                 .
1904                 .area   PROGRAM
1905                 .
1906                 .setdp  0,DIRECT        ; direct page area
1907                 ldd     #DIRECT         ; load the direct page register
1908                 tfr     a,dp            ; for access to the direct page
1909                 .
1910                 .
1911                 .setdp  0x100,DIRECT    ; direct page area
1912                 ldd     #DIRECT+0x100   ; load the direct page register
1913                 tfr     a,dp            ; for access to the direct page
1914
1915         The  linker  will  verify that subsequent direct page references
1916         are in the specified area and offset address range.  It  is  the
1917         programmers responsibility to load the dp register with the cor-
1918         rect page segment  corresponding  to  the  .setdp  base  address
1919         specified.
1920
1921            For  those  cases  where a single piece of code must access a
1922         defined data structure within a direct page and there  are  many
1923         pages,  define  a  dumby  direct page linked at address 0.  This
1924         dumby page is used only to define  the  variable  labels.   Then
1925         load  the dp register with the real base address but donot use a
1926         .setdp  directive.   This  method  is  equivalent   to   indexed
1927 \f
1928
1929         THE ASSEMBLER                                          PAGE 1-27
1930         GENERAL ASSEMBLER DIRECTIVES
1931
1932
1933         addressing,  where the dp register is the index register and the
1934         direct addressing is the offset.
1935
1936
1937         1.5  INVOKING ASXXXX
1938
1939
1940            The  ASxxxx assemblers are command line oriented.  The PC as-
1941         semblers are started with the appropriate option(s) and  file(s)
1942         to assemble following the assembler name:
1943
1944         as-z80 [-dqxjgaloscpff] file1 [file2 file3 ...  file6]
1945
1946         The options are:
1947
1948                 d       decimal listing
1949                 q       octal   listing
1950                 x       hex     listing (default)
1951
1952                         The listing radix affects the
1953                         .lst, .rel, and .sym files.
1954
1955                 j       add line number and debug information to file
1956                 g       undefined symbols made global
1957                 a       all user symbols made global
1958
1959                 l       create list   output file1.lst
1960                 o       create object output file1.rel
1961                 s       create symbol output file1.sym
1962
1963                 c       generate sdcdb debug information
1964
1965                 p       disable listing pagination
1966
1967                         relocatable reference flagging:
1968
1969                 f       by  `   in the listing file
1970                 ff      by mode in the listing file
1971
1972         asx8051 specific command line option:
1973                 -I<dir>  Add the named directory to the include file
1974                         search path.  This option may be used more than once.
1975                         Directories are searched in the order given.
1976
1977            The file name for the .lst, .rel, and .sym files is the first
1978         file name specified in the command line.  All output  files  are
1979         ascii  text  files which may be edited, copied, etc.  The output
1980         files are the concatenation of all the input files, if files are
1981         to  be  assembled  independently  invoke  the assembler for each
1982         file.
1983
1984            The  .rel  file contains a radix directive so that the linker
1985         will use the proper conversion for this file.  Linked files  may
1986         have different radices.
1987
1988         ASXXXX assembles supported by and distributed with SDCC are:
1989                 asx8051         (Intel 8051)
1990                 as-z80          (Zilog Z80 / Hitachi HD64180)
1991                 as-gbz80        (GameBoy Z80-like CPU)
1992                 as-hc08         (Motorola 68HC08)
1993 \f
1994
1995         THE ASSEMBLER                                          PAGE 1-28
1996         INVOKING ASXXXX
1997
1998
1999            If  the list (l) option is specified without the symbol table
2000         (s) option, the symbol table is placed at the end of the listing
2001         file.
2002
2003
2004         1.6  ERRORS
2005
2006
2007            The  ASxxxx assemblers provide limited diagnostic error codes
2008         during the assembly process, these errors will be noted  in  the
2009         listing file and printed on the stderr device.
2010
2011            The assembler reports the errors on the stderr device as
2012
2013                 ?ASxxxx-Error-&lt;*&gt; in line nnn of filename
2014
2015         where  * is the error code, nnn is the line number, and filename
2016         is the source/include file.
2017
2018            The errors are:
2019
2020               (.)   This  error  is caused by an absolute direct assign-
2021                     ment of the current location counter
2022                           . = expression (incorrect)
2023                     rather than the correct
2024                           . = . + expression
2025
2026               (a)   Indicates  a machine specific addressing or address-
2027                     ing mode error.
2028
2029               (b)   Indicates a direct page boundary error.
2030
2031               (d)   Indicates a direct page addressing error.
2032
2033               (i)   Caused  by  an  .include file error or an .if/.endif
2034                     mismatch.
2035
2036               (m)   Multiple  definitions  of  the  same label, multiple
2037                     .module directives, or multiple  conflicting  attri-
2038                     butes in an .area directive.
2039
2040               (o)   Directive  or  mnemonic error or the use of the .org
2041                     directive in a relocatable area.
2042
2043               (p)   Phase error:  label location changing between passes
2044                     2 and 3.  Normally caused by having  more  than  one
2045                     level of forward referencing.
2046
2047               (q)   Questionable syntax:  missing or improper operators,
2048                     terminators, or delimiters.
2049
2050               (r)   Relocation  error:   logic  operation attempted on a
2051 \f
2052
2053         THE ASSEMBLER                                          PAGE 1-29
2054         ERRORS
2055
2056
2057                     relocatable term, addition of two relocatable terms,
2058                     subtraction  of two relocatable terms not within the
2059                     same programming area or external symbols.
2060
2061               (u)   Undefined symbol encountered during assembly.
2062
2063
2064         1.7  LISTING FILE
2065
2066
2067            The  (-l) option produces an ascii output listing file.  Each
2068         page of output contains a four line header:
2069
2070
2071              1.  The ASxxxx program name and page number
2072
2073              2.  Title from a .title directive (if any)
2074
2075              3.  Subtitle from a .sbttl directive (if any)
2076
2077              4.  Blank line
2078
2079
2080
2081         Each succeeding line contains five fields:
2082
2083
2084              1.  Error field (first three characters of line)
2085
2086              2.  Current location counter
2087
2088              3.  Generated code in byte format
2089
2090              4.  Source text line number
2091
2092              5.  Source text
2093
2094
2095            The error field may contain upto 2 error flags indicating any
2096         errors encountered while assembling this line of source code.
2097
2098            The  current  location counter field displays the 16-bit pro-
2099         gram position.  This field will be in the selected radix.
2100
2101            The generated code follows the program location.  The listing
2102         radix determines the number of bytes that will be  displayed  in
2103         this field.  Hexidecimal listing allows six bytes of data within
2104         the field, decimal and octal allow four bytes within the  field.
2105         If more than one field of data is generated from the assembly of
2106         a single line of source code, then the data field is repeated on
2107         successive lines.
2108
2109 \f
2110
2111         THE ASSEMBLER                                          PAGE 1-30
2112         LISTING FILE
2113
2114
2115            The source text line number is printed in decimal and is fol-
2116         lowed by the source text.
2117
2118            Two  special  cases  will  disable  the  listing of a line of
2119         source text:
2120
2121              1.  Source line with a .page directive is never listed.
2122
2123              2.  Source  line  with  a  .include  file  directive is not
2124                  listed unless the .include file cannot be opened.
2125
2126
2127            Two  data  field  options  are  available to flag those bytes
2128         which will be relocated by the linker.   If  the  -f  option  is
2129         specified  then  each  byte to be relocated will be preceeded by
2130         the '`' character.  If the -ff option  is  specified  then  each
2131         byte  to  be relocated will be preceeded by one of the following
2132         characters:
2133
2134              1.  *   paged relocation
2135
2136              2.  u   low  byte of unsigned word or unsigned byte
2137
2138              3.  v   high byte of unsigned word
2139
2140              4.  p   PCR low  byte of word relocation or PCR byte
2141
2142              5.  q   PCR high byte of word relocation
2143
2144              6.  r   low  byte relocation or byte relocation
2145
2146              7.  s   high byte relocation
2147
2148
2149
2150         1.8  SYMBOL TABLE FILE
2151
2152
2153            The symbol table has two parts:
2154
2155              1.  The alphabetically sorted list of symbols and/or labels
2156                  defined or referenced in the source program.
2157
2158              2.  A  list of the program areas defined during assembly of
2159                  the source program.
2160
2161
2162            The sorted list of symbols and/or labels contains the follow-
2163         ing information:
2164
2165              1.  Program  area  number (none if absolute value or exter-
2166                  nal)
2167 \f
2168
2169         THE ASSEMBLER                                          PAGE 1-31
2170         SYMBOL TABLE FILE
2171
2172
2173              2.  The symbol or label
2174
2175              3.  Directly assigned symbol is denoted with an (=) sign
2176
2177              4.  The  value of a symbol, location of a label relative to
2178                  the program area base address (=0), or a ****  indicat-
2179                  ing the symbol or label is undefined.
2180
2181              5.  The  characters:   G - global, R - relocatable, and X -
2182                  external.
2183
2184
2185            The list of program areas provides the correspondence between
2186         the program area numbers and the defined program areas, the size
2187         of the program areas, and the area flags (attributes).
2188
2189
2190         1.9  OBJECT FILE
2191
2192
2193            The  object  file is an ascii file containing the information
2194         needed by the linker to bind multiple object modules into a com-
2195         plete  loadable  memory  image.   The object module contains the
2196         following designators:
2197
2198                 [XDQ][HL]
2199                         X       Hexidecimal radix
2200                         D       Decimal radix
2201                         Q       Octal radix
2202
2203                         H       Most significant byte first
2204                         L       Least significant byte first
2205
2206                 H       Header
2207                 M       Module
2208                 A       Area
2209                 S       Symbol
2210                 T       Object code
2211                 R       Relocation information
2212                 P       Paging information
2213
2214            Refer to the linker for a detailed description of each of the
2215         designators and the format of the information contained  in  the
2216         object file.
2217 \f
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231                                     CHAPTER 2
2232
2233                                    THE LINKER
2234
2235
2236
2237
2238
2239         2.1  ASLINK RELOCATING LINKER
2240
2241
2242            ASLINK is the companion linker for the ASxxxx assemblers.
2243
2244            The  program ASLINK is a general relocating linker performing
2245         the following functions:
2246
2247              1.  Bind multiple object modules into a single memory image
2248
2249              2.  Resolve inter-module symbol references
2250
2251              3.  Combine  code  belonging to the same area from multiple
2252                  object files into a single contiguous memory region
2253
2254              4.  Search and import object module libraries for undefined
2255                  global variables
2256
2257              5.  Perform   byte   and   word  program  counter  relative
2258                  (pc or pcr) addressing calculations
2259
2260              6.  Define absolute symbol values at link time
2261
2262              7.  Define absolute area base address values at link time
2263
2264              8.  Produce Intel Hex or Motorola S19 output file
2265
2266              9.  Produce a map of the linked memory image
2267
2268             10.  Produce  an updated listing file with the relocated ad-
2269                  dresses and data
2270
2271
2272
2273 \f
2274
2275         THE LINKER                                              PAGE 2-2
2276         INVOKING ASLINK
2277
2278
2279         2.2  INVOKING ASLINK
2280
2281
2282            The  linker  may run in the command line mode or command file
2283         modes.  The allowed startup linker commands are:
2284
2285         -c/-f           command line / command file modes
2286
2287         -p/-n           enable/disable echo file.lnk input to stdout
2288
2289            If  command  line  mode is selected, all linker commands come
2290         from stdin, if the command file mode is  selected  the  commands
2291         are input from the specified file (extension must be .lnk).
2292
2293            Most  sytems require the initial options to be entered on the
2294            command line:
2295
2296                 ASLINK -[cfpn]
2297
2298            Some  systems  may  request the arguments after the linker is
2299            started at a system specific prompt:
2300
2301                 ASLINK
2302                 argv:  -[cfpn]
2303
2304         After invoking the linker the valid options are:
2305
2306              1.  -i/-s   Intel Hex (file.ihx) or Motorola S19 (file.s19)
2307                  image output file.
2308
2309              2.  -m      Generate a map file (file.map).  This file con-
2310                  tains a list of the symbols (by area) with absolute ad-
2311                  dresses,  sizes  of  linked  areas,  and  other linking
2312                  information.
2313
2314              3.  -xdq    Specifies  the  number  radix  for the map file
2315                  (Hexidecimal, Decimal, or Octal).
2316
2317              4.  -u      Generate  an  updated  listing  file (file.rst)
2318                  derived from the relocated addresses and data from  the
2319                  linker
2320
2321              5.  fileN   Files  to  be linked.  Files may be on the same
2322                  line as the above options or on a separate line(s)  one
2323                  file  per line or multiple files separated by spaces or
2324                  tabs.
2325
2326              6.  -b  area = expression (one definition per line)
2327                  This  specifies  an area base address where the expres-
2328                  sion may contain constants and/or defined symbols  from
2329                  the linked files.
2330
2331              7.  -g  symbol = expression (one definition per line)
2332                  This  specifies  the value for the symbol where the ex-
2333                  pression may contain constants and/or  defined  symbols
2334                  from the linked files.
2335
2336              8.  -k  library directory path
2337                  (one  definition  per line) This specifies one possible
2338
2339 \f
2340
2341         THE LINKER                                              PAGE 2-3
2342         INVOKING ASLINK
2343
2344
2345                  path to an object library.  More than one path  is  al-
2346                  lowed.
2347
2348              9.  -l  library file specification
2349                  (one  definition  per  line)  This specifies a possible
2350                  library file.  More than one file is allowed.
2351
2352             10.  -e      or null line, terminates input to the linker.
2353
2354         ASLINK linkers supported by and distributed with SDCC are:
2355                 aslink          (Intel 8051)
2356                 link-z90        (Zilog Z80 / Hitachi HD64180)
2357                 link-gbz80      (GameBoy Z80-like CPU)
2358                 link-hc08       (Motorola 68HC08)
2359
2360         aslink (Intel 8051) specific options:
2361
2362         Output:
2363           -j   Produce NoICE debug as file[NOI]
2364           -z   Produce SDCdb debug as file[cdb]
2365           -u   Update listing file(s) with link data as file(s)[.RST]
2366         Miscellaneous:
2367           -a   [iram-size] Check for internal RAM overflow
2368           -v   [xram-size] Check for external RAM overflow
2369           -w   [code-size] Check for code overflow
2370           -y   Generate memory usage summary file[mem]
2371           -Y   Pack internal ram
2372           -A   [stack-size] Allocate space for stack
2373
2374
2375         link-z80 (Zilog Z80 / Hitachi HD64180) specific options:
2376
2377         Map format:
2378           -j   no$gmb symbol file generated as file[SYM]
2379         Output:
2380           -z   Produce SDCdb debug as file[cdb]
2381           -Z   Gameboy image as file[GB]
2382         List:
2383           -u   Update listing file(s) with link data as file(s)[.RST]
2384
2385
2386         link-gbz80 (GameBoy Z80-like CPU) specific options:
2387
2388         Relocation:
2389           -yo  Number of rom banks (default: 2)
2390           -ya  Number of ram banks (default: 0)
2391           -yt  MBC type (default: no MBC)
2392           -yn  Name of program (default: name of output file)
2393           -yp# Patch one byte in the output GB file (# is: addr=byte)
2394         Map format:
2395           -j   no$gmb symbol file generated as file[SYM]
2396         Output:
2397           -Z   Gameboy image as file[GB]
2398         List:
2399           -u   Update listing file(s) with link data as file(s)[.RST]
2400
2401
2402         link-hc08 (Motorola 68HC08) specific options:
2403         Output:
2404           -t   ELF executable as file[elf]
2405           -j    Produce NoICE debug as file[NOI]
2406           -z   Produce SDCdb debug as file[cdb]
2407           -u    Update listing file(s) with link data as file(s)[.RST]
2408         Miscellaneous:
2409           -a    [iram-size] Check for internal RAM overflow
2410           -v    [xram-size] Check for external RAM overflow
2411           -w    [code-size] Check for code overflow
2412
2413
2414
2415         2.3  LIBRARY PATH(S) AND FILE(S)
2416
2417
2418            The process of resolving undefined symbols after scanning the
2419         input object  files  includes  the  scanning  of  object  module
2420         libraries.   The  linker will search through all combinations of
2421         the library path specifications (input by the -k option) and the
2422         library  file  specifications (input by the -l option) that lead
2423         to an existing library file.  Each library file contains a  list
2424         (one  file  per  line)  of  modules  included in this particular
2425         library.  Each existing object module is scanned for a match  to
2426         the undefined symbol.  The first module containing the symbol is
2427         then linked with the previous modules to resolve the symbol  de-
2428         finition.   The  library  object  modules are rescanned until no
2429         more symbols can be resolved.   The  scanning  algorithm  allows
2430         resolution  of  back references.  No errors are reported for non
2431         existant library files or object modules.
2432
2433            The  library  file  specification may be formed in one of two
2434         ways:
2435
2436              1.  If  the  library  file  contained an absolute path/file
2437                  specification  then  this  is   the   object   module's
2438                  path/file.
2439                  (i.e.  C:\...)
2440
2441              2.  If  the  library  file  contains  a  relative path/file
2442                  specification then the concatenation of  the  path  and
2443 \f
2444
2445         THE LINKER                                              PAGE 2-4
2446         LIBRARY PATH(S) AND FILE(S)
2447
2448
2449                  this  file  specification  becomes  the object module's
2450                  path/file.
2451                  (i.e.  \...)
2452
2453
2454            As  an example, assume there exists a library file termio.lib
2455         in the syslib directory specifying the following object modules:
2456
2457         \6809\io_disk        first object module
2458         d:\special\io_comm   second object module
2459
2460         and the following parameters were specified to the linker:
2461
2462         -k c:\iosystem\    the first path
2463         -k c:\syslib\      the second path
2464
2465         -l termio          the first library file
2466         -l io              the second library file (no such file)
2467
2468         The  linker  will attempt to use the following object modules to
2469         resolve any undefined symbols:
2470
2471         c:\syslib\6809\io_disk.rel     (concatenated path/file)
2472         d:\special\io_comm.rel         (absolute path/file)
2473
2474         all  other path(s)/file(s) don't exist.  (No errors are reported
2475         for non existant path(s)/file(s).)
2476
2477
2478         2.4  ASLINK PROCESSING
2479
2480
2481            The  linker  processes  the  files  in  the  order  they  are
2482         presented.  The first pass through the input files  is  used  to
2483         define  all  program  areas, the section area sizes, and symbols
2484         defined or referenced.  Undefined symbols will initiate a search
2485         of any specified library file(s) and the importing of the module
2486         containing the symbol definition.  After the first pass  the  -b
2487         (area  base  address) definitions, if any, are processed and the
2488         areas linked.
2489
2490            The  area  linking proceeds by first examining the area types
2491         ABS, CON, REL, OVR and PAG.  Absolute areas (ABS) from  separate
2492         object modules are always overlayed and have been assembled at a
2493         specific address, these are not normally relocated (if a -b com-
2494         mand  is  used  on an absolute area the area will be relocated).
2495         Relative areas (normally defined as REL|CON) have a base address
2496         of  0x0000  as read from the object files, the -b command speci-
2497         fies the beginning address of the area.  All subsequent relative
2498         areas  will  be  concatenated  with  proceeding  relative areas.
2499         Where specific ordering is desired, the first linker input  file
2500         should  have  the area definitions in the desired order.  At the
2501 \f
2502
2503         THE LINKER                                              PAGE 2-5
2504         ASLINK PROCESSING
2505
2506
2507         completion of the area linking all area  addresses  and  lengths
2508         have  been determined.  The areas of type PAG are verified to be
2509         on a 256 byte boundary and that the length does not  exceed  256
2510         bytes.  Any errors are noted on stderr and in the map file.
2511
2512            Next  the  global symbol definitions (-g option), if any, are
2513         processed.  The symbol definitions have been delayed until  this
2514         point because the absolute addresses of all internal symbols are
2515         known and can be used in the expression calculations.
2516
2517            Before  continuing  with the linking process the symbol table
2518         is scanned to determine if any symbols have been referenced  but
2519         not defined.  Undefined symbols are listed on the stderr device.
2520         if a .module directive was included in the  assembled  file  the
2521         module  making  the reference to this undefined variable will be
2522         printed.
2523
2524            Constants  defined  as global in more than one module will be
2525         flagged as multiple definitions if their values are not  identi-
2526         cal.
2527
2528            After  the  preceeding  processes are complete the linker may
2529         output a map file (-m option).  This file provides the following
2530         information:
2531
2532              1.  Global symbol values and label absolute addresses
2533
2534              2.  Defined areas and there lengths
2535
2536              3.  Remaining undefined symbols
2537
2538              4.  List of modules linked
2539
2540              5.  List of library modules linked
2541
2542              6.  List of -b and -g definitions
2543
2544
2545
2546
2547            The final step of the linking process is performed during the
2548         second pass of the input files.  As the xxx.rel files  are  read
2549         the code is relocated by substituting the physical addresses for
2550         the referenced symbols and areas and may be output in  Intel  or
2551         Motorola  formats.   The  number of files linked and symbols de-
2552         fined/referenced is limited by the processor space available  to
2553         build the area/symbol lists.  If the -u option is specified then
2554         the listing files  (file.lst)  associated  with  the  relocation
2555         files  (file.rel)  are  scanned  and  used  to create a new file
2556         (file.rst) which has all addresses and data relocated  to  their
2557         final values.
2558
2559 \f
2560
2561         THE LINKER                                              PAGE 2-6
2562         LINKER INPUT FORMAT
2563
2564
2565         2.5  LINKER INPUT FORMAT
2566
2567
2568            The  linkers'  input  object file is an ascii file containing
2569         the information needed by the linker  to  bind  multiple  object
2570         modules into a complete loadable memory image.
2571
2572         The object module contains the following designators:
2573
2574                 [XDQ][HL]
2575                         X       Hexidecimal radix
2576                         D       Decimal radix
2577                         Q       Octal radix
2578
2579                         H       Most significant byte first
2580                         L       Least significant byte first
2581
2582                 H       Header
2583                 M       Module
2584                 A       Area
2585                 S       Symbol
2586                 T       Object code
2587                 R       Relocation information
2588                 P       Paging information
2589
2590
2591         2.5.1  Object Module Format
2592
2593
2594            The  first  line  of  an object module contains the [XDQ][HL]
2595         format specifier (i.e.  XH indicates  a  hexidecimal  file  with
2596         most significant byte first) for the following designators.
2597
2598
2599         2.5.2  Header Line
2600
2601                 H aa areas gg global symbols
2602
2603            The  header  line  specifies  the number of areas(aa) and the
2604         number of global symbols(gg) defined or referenced in  this  ob-
2605         ject module segment.
2606
2607
2608 \f
2609
2610         THE LINKER                                              PAGE 2-7
2611         LINKER INPUT FORMAT
2612
2613
2614         2.5.3  Module Line
2615
2616                 M name
2617
2618            The  module  line  specifies  the module name from which this
2619         header segment was assembled.  The module line will  not  appear
2620         if the .module directive was not used in the source program.
2621
2622
2623         2.5.4  Symbol Line
2624
2625                 S string Defnnnn
2626
2627                         or
2628
2629                 S string Refnnnn
2630
2631            The  symbol line defines (Def) or references (Ref) the symbol
2632         'string' with the value nnnn.  The defined value is relative  to
2633         the  current area base address.  References to constants and ex-
2634         ternal global symbols will always appear before the  first  area
2635         definition.  References to external symbols will have a value of
2636         zero.
2637
2638
2639         2.5.5  Area Line
2640
2641                 A label size ss flags ff
2642
2643            The  area  line  defines the area label, the size (ss) of the
2644         area in bytes, and the area flags (ff).  The area flags  specify
2645         the ABS, REL, CON, OVR, and PAG parameters:
2646
2647                 OVR/CON  (0x04/0x00 i.e.  bit position 2)
2648
2649                 ABS/REL  (0x08/0x00 i.e.  bit position 3)
2650
2651                 PAG      (0x10 i.e.  bit position 4)
2652
2653
2654         2.5.6  T Line
2655
2656                 T xx xx nn nn nn nn nn ...
2657
2658            The  T  line contains the assembled code output by the assem-
2659         bler with xx xx being the offset address from the  current  area
2660         base address and nn being the assembled instructions and data in
2661         byte format.
2662
2663
2664 \f
2665
2666         THE LINKER                                              PAGE 2-8
2667         LINKER INPUT FORMAT
2668
2669
2670         2.5.7  R Line
2671
2672                 R 0 0 nn nn n1 n2 xx xx ...
2673
2674            The R line provides the relocation information to the linker.
2675         The nn nn value is the current area index, i.e.  which area  the
2676         current  values  were  assembled.  Relocation information is en-
2677         coded in groups of 4 bytes:
2678
2679              1.  n1  is  the  relocation mode and object format, for the
2680                  adhoc extension modes refer to asxxxx.h or aslink.h
2681                  1.  bit 0  word(0x00)/byte(0x01)
2682                  2.  bit 1  relocatable area(0x00)/symbol(0x02)
2683                  3.  bit 2  normal(0x00)/PC relative(0x04) relocation
2684                  4.  bit 3  1-byte(0x00)/2-byte(0x08)  object format for
2685                      byte data
2686                  5.  bit 4  signed(0x00)/unsigned(0x10) byte data
2687                  6.  bit 5  normal(0x00)/page '0'(0x20) reference
2688                  7.  bit 6  normal(0x00)/page 'nnn'(0x40) reference
2689                  8.  bit 7  LSB  byte(0x00)/MSB  byte(0x80)  with 2-byte
2690                      mode
2691
2692              2.  n2  is  a byte index into the corresponding (i.e.  pre-
2693                  ceeding) T line data (i.e.  a pointer to the data to be
2694                  updated  by  the  relocation).   The T line data may be
2695                  1-byte or  2-byte  byte  data  format  or  2-byte  word
2696                  format.
2697
2698              3.  xx xx  is the area/symbol index for the area/symbol be-
2699                  ing referenced.  the corresponding area/symbol is found
2700                  in the header area/symbol lists.
2701
2702
2703         The groups of 4 bytes are repeated for each item requiring relo-
2704         cation in the preceeding T line.
2705
2706
2707         2.5.8  P Line
2708
2709                 P 0 0 nn nn n1 n2 xx xx
2710
2711            The  P  line provides the paging information to the linker as
2712         specified by a .setdp directive.  The format of  the  relocation
2713         information is identical to that of the R line.  The correspond-
2714         ing T line has the following information:
2715                 T xx xx aa aa bb bb
2716
2717            Where  aa aa is the area reference number which specifies the
2718         selected page area and bb bb is the base address  of  the  page.
2719         bb bb will require relocation processing if the 'n1 n2 xx xx' is
2720         specified in the P line.  The linker will verify that  the  base
2721 \f
2722
2723         THE LINKER                                              PAGE 2-9
2724         LINKER INPUT FORMAT
2725
2726
2727         address is on a 256 byte boundary and that the page length of an
2728         area defined with the PAG type is not larger than 256 bytes.
2729
2730            The  linker  defaults any direct page references to the first
2731         area defined in the input REL file.  All ASxxxx assemblers  will
2732         specify the _CODE area first, making this the default page area.
2733
2734
2735         2.6  LINKER ERROR MESSAGES
2736
2737
2738            The linker provides detailed error messages allowing the pro-
2739         grammer to quickly find the errant code.   As  the  linker  com-
2740         pletes  pass 1  over  the  input  file(s)  it  reports  any page
2741         boundary or page length errors as follows:
2742
2743         ?ASlink-Warning-Paged Area PAGE0 Boundary Error
2744
2745         and/or
2746
2747         ?ASlink-Warning-Paged Area PAGE0 Length Error
2748
2749         where PAGE0 is the paged area.
2750
2751            During  Pass  two the linker reads the T, R, and P lines per-
2752         forming the necessary relocations and  outputting  the  absolute
2753         code.  Various errors may be reported during this process
2754         The P line processing can produce only one possible error:
2755
2756         ?ASlink-Warning-Page Definition Boundary Error
2757                  file        module      pgarea      pgoffset
2758           PgDef  t6809l      t6809l      PAGE0       0001
2759
2760         The error message specifies the file and module where the .setdp
2761         direct was issued and indicates  the  page  area  and  the  page
2762         offset value determined after relocation.
2763
2764
2765         The R line processing produces various errors:
2766
2767         ?ASlink-Warning-Byte PCR relocation error for symbol  bra2
2768                  file        module      area        offset
2769           Refby  t6809l      t6809l      TEST        00FE
2770           Defin  tconst      tconst      .  .ABS.    0080
2771
2772         ?ASlink-Warning-Unsigned Byte error for symbol  two56
2773                  file        module      area        offset
2774           Refby  t6800l      t6800l      DIRECT      0015
2775           Defin  tconst      tconst      .  .ABS.    0100
2776 \f
2777
2778         THE LINKER                                             PAGE 2-10
2779         LINKER ERROR MESSAGES
2780
2781
2782         ?ASlink-Warning-Page0 relocation error for symbol  ltwo56
2783                  file        module      area        offset
2784           Refby  t6800l      t6800l      DIRECT      000D
2785           Defin  tconst      tconst      DIRECT      0100
2786
2787         ?ASlink-Warning-Page Mode relocation error for symbol  two56
2788                  file        module      area        offset
2789           Refby  t6809l      t6809l      DIRECT      0005
2790           Defin  tconst      tconst      .  .ABS.    0100
2791
2792         ?ASlink-Warning-Page Mode relocation error
2793                  file        module      area        offset
2794           Refby  t           Pagetest    PROGRAM     0006
2795           Defin  t           Pagetest    DIRECT      0100
2796
2797         These  error messages specify the file, module, area, and offset
2798         within the area of the code  referencing  (Refby)  and  defining
2799         (Defin) the symbol.  If the symbol is defined in the same module
2800         as the reference the linker is unable to report the symbol name.
2801         The  assembler  listing file(s) should be examined at the offset
2802         from the specified area to located the offending code.
2803
2804            The errors are:
2805
2806              1.  The  byte PCR error is caused by exceeding the pc rela-
2807                  tive byte branch range.
2808
2809              2.  The Unsigned byte error indicates an indexing value was
2810                  negative or larger than 255.
2811
2812              3.  The  Page0  error is generated if the direct page vari-
2813                  able is not in the page0 range of 0 to 255.
2814
2815              4.  The page mode error is generated if the direct variable
2816                  is not within the current direct page (6809).
2817
2818 \f
2819
2820         THE LINKER                                             Page 2-11
2821         INTEL HEX OUTPUT FORMAT
2822
2823
2824         2.7  INTEL HEX OUTPUT FORMAT
2825
2826         Record Mark Field    -  This  field  signifies  the  start  of a
2827                                 record, and consists of an  ascii  colon
2828                                 (:).
2829
2830         Record Length Field  -  This   field   consists   of  two  ascii
2831                                 characters which indicate the number  of
2832                                 data   bytes   in   this   record.   The
2833                                 characters are the result of  converting
2834                                 the  number  of  bytes  in binary to two
2835                                 ascii characters, high digit first.   An
2836                                 End  of  File  record contains two ascii
2837                                 zeros in this field.
2838
2839         Load Address Field   -  This  field  consists  of the four ascii
2840                                 characters which result from  converting
2841                                 the  the  binary value of the address in
2842                                 which to begin loading this record.  The
2843                                 order is as follows:
2844
2845                                     High digit of high byte of address.
2846                                     Low digit of high byte of address.
2847                                     High digit of low byte of address.
2848                                     Low digit of low byte of address.
2849
2850                                 In an End of File record this field con-
2851                                 sists of either four ascii zeros or  the
2852                                 program  entry  address.   Currently the
2853                                 entry address option is not supported.
2854
2855         Record Type Field    -  This  field  identifies the record type,
2856                                 which is either 0 for data records or  1
2857                                 for  an End of File record.  It consists
2858                                 of two ascii characters, with  the  high
2859                                 digit of the record type first, followed
2860                                 by the low digit of the record type.
2861
2862         Data Field           -  This  field consists of the actual data,
2863                                 converted to two ascii characters,  high
2864                                 digit first.  There are no data bytes in
2865                                 the End of File record.
2866
2867         Checksum Field       -  The  checksum  field is the 8 bit binary
2868                                 sum of the record length field, the load
2869                                 address  field,  the  record type field,
2870                                 and the data field.  This  sum  is  then
2871                                 negated  (2's  complement) and converted
2872                                 to  two  ascii  characters,  high  digit
2873                                 first.
2874 \f
2875
2876         THE LINKER                                             Page 2-12
2877         MOTOROLA S1-S9 OUTPUT FORMAT
2878
2879
2880         2.8  MOTORLA S1-S9 OUTPUT FORMAT
2881
2882         Record Type Field    -  This  field  signifies  the  start  of a
2883                                 record and  identifies  the  the  record
2884                                 type as follows:
2885
2886                                     Ascii S1 - Data Record
2887                                     Ascii S9 - End of File Record
2888
2889         Record Length Field  -  This  field  specifies the record length
2890                                 which includes the  address,  data,  and
2891                                 checksum   fields.   The  8  bit  record
2892                                 length value is converted to  two  ascii
2893                                 characters, high digit first.
2894
2895         Load Address Field   -  This  field  consists  of the four ascii
2896                                 characters which result from  converting
2897                                 the  the  binary value of the address in
2898                                 which to begin loading this record.  The
2899                                 order is as follows:
2900
2901                                     High digit of high byte of address.
2902                                     Low digit of high byte of address.
2903                                     High digit of low byte of address.
2904                                     Low digit of low byte of address.
2905
2906                                 In an End of File record this field con-
2907                                 sists of either four ascii zeros or  the
2908                                 program  entry  address.   Currently the
2909                                 entry address option is not supported.
2910
2911         Data Field           -  This  field consists of the actual data,
2912                                 converted to two ascii characters,  high
2913                                 digit first.  There are no data bytes in
2914                                 the End of File record.
2915
2916         Checksum Field       -  The  checksum  field is the 8 bit binary
2917                                 sum of the record length field, the load
2918                                 address field, and the data field.  This
2919                                 sum is then  complemented  (1's  comple-
2920                                 ment)   and   converted   to  two  ascii
2921                                 characters, high digit first.
2922 \f
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936                                     CHAPTER 3
2937
2938                            BUILDING ASXXXX AND ASLINK
2939
2940
2941
2942
2943            The assemblers and linker have been successfully compiled us-
2944         ing  the  DECUS C  (PDP-11)  compiler  (patch  level   9)   with
2945         RT-11/TSX+,  Eyring  Research  Institute,  Inc.   PDOS (680x0) C
2946         V5.4b compiler, and Symantec C/C++ V6.1/V7.2.
2947
2948            The  device  specific  header  file  (i.e.  m6800.h, m6801.h,
2949         etc.) contains the DECUS C 'BUILD' directives for  generating  a
2950         command  file to compile, assemble, and link the necessary files
2951         to prepare an executable image for a particular assembler.
2952
2953
2954         3.1  BUILDING AN ASSEMBLER
2955
2956
2957            The  building  of  a typical assembler (6809 for example) re-
2958         quires the following files:
2959
2960              1.  M6809.H
2961              2.  M09EXT.C
2962              3.  M09MCH.C
2963              4.  M09ADR.C
2964              5.  M09PST.C
2965              6.  ASXXXX.H
2966              7.  ASMAIN.C
2967              8.  ASLEX.C
2968              9.  ASSYM.C
2969             10.  ASSUBR.C
2970             11.  ASEXPR.C
2971             12.  ASDATA.C
2972             13.  ASLIST.C
2973             14.  ASOUT.C
2974
2975
2976            The  first  five  files are the 6809 processor dependent sec-
2977         tions which contain the following:
2978
2979
2980 \f
2981
2982         BUILDING ASXXXX AND ASLINK                              PAGE 3-2
2983         BUILDING AN ASSEMBLER
2984
2985
2986              1.  m6809.h -  header  file containing the machine specific
2987                  definitions of constants,  variables,  structures,  and
2988                  types
2989
2990              2.  m09ext -  device  description, byte order, and file ex-
2991                  tension information
2992
2993              3.  m09pst -  a  table of the assembler general directives,
2994                  special device directives, and assembler mnemonics with
2995                  associated operation codes
2996
2997              4.  m09mch / m09adr -  machine specific code for processing
2998                  the device mnemonics,  addressing  modes,  and  special
2999                  directives
3000
3001
3002            The  remaining nine files provide the device independent sec-
3003         tions which handle the  details  of  file  input/output,  symbol
3004         table  generation,  program/data areas, expression analysis, and
3005         assembler directive processing.
3006
3007
3008         3.2  BUILDING ASLINK
3009
3010
3011            The building of the linker requires the following files:
3012
3013              1.  ASLINK.H
3014              2.  LKMAIN.C
3015              3.  LKLEX.C
3016              4.  LKAREA.C
3017              5.  LKHEAD.C
3018              6.  LKSYM.C
3019              7.  LKEVAL.C
3020              8.  LKDATA.C
3021              9.  LKLIST.C
3022             10.  LKRLOC.C
3023             11.  LKLIBR.C
3024             12.  LKS19.C
3025             13.  LKIHX.C
3026
3027 \f
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041                                    APPENDIX A
3042
3043                                 AS6800 ASSEMBLER
3044
3045
3046
3047
3048
3049         A.1  6800 REGISTER SET
3050
3051         The following is a list of the 6800 registers used by AS6800:
3052
3053                 a,b     -       8-bit accumulators
3054                 x       -       index register
3055
3056
3057         A.2  6800 INSTRUCTION SET
3058
3059
3060            The following tables list all 6800/6802/6808 mnemonics recog-
3061         nized by the AS6800 assembler.  The designation [] refers  to  a
3062         required addressing mode argument.  The following list specifies
3063         the format for each addressing mode supported by AS6800:
3064
3065                 #data           immediate data
3066                                 byte or word data
3067
3068                 *dir            direct page addressing
3069                                 (see .setdp directive)
3070                                 0 &lt;= dir &lt;= 255
3071
3072                 ,x              register indirect addressing
3073                                 zero offset
3074
3075                 offset,x        register indirect addressing
3076                                 0 &lt;= offset &lt;= 255
3077
3078                 ext             extended addressing
3079
3080                 label           branch label
3081
3082         The  terms  data, dir, offset, ext, and label may all be expres-
3083         sions.
3084
3085 \f
3086
3087         AS6800 ASSEMBLER                                        PAGE A-2
3088         6800 INSTRUCTION SET
3089
3090
3091            Note  that  not all addressing modes are valid with every in-
3092         struction, refer to the 6800 technical data for valid modes.
3093
3094
3095         A.2.1  Inherent Instructions
3096
3097                 aba                     cba
3098                 clc                     cli
3099                 clv                     daa
3100                 des                     dex
3101                 ins                     inx
3102                 nop                     rti
3103                 rts                     sba
3104                 sec                     sei
3105                 sev                     swi
3106                 tab                     tap
3107                 tba                     tpa
3108                 tsx                     txs
3109                 wai
3110
3111                 psha                    pshb
3112                 psh a                   psh b
3113                 pula                    pulb
3114                 pul a                   pul b
3115
3116
3117         A.2.2  Branch Instructions
3118
3119                 bra     label           bhi     label
3120                 bls     label           bcc     label
3121                 bhs     label           bcs     label
3122                 blo     label           bne     label
3123                 beq     label           bvc     label
3124                 bvs     label           bpl     label
3125                 bmi     label           bge     label
3126                 blt     label           bgt     label
3127                 ble     label           bsr     label
3128 \f
3129
3130         AS6800 ASSEMBLER                                        PAGE A-3
3131         6800 INSTRUCTION SET
3132
3133
3134         A.2.3  Single Operand Instructions
3135
3136                 asla                    aslb
3137                 asl a                   asl b
3138                 asl     []
3139
3140                 asra                    asrb
3141                 asr a                   asr b
3142                 asr     []
3143
3144                 clra                    clrb
3145                 clr a                   clr b
3146                 clr     []
3147
3148                 coma                    comb
3149                 com a                   com b
3150                 com     []
3151
3152                 deca                    decb
3153                 dec a                   dec b
3154                 dec     []
3155
3156                 inca                    incb
3157                 inc a                   inc b
3158                 inc     []
3159
3160                 lsla                    lslb
3161                 lsl a                   lsl b
3162                 lsl     []
3163
3164                 lsra                    lsrb
3165                 lsr a                   lsr b
3166                 lsr     []
3167
3168                 nega                    negb
3169                 neg a                   neg b
3170                 neg     []
3171
3172                 rola                    rolb
3173                 rol a                   rol b
3174                 rol     []
3175
3176                 rora                    rorb
3177                 ror a                   ror b
3178                 ror     []
3179
3180                 tsta                    tstb
3181                 tst a                   tst b
3182                 tst     []
3183 \f
3184
3185         AS6800 ASSEMBLER                                        PAGE A-4
3186         6800 INSTRUCTION SET
3187
3188
3189         A.2.4  Double Operand Instructions
3190
3191                 adca    []              adcb    []
3192                 adc a   []              adc b   []
3193
3194                 adda    []              addb    []
3195                 add a   []              add b   []
3196
3197                 anda    []              andb    []
3198                 and a   []              and b   []
3199
3200                 bita    []              bitb    []
3201                 bit a   []              bit b   []
3202
3203                 cmpa    []              cmpb    []
3204                 cmp a   []              cmp b   []
3205
3206                 eora    []              eorb    []
3207                 eor a   []              eor b   []
3208
3209                 ldaa    []              ldab    []
3210                 lda a   []              lda b   []
3211
3212                 oraa    []              orab    []
3213                 ora a   []              ora b   []
3214
3215                 sbca    []              sbcb    []
3216                 sbc a   []              sbc b   []
3217
3218                 staa    []              stab    []
3219                 sta a   []              sta b   []
3220
3221                 suba    []              subb    []
3222                 sub a   []              sub b   []
3223
3224
3225         A.2.5  Jump and Jump to Subroutine Instructions
3226
3227                 jmp     []              jsr     []
3228
3229
3230 \f
3231
3232         AS6800 ASSEMBLER                                        PAGE A-5
3233         6800 INSTRUCTION SET
3234
3235
3236         A.2.6  Long Register Instructions
3237
3238                 cpx     []
3239                 lds     []              sts     []
3240                 ldx     []              stx     []
3241 \f
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255                                    APPENDIX B
3256
3257                                 AS6801 ASSEMBLER
3258
3259
3260
3261
3262
3263         B.1  .hd6303 DIRECTIVE
3264
3265         Format:
3266
3267                 .hd6303
3268
3269         The  .hd6303 directive enables processing of the HD6303 specific
3270         mnemonics not included in  the  6801  instruction  set.   HD6303
3271         mnemonics  encountered  without  the  .hd6303  directive will be
3272         flagged with an 'o' error.
3273
3274
3275         B.2  6801 REGISTER SET
3276
3277         The following is a list of the 6801 registers used by AS6801:
3278
3279                 a,b     -       8-bit accumulators
3280                 d       -       16-bit accumulator &lt;a:b&gt;
3281                 x       -       index register
3282
3283
3284         B.3  6801 INSTRUCTION SET
3285
3286
3287            The  following tables list all 6801/6303 mnemonics recognized
3288         by the AS6801 assembler.  The designation []  refers  to  a  re-
3289         quired  addressing  mode argument.  The following list specifies
3290         the format for each addressing mode supported by AS6801:
3291
3292                 #data           immediate data
3293                                 byte or word data
3294
3295                 *dir            direct page addressing
3296                                 (see .setdp directive)
3297                                 0 &lt;= dir &lt;= 255
3298
3299 \f
3300
3301         AS6801 ASSEMBLER                                        PAGE B-2
3302         6801 INSTRUCTION SET
3303
3304
3305                 ,x              register indirect addressing
3306                                 zero offset
3307
3308                 offset,x        register indirect addressing
3309                                 0 &lt;= offset &lt;= 255
3310
3311                 ext             extended addressing
3312
3313                 label           branch label
3314
3315         The  terms  data, dir, offset, ext, and label may all be expres-
3316         sions.
3317
3318            Note  that  not all addressing modes are valid with every in-
3319         struction, refer to  the  6801/6303  technical  data  for  valid
3320         modes.
3321
3322
3323         B.3.1  Inherent Instructions
3324
3325                 aba             abx
3326                 cba             clc
3327                 cli             clv
3328                 daa             des
3329                 dex             ins
3330                 inx             mul
3331                 nop             rti
3332                 rts             sba
3333                 sec             sei
3334                 sev             swi
3335                 tab             tap
3336                 tba             tpa
3337                 tsx             txs
3338                 wai
3339
3340
3341         B.3.2  Branch Instructions
3342
3343                 bra     label           brn     label
3344                 bhi     label           bls     label
3345                 bcc     label           bhs     label
3346                 bcs     label           blo     label
3347                 bne     label           beq     label
3348                 bvc     label           bvs     label
3349                 bpl     label           bmi     label
3350                 bge     label           blt     label
3351                 bgt     label           ble     label
3352                 bsr     label
3353 \f
3354
3355         AS6801 ASSEMBLER                                        PAGE B-3
3356         6801 INSTRUCTION SET
3357
3358
3359         B.3.3  Single Operand Instructions
3360
3361                 asla            aslb            asld
3362                 asl a           asl b           asl d
3363                 asl     []
3364
3365                 asra            asrb
3366                 asr a           asr b
3367                 asr     []
3368
3369                 clra            clrb
3370                 clr a           clr b
3371                 clr     []
3372
3373                 coma            comb
3374                 com a           com b
3375                 com     []
3376
3377                 deca            decb
3378                 dec a           dec b
3379                 dec     []
3380
3381                 eora            eorb
3382                 eor a           eor b
3383                 eor     []
3384
3385                 inca            incb
3386                 inc a           inc b
3387                 inc     []
3388
3389                 lsla            lslb            lsld
3390                 lsl a           lsl b           lsl d
3391                 lsl     []
3392
3393                 lsra            lsrb            lsrd
3394                 lsr a           lsr b           lsr d
3395                 lsr     []
3396
3397                 nega            negb
3398                 neg a           neg b
3399                 neg     []
3400
3401                 psha            pshb            pshx
3402                 psh a           psh b           psh x
3403
3404                 pula            pulb            pulx
3405                 pul a           pul b           pul x
3406
3407                 rola            rolb
3408                 rol a           rol b
3409                 rol     []
3410
3411 \f
3412
3413         AS6801 ASSEMBLER                                        PAGE B-4
3414         6801 INSTRUCTION SET
3415
3416
3417                 rora            rorb
3418                 ror a           ror b
3419                 ror     []
3420
3421                 tsta            tstb
3422                 tst a           tst b
3423                 tst     []
3424
3425
3426         B.3.4  Double Operand Instructions
3427
3428                 adca    []      adcb    []
3429                 adc a   []      adc b   []
3430
3431                 adda    []      addb    []      addd    []
3432                 add a   []      add b   []      add d   []
3433
3434                 anda    []      andb    []
3435                 and a   []      and b   []
3436
3437                 bita    []      bitb    []
3438                 bit a   []      bit b   []
3439
3440                 cmpa    []      cmpb    []
3441                 cmp a   []      cmp b   []
3442
3443                 ldaa    []      ldab    []
3444                 lda a   []      lda b   []
3445
3446                 oraa    []      orab    []
3447                 ora a   []      ora b   []
3448
3449                 sbca    []      sbcb    []
3450                 sbc a   []      sbc b   []
3451
3452                 staa    []      stab    []
3453                 sta a   []      sta b   []
3454
3455                 suba    []      subb    []      subd    []
3456                 sub a   []      sub b   []      sub d   []
3457
3458
3459 \f
3460
3461         AS6801 ASSEMBLER                                        PAGE B-5
3462         6801 INSTRUCTION SET
3463
3464
3465         B.3.5  Jump and Jump to Subroutine Instructions
3466
3467                 jmp     []      jsr     []
3468
3469
3470         B.3.6  Long Register Instructions
3471
3472                 cpx     []      ldd     []
3473                 lds     []      ldx     []
3474                 std     []      sts     []
3475                 stx     []
3476
3477
3478         B.3.7  6303 Specific Instructions
3479
3480                 aim     #data, []       eim     #data, []
3481                 oim     #data, []       tim     #data, []
3482
3483                 xgdx            slp
3484 \f
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498                                    APPENDIX C
3499
3500                                 AS6804 ASSEMBLER
3501
3502
3503
3504
3505            Requires the .setdp directive to specify the ram area.
3506
3507
3508         C.1  6804 REGISTER SET
3509
3510         The following is a list of the 6804 registers used by AS6804:
3511
3512                 x,y     -       index registers
3513
3514
3515         C.2  6804 INSTRUCTION SET
3516
3517
3518            The  following  tables  list all 6804 mnemonics recognized by
3519         the AS6804 assembler.  The designation [] refers to  a  required
3520         addressing  mode  argument.   The  following  list specifies the
3521         format for each addressing mode supported by AS6804:
3522
3523                 #data           immediate data
3524                                 byte or word data
3525
3526                 ,x              register indirect addressing
3527
3528                 dir             direct addressing
3529                                 (see .setdp directive)
3530                                 0 &lt;= dir &lt;= 255
3531
3532                 ext             extended addressing
3533
3534                 label           branch label
3535
3536         The  terms data, dir, and ext may be expressions.  The label for
3537         the short branchs beq, bne, bcc, and bcs must not be external.
3538
3539            Note  that  not all addressing modes are valid with every in-
3540         struction, refer to the 6804 technical data for valid modes.
3541 \f
3542
3543         AS6804 ASSEMBLER                                        PAGE C-2
3544         6804 INSTRUCTION SET
3545
3546
3547         C.2.1  Inherent Instructions
3548
3549                 coma            decx
3550                 decy            incx
3551                 incy            rola
3552                 rti             rts
3553                 stop            tax
3554                 tay             txa
3555                 tya             wait
3556
3557
3558         C.2.2  Branch Instructions
3559
3560                 bne     label           beq     label
3561                 bcc     label           bcs     label
3562
3563
3564         C.2.3  Single Operand Instructions
3565
3566                 add     []
3567                 and     []
3568                 cmp     []
3569                 dec     []
3570                 inc     []
3571                 lda     []
3572                 sta     []
3573                 sub     []
3574
3575
3576         C.2.4  Jump and Jump to Subroutine Instructions
3577
3578                 jsr     []
3579                 jmp     []
3580
3581
3582         C.2.5  Bit Test Instructions
3583
3584                 brclr   #data,[],label
3585                 brset   #data,[],label
3586
3587                 bclr    #label,[]
3588                 bset    #label,[]
3589
3590
3591 \f
3592
3593         AS6804 ASSEMBLER                                        PAGE C-3
3594         6804 INSTRUCTION SET
3595
3596
3597         C.2.6  Load Immediate data Instruction
3598
3599                 mvi     [],#data
3600
3601
3602         C.2.7  6804 Derived Instructions
3603
3604                 asla
3605                 bam     label
3606                 bap     label
3607                 bxmi    label
3608                 bxpl    label
3609                 bymi    label
3610                 bypl    label
3611                 clra
3612                 clrx
3613                 clry
3614                 deca
3615                 decx
3616                 decy
3617                 inca
3618                 incx
3619                 incy
3620                 ldxi    #data
3621                 ldyi    #data
3622                 nop
3623                 tax
3624                 tay
3625                 txa
3626                 tya
3627 \f
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641                                    APPENDIX D
3642
3643                                 AS6805 ASSEMBLER
3644
3645
3646
3647
3648
3649         D.1  6805 REGISTER SET
3650
3651         The following is a list of the 6805 registers used by AS6805:
3652
3653                 a       -       8-bit accumulator
3654                 x       -       index register
3655
3656
3657         D.2  6805 INSTRUCTION SET
3658
3659
3660            The  following  tables  list all 6805 mnemonics recognized by
3661         the AS6805 assembler.  The designation [] refers to  a  required
3662         addressing  mode  argument.   The  following  list specifies the
3663         format for each addressing mode supported by AS6805:
3664
3665                 #data           immediate data
3666                                 byte or word data
3667
3668                 *dir            direct page addressing
3669                                 (see .setdp directive)
3670                                 0 &lt;= dir &lt;= 255
3671
3672                 ,x              register indirect addressing
3673                                 zero offset
3674
3675                 offset,x        register indirect addressing
3676                                   0 &lt;= offset &lt;= 255   --- byte mode
3677                                 256 &lt;= offset &lt;= 65535 --- word mode
3678                                 (an externally defined offset uses the
3679                                  word mode)
3680
3681                 ext             extended addressing
3682
3683                 label           branch label
3684
3685 \f
3686
3687         AS6805 ASSEMBLER                                        PAGE D-2
3688         6805 INSTRUCTION SET
3689
3690
3691         The terms data, dir, offset, and ext may all be expressions.
3692
3693            Note  that  not all addressing modes are valid with every in-
3694         struction, refer to the 6805 technical data for valid modes.
3695
3696
3697         D.2.1  Control Instructions
3698
3699                 clc             cli
3700                 nop             rsp
3701                 rti             rts
3702                 sec             sei
3703                 stop            swi
3704                 tax             txa
3705                 wait
3706
3707
3708         D.2.2  Bit Manipulation Instructions
3709
3710                 brset   #data,*dir,label
3711                 brclr   #data,*dir,label
3712
3713                 bset    #data,*dir
3714                 bclr    #data,*dir
3715
3716
3717         D.2.3  Branch Instructions
3718
3719                 bra     label           brn     label
3720                 bhi     label           bls     label
3721                 bcc     label           bcs     label
3722                 bne     label           beq     label
3723                 bhcc    label           bhcs    label
3724                 bpl     label           bmi     label
3725                 bmc     label           bms     label
3726                 bil     label           bih     label
3727                 bsr     label
3728 \f
3729
3730         AS6805 ASSEMBLER                                        PAGE D-3
3731         6805 INSTRUCTION SET
3732
3733
3734         D.2.4  Read-Modify-Write Instructions
3735
3736                 nega            negx
3737                 neg     []
3738
3739                 coma            comx
3740                 com     []
3741
3742                 lsra            lsrx
3743                 lsr     []
3744
3745                 rora            rorx
3746                 ror     []
3747
3748                 asra            asrx
3749                 asr     []
3750
3751                 lsla            lslx
3752                 lsl     []
3753
3754                 rola            rolx
3755                 rol     []
3756
3757                 deca            decx
3758                 dec     []
3759
3760                 inca            incx
3761                 inc     []
3762
3763                 tsta            tstx
3764                 tst     []
3765
3766                 clra            clrx
3767                 clr     []
3768
3769
3770         D.2.5  Register\Memory Instructions
3771
3772                 sub     []              cmp     []
3773                 sbc     []              cpx     []
3774                 and     []              bit     []
3775                 lda     []              sta     []
3776                 eor     []              adc     []
3777                 ora     []              add     []
3778                 ldx     []              stx     []
3779 \f
3780
3781         AS6805 ASSEMBLER                                        PAGE D-4
3782         6805 INSTRUCTION SET
3783
3784
3785         D.2.6  Jump and Jump to Subroutine Instructions
3786
3787                 jmp     []              jsr     []
3788 \f
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802                                    APPENDIX E
3803
3804                                 AS6808 ASSEMBLER
3805
3806
3807
3808
3809
3810         E.1  68HC08 REGISTER SET
3811
3812         The  following  is  a  list  of  the  68HC08  registers  used by
3813         AS68HC08:
3814
3815                 a       -       8-bit accumulator
3816                 x       -       index register  &lt;H:X&gt;
3817                 s       -       stack pointer
3818
3819
3820         E.2  68HC08 INSTRUCTION SET
3821
3822
3823            The  following tables list all 68HC08 mnemonics recognized by
3824         the AS6808 assembler.  The designation [] refers to  a  required
3825         addressing  mode  argument.   The  following  list specifies the
3826         format for each addressing mode supported by AS6808:
3827
3828                 #data           immediate data
3829                                 byte or word data
3830
3831                 *dir            direct page addressing
3832                                 (see .setdp directive)
3833                                 0 &lt;= dir &lt;= 255
3834
3835                 ,x              register indexed addressing
3836                                 zero offset
3837
3838                 offset,x        register indexed addressing
3839                                   0 &lt;= offset &lt;= 255   --- byte mode
3840                                 256 &lt;= offset &lt;= 65535 --- word mode
3841                                 (an externally defined offset uses the
3842                                  word mode)
3843
3844                 ,x+             register indexed addressing
3845                                 zero offset with post increment
3846 \f
3847
3848         AS6808 ASSEMBLER                                        PAGE E-2
3849         68HC08 INSTRUCTION SET
3850
3851
3852
3853                 offset,x+       register indexed addressing
3854                                 unsigned byte offset with post increment
3855
3856                 offset,s        stack pointer indexed addressing
3857                                   0 &lt;= offset &lt;= 255   --- byte mode
3858                                 256 &lt;= offset &lt;= 65535 --- word mode
3859                                 (an externally defined offset uses the
3860                                  word mode)
3861
3862                 ext             extended addressing
3863
3864                 label           branch label
3865
3866         The terms data, dir, offset, and ext may all be expressions.
3867
3868            Note  that  not all addressing modes are valid with every in-
3869         struction, refer to the 68HC08 technical data for valid modes.
3870
3871
3872         E.2.1  Control Instructions
3873
3874                 clc             cli             daa             div
3875                 mul             nop             nsa             psha
3876                 pshh            pshx            pula            pulh
3877                 pulx            rsp             rti             rts
3878                 sec             sei             stop            swi
3879                 tap             tax             tpa             tsx
3880                 txa             txs             wait
3881
3882
3883         E.2.2  Bit Manipulation Instructions
3884
3885                 brset   #data,*dir,label
3886                 brclr   #data,*dir,label
3887
3888                 bset    #data,*dir
3889                 bclr    #data,*dir
3890 \f
3891
3892         AS6808 ASSEMBLER                                        PAGE E-3
3893         68HC08 INSTRUCTION SET
3894
3895
3896         E.2.3  Branch Instructions
3897
3898                 bra     label           brn     label
3899                 bhi     label           bls     label
3900                 bcc     label           bcs     label
3901                 bne     label           beq     label
3902                 bhcc    label           bhcs    label
3903                 bpl     label           bmi     label
3904                 bmc     label           bms     label
3905                 bil     label           bih     label
3906                 bsr     label           bge     label
3907                 blt     label           bgt     label
3908                 ble     label
3909
3910
3911         E.2.4  Complex Branch Instructions
3912
3913                 cbeqa   [],label
3914                 cbeqx   [],label
3915                 cbeq    [],label
3916                 dbnza   label
3917                 dbnzx   label
3918                 dbnz    [],label
3919 \f
3920
3921         AS6808 ASSEMBLER                                        PAGE E-4
3922         68HC08 INSTRUCTION SET
3923
3924
3925         E.2.5  Read-Modify-Write Instructions
3926
3927                 nega                    negx
3928                 neg     []
3929
3930                 coma                    comx
3931                 com     []
3932
3933                 lsra                    lsrx
3934                 lsr     []
3935
3936                 rora                    rorx
3937                 ror     []
3938
3939                 asra                    asrx
3940                 asr     []
3941
3942                 asla                    aslx
3943                 asl     []
3944
3945                 lsla                    lslx
3946                 lsl     []
3947
3948                 rola                    rolx
3949                 rol     []
3950
3951                 deca                    decx
3952                 dec     []
3953
3954                 inca                    incx
3955                 inc     []
3956
3957                 tsta                    tstx
3958                 tst     []
3959
3960                 clra                    clrx
3961                 clr     []              clrh
3962
3963                 aix     #data
3964
3965                 ais     #data
3966 \f
3967
3968         AS6808 ASSEMBLER                                        PAGE E-5
3969         68HC08 INSTRUCTION SET
3970
3971
3972         E.2.6  Register\Memory Instructions
3973
3974                 sub     []              cmp     []
3975                 sbc     []              cpx     []
3976                 and     []              bit     []
3977                 lda     []              sta     []
3978                 eor     []              adc     []
3979                 ora     []              add     []
3980                 ldx     []              stx     []
3981
3982
3983         E.2.7  Double Operand Move Instruction
3984
3985                 mov     [],[]
3986
3987
3988         E.2.8  16-Bit &lt;H:X&gt; Index Register Instructions
3989
3990                 cphx    []
3991                 ldhx    []
3992                 sthx    []
3993
3994
3995         E.2.9  Jump and Jump to Subroutine Instructions
3996
3997                 jmp     []              jsr     []
3998 \f
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012                                    APPENDIX F
4013
4014                                 AS6809 ASSEMBLER
4015
4016
4017
4018
4019
4020         F.1  6809 REGISTER SET
4021
4022         The following is a list of the 6809 registers used by AS6809:
4023
4024                 a,b     -       8-bit accumulators
4025                 d       -       16-bit accumulator &lt;a:b&gt;
4026                 x,y     -       index registers
4027                 s,u     -       stack pointers
4028                 pc      -       program counter
4029                 cc      -       condition code
4030                 dp      -       direct page
4031
4032
4033         F.2  6809 INSTRUCTION SET
4034
4035
4036            The  following  tables  list all 6809 mnemonics recognized by
4037         the AS6809 assembler.  The designation [] refers to  a  required
4038         addressing  mode  argument.   The  following  list specifies the
4039         format for each addressing mode supported by AS6809:
4040
4041                 #data           immediate data
4042                                 byte or word data
4043
4044                 *dir            direct page addressing
4045                                 (see .setdp directive)
4046                                 0 &lt;= dir &lt;= 255
4047
4048                 label           branch label
4049
4050                 r,r1,r2         registers
4051                                 cc,a,b,d,dp,x,y,s,u,pc
4052
4053                 ,-x     ,--x    register indexed
4054                                 autodecrement
4055
4056 \f
4057
4058         AS6809 ASSEMBLER                                        PAGE F-2
4059         6809 INSTRUCTION SET
4060
4061
4062                 ,x+     ,x++    register indexed
4063                                 autoincrement
4064
4065                 ,x              register indexed addressing
4066                                 zero offset
4067
4068                 offset,x        register indexed addressing
4069                                    -16 &lt;= offset &lt;= 15    ---  5-bit
4070                                   -128 &lt;= offset &lt;= -17   ---  8-bit
4071                                     16 &lt;= offset &lt;= 127   ---  8-bit
4072                                 -32768 &lt;= offset &lt;= -129  --- 16-bit
4073                                    128 &lt;= offset &lt;= 32767 --- 16-bit
4074                                 (external definition of offset
4075                                  uses 16-bit mode)
4076
4077                 a,x             accumulator offset indexed addressing
4078
4079                 ext             extended addressing
4080
4081                 ext,pc          pc addressing ( pc &lt;- pc + ext )
4082
4083                 ext,pcr         pc relative addressing
4084
4085                 [,--x]          register indexed indirect
4086                                 autodecrement
4087
4088                 [,x++]          register indexed indirect
4089                                 autoincrement
4090
4091                 [,x]            register indexed indirect addressing
4092                                 zero offset
4093
4094                 [offset,x]      register indexed indirect addressing
4095                                   -128 &lt;= offset &lt;= 127   ---  8-bit
4096                                 -32768 &lt;= offset &lt;= -129  --- 16-bit
4097                                    128 &lt;= offset &lt;= 32767 --- 16-bit
4098                                 (external definition of offset
4099                                  uses 16-bit mode)
4100
4101                 [a,x]           accumulator offset indexed
4102                                 indirect addressing
4103
4104                 [ext]           extended indirect addressing
4105
4106                 [ext,pc]        pc indirect addressing
4107                                 ( [pc &lt;- pc + ext] )
4108
4109                 [ext,pcr]       pc relative indirect addressing
4110
4111         The  terms  data, dir, label, offset, and ext may all be expres-
4112         sions.
4113
4114 \f
4115
4116         AS6809 ASSEMBLER                                        PAGE F-3
4117         6809 INSTRUCTION SET
4118
4119
4120            Note  that  not all addressing modes are valid with every in-
4121         struction, refer to the 6809 technical data for valid modes.
4122
4123
4124         F.2.1  Inherent Instructions
4125
4126                 abx             daa
4127                 mul             nop
4128                 rti             rts
4129                 sex             swi
4130                 swi1            swi2
4131                 swi3            sync
4132
4133
4134         F.2.2  Short Branch Instructions
4135
4136                 bcc     label           bcs     label
4137                 beq     label           bge     label
4138                 bgt     label           bhi     label
4139                 bhis    label           bhs     label
4140                 ble     label           blo     label
4141                 blos    label           bls     label
4142                 blt     label           bmi     label
4143                 bne     label           bpl     label
4144                 bra     label           brn     label
4145                 bvc     label           bvs     label
4146                 bsr     label
4147
4148
4149         F.2.3  Long Branch Instructions
4150
4151                 lbcc    label           lbcs    label
4152                 lbeq    label           lbge    label
4153                 lbgt    label           lbhi    label
4154                 lbhis   label           lbhs    label
4155                 lble    label           lblo    label
4156                 lblos   label           lbls    label
4157                 lblt    label           lbmi    label
4158                 lbne    label           lbpl    label
4159                 lbra    label           lbrn    label
4160                 lbvc    label           lbvs    label
4161                 lbsr    label
4162 \f
4163
4164         AS6809 ASSEMBLER                                        PAGE F-4
4165         6809 INSTRUCTION SET
4166
4167
4168         F.2.4  Single Operand Instructions
4169
4170                 asla            aslb
4171                 asl     []
4172
4173                 asra            asrb
4174                 asr     []
4175
4176                 clra            clrb
4177                 clr     []
4178
4179                 coma            comb
4180                 com     []
4181
4182                 deca            decb
4183                 dec     []
4184
4185                 inca            incb
4186                 inc     []
4187
4188                 lsla            lslb
4189                 lsl     []
4190
4191                 lsra            lsrb
4192                 lsr     []
4193
4194                 nega            negb
4195                 neg     []
4196
4197                 rola            rolb
4198                 rol     []
4199
4200                 rora            rorb
4201                 ror     []
4202
4203                 tsta            tstb
4204                 tst     []
4205 \f
4206
4207         AS6809 ASSEMBLER                                        PAGE F-5
4208         6809 INSTRUCTION SET
4209
4210
4211         F.2.5  Double Operand Instructions
4212
4213                 adca    []              adcb    []
4214
4215                 adda    []              addb    []
4216
4217                 anda    []              andb    []
4218
4219                 bita    []              bitb    []
4220
4221                 cmpa    []              cmpb    []
4222
4223                 eora    []              eorb    []
4224
4225                 lda     []              ldb     []
4226
4227                 ora     []              orb     []
4228
4229                 sbca    []              sbcb    []
4230
4231                 sta     []              stb     []
4232
4233                 suba    []              subb    []
4234
4235
4236         F.2.6  D-register Instructions
4237
4238                 addd    []              subd    []
4239                 cmpd    []              ldd     []
4240                 std     []
4241
4242
4243         F.2.7  Index/Stack Register Instructions
4244
4245                 cmps    []              cmpu    []
4246                 cmpx    []              cmpy    []
4247
4248                 lds     []              ldu     []
4249                 ldx     []              ldy     []
4250
4251                 leas    []              leau    []
4252                 leax    []              leay    []
4253
4254                 sts     []              stu     []
4255                 stx     []              sty     []
4256
4257                 pshs    r               pshu    r
4258                 puls    r               pulu    r
4259 \f
4260
4261         AS6809 ASSEMBLER                                        PAGE F-6
4262         6809 INSTRUCTION SET
4263
4264
4265         F.2.8  Jump and Jump to Subroutine Instructions
4266
4267                 jmp     []              jsr     []
4268
4269
4270         F.2.9  Register - Register Instructions
4271
4272                 exg     r1,r2           tfr     r1,r2
4273
4274
4275         F.2.10  Condition Code Register Instructions
4276
4277                 andcc   #data           orcc    #data
4278                 cwai    #data
4279
4280
4281         F.2.11  6800 Compatibility Instructions
4282
4283                 aba             cba
4284                 clc             cli
4285                 clv             des
4286                 dex             ins
4287                 inx
4288                 ldaa    []      ldab    []
4289                 oraa    []      orab    []
4290                 psha            pshb
4291                 pula            pulb
4292                 sba             sec
4293                 sei             sev
4294                 staa    []      stab    []
4295                 tab             tap
4296                 tba             tpa
4297                 tsx             txs
4298                 wai
4299 \f
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313                                    APPENDIX G
4314
4315                                 AS6811 ASSEMBLER
4316
4317
4318
4319
4320
4321         G.1  68HC11 REGISTER SET
4322
4323         The following is a list of the 68HC11 registers used by AS6811:
4324
4325                 a,b     -       8-bit accumulators
4326                 d       -       16-bit accumulator &lt;a:b&gt;
4327                 x,y     -       index registers
4328
4329
4330         G.2  68HC11 INSTRUCTION SET
4331
4332
4333            The  following tables list all 68HC11 mnemonics recognized by
4334         the AS6811 assembler.  The designation [] refers to  a  required
4335         addressing  mode  argument.   The  following  list specifies the
4336         format for each addressing mode supported by AS6811:
4337
4338                 #data           immediate data
4339                                 byte or word data
4340
4341                 *dir            direct page addressing
4342                                 (see .setdp directive)
4343                                 0 &lt;= dir &lt;= 255
4344
4345                 ,x              register indirect addressing
4346                                 zero offset
4347
4348                 offset,x        register indirect addressing
4349                                 0 &lt;= offset &lt;= 255
4350
4351                 ext             extended addressing
4352
4353                 label           branch label
4354
4355         The terms data, dir, offset, and ext may all be expressions.
4356
4357 \f
4358
4359         AS6811 ASSEMBLER                                        PAGE G-2
4360         68HC11 INSTRUCTION SET
4361
4362
4363            Note  that  not all addressing modes are valid with every in-
4364         struction, refer to the 68HC11 technical data for valid modes.
4365
4366
4367         G.2.1  Inherent Instructions
4368
4369                 aba             abx
4370                 aby             cba
4371                 clc             cli
4372                 clv             daa
4373                 des             dex
4374                 dey             fdiv
4375                 idiv            ins
4376                 inx             iny
4377                 mul             nop
4378                 rti             rts
4379                 sba             sec
4380                 sei             sev
4381                 stop            swi
4382                 tab             tap
4383                 tba             tpa
4384                 tsx             txs
4385                 wai             xgdx
4386                 xgdy
4387
4388                 psha            pshb
4389                 psh a           psh b
4390                 pshx            pshy
4391                 psh x           psh y
4392
4393                 pula            pulb
4394                 pul a           pul b
4395                 pulx            puly
4396                 pul x           pul y
4397
4398
4399         G.2.2  Branch Instructions
4400
4401                 bra     label           brn     label
4402                 bhi     label           bls     label
4403                 bcc     label           bhs     label
4404                 bcs     label           blo     label
4405                 bne     label           beq     label
4406                 bvc     label           bvs     label
4407                 bpl     label           bmi     label
4408                 bge     label           blt     label
4409                 bgt     label           ble     label
4410                 bsr     label
4411 \f
4412
4413         AS6811 ASSEMBLER                                        PAGE G-3
4414         68HC11 INSTRUCTION SET
4415
4416
4417         G.2.3  Single Operand Instructions
4418
4419                 asla            aslb            asld
4420                 asl a           asl b           asl d
4421                 asl     []
4422
4423                 asra            asrb
4424                 asr a           asr b
4425                 asr     []
4426
4427                 clra            clrb
4428                 clr a           clr b
4429                 clr     label
4430
4431                 coma            comb
4432                 com a           com b
4433                 com     []
4434
4435                 deca            decb
4436                 dec a           dec b
4437                 dec     []
4438
4439                 inca            incb
4440                 inc a           inc b
4441                 inc     []
4442
4443                 lsla            lslb            lsld
4444                 lsl a           lsl b           lsl d
4445                 lsl     []
4446
4447                 lsra            lsrb            lsrd
4448                 lsr a           lsr b           lsr d
4449                 lsr     []
4450
4451                 nega            negb
4452                 neg a           neg b
4453                 neg     []
4454
4455                 rola            rolb
4456                 rol a           rol b
4457                 rol     []
4458
4459                 rora            rorb
4460                 ror a           ror b
4461                 ror     []
4462
4463                 tsta            tstb
4464                 tst a           tst b
4465                 tst     []
4466 \f
4467
4468         AS6811 ASSEMBLER                                        PAGE G-4
4469         68HC11 INSTRUCTION SET
4470
4471
4472         G.2.4  Double Operand Instructions
4473
4474                 adca    []              adcb    []
4475                 adc a   []              adc b   []
4476
4477                 adda    []      addb    []      addd    []
4478                 add a   []      add b   []      add d   []
4479
4480                 anda    []              andb    []
4481                 and a   []              and b   []
4482
4483                 bita    []              bitb    []
4484                 bit a   []              bit b   []
4485
4486                 cmpa    []              cmpb    []
4487                 cmp a   []              cmp b   []
4488
4489                 eora    []              eorb    []
4490                 eor a   []              eor b   []
4491
4492                 ldaa    []              ldab    []
4493                 lda a   []              lda b   []
4494
4495                 oraa    []              orab    []
4496                 ora a   []              ora b   []
4497
4498                 sbca    []              sbcb    []
4499                 sbc a   []              sbc b   []
4500
4501                 staa    []              stab    []
4502                 sta a   []              sta b   []
4503
4504                 suba    []      subb    []      subd    []
4505                 sub a   []      sub b   []      sub d   []
4506
4507
4508         G.2.5  Bit Manupulation Instructions
4509
4510                 bclr    [],#data
4511                 bset    [],#data
4512
4513                 brclr   [],#data,label
4514                 brset   [],#data,label
4515
4516
4517 \f
4518
4519         AS6811 ASSEMBLER                                        PAGE G-5
4520         68HC11 INSTRUCTION SET
4521
4522
4523         G.2.6  Jump and Jump to Subroutine Instructions
4524
4525                 jmp     []              jsr     []
4526
4527
4528         G.2.7  Long Register Instructions
4529
4530                 cpx     []              cpy     []
4531
4532                 ldd     []              lds     []
4533                 ldx     []              ldy     []
4534
4535                 std     []              sts     []
4536                 stx     []              sty     []
4537 \f
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551                                    APPENDIX H
4552
4553                                 AS6812 ASSEMBLER
4554
4555
4556
4557
4558
4559         H.1  68HC12 REGISTER SET
4560
4561         The following is a list of the 68HC12 registers used by AS6812:
4562
4563                 a,b     -       8-bit accumulators
4564                 d       -       16-bit accumulator &lt;a:b&gt;
4565                 x,y     -       index registers
4566                 sp,s    -       stack pointer
4567                 pc      -       program counter
4568                 ccr,cc  -       condition code register
4569
4570
4571         H.2  68HC12 INSTRUCTION SET
4572
4573
4574            The  following tables list all 68HC12 mnemonics recognized by
4575         the AS6812 assembler.  The designation [] refers to  a  required
4576         addressing  mode  argument.   The  following  list specifies the
4577         format for each addressing mode supported by AS6812:
4578
4579                 #data           immediate data
4580                                 byte or word data
4581
4582                 ext             extended addressing
4583
4584                 pg              memory page number
4585
4586                 *dir            direct page addressing
4587                                 (see .setdp directive)
4588                                 0 &lt;= dir &lt;= 255
4589
4590                 label           branch label
4591
4592                 r,r1,r2         registers
4593                                 ccr,a,b,d,x,y,sp,pc
4594
4595 \f
4596
4597         AS6812 ASSEMBLER                                        PAGE H-2
4598         68HC12 INSTRUCTION SET
4599
4600
4601                 -x      x-      register indexed, pre or
4602                 ,-x     ,x-     post autodecrement by 1
4603
4604                 n,-x    n,x-    register indexed, pre or
4605                                 post autodecrement by 1 - 8
4606
4607                 +x      x+      register indexed, pre or
4608                 ,+x     ,x+     post autoincrement by 1
4609
4610                 n,+x    n,x+    register indexed, pre or
4611                                 post autoincrement by 1 - 8
4612
4613                 offset,x        register indexed addressing
4614                                    -16 &lt;= offset &lt;= 15    ---  5-bit
4615                                   -256 &lt;= offset &lt;= -17   ---  9-bit
4616                                     16 &lt;= offset &lt;= 255   ---  9-bit
4617                                 -32768 &lt;= offset &lt;= -257  --- 16-bit
4618                                    256 &lt;= offset &lt;= 32767 --- 16-bit
4619                                 (external definition of offset
4620                                  uses 16-bit mode)
4621
4622                 [offset,x]      register indexed indirect addressing
4623                                 -32768 &lt;= offset &lt;= 32767 --- 16-bit
4624
4625                 [,x]            register indexed indirect addressing
4626                                 zero offset
4627
4628                 a,x             accumulator offset indexed addressing
4629
4630                 [d,x]           d accumulator offset indexed
4631                                 indirect addressing
4632
4633         The  terms  data, dir, label, offset, and ext may all be expres-
4634         sions.
4635
4636            Note  that  not all addressing modes are valid with every in-
4637         struction, refer to the 68HC12 technical data for valid modes.
4638 \f
4639
4640         AS6812 ASSEMBLER                                        PAGE H-3
4641         68HC12 INSTRUCTION SET
4642
4643
4644         H.2.1  Inherent Instructions
4645
4646                 aba             bgnd            cba
4647                 daa             dex             dey
4648                 ediv            edivs           emul
4649                 emuls           fdiv            idiv
4650                 idivs           inx             iny
4651                 mem             mul             nop
4652                 psha            pshb            pshc
4653                 pshd            pshx            pshy
4654                 pula            pulb            pulc
4655                 puld            pulx            puly
4656                 rev             revw            rtc
4657                 rti             rts             sba
4658                 stop            swi             tab
4659                 tba             wai             wav
4660                 wavr
4661
4662
4663         H.2.2  Short Branch Instructions
4664
4665                 bcc     label           bcs     label
4666                 beq     label           bge     label
4667                 bgt     label           bhi     label
4668                 bhis    label           bhs     label
4669                 ble     label           blo     label
4670                 blos    label           bls     label
4671                 blt     label           bmi     label
4672                 bne     label           bpl     label
4673                 bra     label           brn     label
4674                 bvc     label           bvs     label
4675                 bsr     label
4676
4677
4678         H.2.3  Long Branch Instructions
4679
4680                 lbcc    label           lbcs    label
4681                 lbeq    label           lbge    label
4682                 lbgt    label           lbhi    label
4683                 lbhis   label           lbhs    label
4684                 lble    label           lblo    label
4685                 lblos   label           lbls    label
4686                 lblt    label           lbmi    label
4687                 lbne    label           lbpl    label
4688                 lbra    label           lbrn    label
4689                 lbvc    label           lbvs    label
4690 \f
4691
4692         AS6812 ASSEMBLER                                        PAGE H-4
4693         68HC12 INSTRUCTION SET
4694
4695
4696         H.2.4  Branch on Decrement, Test, or Increment
4697
4698                 dbeq    r,label         dbne    r,label
4699                 ibeq    r,label         ibne    r,label
4700                 tbeq    r,label         tbne    r,label
4701
4702
4703         H.2.5  Bit Clear and Set Instructions
4704
4705                 bclr    [],#data
4706                 bset    [],#data
4707
4708
4709         H.2.6  Branch on Bit Clear or Set
4710
4711                 brclr   [],#data,label
4712                 brset   [],#data,label
4713 \f
4714
4715         AS6812 ASSEMBLER                                        PAGE H-5
4716         68HC12 INSTRUCTION SET
4717
4718
4719         H.2.7  Single Operand Instructions
4720
4721                 asla            aslb
4722                 asl     []
4723
4724                 asra            asrb
4725                 asr     []
4726
4727                 clra            clrb
4728                 clr     []
4729
4730                 coma            comb
4731                 com     []
4732
4733                 deca            decb
4734                 dec     []
4735
4736                 inca            incb
4737                 inc     []
4738
4739                 lsla            lslb
4740                 lsl     []
4741
4742                 lsra            lsrb
4743                 lsr     []
4744
4745                 nega            negb
4746                 neg     []
4747
4748                 rola            rolb
4749                 rol     []
4750
4751                 rora            rorb
4752                 ror     []
4753
4754                 tsta            tstb
4755                 tst     []
4756 \f
4757
4758         AS6812 ASSEMBLER                                        PAGE H-6
4759         68HC12 INSTRUCTION SET
4760
4761
4762         H.2.8  Double Operand Instructions
4763
4764                 adca    []              adcb    []
4765
4766                 adda    []              addb    []
4767
4768                 anda    []              andb    []
4769
4770                 bita    []              bitb    []
4771
4772                 cmpa    []              cmpb    []
4773
4774                 eora    []              eorb    []
4775
4776                 ldaa    []      &lt;=&gt;     lda     []
4777
4778                 ldab    []      &lt;=&gt;     ldb     []
4779
4780                 oraa    []      &lt;=&gt;     ora     []
4781
4782                 orab    []      &lt;=&gt;     orb     []
4783
4784                 sbca    []              sbcb    []
4785
4786                 staa    []      &lt;=&gt;     sta     []
4787
4788                 stab    []      &lt;=&gt;     stb     []
4789
4790                 suba    []              subb    []
4791
4792
4793         H.2.9  Move Instructions
4794
4795                 movb    [],[]           movw    [],[]
4796
4797
4798         H.2.10  D-register Instructions
4799
4800                 addd    []              subd    []
4801                 cpd     []      &lt;=&gt;     cmpd    []
4802                 ldd     []              std     []
4803 \f
4804
4805         AS6812 ASSEMBLER                                        PAGE H-7
4806         68HC12 INSTRUCTION SET
4807
4808
4809         H.2.11  Index/Stack Register Instructions
4810
4811                 cps     []      &lt;=&gt;     cmps    []
4812                 cpx     []      &lt;=&gt;     cmpx    []
4813                 cpy     []      &lt;=&gt;     cmpy    []
4814
4815                 lds     []
4816                 ldx     []              ldy     []
4817
4818                 leas    []
4819                 leax    []              leay    []
4820
4821                 sts     []
4822                 stx     []              sty     []
4823
4824
4825         H.2.12  Jump and Jump/Call to Subroutine Instructions
4826
4827                 call    [],pg
4828                 jmp     []              jsr     []
4829
4830
4831         H.2.13  Other Special Instructions
4832
4833                 emacs   []
4834                 emaxd   []              emaxm   []
4835                 emind   []              eminm   []
4836                 etbl    []
4837                 maxa    []              maxm    []
4838                 mina    []              minm    []
4839                 tbl     []              trap    #data
4840
4841
4842         H.2.14  Register - Register Instructions
4843
4844                 exg     r1,r2           sex     r1,r2
4845                 tfr     r1,r2
4846
4847
4848         H.2.15  Condition Code Register Instructions
4849
4850                 andcc   #data           orcc    #data
4851 \f
4852
4853         AS6812 ASSEMBLER                                        PAGE H-8
4854         68HC12 INSTRUCTION SET
4855
4856
4857         H.2.16  M68HC11 Compatibility Mode Instructions
4858
4859                 abx             aby             clc
4860                 cli             clv             des
4861                 ins             sec             sei
4862                 sev             tap             tpa
4863                 tsx             tsy             txs
4864                 tys             xgdx            xgdy
4865 \f
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879                                    APPENDIX I
4880
4881                                 AS6816 ASSEMBLER
4882
4883
4884
4885
4886
4887         I.1  68HC16 REGISTER SET
4888
4889         The following is a list of the 68HC16 registers used by AS6816:
4890
4891                 a,b     -       8-bit accumulators
4892                 d       -       16-bit accumulator &lt;a:b&gt;
4893                 e       -       16-bit accumulator
4894                 x,y,z   -       index registers
4895                 k       -       address extension register
4896                 s       -       stack pointer
4897                 ccr     -       condition code
4898
4899
4900         I.2  68HC16 INSTRUCTION SET
4901
4902
4903            The  following tables list all 68HC16 mnemonics recognized by
4904         the AS6816 assembler.  The designation [] refers to  a  required
4905         addressing  mode  argument.   The  following  list specifies the
4906         format for each addressing mode supported by AS6816:
4907
4908                 #data           immediate data
4909                                 byte or word data
4910
4911                 #xo,#yo         local immediate data (mac / rmac)
4912
4913                 label           branch label
4914
4915                 r               register
4916                                 ccr,a,b,d,e,x,y,z,s
4917
4918                 ,x              zero offset register indexed addressing
4919                 ,x8
4920                 ,x16
4921
4922                 offset,x        register indexed addressing
4923 \f
4924
4925         AS6816 ASSEMBLER                                        PAGE I-2
4926         68HC16 INSTRUCTION SET
4927
4928
4929                                      0 &lt;= offset &lt;= 255   ---  8-bit
4930                                 -32768 &lt;= offset &lt;= -1    --- 16-bit
4931                                    256 &lt;= offset &lt;= 32767 --- 16-bit
4932                                 (external definition of offset
4933                                  uses 16-bit mode)
4934
4935                 offset,x8       unsigned 8-bit offset indexed addressing
4936                 offset,x16      signed 16-bit offset indexed addressing
4937
4938                 e,x             accumulator offset indexed addressing
4939
4940                 ext             extended addressing
4941
4942                 bank            64K bank number (jmp / jsr)
4943
4944         The  terms data, label, offset, bank, and ext may all be expres-
4945         sions.
4946
4947            Note  that  not all addressing modes are valid with every in-
4948         struction, refer to the 6816 technical data for valid modes.
4949
4950
4951         I.2.1  Inherent Instructions
4952
4953                 aba             abx             aby             abz
4954                 ace             aced            ade             adx
4955                 ady             adz             aex             aey
4956                 aez             bgnd            cba             daa
4957                 ediv            edivs           emul            emuls
4958                 fdiv            fmuls           idiv            ldhi
4959                 lpstop          mul             nop             psha
4960                 pshb            pshmac          pula            pulb
4961                 pulmac          rtr             rts             sba
4962                 sde             sted            swi             sxt
4963                 tab             tap             tba             tbek
4964                 tbsk            tbxk            tbyk            tbzk
4965                 tde             tdmsk           tdp             ted
4966                 tedm            tekb            tem             tmer
4967                 tmet            tmxed           tpa             tpd
4968                 tskb            tsx             tsy             tsz
4969                 txkb            txs             txy             txz
4970                 tykb            tys             tyx             tyz
4971                 tzkb            tzs             tzx             tzy
4972                 wai             xgab            xgde            xgdx
4973                 xgdy            xgdz            xgex            xgey
4974                 xgez
4975 \f
4976
4977         AS6816 ASSEMBLER                                        PAGE I-3
4978         68HC16 INSTRUCTION SET
4979
4980
4981         I.2.2  Push/Pull Multiple Register Instructions
4982
4983                 pshm    r,...           pulm    r,...
4984
4985
4986         I.2.3  Short Branch Instructions
4987
4988                 bcc     label           bcs     label
4989                 beq     label           bge     label
4990                 bgt     label           bhi     label
4991                 bhis    label           bhs     label
4992                 ble     label           blo     label
4993                 blos    label           bls     label
4994                 blt     label           bmi     label
4995                 bne     label           bpl     label
4996                 bra     label           brn     label
4997                 bvc     label           bvs     label
4998                 bsr     label
4999
5000
5001         I.2.4  Long Branch Instructions
5002
5003                 lbcc    label           lbcs    label
5004                 lbeq    label           lbge    label
5005                 lbgt    label           lbhi    label
5006                 lbhis   label           lbhs    label
5007                 lble    label           lblo    label
5008                 lblos   label           lbls    label
5009                 lblt    label           lbmi    label
5010                 lbne    label           lbpl    label
5011                 lbra    label           lbrn    label
5012                 lbvc    label           lbvs    label
5013                 lbsr    label
5014
5015
5016         I.2.5  Bit Manipulation Instructions
5017
5018                 bclr    [],#data
5019                 bset    [],#data
5020
5021                 brclr   [],#data,label
5022                 brset   [],#data,label
5023 \f
5024
5025         AS6816 ASSEMBLER                                        PAGE I-4
5026         68HC16 INSTRUCTION SET
5027
5028
5029         I.2.6  Single Operand Instructions
5030
5031                 asla                    aslb
5032                 asld                    asle
5033                 aslm
5034                 asl     []              aslw    []
5035
5036                 asra                    asrb
5037                 asrd                    asre
5038                 asrm
5039                 asr     []              asrw    []
5040
5041                 clra                    clrb
5042                 clrd                    clre
5043                                         clrm
5044                 clr     []              clrw    []
5045
5046                 coma                    comb
5047                 comd                    come
5048                 com     []              comw    []
5049
5050                 deca                    decb
5051                 dec     []              decw    []
5052
5053                 inca                    incb
5054                 inc     []              incw    []
5055
5056                 lsla                    lslb
5057                 lsld                    lsle
5058                 lslm
5059                 lsl     []              lslw    []
5060
5061                 lsra                    lsrb
5062                 lsrd                    lsre
5063                 lsr     []              lsrw    []
5064
5065                 nega                    negb
5066                 negd                    nege
5067                 neg     []              negw    []
5068
5069                 rola                    rolb
5070                 rold                    role
5071                 rol     []              rolw    []
5072
5073                 rora                    rorb
5074                 rord                    rore
5075                 ror     []              rorw    []
5076
5077                 tsta                    tstb
5078                 tsta                    tste
5079                 tst     []              tstw    []
5080 \f
5081
5082         AS6816 ASSEMBLER                                        PAGE I-5
5083         68HC16 INSTRUCTION SET
5084
5085
5086         I.2.7  Double Operand Instructions
5087
5088                 adca    []              adcb    []
5089                 adcd    []              adce    []
5090
5091                 adda    []              addb    []
5092                 addd    []              adde    []
5093
5094                 anda    []              andb    []
5095                 andd    []              ande    []
5096
5097                 bita    []              bitb    []
5098
5099                 cmpa    []              cmpb    []
5100                 cpd     []              cpe     []
5101
5102                 eora    []              eorb    []
5103                 eord    []              eore    []
5104
5105                 ldaa    []              ldab    []
5106                 ldd     []              lde     []
5107
5108                 oraa    []              orab    []
5109                 ord     []              ore     []
5110
5111                 sbca    []              sbcb    []
5112                 sbcd    []              sbce    []
5113
5114                 staa    []              stab    []
5115                 std     []              ste     []
5116
5117                 suba    []              subb    []
5118                 subd    []              sube    []
5119
5120
5121         I.2.8  Index/Stack Register Instructions
5122
5123                 cps     []              cpx     []
5124                 cpy     []              cpz     []
5125
5126                 lds     []              ldx     []
5127                 ldy     []              ldz     []
5128
5129                 sts     []              stx     []
5130                 sty     []              stz     []
5131 \f
5132
5133         AS6816 ASSEMBLER                                        PAGE I-6
5134         68HC16 INSTRUCTION SET
5135
5136
5137         I.2.9  Jump and Jump to Subroutine Instructions
5138
5139                 jmp     bank,[]         jsr     bank,[]
5140
5141
5142         I.2.10  Condition Code Register Instructions
5143
5144                 andp    #data           orp     #data
5145
5146
5147         I.2.11  Multiply and Accumulate Instructions
5148
5149                 mac     #data           rmac    #data
5150                 mac     #xo,#yo         rmac    #xo,#yo
5151 \f
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165                                    APPENDIX J
5166
5167                                  ASH8 ASSEMBLER
5168
5169
5170
5171
5172
5173         J.1  H8/3XX REGISTER SET
5174
5175         The following is a list of the H8 registers used by ASH8:
5176
5177                 r0  -  r7,sp            16-bit accumulators
5178                 r0L -  r7L,spL          8-bit accumulators
5179                 r0H -  r7H,spH          8-bit accumulators
5180                 spL,spH,sp              stack pointers
5181                 ccr                     condition code
5182
5183
5184         J.2  H8/3XX INSTRUCTION SET
5185
5186
5187            The  following tables list all H8/3xx mnemonics recognized by
5188         the ASH8 assembler.  The designation [] refers to a required ad-
5189         dressing mode argument.  The following list specifies the format
5190         for each addressing mode supported by ASH8:
5191
5192                 #xx:3           immediate data (3  bit)
5193                 #xx:8           immediate data (8  bit)
5194                 #xx:16          immediate data (16 bit)
5195
5196                 *dir            direct page addressing
5197                                 (see .setdp directive)
5198                                 0xFF00 &lt;= dir &lt;= 0xFFFF
5199
5200                 label           branch label
5201
5202
5203                 rn              registers (16 bit)
5204                                 r0-r7,sp
5205
5206                 rnB             registers (8 bit)
5207                                 r0H-r7H,r0L-r7L,spH,spL
5208
5209 \f
5210
5211         ASH8 ASSEMBLER                                          PAGE J-2
5212         H8/3XX INSTRUCTION SET
5213
5214
5215                 ccr             condition code register
5216
5217                 @rn             register indirect
5218
5219                 @-rn            register indirect (auto pre-decrement)
5220
5221                 @rn+            register indirect (auto post-increment)
5222
5223                 @[offset,rn]    register indirect, 16-bit displacement
5224
5225                 @@offset        memory indirect, (8-bit address)
5226
5227                 ext             extended addressing (16-bit)
5228
5229         The  terms  data, dir, label, offset, and ext may all be expres-
5230         sions.
5231
5232            Note  that  not all addressing modes are valid with every in-
5233         struction, refer to the H8/3xx technical data for valid modes.
5234
5235
5236         J.2.1  Inherent Instructions
5237
5238                 eepmov
5239                 nop
5240                 sleep
5241                 rte
5242                 rts
5243
5244
5245         J.2.2  Branch Instructions
5246
5247                 bcc     label                   bcs     label
5248                 beq     label                   bf      label
5249                 bge     label                   bgt     label
5250                 bhi     label                   bhis    label
5251                 bhs     label                   ble     label
5252                 blo     label                   blos    label
5253                 bls     label                   blt     label
5254                 bmi     label                   bne     label
5255                 bpl     label                   bra     label
5256                 brn     label                   bt      label
5257                 bvc     label                   bvs     label
5258                 bsr     label
5259 \f
5260
5261         ASH8 ASSEMBLER                                          PAGE J-3
5262         H8/3XX INSTRUCTION SET
5263
5264
5265         J.2.3  Single Operand Instructions
5266
5267                 Free Form
5268
5269                 daa     rnB                     das     rnB
5270
5271                 dec     rnB                     inc     rnB
5272
5273                 neg     rnB                     not     rnB
5274
5275                 rotxl   rnB                     rotxr   rnB
5276
5277                 rotl    rnB                     rotr    rnB
5278
5279                 shal    rnB                     shar    rnB
5280
5281                 shll    rnB                     shlr    rnB
5282
5283                 push    rn                      pop     rn
5284
5285
5286                 Byte / Word Form
5287
5288                 daa.b   rnB                     das.b   rnB
5289
5290                 dec.b   rnB                     inc.b   rnB
5291
5292                 neg.b   rnB                     not.b   rnB
5293
5294                 rotxl.b rnB                     rotxr.b rnB
5295
5296                 rotl.b  rnB                     rotr.b  rnB
5297
5298                 shal.b  rnB                     shar.b  rnB
5299
5300                 shll.b  rnB                     shlr.b  rnB
5301
5302                 push.w  rn                      pop.w   rn
5303 \f
5304
5305         ASH8 ASSEMBLER                                          PAGE J-4
5306         H8/3XX INSTRUCTION SET
5307
5308
5309         J.2.4  Double Operand Instructions
5310
5311                 Free Form
5312
5313                 add     rnB,rnB                 add     #xx:8,rnB
5314                 add     rn,rn
5315                 adds    #1,rn                   adds    #2,rn
5316                 addx    rnB,rnB                 addx    #xx:8,rnB
5317
5318                 cmp     rnB,rnB                 cmp     #xx:8,rnB
5319                 cmp     rn,rn
5320
5321                 sub     rnB,rnB
5322                 sub     rn,rn
5323                 subs    #1,rn                   subs    #2,rn
5324                 subx    rnB,rnB                 subx    #xx:8,rnB
5325
5326                 and     rnB,rnB                 and     #xx:8,rnB
5327                                                 and     #xx:8,ccr
5328
5329                 or      rnB,rnB                 or      #xx:8,rnB
5330                                                 or      #xx:8,ccr
5331
5332                 xor     rnB,rnB                 xor     #xx:8,rnB
5333                                                 xor     #xx:8,ccr
5334
5335
5336                 Byte / Word Form
5337
5338                 add.b   rnB,rnB                 add.b   #xx:8,rnB
5339                 add.w   rn,rn
5340
5341                 cmp.b   rnB,rnB                 cmp.b   #xx:8,rnB
5342                 cmp.w   rn,rn
5343
5344                 sub.b   rnB,rnB
5345                 sub.w   rn,rn
5346
5347                 addx.b  rnB,rnB                 addx.b  #xx:8,rnB
5348
5349                 and.b   rnB,rnB                 and.b   #xx:8,rnB
5350                                                 and.b   #xx:8,ccr
5351
5352                 or.b    rnB,rnB                 or.b    #xx:8,rnB
5353                                                 or.b    #xx:8,ccr
5354
5355                 subx.b  rnB,rnB                 subx.b  #xx:8,rnB
5356
5357                 xor.b   rnB,rnB                 xor.b   #xx:8,rnB
5358                                                 xor.b   #xx:8,ccr
5359 \f
5360
5361         ASH8 ASSEMBLER                                          PAGE J-5
5362         H8/3XX INSTRUCTION SET
5363
5364
5365         J.2.5  Mov Instructions
5366
5367                 Free Form
5368
5369                 mov     rnB,rnB                 mov     rn,rn
5370                 mov     #xx:8,rnB               mov     #xx:16,rn
5371                 mov     @rn,rnB                 mov     @rn,rn
5372                 mov     @[offset,rn],rnB        mov     @[offset,rn],rn
5373                 mov     @rn+,rnB                mov     @rn+,rn
5374                 mov     @dir,rnB
5375                 mov     dir,rnB
5376                 mov     *@dir,rnB
5377                 mov     *dir,rnB
5378                 mov     @label,rnB              mov     @label,rn
5379                 mov     label,rnB               mov     label,rn
5380                 mov     rnB,@rn                 mov     rn,@rn
5381                 mov     rnB,@[offset,rn]        mov     rn,@[offset,rn]
5382                 mov     rnB,@-rn                mov     rn,@-rn
5383                 mov     rnB,@dir
5384                 mov     rnB,dir
5385                 mov     rnB,*@dir
5386                 mov     rnB,*dir
5387                 mov     rnB,@label              mov     rn,@label
5388                 mov     rnB,label               mov     rn,label
5389
5390
5391                 Byte / Word Form
5392
5393                 mov.b   rnB,rnB                 mov.w   rn,rn
5394                 mov.b   #xx:8,rnB               mov.w   #xx:16,rn
5395                 mov.b   @rn,rnB                 mov.w   @rn,rn
5396                 mov.b   @[offset,rn],rnB        mov.w   @[offset,rn],rn
5397                 mov.b   @rn+,rnB                mov.w   @rn+,rn
5398                 mov.b   @dir,rnB
5399                 mov.b   dir,rnB
5400                 mov.b   *@dir,rnB
5401                 mov.b   *dir,rnB
5402                 mov.b   @label,rnB              mov.w   @label,rn
5403                 mov.b   label,rnB               mov.w   label,rn
5404                 mov.b   rnB,@rn                 mov.w   rn,@rn
5405                 mov.b   rnB,@[offset,rn]        mov.w   rn,@[offset,rn]
5406                 mov.b   rnB,@-rn                mov.w   rn,@-rn
5407                 mov.b   rnB,@dir
5408                 mov.b   rnB,dir
5409                 mov.b   rnB,*@dir
5410                 mov.b   rnB,*dir
5411                 mov.b   rnB,@label              mov.w   rn,@label
5412                 mov.b   rnB,label               mov.w   rn,label
5413 \f
5414
5415         ASH8 ASSEMBLER                                          PAGE J-6
5416         H8/3XX INSTRUCTION SET
5417
5418
5419         J.2.6  Bit Manipulation Instructions
5420
5421                 bld     #xx:3,rnB               bld     #xx:3,@rn
5422                 bld     #xx:3,@dir              bld     #xx:3,dir
5423                 bld     #xx:3,*@dir             bld     #xx:3,*dir
5424
5425                 bild    #xx:3,rnB               bild    #xx:3,@rn
5426                 bild    #xx:3,@dir              bild    #xx:3,dir
5427                 bild    #xx:3,*@dir             bild    #xx:3,*dir
5428
5429                 bst     #xx:3,rnB               bst     #xx:3,@rn
5430                 bst     #xx:3,@dir              bst     #xx:3,dir
5431                 bst     #xx:3,*@dir             bst     #xx:3,*dir
5432
5433                 bist    #xx:3,rnB               bist    #xx:3,@rn
5434                 bist    #xx:3,@dir              bist    #xx:3,dir
5435                 bist    #xx:3,*@dir             bist    #xx:3,*dir
5436
5437                 band    #xx:3,rnB               band    #xx:3,@rn
5438                 band    #xx:3,@dir              band    #xx:3,dir
5439                 band    #xx:3,*@dir             band    #xx:3,*dir
5440
5441                 biand   #xx:3,rnB               biand   #xx:3,@rn
5442                 biand   #xx:3,@dir              biand   #xx:3,dir
5443                 biand   #xx:3,*@dir             biand   #xx:3,*dir
5444
5445                 bor     #xx:3,rnB               bor     #xx:3,@rn
5446                 bor     #xx:3,@dir              bor     #xx:3,dir
5447                 bor     #xx:3,*@dir             bor     #xx:3,*dir
5448
5449                 bior    #xx:3,rnB               bior    #xx:3,@rn
5450                 bior    #xx:3,@dir              bior    #xx:3,dir
5451                 bior    #xx:3,*@dir             bior    #xx:3,*dir
5452
5453                 bxor    #xx:3,rnB               bxor    #xx:3,@rn
5454                 bxor    #xx:3,@dir              bxor    #xx:3,dir
5455                 bxor    #xx:3,*@dir             bxor    #xx:3,*dir
5456
5457                 bixor   #xx:3,rnB               bixor   #xx:3,@rn
5458                 bixor   #xx:3,@dir              bixor   #xx:3,dir
5459                 bixor   #xx:3,*@dir             bixor   #xx:3,*dir
5460 \f
5461
5462         ASH8 ASSEMBLER                                          PAGE J-7
5463         H8/3XX INSTRUCTION SET
5464
5465
5466         J.2.7  Extended Bit Manipulation Instructions
5467
5468                 bset    #xx:3,rnB               bset    #xx:3,@rn
5469                 bset    #xx:3,@dir              bset    #xx:3,dir
5470                 bset    #xx:3,*@dir             bset    #xx:3,*dir
5471                 bset    rnB,rnB                 bset    rnB,@rn
5472                 bset    rnB,@dir                bset    rnB,dir
5473                 bset    rnB,*@dir               bset    rnB,*dir
5474
5475                 bclr    #xx:3,rnB               bclr    #xx:3,@rn
5476                 bclr    #xx:3,@dir              bclr    #xx:3,dir
5477                 bclr    #xx:3,*@dir             bclr    #xx:3,*dir
5478                 bclr    rnB,rnB                 bclr    rnB,@rn
5479                 bclr    rnB,@dir                bclr    rnB,dir
5480                 bclr    rnB,*@dir               bclr    rnB,*dir
5481
5482                 bnot    #xx:3,rnB               bnot    #xx:3,@rn
5483                 bnot    #xx:3,@dir              bnot    #xx:3,dir
5484                 bnot    #xx:3,*@dir             bnot    #xx:3,*dir
5485                 bnot    rnB,rnB                 bnot    rnB,@rn
5486                 bnot    rnB,@dir                bnot    rnB,dir
5487                 bnot    rnB,*@dir               bnot    rnB,*dir
5488
5489                 btst    #xx:3,rnB               btst    #xx:3,@rn
5490                 btst    #xx:3,@dir              btst    #xx:3,dir
5491                 btst    #xx:3,*@dir             btst    #xx:3,*dir
5492                 btst    rnB,rnB                 btst    rnB,@rn
5493                 btst    rnB,@dir                btst    rnB,dir
5494                 btst    rnB,*@dir               btst    rnB,*dir
5495
5496
5497         J.2.8  Condition Code Instructions
5498
5499                 andc    #xx:8,ccr               andc    #xx:8
5500                 and     #xx:8,ccr               and.b   #xx:8,ccr
5501
5502                 ldc     #xx:8,ccr               ldc     #xx:8
5503                 ldc     rnB,ccr                 ldc     rnB
5504
5505                 orc     #xx:8,ccr               orc     #xx:8
5506                 or      #xx:8,ccr               or.b    #xx:8,ccr
5507
5508                 xorc    #xx:8,ccr               xorc    #xx:8
5509                 xor     #xx:8,ccr               xor.b   #xx:8,ccr
5510
5511                 stc     ccr,rnB                 stc     rnB
5512 \f
5513
5514         ASH8 ASSEMBLER                                          PAGE J-8
5515         H8/3XX INSTRUCTION SET
5516
5517
5518         J.2.9  Other Instructions
5519
5520                 divxu   rnB,rn                  divxu.b rnB,rn
5521
5522                 mulxu   rnB,rn                  mulxu.b rnB,rn
5523
5524                 movfpe  @label,rnB              movfpe  label,rnB
5525                 movfpe.b  @label,rnB            movfpe.b  label,rnB
5526
5527                 movtpe  @label,rnB              movtpe  label,rnB
5528                 movtpe.b  @label,rnB            movtpe.b  label,rnB
5529
5530
5531         J.2.10  Jump and Jump to Subroutine Instructions
5532
5533                 jmp     @rn                     jmp     @@dir
5534                 jmp     @label                  jmp     label
5535
5536                 jsr     @rn                     jsr     @@dir
5537                 jsr     @label                  jsr     label
5538 \f
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552                                    APPENDIX K
5553
5554                                 AS8051 ASSEMBLER
5555
5556
5557
5558
5559
5560         K.1  ACKNOWLEDGMENT
5561
5562
5563            Thanks  to  John  Hartman  for his contribution of the AS8051
5564         cross assembler.
5565
5566                 John L. Hartman
5567                 jhartman@compuserve.com
5568
5569
5570         K.2  8051 REGISTER SET
5571
5572         The following is a list of the 8051 registers used by AS8051:
5573
5574                 a,b             -       8-bit accumulators
5575                 r0,r1,r2,r3     -       8-bit registers
5576                 r4,r5,r6,r7
5577                 dptr            -       data pointer
5578                 sp              -       stack pointer
5579                 pc              -       program counter
5580                 psw             -       status word
5581                 c               -       carry (bit in status word)
5582 \f
5583
5584         AS8051 ASSEMBLER                                        PAGE K-2
5585         8051 REGISTER SET
5586
5587
5588         K.3  8051 INSTRUCTION SET
5589
5590
5591            The  following  tables  list all 8051 mnemonics recognized by
5592         the AS8051 assembler.  The following list specifies  the  format
5593         for each addressing mode supported by AS8051:
5594
5595                 #data           immediate data
5596                                 byte or word data
5597
5598                 r,r1,r2         register r0,r1,r2,r3,r4,r5,r6, or r7
5599
5600                 @r              indirect on register r0 or r1
5601                 @dptr           indirect on data pointer
5602                 @a+dptr         indirect on accumulator
5603                                 plus data pointer
5604                 @a+pc           indirect on accumulator
5605                                 plus program counter
5606
5607                 addr            direct memory address
5608
5609                 bitaddr         bit address
5610
5611                 label           call or jump label
5612
5613         The terms data, addr, bitaddr, and label may all be expressions.
5614
5615            Note  that  not all addressing modes are valid with every in-
5616         struction.  Refer to the 8051 technical data for valid modes.
5617
5618
5619         K.3.1  Inherent Instructions
5620
5621                 nop
5622 \f
5623
5624         AS8051 ASSEMBLER                                        PAGE K-3
5625         8051 INSTRUCTION SET
5626
5627
5628         K.3.2  Move Instructions
5629
5630                 mov     a,#data         mov     a,addr
5631                 mov     a,r             mov     a,@r
5632
5633                 mov     r,#data         mov     r,addr
5634                 mov     r,a
5635
5636                 mov     addr,a          mov     addr,#data
5637                 mov     addr,r          mov     addr,@r
5638                 mov     addr1,addr2     mov     bitaddr,c
5639
5640                 mov     @r,#data        mov     @r,addr
5641                 mov     @r,a
5642
5643                 mov     c,bitaddr
5644                 mov     dptr,#data
5645
5646                 movc    a,@a+dptr       movc    a,@a+pc
5647                 movx    a,@dptr         movx    a,@r
5648                 movx    @dptr,a         movx    @r,a
5649
5650
5651         K.3.3  Single Operand Instructions
5652
5653                 clr     a               clr     c
5654                 clr     bitaddr
5655                 cpl     a               cpl     c
5656                 cpl     bitaddr
5657                 setb    c               setb    bitaddr
5658
5659                 da      a
5660                 rr      a               rrc     a
5661                 rl      a               rlc     a
5662                 swap    a
5663
5664                 dec     a               dec     r
5665                 dec     @r
5666                 inc     a               inc     r
5667                 inc     dptr            inc     @r
5668
5669                 div     ab              mul     ab
5670
5671                 pop     addr            push    addr
5672 \f
5673
5674         AS8051 ASSEMBLER                                        PAGE K-4
5675         8051 INSTRUCTION SET
5676
5677
5678         K.3.4  Two Operand Instructions
5679
5680                 add     a,#data         add     a,addr
5681                 add     a,r             add     a,@r
5682                 addc    a,#data         addc    a,addr
5683                 addc    a,r             addc    a,@r
5684                 subb    a,#data         subb    a,addr
5685                 subb    a,r             subb    a,@r
5686                 orl     a,#data         orl     a,addr
5687                 orl     a,r             orl     a,@r
5688                 orl     addr,a          orl     addr,#data
5689                 orl     c,bitaddr       orl     c,/bitaddr
5690                 anl     a,#data         anl     a,addr
5691                 anl     a,r             anl     a,@r
5692                 anl     addr,a          anl     addr,#data
5693                 anl     c,bitaddr       anl     c,/bitaddr
5694                 xrl     a,#data         xrl     a,addr
5695                 xrl     a,r             xrl     a,@r
5696                 xrl     addr,a          xrl     addr,#data
5697                 xrl     c,bitaddr       xrl     c,/bitaddr
5698                 xch     a,addr          xch     a,r
5699                 xch     a,@r            xchd    a,@r
5700
5701
5702         K.3.5  Call and Return Instructions
5703
5704                 acall   label           lcall   label
5705                 ret                     reti
5706                 in      data
5707                 out     data
5708                 rst     data
5709
5710
5711         K.3.6  Jump Instructions
5712
5713                 ajmp    label
5714                 cjne    a,#data,label   cjne    a,addr,label
5715                 cjne    r,#data,label   cjne    @r,#data,label
5716                 djnz    r,label         djnz    addr,label
5717                 jbc     bitadr,label
5718                 jb      bitadr,label    jnb     bitadr,label
5719                 jc      label           jnc     label
5720                 jz      label           jnz     label
5721                 jmp     @a+dptr
5722                 ljmp    label           sjmp    label
5723 \f
5724
5725         AS8051 ASSEMBLER                                        PAGE K-5
5726         8051 INSTRUCTION SET
5727
5728
5729         K.3.7  Predefined Symbols:  SFR Map
5730
5731                         --------- 4 Bytes ----------
5732                         ----    ----    ----    ----
5733                 FC                                          FF
5734                 F8                                          FB
5735                 F4                                          F7
5736                 F0      B                                   F3
5737                 EC                                          EF
5738                 E8                                          EB
5739                 E4                                          E7
5740                 E0      ACC                                 E3
5741                 DC                                          DF
5742                 D8                                          DB
5743                 D4                                          D7
5744                 D0      PSW                                 D3
5745                 CC   [  TL2     TH2                     ]   CF
5746                 C8   [  T2CON           RCAP2L  RCAP2H  ]   CB
5747                 C4                                          C7
5748                 C0                                          C3
5749                 BC                                          BF
5750                 B8      IP                                  BB
5751                 B4                                          B7
5752                 B0      P3                                  B3
5753                 AC                                          AF
5754                 A8      IE                                  AB
5755                 A4                                          A7
5756                 A0      P2                                  A3
5757                 9C                                          9F
5758                 98      SCON    SBUF                        9B
5759                 94                                          97
5760                 90      P1                                  93
5761                 8C      TH0     TH1                         8F
5762                 88      TCON    TMOD    TL0     TL1         8B
5763                 84                              PCON        87
5764                 80      P0      SP      DPL     DPH         83
5765
5766                 [...] Indicates Resident in 8052, not 8051
5767 \f
5768
5769         AS8051 ASSEMBLER                                        PAGE K-6
5770         8051 INSTRUCTION SET
5771
5772
5773         K.3.8  Predefined Symbols:  SFR Bit Addresses
5774
5775                         ---------- 4 BITS ----------
5776                         ----    ----    ----    ----
5777                 FC                                          FF
5778                 F8                                          FB
5779                 F4      B.4     B.5     B.6     B.7         F7
5780                 F0      B.0     B.1     B.2     B.3         F3
5781                 EC                                          EF
5782                 E8                                          EB
5783                 E4      ACC.4   ACC.5   ACC.6   ACC.7       E7
5784                 E0      ACC.0   ACC.1   ACC.2   ACC.3       E3
5785                 DC                                          DF
5786                 D8                                          DB
5787                 D4      PSW.4   PSW.5   PSW.6   PSW.7       D7
5788                 D0      PSW.0   PSW.1   PSW.2   PSW.3       D3
5789                 CC   [  T2CON.4 T2CON.5 T2CON.6 T2CON.7 ]   CF
5790                 C8   [  T2CON.0 T2CON.1 T2CON.2 T2CON.3 ]   CB
5791                 C4                                          C7
5792                 C0                                          C3
5793                 BC      IP.4    IP.5    IP.6    IP.7        BF
5794                 B8      IP.0    IP.1    IP.2    IP.3        BB
5795                 B4      P3.4    P3.5    P3.6    P3.7        B7
5796                 B0      P3.0    P3.1    P3.2    P3.3        B3
5797                 AC      IE.4    IE.5    EI.6    IE.7        AF
5798                 A8      IE.0    IE.1    IE.2    IE.3        AB
5799                 A4      P2.4    P2.5    P2.6    P2.7        A7
5800                 A0      P2.0    P2.1    P2.2    P2.3        A3
5801                 9C      SCON.4  SCON.5  SCON.6  SCON.7      9F
5802                 98      SCON.0  SCON.1  SCON.2  SCON.3      9B
5803                 94      P1.4    P1.5    P1.6    P1.7        97
5804                 90      P1.0    P1.1    P1.2    P1.3        93
5805                 8C      TCON.4  TCON.5  TCON.6  TCON.7      8F
5806                 88      TCON.0  TCON.1  TCON.2  TCON.3      8B
5807                 84      P0.4    P0.5    P0.6    P0.7        87
5808                 80      P0.0    P0.1    P0.2    P0.3        83
5809
5810                 [...] Indicates Resident in 8052, not 8051
5811 \f
5812
5813         AS8051 ASSEMBLER                                        PAGE K-7
5814         8051 INSTRUCTION SET
5815
5816
5817         K.3.9  Predefined Symbols:  Control Bits
5818
5819                         ---------- 4 BITS ----------
5820                         ----    ----    ----    ----
5821                 FC                                          FF
5822                 F8                                          FB
5823                 F4                                          F7
5824                 F0                                          F3
5825                 EC                                          EF
5826                 E8                                          EB
5827                 E4                                          E7
5828                 E0                                          E3
5829                 DC                                          DF
5830                 D8                                          DB
5831                 D4      RS1     F0      AC      CY          D7
5832                 D0      P               OV      RS0         D3
5833                 CC   [  TLCK    RCLK    EXF2    TF2     ]   CF
5834                 C8   [  CPRL2   CT2     TR2     EXEN2   ]   CB
5835                 C4                                          C7
5836                 C0                                          C3
5837                 BC      PS      PT2                         BF
5838                 B8      PX0     PT0     PX1     PT1         BB
5839                 B4                                          B7
5840                 B0      RXD     TXD     INT0    INT1        B3
5841                 AC      ES      ET2             EA          AF
5842                 A8      EX0     ET0     EX1     ET1         AB
5843                 A4                                          A7
5844                 A0                                          A3
5845                 9C      REN     SM2     SM1     SM0         9F
5846                 98      RI      TI      RB8     TB8         9B
5847                 94                                          97
5848                 90                                          93
5849                 8C      TR0     TF0     TR1     TF1         8F
5850                 88      IT0     IE0     IT1     IE1         8B
5851                 84                                          87
5852                 80                                          83
5853
5854                 [...] Indicates Resident in 8052, not 8051
5855 \f
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869                                    APPENDIX L
5870
5871                                 AS8085 ASSEMBLER
5872
5873
5874
5875
5876
5877         L.1  8085 REGISTER SET
5878
5879         The  following  is  a  list  of  the 8080/8085 registers used by
5880         AS8085:
5881
5882                 a,b,c,d,e,h,l   -       8-bit accumulators
5883                 m               -       memory through (hl)
5884                 sp              -       stack pointer
5885                 psw             -       status word
5886
5887
5888         L.2  8085 INSTRUCTION SET
5889
5890
5891            The  following tables list all 8080/8085 mnemonics recognized
5892         by the AS8085  assembler.   The  following  list  specifies  the
5893         format for each addressing mode supported by AS8085:
5894
5895                 #data           immediate data
5896                                 byte or word data
5897
5898                 r,r1,r2         register or register pair
5899                                 psw,a,b,c,d,e,h,l
5900                                 bc,de,hl,sp,pc
5901
5902                 m               memory address using (hl)
5903
5904                 addr            direct memory addressing
5905
5906                 label           call or jump label
5907
5908         The terms data, m, addr, and label may be expressions.
5909
5910            Note  that  not all addressing modes are valid with every in-
5911         struction, refer to  the  8080/8085  technical  data  for  valid
5912         modes.
5913 \f
5914
5915         AS8085 ASSEMBLER                                        PAGE L-2
5916         8085 INSTRUCTION SET
5917
5918
5919         L.2.1  Inherent Instructions
5920
5921                 cma             cmc
5922                 daa             di
5923                 ei              hlt
5924                 nop             pchl
5925                 ral             rar
5926                 ret             rim
5927                 rrc             rlc
5928                 sim             sphl
5929                 stc             xchg
5930                 xthl
5931
5932
5933         L.2.2  Register/Memory/Immediate Instructions
5934
5935                 adc     r       adc     m       aci     #data
5936                 add     r       add     m       adi     #data
5937                 ana     r       ana     m       ani     #data
5938                 cmp     r       cmp     m       cpi     #data
5939                 ora     r       ora     m       ori     #data
5940                 sbb     r       sbb     m       sbi     #data
5941                 sub     r       sub     m       sui     #data
5942                 xra     r       xra     m       xri     #data
5943
5944
5945         L.2.3  Call and Return Instructions
5946
5947                 cc      label           rc
5948                 cm      label           rm
5949                 cnc     label           rnc
5950                 cnz     label           rnz
5951                 cp      label           rp
5952                 cpe     label           rpe
5953                 cpo     label           rpo
5954                 cz      label           rz
5955                 call    label
5956
5957
5958         L.2.4  Jump Instructions
5959
5960                 jc      label
5961                 jm      label
5962                 jnc     label
5963                 jnz     label
5964                 jp      label
5965                 jpe     label
5966                 jpo     label
5967                 jz      label
5968                 jmp     label
5969 \f
5970
5971         AS8085 ASSEMBLER                                        PAGE L-3
5972         8085 INSTRUCTION SET
5973
5974
5975         L.2.5  Input/Output/Reset Instructions
5976
5977                 in      data
5978                 out     data
5979                 rst     data
5980
5981
5982         L.2.6  Move Instructions
5983
5984                 mov     r1,r2
5985                 mov     r,m
5986                 mov     m,r
5987
5988                 mvi     r,#data
5989                 mvi     m,#data
5990
5991
5992         L.2.7  Other Instructions
5993
5994                 dcr     r               dcr     m
5995                 inr     r               inr     m
5996
5997                 dad     r               dcx     r
5998                 inx     r               ldax    r
5999                 pop     r               push    r
6000                 stax    r
6001
6002                 lda     addr            lhld    addr
6003                 shld    addr            sta     addr
6004
6005                 lxi     r,#data
6006 \f
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020                                    APPENDIX M
6021
6022                                  ASZ80 ASSEMBLER
6023
6024
6025
6026
6027
6028         M.1  .hd64 DIRECTIVE
6029
6030         Format:
6031
6032                 .hd64
6033
6034         The  .hd64  directive enables processing of the HD64180 specific
6035         mnemonics not included in  the  Z80  instruction  set.   HD64180
6036         mnemonics  encountered  without  the  .hd64  directive  will  be
6037         flagged with an 'o' error.
6038
6039
6040         M.2  Z80 REGISTER SET AND CONDITIONS
6041
6042
6043            The following is a complete list of register designations and
6044         condition mnemonics:
6045
6046                 byte registers  -       a,b,c,d,e,h,l,i,r
6047                 register pairs  -       af,af',bc,de,hl
6048                 word registers  -       pc,sp,ix,iy
6049
6050                 C -     carry bit set
6051                 M -     sign bit set
6052                 NC -    carry bit clear
6053                 NZ -    zero bit clear
6054                 P -     sign bit clear
6055                 PE -    parity even
6056                 PO -    parity odd
6057                 Z -     zero bit set
6058
6059
6060 \f
6061
6062         ASZ80 ASSEMBLER                                         PAGE M-2
6063         Z80 INSTRUCTION SET
6064
6065
6066         M.3  Z80 INSTRUCTION SET
6067
6068
6069            The  following  tables  list all Z80/HD64180 mnemonics recog-
6070         nized by the ASZ80 assembler.  The designation []  refers  to  a
6071         required addressing mode argument.  The following list specifies
6072         the format for each addressing mode supported by ASZ80:
6073
6074                 #data           immediate data
6075                                 byte or word data
6076
6077                 n               byte value
6078
6079                 rg              a byte register
6080                                 a,b,c,d,e,h,l
6081
6082                 rp              a register pair
6083                                 bc,de,hl
6084
6085                 (hl)            implied addressing or
6086                                 register indirect addressing
6087
6088                 (label)         direct addressing
6089
6090                 offset(ix)      indexed addressing with
6091                                 an offset
6092
6093                 label           call/jmp/jr label
6094
6095         The  terms  data,  dir,  offset, and ext may all be expressions.
6096         The terms dir and offset are not allowed to be  external  refer-
6097         ences.
6098
6099            Note  that  not all addressing modes are valid with every in-
6100         struction, refer to the Z80/HD64180  technical  data  for  valid
6101         modes.
6102 \f
6103
6104         ASZ80 ASSEMBLER                                         PAGE M-3
6105         Z80 INSTRUCTION SET
6106
6107
6108         M.3.1  Inherent Instructions
6109
6110                 ccf             cpd
6111                 cpdr            cpi
6112                 cpir            cpl
6113                 daa             di
6114                 ei              exx
6115                 halt            neg
6116                 nop             reti
6117                 retn            rla
6118                 rlca            rld
6119                 rra             rrca
6120                 rrd             scf
6121
6122
6123         M.3.2  Implicit Operand Instructions
6124
6125                 adc     a,[]            adc     []
6126                 add     a,[]            add     []
6127                 and     a,[]            and     []
6128                 cp      a,[]            cp      []
6129                 dec     a,[]            dec     []
6130                 inc     a,[]            inc     []
6131                 or      a,[]            or      []
6132                 rl      a,[]            rl      []
6133                 rlc     a,[]            rlc     []
6134                 rr      a,[]            rr      []
6135                 rrc     a,[]            rrc     []
6136                 sbc     a,[]            sbc     []
6137                 sla     a,[]            sla     []
6138                 sra     a,[]            sra     []
6139                 srl     a,[]            srl     []
6140                 sub     a,[]            sub     []
6141                 xor     a,[]            xor     []
6142 \f
6143
6144         ASZ80 ASSEMBLER                                         PAGE M-4
6145         Z80 INSTRUCTION SET
6146
6147
6148         M.3.3  Load Instruction
6149
6150                 ld      rg,[]           ld      [],rg
6151                 ld      (bc),a          ld      a,(bc)
6152                 ld      (de),a          ld      a,(de)
6153                 ld      (label),a       ld      a,(label)
6154                 ld      (label),rp      ld      rp,(label)
6155                 ld      i,a             ld      r,a
6156                 ld      a,i             ld      a,r
6157                 ld      sp,hl           ld      sp,ix
6158                 ld      sp,iy           ld      rp,#data
6159
6160                 ldd                     lddr
6161                 ldi                     ldir
6162
6163
6164         M.3.4  Call/Return Instructions
6165
6166                 call    C,label         ret     C
6167                 call    M,label         ret     M
6168                 call    NC,label        ret     NC
6169                 call    NZ,label        ret     NZ
6170                 call    P,label         ret     P
6171                 call    PE,label        ret     PE
6172                 call    PO,label        ret     PO
6173                 call    Z,label         ret     Z
6174                 call    label           ret
6175
6176
6177         M.3.5  Jump and Jump to Subroutine Instructions
6178
6179                 jp      C,label         jp      M,label
6180                 jp      NC,label        jp      NZ,label
6181                 jp      P,label         jp      PE,label
6182                 jp      PO,label        jp      Z,label
6183
6184                 jp      (hl)            jp      (ix)
6185                 jp      (iy)            jp      label
6186
6187                 djnz    label
6188
6189                 jr      C,label         jr      NC,label
6190                 jr      NZ,label        jr      Z,label
6191                 jr      label
6192 \f
6193
6194         ASZ80 ASSEMBLER                                         PAGE M-5
6195         Z80 INSTRUCTION SET
6196
6197
6198         M.3.6  Bit Manipulation Instructions
6199
6200                 bit     n,[]
6201                 res     n,[]
6202                 set     n,[]
6203
6204
6205         M.3.7  Interrupt Mode and Reset Instructions
6206
6207                 im      n
6208                 im      n
6209                 im      n
6210                 rst     n
6211
6212
6213         M.3.8  Input and Output Instructions
6214
6215                 in      a,(n)           in      rg,(c)
6216                 ind                     indr
6217                 ini                     inir
6218
6219                 out     (n),a           out     (c),rg
6220                 outd                    otdr
6221                 outi                    otir
6222
6223
6224         M.3.9  Register Pair Instructions
6225
6226                 add     hl,rp           add     ix,rp
6227                 add     iy,rp
6228
6229                 adc     hl,rp           sbc     hl,rp
6230
6231                 ex      (sp),hl         ex      (sp),ix
6232                 ex      (sp),iy
6233                 ex      de,hl
6234                 ex      af,af'
6235
6236                 push    rp              pop     rp
6237 \f
6238
6239         ASZ80 ASSEMBLER                                         PAGE M-6
6240         Z80 INSTRUCTION SET
6241
6242
6243         M.3.10  HD64180 Specific Instructions
6244
6245                 in0     rg,(n)
6246                 out0    (n),rg
6247
6248                 otdm                    otdmr
6249                 otim                    otimr
6250
6251                 mlt     bc              mlt     de
6252                 mlt     hl              mlt     sp
6253
6254                 slp
6255
6256                 tst     a
6257                 tstio   #data
6258 \f
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272                                    APPENDIX N
6273
6274                                 AS6500 ASSEMBLER
6275
6276
6277
6278
6279
6280         N.1  ACKNOWLEDGMENT
6281
6282
6283            Thanks  to  Marko  Makela  for his contribution of the AS6500
6284         cross assembler.
6285
6286                 Marko Makela
6287                 Sillitie 10 A
6288                 01480 Vantaa
6289                 Finland
6290                 Internet: Marko.Makela@Helsinki.Fi
6291                 EARN/BitNet: msmakela@finuh
6292
6293            Several  additions and modifications were made to his code to
6294         support the following families of 6500 processors:
6295
6296                 (1)     650X and 651X processor family
6297                 (2)     65F11 and 65F12 processor family
6298                 (3)     65C00/21 and 65C29 processor family
6299                 (4)     65C02, 65C102, and 65C112 processor family
6300
6301            The  instruction  syntax of this cross assembler contains two
6302         peculiarities:  (1) the addressing indirection is denoted by the
6303         square  brackets  []  and (2) the `bbrx' and `bbsx' instructions
6304         are written `bbr0 memory,label'.
6305
6306
6307 \f
6308
6309         AS6500 ASSEMBLER                                        PAGE N-2
6310         6500 REGISTER SET
6311
6312
6313         N.2  6500 REGISTER SET
6314
6315         The following is a list of the 6500 registers used by AS6500:
6316
6317                 a       -       8-bit accumulator
6318                 x,y     -       index registers
6319
6320
6321         N.3  6500 INSTRUCTION SET
6322
6323
6324            The  following  tables  list all 6500 family mnemonics recog-
6325         nized by the AS6500 assembler.  The designation [] refers  to  a
6326         required addressing mode argument.  The following list specifies
6327         the format for each addressing mode supported by AS6500:
6328
6329                 #data           immediate data
6330                                 byte or word data
6331
6332                 *dir            direct page addressing
6333                                 (see .setdp directive)
6334                                 0 &lt;= dir &lt;= 255
6335
6336                 offset,x        indexed addressing
6337                 offset,y        indexed addressing
6338                                 address = (offset + (x or y))
6339
6340                 [offset,x]      pre-indexed indirect addressing
6341                                 0 &lt;= offset &lt;= 255
6342                                 address = contents of location
6343                                     (offset + (x or y)) mod 256
6344
6345                 [offset],y      post-indexed indirect addressing
6346                                 address = contents of location at offset
6347                                     plus the value of the y register
6348
6349                 [address]       indirect addressing
6350
6351                 ext             extended addressing
6352
6353                 label           branch label
6354
6355                 address,label   direct page memory location
6356                                 branch label
6357                                 bbrx and bbsx instruction addressing
6358
6359         The  terms data, dir, offset, address, ext, and label may all be
6360         expressions.
6361
6362            Note  that  not all addressing modes are valid with every in-
6363         struction, refer to the 65xx technical data for valid modes.
6364 \f
6365
6366         AS6500 ASSEMBLER                                        PAGE N-3
6367         6500 INSTRUCTION SET
6368
6369
6370         N.3.1  Processor Specific Directives
6371
6372
6373            The  AS6500  cross  assembler has four (4) processor specific
6374         assembler directives which  define  the  target  65xx  processor
6375         family:
6376
6377                 .r6500          Core 650X and 651X family (default)
6378                 .r65f11         Core plus 65F11 and 65F12
6379                 .r65c00         Core plus 65C00/21 and 65C29
6380                 .r65c02         Core plus 65C02, 65C102, and 65C112
6381
6382
6383         N.3.2  65xx Core Inherent Instructions
6384
6385                 brk                     clc
6386                 cld                     cli
6387                 clv                     dex
6388                 dey                     inx
6389                 iny                     nop
6390                 pha                     php
6391                 pla                     plp
6392                 rti                     rts
6393                 sec                     sed
6394                 sei                     tax
6395                 tay                     tsx
6396                 txa                     txs
6397                 tya
6398
6399
6400         N.3.3  65xx Core Branch Instructions
6401
6402                 bcc     label           bhs     label
6403                 bcs     label           blo     label
6404                 beq     label           bmi     label
6405                 bne     label           bpl     label
6406                 bvc     label           bvs     label
6407
6408
6409         N.3.4  65xx Core Single Operand Instructions
6410
6411                 asl     []
6412                 dec     []
6413                 inc     []
6414                 lsr     []
6415                 rol     []
6416                 ror     []
6417 \f
6418
6419         AS6500 ASSEMBLER                                        PAGE N-4
6420         6500 INSTRUCTION SET
6421
6422
6423         N.3.5  65xx Core Double Operand Instructions
6424
6425                 adc     []
6426                 and     []
6427                 bit     []
6428                 cmp     []
6429                 eor     []
6430                 lda     []
6431                 ora     []
6432                 sbc     []
6433                 sta     []
6434
6435
6436         N.3.6  65xx Core Jump and Jump to Subroutine Instructions
6437
6438                 jmp     []              jsr     []
6439
6440
6441         N.3.7  65xx Core Miscellaneous X and Y Register Instructions
6442
6443                 cpx     []
6444                 cpy     []
6445                 ldx     []
6446                 stx     []
6447                 ldy     []
6448                 sty     []
6449 \f
6450
6451         AS6500 ASSEMBLER                                        PAGE N-5
6452         6500 INSTRUCTION SET
6453
6454
6455         N.3.8  65F11 and 65F12 Specific Instructions
6456
6457                 bbr0    [],label                bbr1    [],label
6458                 bbr2    [],label                bbr3    [],label
6459                 bbr4    [],label                bbr5    [],label
6460                 bbr6    [],label                bbr7    [],label
6461
6462                 bbs0    [],label                bbs1    [],label
6463                 bbs2    [],label                bbs3    [],label
6464                 bbs4    [],label                bbs5    [],label
6465                 bbs6    [],label                bbs7    [],label
6466
6467                 rmb0    []                      rmb1    []
6468                 rmb2    []                      rmb3    []
6469                 rmb4    []                      rmb5    []
6470                 rmb6    []                      rmb7    []
6471
6472                 smb0    []                      smb1    []
6473                 smb2    []                      smb3    []
6474                 smb4    []                      smb5    []
6475                 smb6    []                      smb7    []
6476
6477
6478         N.3.9  65C00/21 and 65C29 Specific Instructions
6479
6480                 bbr0    [],label                bbr1    [],label
6481                 bbr2    [],label                bbr3    [],label
6482                 bbr4    [],label                bbr5    [],label
6483                 bbr6    [],label                bbr7    [],label
6484
6485                 bbs0    [],label                bbs1    [],label
6486                 bbs2    [],label                bbs3    [],label
6487                 bbs4    [],label                bbs5    [],label
6488                 bbs6    [],label                bbs7    [],label
6489
6490                 bra     label
6491
6492                 phx                             phy
6493                 plx                             ply
6494
6495                 rmb0    []                      rmb1    []
6496                 rmb2    []                      rmb3    []
6497                 rmb4    []                      rmb5    []
6498                 rmb6    []                      rmb7    []
6499
6500                 smb0    []                      smb1    []
6501                 smb2    []                      smb3    []
6502                 smb4    []                      smb5    []
6503                 smb6    []                      smb7    []
6504 \f
6505
6506         AS6500 ASSEMBLER                                        PAGE N-6
6507         6500 INSTRUCTION SET
6508
6509
6510         N.3.10  65C02, 65C102, and 65C112 Specific Instructions
6511
6512                 bbr0    [],label                bbr1    [],label
6513                 bbr2    [],label                bbr3    [],label
6514                 bbr4    [],label                bbr5    [],label
6515                 bbr6    [],label                bbr7    [],label
6516
6517                 bbs0    [],label                bbs1    [],label
6518                 bbs2    [],label                bbs3    [],label
6519                 bbs4    [],label                bbs5    [],label
6520                 bbs6    [],label                bbs7    [],label
6521
6522                 bra     label
6523
6524                 phx                             phy
6525                 plx                             ply
6526
6527                 rmb0    []                      rmb1    []
6528                 rmb2    []                      rmb3    []
6529                 rmb4    []                      rmb5    []
6530                 rmb6    []                      rmb7    []
6531
6532                 smb0    []                      smb1    []
6533                 smb2    []                      smb3    []
6534                 smb4    []                      smb5    []
6535                 smb6    []                      smb7    []
6536
6537                 stz     []
6538                 trb     []
6539                 tsb     []
6540
6541            Additional  addressing  modes for the following core instruc-
6542         tions are also available with the 65C02, 65C102, and 65C112 pro-
6543         cessors.
6544
6545                 adc     []                      and     []
6546                 cmp     []                      eor     []
6547                 lda     []                      ora     []
6548                 sbc     []                      sta     []
6549
6550                 bit     []                      jmp     []
6551
6552                 dec                             inc
6553 </PRE></B>
6554
6555 <IMG width=576 height=5 border=0 SRC="rnbow.gif">
6556
6557 <P><a href="../home.htm">
6558 <IMG width=32 height=32 border=0 SRC="spcshp.gif" ALIGN=BOTTOM></a>
6559 <B>...  Home Page</B></P>
6560 </BODY>
6561 </HTML>