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