home *** CD-ROM | disk | FTP | other *** search
/ ftp.uni-stuttgart.de/pub/systems/acorn/ / Acorn.tar / Acorn / 6502 / lang / assembler / a01asm.dc1 < prev    next >
Text File  |  1992-05-04  |  97KB  |  2,993 lines

  1.  
  2.  
  3.      
  4.  
  5.  
  6.  
  7.      
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.                            USING THE 65C02 ASSEMBLER 
  18.                                  (Version 1.60)
  19.      
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.      This  guide  describes how to use the 65C02 Assembler produced by Alan
  30.      Phillips of the Department of Computing at Lancaster  University.  The
  31.      reader  is  assumed to be familiar with the concepts of programming at
  32.      assembly level.
  33.      
  34.      
  35.      The 65C02 Assembler is copyright (C) Alan Phillips  1987.  It  may  be
  36.      passed  on  by  anyone,  to  anyone, and used for any peaceful purpose
  37.      whether private or commercial. No purchase, licensing or permission is
  38.      needed. It may be distributed in any way or  posted  on  any  Bulletin
  39.      Board  system  provided  that  it  is  not sold (apart from reasonable
  40.      handling and media costs), that due credit is made for authorship, and
  41.      that this paragraph is brought to the attention of the recipient.
  42.      
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.                                                                 Edition 3.1
  57.                                                                October 1987
  58.                                                               Alan Phillips
  59.      
  60.  
  61.  
  62.  
  63.      
  64.  
  65.  
  66.  
  67.  
  68.  
  69.                                         
  70.  
  71.  
  72.  
  73.                                     CONTENTS
  74.      
  75.  
  76.           1.  INTRODUCTION
  77.               1.1  Installing the Assembler
  78.               1.2  The Assembler's CLI mode
  79.               1.3  Creating source files
  80.               1.4  Starting an assembly
  81.                    1.4.1  The command line options
  82.                    1.4.2  Alternative syntax forms for the command line
  83.               1.5  Assembly on a second processor
  84.               1.6  The object code buffer
  85.               1.7  Returning to the calling language
  86.               1.8  Use of control keys during assembly
  87.           
  88.           2.  SOURCE PROGRAM FORMAT
  89.               2.1  Syntax of the line
  90.                    2.1.1  The label field
  91.                    2.1.2  The opcode field
  92.                    2.1.3  The operand field
  93.                    2.1.4  The comment field
  94.               2.2  The syntax of expressions
  95.                    2.2.1  Numeric expressions
  96.                    2.2.2  Strings
  97.                    2.2.3  String expressions
  98.           
  99.           3.  THE OUTPUT LISTING
  100.               3.1  The source listing level
  101.               3.2  Source listing format
  102.                    3.2.1  Listing object code bytes
  103.               3.4  Symbol table listing format
  104.               3.5  Error reports
  105.               3.6  Output page control
  106.                    3.6.1  Setting page dimensions
  107.                    3.6.2  Setting the page title
  108.                    3.6.3  Setting the timestamp
  109.                    3.6.4  Page layout directives
  110.               3.7  Controlling the output destination
  111.                    3.7.1  Output to a printer
  112.                    3.7.2  Output to a file
  113.                    3.7.3  Printer control
  114.           
  115.           4.  DIRECTIVES DEFINING DATA AND CONSTANTS
  116.               4.1  Defining constants
  117.               4.2  Byte and word directives
  118.                    4.2.1  Byte directives
  119.                    4.2.2  Word directives
  120.                    4.2.3  Using repeat counts
  121.               4.3  Character string directives
  122.                    4.3.1  The ASC and STR directives
  123.                    4.3.2  The CASC and CSTR directives
  124.                    4.3.3  Planting special characters
  125.               4.4  The HEX directive
  126.               4.5  The CODE directive
  127.  
  128.  
  129.           
  130.  
  131.  
  132.  
  133.  
  134.  
  135.           
  136.  
  137.  
  138.  
  139.           
  140.           5.  OBJECT FILE CONTROL DIRECTIVES
  141.               5.1  Defining the current address
  142.               5.2  Using dummy sections
  143.               5.3  Reading the current address
  144.                    5.3.1  The DS directive
  145.                    5.3.2  Reading the current address
  146.               5.4  Defining object load and execution addresses
  147.                    5.4.1  Specifying the low bytes of the addresses
  148.           
  149.           6.  SOURCE FILE CONTROL DIRECTIVES
  150.               6.1  Chaining source files
  151.               6.2  Including one file into another
  152.           
  153.           7.  CONDITIONAL ASSEMBLY
  154.               7.1  Assembly conditional on expressions
  155.               7.2  Assembly conditional on the existence of symbols
  156.               7.3  Nesting conditionals
  157.               7.4  Listing conditionals
  158.           
  159.           8.  PROGRESS REPORTING DIRECTIVES
  160.               8.1  The DISP, DISP1 and DISP2 directives
  161.               8.2  The WAIT, WAIT1 and WAIT2 directives
  162.               8.3  The QUERY directive
  163.               8.4  The STOP directive
  164.           
  165.           9.  WRITING SIMPLE MACROS
  166.               9.1  Using macro parameters
  167.               9.2  Specifying macro parameters
  168.               9.3  Nesting macros
  169.               9.4  Redefining opcodes and directives
  170.               9.5  Labels within macros
  171.           
  172.           10. THE MACRO PROGRAMMING LANGUAGE
  173.               10.1 Sequence Symbols
  174.               10.2 Assembly Time Variables
  175.                    10.2.1 Creating Assembly Time Variables
  176.                           10.2.1.1 Local and global ATVs
  177.                           10.2.1.2 String and numeric values
  178.                           10.2.1.3 Efficient use of memory
  179.                    10.2.2 Simple substitution of Assembly Time Variables
  180.               10.3 Writing complex macros
  181.                    10.3.1 Programming macro loops
  182.                           10.3.1.1 Loops controlled by counter
  183.                           10.3.1.2 Loops accessing macro parameters
  184.                    10.3.2 Changing macro parameters
  185.                    10.3.3 Listing control for macros
  186.                    10.3.4 Exiting a macro prematurely
  187.                    10.3.5 Comment lines within macros
  188.               10.4 System ATVs
  189.           
  190.  
  191.  
  192.  
  193.  
  194.  
  195.           
  196.  
  197.  
  198.  
  199.  
  200.  
  201.           
  202.  
  203.  
  204.  
  205.           Appendices
  206.           
  207.           
  208.           
  209.           A1. Opcodes and addressing modes
  210.           A2. Assembler directives
  211.           A3. Differences from the ADE Assembler
  212.           A4. Differences from previous releases
  213.           A5. Customising the Assembler
  214.           
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.      
  245.                                 Acknowledgments 
  246.      
  247.      Thanks are due to Dave Morriss, Neil Mercer, Alan Baker, Peter  Vince,
  248.      Mike   Tubby,   Scott  Larson  and  Peter  Francis  for  many  helpful
  249.      suggestions and comments during the development of the Assembler.
  250.      
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.      
  262.  
  263.  
  264.  
  265.  
  266.  
  267.                            USING THE 65C02 ASSEMBLER
  268.  
  269.  
  270.  
  271.      1. INTRODUCTION
  272.      
  273.      
  274.         The 65C02 Assembler runs in sideways RAM or as a  sideways  ROM  on
  275.      the  BBC  Models  B, B+, B+128, Master 128 and Master Compact, with or
  276.      without a 6502 Second Processor. It supports all the  opcodes  of  the
  277.      6502  and  65C02  processor  families,  and  contains a powerful Macro
  278.      Programming Language.
  279.      
  280.         The Assembler is a disc-oriented system. Source files must be  held
  281.      on  disc,  and the object code will be written to disc. It can be used
  282.      with the Acorn DFS, ADFS, NFS and any other Acorn-compatible  disc  or
  283.      network filing system, but not on cassette-only machines.
  284.      
  285.         There  are no source editing facilities contained in the Assembler.
  286.      However, it is able to accept source produced by most text editors  or
  287.      word-processor programs.
  288.      
  289.      
  290.      1.1 Installing the Assembler
  291.      
  292.      
  293.         The  65C02  Assembler code is completely unprotected. If you have a
  294.      machine with sideways RAM, you will be able to load it to a  RAM  bank
  295.      and run it; if not, you will need to program it into a 27128 EPROM and
  296.      fit it into a sideways ROM socket.
  297.      
  298.      
  299.      1.2 The Assembler's CLI mode
  300.      
  301.         If you have the Assembler fitted into the highest priority ROM slot
  302.      of  your  machine, pressing CONTROL-BREAK or powering on will enter it
  303.      as the current language. In this case the Assembler is said to  be  in
  304.      "CLI  (Command  Language  Interpreter)  mode".  You  will  see  a  "*"
  305.      prompting you for input, and any lines you type will be  sent  to  the
  306.      BBC Operating System as MOS commands. In this mode there is no need to
  307.      type a "*" yourself in front of the commands, although it won't matter
  308.      if you do.
  309.      
  310.         You can also enter CLI mode by issuing the command
  311.      
  312.                                       *CLI
  313.      
  314.      regardless of the ROM socket the Assembler is in. 
  315.      
  316.         From  CLI  mode  you  can  of  course  start  an  assembly with the
  317.      *ASSEMBLE command described  below.  Alternatively,  you  could  enter
  318.      another language by typing, say,
  319.      
  320.                                      *BASIC
  321.      
  322.      or
  323.      
  324.                                    *WORDWISE
  325.  
  326.  
  327.                                        1
  328.  
  329.  
  330.  
  331.  
  332.  
  333.                            USING THE 65C02 ASSEMBLER
  334.  
  335.  
  336.  
  337.      
  338.      
  339.         Naturally,  you  are able to issue DFS commands in CLI mode, or you
  340.      could *TYPE files, and so on. You can't use the BASIC  statement  MODE
  341.      to  change  screen  mode,  though,  since  the current language is not
  342.      BASIC. However, for  convenience  the  Assembler  will  respond  to  a
  343.      command *MODE, so you could type
  344.      
  345.                                     *MODE 3
  346.      
  347.      to set mode 3 if you wished. This command is available either from the
  348.      Assembler's CLI mode or from any other language.
  349.      
  350.      
  351.      1.3 Creating source files
  352.      
  353.         Though  the  Assembler  does not contain any editing facilities, it
  354.      will accept files produced on just about any word processor or  source
  355.      editor.   The   source   you  create  should  contain  only  printable
  356.      characters, spaces and TAB characters, and each line should end with a
  357.      carriage return byte (with optionally a line feed character before  or
  358.      after  it).  The  Assembler  will  treat  the  character used in saved
  359.      Wordwise files to indicate a TAB (ASCII code  &DD)  as  a  "real"  TAB
  360.      character.
  361.      
  362.         The  Assembler  will  normally  ignore  any other characters in the
  363.      source. Some word processors, though, may use  characters  with  ASCII
  364.      codes  in the range 128 to 255 for special purposes: the Assembler can
  365.      be configured to change its action  on  encountering  these.  This  is
  366.      described in detail in Appendix 5.
  367.      
  368.         You can create suitable files easily with WordWise or View:
  369.      
  370.      
  371.        a. Using WordWise
  372.           
  373.           Files saved by menu option 1 can be used directly as input to the
  374.           Assembler,  provided  that  you  have  not  included any embedded
  375.           commands. The  WordWise  TAB  character,  which  appears  on  the
  376.           editing  screen  as a right-pointing arrow, will be accepted as a
  377.           TAB by the Assembler. Remember to press RETURN at the end of each
  378.           source line.
  379.           
  380.           Alternatively, you can spool the file to disc  first  using  menu
  381.           option  8  -  but  this will create a bigger file, that will take
  382.           longer to assemble. You may need some caution  here  if  you  are
  383.           using  the  "|"  character within string constants: remember that
  384.           this is the WordWise "pad" character, so by default  will  appear
  385.           as  a  space  in  the  spooled  file.  To  overcome this, use the
  386.           WordWise  "pc"  directive  to  redefine  the  pad  character   to
  387.           something else.
  388.           
  389.           
  390.           
  391.  
  392.  
  393.                                        2
  394.  
  395.  
  396.  
  397.  
  398.  
  399.                            USING THE 65C02 ASSEMBLER
  400.  
  401.  
  402.  
  403.        b. Using View
  404.           
  405.           A  file  created  by the View SAVE, WRITE or EDIT commands can be
  406.           directly input to the Assembler. You should not  include  rulers,
  407.           stored  commands  or  highlight  codes  in  this file. You should
  408.           always remember to press RETURN at the end of every source  line:
  409.           it  will  be necessary to turn off the Format and Justify options
  410.           when typing the source, otherwise View will interfere with this.
  411.           
  412.           
  413.      1.4 Starting an assembly
  414.      
  415.      
  416.         The Assembler is  started  with  the  *ASSEMBLE  command.  This  is
  417.      followed by a number of "option flags" that tell the Assembler exactly
  418.      how you wish it to operate.
  419.      
  420.         The simplest use of the command would be, for example:
  421.      
  422.                                 *ASSEMBLE SOURCE
  423.      
  424.      where  the  source file name is SOURCE. This format performs a "syntax
  425.      check run" - no object code  is  produced.  This  will  give  you  the
  426.      fastest  possibly  assembly, and it can be very useful when checking a
  427.      large program for errors. To produce an  object  file  containing  the
  428.      assembled code, you need to specify a "-O" option:
  429.      
  430.                            *ASSEMBLE SOURCE -OPROGRAM
  431.      
  432.      where  the "-O" is followed by the name of the object file you wish to
  433.      produce.
  434.      
  435.         After assembly, the Assembler will return you to the  language  you
  436.      were  running  when  you  issued  the *ASSEMBLE command. If you have a
  437.      machine  with   shadow   screen   capability,   the   Assembler   will
  438.      automatically turn it on to give you the maximum space for symbols. It
  439.      will  return  the shadow screen to its initial state when it finishes,
  440.      and since this involves clearing the screen in a mode change, it  will
  441.      pause for you to press a key before it does so.
  442.      
  443.      
  444.      
  445.           1.4.1 The command line options
  446.           
  447.           
  448.           The  various  options  you  can specify to the command are listed
  449.           below. Each option flag consists of a "-" character followed by a
  450.           letter, for example "-S". Some  option  flags  must  be  followed
  451.           immediately by numbers or filenames. You must separate one option
  452.           from another by spaces.
  453.           
  454.           Options can be given in any order, but the first parameter to the
  455.           command  must  always  be  the name of the first (or only) source
  456.           file.
  457.  
  458.  
  459.                                        3
  460.  
  461.  
  462.  
  463.  
  464.  
  465.                            USING THE 65C02 ASSEMBLER
  466.  
  467.  
  468.  
  469.           
  470.           
  471.                 -A  You must specify this option to assemble the source for
  472.                     BBC  KERMIT,  and  it  is   recommended   for   sources
  473.                     originally  written for the ADE Assembler. It makes the
  474.                     syntax of labels ADE-compatible, and  treats  only  the
  475.                     first  6 characters of each as significant. This option
  476.                     implies a -R.
  477.                     
  478.                     By  default,  all  the  characters  of  a   label   are
  479.                     significant.
  480.                     
  481.                 -B  Specifies that a memory buffer is to be used for object
  482.                     code.  This  must  be followed by a number in the range
  483.                     1..16 (see section 1.6)
  484.                     
  485.                     By default, no object buffer is  used,  and  bytes  are
  486.                     written to the object file one by one.
  487.                     
  488.                 -C  Specifies  the default code listing level (see the CLST
  489.                     directive). This must be followed by 0, 1 or 2.
  490.                     
  491.                     By default, the Assembler will start an assembly with a
  492.                     code listing level of 1.
  493.                     
  494.                 -F  Specifies the name of a listing file, which must follow
  495.                     the option flag. If you give this option, the  assembly
  496.                     listing  will  be  written to the file instead of being
  497.                     sent to the screen.
  498.                     
  499.                     If you do not use either the  -P  or  -F  options,  the
  500.                     listing will be sent to the screen only.
  501.                     
  502.                     Note  that  if you specify both -P and -F options, only
  503.                     the -F will take effect.
  504.                     
  505.                 -G  Specifies that the Assembler is to restart the  calling
  506.                     language immediately the assembly is over. (See section
  507.                     1.7)
  508.                     
  509.                     By  default, the Assembler pauses after assembly unless
  510.                     it is called from BASIC or its own CLI mode.
  511.                     
  512.                 -L  Specifies the default source listing level (see the LST
  513.                     directive). This must be followed by 0, 1, 2 or 3.  You
  514.                     can  also  control  the  list  level  during the actual
  515.                     assembly with function keys f0, f1, f2 and f3.
  516.                     
  517.                     By default, the Assembler will start an assembly with a
  518.                     source listing level of 0.
  519.                     
  520.                 -M  Instructs the Assembler to change screen mode before it
  521.                     starts to process the source. The number  of  the  mode
  522.                     you wish to use should follow the letter M, and must be
  523.  
  524.  
  525.                                        4
  526.  
  527.  
  528.  
  529.  
  530.  
  531.                            USING THE 65C02 ASSEMBLER
  532.  
  533.  
  534.  
  535.                     in the range 0..7.
  536.                     
  537.                     By  default,  the  Assembler will leave the screen mode
  538.                     unchanged.
  539.                     
  540.                 -O  Specifies the name  of  the  object  file,  which  must
  541.                     follow the option flag. If you omit this, the Assembler
  542.                     performs  a  syntax  check only and does not produce an
  543.                     object file.
  544.                     
  545.                 -P  Specifies that the listing is to be sent to  a  printer
  546.                     only.
  547.                     
  548.                     If  you  do  not  use  either the -P or -F options, the
  549.                     listing will be sent to the screen only.
  550.                     
  551.                     Note that if you specify both -P and -F  options,  only
  552.                     the -F will take effect.
  553.                     
  554.                 -R  If  this  is  specified,  65C02  opcodes and addressing
  555.                     modes are rejected. If you omit it, all 65C02 codes are
  556.                     assembled.
  557.                     
  558.                 -S  Specifies that lines skipped in  conditionals  are  not
  559.                     listed (see the SFCOND and LFCOND directives)
  560.                     
  561.                     By  default,  the Assembler will list all skipped lines
  562.                     in conditionals.
  563.                     
  564.                 -W  Specifies  that  the  Assembler   should   wait   after
  565.                     displaying  a line containing an error, so you can note
  566.                     down the details. To resume assembly,  press  any  key.
  567.                     This  option has no effect if you are sending output to
  568.                     a printer or to a file. You can change the  setting  of
  569.                     this  option  at  any  time during assembly by pressing
  570.                     CONTROL-W.
  571.                     
  572.                     By default, the Assembler will report all  errors,  but
  573.                     will not pause.
  574.                     
  575.                     
  576.           As an example, the line:
  577.           
  578.                        *ASSEMBLE SOURCE -OPROG -P -L2 -B8
  579.           
  580.           will assemble from file SOURCE, putting the object code into file
  581.           PROG.  The  default listing level used will be 2, and the listing
  582.           will be sent to the printer only. An 8 kilobyte memory buffer  is
  583.           to be used for the object code to speed up assembly.
  584.           
  585.           The  Assembler  will  leave  the screen in whatever mode you have
  586.           selected, so that for large assemblies you may need to change  to
  587.           mode  7  to  provide  room in memory for the symbol table. Shadow
  588.           mode will automatically be selected if it is available,  so  that
  589.  
  590.  
  591.                                        5
  592.  
  593.  
  594.  
  595.  
  596.  
  597.                            USING THE 65C02 ASSEMBLER
  598.  
  599.  
  600.  
  601.           on  the  B+,  B+128  and  Master  series you will always have the
  602.           maximum space available.
  603.           
  604.           
  605.           
  606.           1.4.2 Alternative syntax forms for the command line
  607.           
  608.           The example given  above,  and  the  output  the  Assembler  will
  609.           produce if you type
  610.           
  611.                                 *HELP ASSEMBLER
  612.           
  613.           detail  the  full  form  of  the command line syntax. As you gain
  614.           experience in using the Assembler, however,  you  might  wish  to
  615.           take  advantage  of  various  ways of specifying the options in a
  616.           more compact form.
  617.           
  618.           Firstly, the Assembler allows you to specify the options  all  at
  619.           once,  without  the need to put the "-" flag before each of them.
  620.           Thus, you could type either
  621.           
  622.                           *ASSEMBLE SOURCE -M3 -W -L2
  623.           
  624.           or the shorter, but less readable
  625.           
  626.                             *ASSEMBLE SOURCE -M3WL2
  627.           
  628.           Secondly, the "-O" flag to specify an object  file  is  optional.
  629.           The Assembler will take the second parameter of the command as an
  630.           object file name, unless it starts with a "-" character. Thus
  631.           
  632.                             *ASSEMBLE SOURCE -OPROG
  633.           
  634.           and
  635.           
  636.                              *ASSEMBLE SOURCE PROG
  637.           
  638.           are  identical  in  effect.  If you should ever need to start the
  639.           object file with a "-" character (e.g.  if  you  wish  to  use  a
  640.           temporary  file  system on a Master 128) you will have to specify
  641.           the "-O" flag explicitly.
  642.           
  643.           
  644.      1.5 Assembly on a second processor
  645.      
  646.         The 65C02 Assembler is  compatible  with  both  the  external  6502
  647.      second  processor,  and  with  the  Master  Turbo-Card. Using a second
  648.      processor will give a faster assembly due to the higher clock rate  of
  649.      the  processor,  and  will  also  give  you more memory for the symbol
  650.      table.
  651.      
  652.         A second processor allows you to organise your source files to take
  653.      advantage of a source file memory buffer. Any source file that is less
  654.      than 14 kilobytes in size is *LOADed into memory  and  assembled  from
  655.  
  656.  
  657.                                        6
  658.  
  659.  
  660.  
  661.  
  662.  
  663.                            USING THE 65C02 ASSEMBLER
  664.  
  665.  
  666.  
  667.      there:  since  the Assembler does not then need to wait for data to be
  668.      fetched from disc, assembly will speed up  dramatically.  It  is  well
  669.      worth arranging your program so each of its source files will fit into
  670.      this buffer area.
  671.      
  672.         The  source  buffer  is  automatically  switched  on  when a second
  673.      processor is in use.
  674.      
  675.      
  676.      1.6 The object code buffer
  677.      
  678.         The Assembler allows you to select an object code buffer in memory.
  679.      Code bytes generated from the source are  written  into  this  buffer,
  680.      rather  than  being sent directly to the object file, and this gives a
  681.      substantial increase in speed of  assembly.  Whenever  the  buffer  is
  682.      full,  the assembly will pause in reading source to write the contents
  683.      to the object file. It then resumes assembly until  the  buffer  again
  684.      fills, and so on.
  685.      
  686.         You  can  specify the buffer size with the "-B" option. The flag is
  687.      followed by a number between 1 and  16,  giving  the  buffer  size  in
  688.      kilobytes.   Note   that   using   a   buffer   means  that  there  is
  689.      correspondingly less space available for the symbol table.
  690.      
  691.         The fastest assembly will be achieved when  the  object  code  fits
  692.      entirely into the buffer. In this case, the Assembler will produce the
  693.      object  file  with  *SAVE  at  the  very  end of an assembly, which is
  694.      substantially faster even than writing it in large blocks.
  695.      
  696.      
  697.      1.7 Returning to the calling language
  698.      
  699.         When an assembly finishes, the Assembler will  always  restart  the
  700.      language ROM that was in use when you issued the *ASSEMBLE command. If
  701.      this language was BASIC or the Assembler's own CLI mode, there will be
  702.      no  difficulty:  however,  some  languages  such  as  WordWise or View
  703.      immediately clear the screen when they start, so you may not have time
  704.      to read the final lines that the Assembler displays on the screen.
  705.      
  706.         To overcome this, the Assembler is able to pause when it ends until
  707.      you press a key. It will do this whenever the previous language is not
  708.      BASIC or the Assembler's CLI mode.
  709.      
  710.         If you don't wish it to pause (you may for example not want to read
  711.      the final screen, or the language may not clear  the  screen),  simply
  712.      specify  a  "-G"  option  in  the command line. Now the Assembler will
  713.      immediately restart the previous language without a pause.
  714.      
  715.         There  are  two  cases  where  the  Assembler   will always   pause
  716.      regardless of the "-G" option or the previous language. These are:
  717.      
  718.        - When an error is detected in the *ASSEMBLE command you typed
  719.          
  720.          or
  721.  
  722.  
  723.                                        7
  724.  
  725.  
  726.  
  727.  
  728.  
  729.                            USING THE 65C02 ASSEMBLER
  730.  
  731.  
  732.  
  733.          
  734.        - On  a  machine  with  a shadow screen that was turned off when you
  735.          began assembly. The Assembler  will  turn  the  shadow  screen  on
  736.          automatically,  and  will  always  turn it off at the end: as this
  737.          requires a mode change which will clear the screen, it will always
  738.          pause.
  739.          
  740.          
  741.      1.8 Use of control keys during assembly
  742.      
  743.         During an assembly you can use various control  keys  to  check  on
  744.      progress or give commands to the Assembler.
  745.      
  746.      
  747.        - Function keys f0, f1, f2 and f3 will force the Assembler to change
  748.          the  source  listing  level to 0, 1, 2 or 3 respectively. Once you
  749.          have pressed one of these keys the level you set  is  locked:  the
  750.          Assembler  will process LST directives in the source, but will not
  751.          implement them. This lets you, for example, change the list  level
  752.          during  an assembly to check on what's happening, or to suppress a
  753.          listing you decide you don't want. To cancel the  locking  of  the
  754.          list  level  and  return  to  that  set  by the last LST directive
  755.          processed, simply press CONTROL-L.
  756.          
  757.        - CONTROL-H displays some help information to remind you  about  the
  758.          use of control keys. The Assembler will pause after displaying the
  759.          information: to resume simply press any key.
  760.          
  761.        - CONTROL-N   and CONTROL-O  turn the BBC Computer's paged scrolling
  762.          mode on and off  respectively.  You  could  use  these  keys,  for
  763.          example, to pause a listing on the screen after every screenful at
  764.          some point during an assembly.
  765.          
  766.        - CONTROL-P  controls  whether  the  Assembler  sends  output  to  a
  767.          printer. If it is printing, pressing CONTROL-P will stop it: if it
  768.          is not printing, CONTROL-P will start it  sending  output  to  the
  769.          printer.
  770.          
  771.          If  you  have used the -F option to send output to a listing file,
  772.          CONTROL-P can be used to switch output between the screen and  the
  773.          file,  but  will  not affect any printer you may have connected to
  774.          your machine.
  775.          
  776.        - CONTROL-Q lets you find out where the Assembler is in the  current
  777.          file. It will tell you whether it is on pass 1 or 2, then give you
  778.          the  number  of  the line it is about to process. If the number is
  779.          followed by "(M)", the  source  line  is  a  macro  call  and  the
  780.          Assembler is currently expanding that macro.
  781.          
  782.        - CONTROL-W  reverses  the  current "wait after error" action set by
  783.          the command line's "-W" option.
  784.          
  785.        - SPACE pauses the assembly. You can use this to examine  a  listing
  786.          on  screen  at  your leisure. To resume assembly, simply press any
  787.  
  788.  
  789.                                        8
  790.  
  791.  
  792.  
  793.  
  794.  
  795.                            USING THE 65C02 ASSEMBLER
  796.  
  797.  
  798.  
  799.          key.
  800.      
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.                                        9
  856.  
  857.  
  858.  
  859.  
  860.  
  861.                            USING THE 65C02 ASSEMBLER
  862.  
  863.  
  864.  
  865.      2. SOURCE PROGRAM FORMAT
  866.      
  867.      
  868.         The Assembler will read source from files produced by any editor or
  869.      word-processor program, as described in section  1.3.  The  source  is
  870.      seen  as  a  number  of lines, each ending with a carriage return byte
  871.      ($0D). Line feed characters are ignored,  as  are  all  other  control
  872.      characters  and (unless you have used one of the configuration options
  873.      detailed in Appendix 5) any with the most significant bit (bit 7) set.
  874.      The general format of a line is:
  875.      
  876.                         label  opcode  operand  comment
  877.      
  878.         Depending on circumstances, the label and  operand  fields  may  be
  879.      optional  or  mandatory; or they may need to be omitted. All lines may
  880.      have a comment field, which is begun with a ";" or a "\" character.
  881.      
  882.         If you include a label field, it must begin in the first  character
  883.      of  the  line.  You  may  separate the fields from each other with any
  884.      number of spaces and/or TAB characters. No line may exceed  132  bytes
  885.      in length; any that do will be truncated.
  886.      
  887.         Any line whose first non-space character is "*", ";", "!" or "\" is
  888.      treated  as comment. Lines beginning with "!" are treated specially if
  889.      they occur within the definition of a macro, as explained  in  section
  890.      9.6.
  891.      
  892.      
  893.      2.1 Syntax of the line
  894.      
  895.      
  896.           2.1.1 The label field
  897.           
  898.           A  label  consists  of  a  string  of characters, starting with a
  899.           letter, and containing any combination of  letters,  numbers  and
  900.           the  characters  ".","$"  and  "_"  (underscore).  Any lower-case
  901.           letters are translated  to  upper-case.  Labels  may  be  of  any
  902.           length,  and  all  are  significant unless you have specified the
  903.           "-A" option in the command  line,  when  only  the  first  6  are
  904.           significant.
  905.           
  906.           A  label  may  be  terminated  with  a  ":" character that is not
  907.           considered part of the label.
  908.           
  909.           Examples of valid labels are:
  910.           
  911.                               OSWRCH
  912.                               osbyte
  913.                               Program.start
  914.                               ITEM_33:
  915.                               
  916.           A label may be written in a line on its own: the value it is  set
  917.           to will be the value of the current address.
  918.           
  919.  
  920.  
  921.                                       10
  922.  
  923.  
  924.  
  925.  
  926.  
  927.                            USING THE 65C02 ASSEMBLER
  928.  
  929.  
  930.  
  931.           A  variant  of  the  label  is  the Sequence Symbol, described in
  932.           section 10.1. This has the same format as a  normal  label,  with
  933.           the exception that the first character must be a "%" character.
  934.           
  935.           Where  the label is a macro name (i.e. in the MACRO directive) it
  936.           may not exceed 8 characters in length.
  937.           
  938.           
  939.           2.1.2 The opcode field
  940.           
  941.           The opcode field, if present, is separated from the label by  one
  942.           or  more  spaces or TABs. If there is no label, the field must be
  943.           preceded by at least one space or TAB.
  944.           
  945.           The opcode field can contain  either  a  normal  opcode  mnemonic
  946.           (such  as  LDA),  an  Assembler  directive  or pseudo-op (such as
  947.           SFCOND) or the name of a macro that you have defined previously.
  948.           
  949.           
  950.           2.1.3 The operand field
  951.           
  952.           For some opcodes and directives an operand field may be supplied.
  953.           This will consist of one or more elements,  separated  by  commas
  954.           and  optional  spaces.  Except  within  strings  delimited by the
  955.           single- or double-quote characters, spaces are not significant in
  956.           the operand field. Thus you can use them to make complex  numeric
  957.           expressions more readable: for example you could write
  958.           
  959.                          LDA   TABLE+(1+FRED/3*(BERT+$1E))
  960.           
  961.           as
  962.           
  963.                          LDA   TABLE + (1 + FRED/3 * (BERT + $1E) )
  964.           
  965.           if you wished.
  966.           
  967.           
  968.           2.1.4 The comment field
  969.           
  970.           The  comment  field can be used to annotate the line. It is begun
  971.           with a  ";"  or  a  "\"  character:  anything  following  is  not
  972.           processed by the Assembler.
  973.           
  974.           
  975.      2.2 The syntax of expressions
  976.      
  977.         Throughout this guide you will see references to "expressions", for
  978.      example  in  the  definitions of directives. The syntax of these is as
  979.      follows:
  980.      
  981.      
  982.           2.2.1 Numeric expressions
  983.           
  984.           These are indicated in definitions as "<expr>",  and  consist  of
  985.  
  986.  
  987.                                       11
  988.  
  989.  
  990.  
  991.  
  992.  
  993.                            USING THE 65C02 ASSEMBLER
  994.  
  995.  
  996.  
  997.           terms  separated  by  arithmetic  operators. For example, a valid
  998.           expression might be
  999.           
  1000.                                  FRED*(2+BERT)
  1001.           
  1002.           The Assembler performs all calculations using 16-bit  arithmetic.
  1003.           Any   results  or  intermediate  values  that  overflow  will  be
  1004.           truncated, and no warning will be given.
  1005.           
  1006.           The various elements that you can use in numeric expressions  are
  1007.           these:
  1008.           
  1009.           a. Symbols
  1010.              
  1011.              These  are  the  labels that you define in the label fields of
  1012.              lines, and in  the  evaluation  of  the  expression  they  are
  1013.              replaced by the value of the label.
  1014.              
  1015.           b. Decimal constants
  1016.              
  1017.              These are numbers, composed of the characters '0'..'9'.
  1018.              
  1019.              For example,
  1020.              
  1021.                                       123
  1022.              
  1023.           c. Hexadecimal constants
  1024.              
  1025.              These are numbers, composed of hexadecimal digits '0'..'9' and
  1026.              'A'..'F', preceded by a "$" or a "&" character.
  1027.              
  1028.              For example,
  1029.              
  1030.                                      $AF34
  1031.              
  1032.           d. Binary constants
  1033.              
  1034.              These  are  numbers  composed  of  binary  digits '0' and '1',
  1035.              preceded by a "%" character.
  1036.              
  1037.              For example,
  1038.              
  1039.                                    %10100111
  1040.              
  1041.              
  1042.           e. Character constants
  1043.              
  1044.              These are single characters, enclosed  in  single-quotes.  The
  1045.              Assembler will use the ASCII code of the particular character.
  1046.              
  1047.              You  can specify that a character value is to be used with bit
  1048.              7 set by preceding the character with a "^", and can specify a
  1049.              control character by preceding it with a "|".  Thus  the  code
  1050.              for  an "A" with bit 7 set is represented as '^A' and that for
  1051.  
  1052.  
  1053.                                       12
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.                            USING THE 65C02 ASSEMBLER
  1060.  
  1061.  
  1062.  
  1063.              CONTROL-A as '|A'.Since the "|" character actually inverts bit
  1064.              6 of the character that follows, you can obtain the  code  for
  1065.              "DEL" (hexadecimal code 7F) by writing '|?'.
  1066.              
  1067.              The  character  codes  for "^" and "|" are obtained by writing
  1068.              the characters twice (i.e. as '^^' and '||').
  1069.              
  1070.              The Assembler does not by default give you a means to  specify
  1071.              that  a  character  value is to be used as a control character
  1072.              and also with bit 7 set. You  may  find  that  this  would  be
  1073.              useful  (if  for  example you wished to plant Teletext control
  1074.              codes such as $81 in  a  string),  so  the  Assembler  can  be
  1075.              configured  to  permit  this  to  be  done. One of the options
  1076.              described in Appendix 5 lets you set up the Assembler so  that
  1077.              the  "~"  character  (which  appears on a Teletext screen as a
  1078.              "divide" sign) causes the next character to  be  output  as  a
  1079.              control character with bit 7 set. Thus, to obtain the hex code
  1080.              $81,  you  would write '~A'. Naturally, once you have selected
  1081.              this option, you will need to double the "~" character as well
  1082.              as the other two special characters  should  you  wish  it  to
  1083.              appear itself in a string.
  1084.              
  1085.              Note that you must always include the final quote character.
  1086.              
  1087.              For example,
  1088.              
  1089.                                       'X'
  1090.              
  1091.           f. Operators
  1092.              
  1093.              A  number  of arithmetic operators can be used in expressions.
  1094.              They are divided into groups of varying  priority,  which,  in
  1095.              decreasing order are:
  1096.                          
  1097.                          () Parentheses
  1098.                          
  1099.                          -  Unary minus
  1100.                          ~  Unary 1's complement (NOT)
  1101.                          
  1102.                          &  Bitwise AND
  1103.                          !  Bitwise OR
  1104.                          
  1105.                          =  Equality
  1106.                          #  Inequality
  1107.                          >  Greater than
  1108.                          <  Less than
  1109.                          
  1110.                          *  Multiplication
  1111.                          /  Integer division
  1112.                          
  1113.                          +  Addition
  1114.                          -  Subtraction
  1115.                          
  1116.              The  "="  and "#" operators return values of -1 and 0 for TRUE
  1117.  
  1118.  
  1119.                                       13
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.                            USING THE 65C02 ASSEMBLER
  1126.  
  1127.  
  1128.  
  1129.              and FALSE respectively.
  1130.              
  1131.              Additionally, expressions  may  be  prefixed  with  two  unary
  1132.              operators  > and <, which select the low-byte and high-byte of
  1133.              the result  respectively.  These  operators  have  the  lowest
  1134.              priority of all. Thus, for example, suppose you have defined a
  1135.              table  starting  at  label  TABLE.  To load the address of the
  1136.              table into X (the low byte) and Y (the high byte),  you  would
  1137.              write
  1138.              
  1139.                          LDX   #>TABLE    ; load low byte
  1140.                          LDY   #<TABLE   ; load high byte
  1141.                          
  1142.              Note  that  the  MOD  and  DIV operators used in the BBC Basic
  1143.              assembler to achieve this result cannot be used.
  1144.              
  1145.              
  1146.           g. Current address
  1147.              
  1148.              The current value of the address counter may be represented in
  1149.              expressions by the "*" character.
  1150.              
  1151.              For example:
  1152.              
  1153.                                       *-3
  1154.              
  1155.              
  1156.           2.2.2 Strings
  1157.           
  1158.           These are indicated in definitions as <string>,  and  consist  of
  1159.           one  or  more  ASCII characters, enclosed in delimiters. Only the
  1160.           single- and double-quote characters (' and  ")  can  be  used  as
  1161.           delimiters, and the start and end delimiter must be the same.
  1162.           
  1163.           For example:
  1164.           
  1165.                                'This is a string'
  1166.                            "And so, you see, is this"
  1167.           
  1168.           To include the ' or " character in a string, use the other as the
  1169.           delimiter.
  1170.           
  1171.           Within  a string you can obtain control characters and characters
  1172.           with B7 set in the way described above for character constants.
  1173.           
  1174.           
  1175.           2.2.2 String expressions
  1176.           
  1177.           These are indicated  in  definitions  as  <stringexpr>,  and  all
  1178.           involve comparisons between strings. The general format is
  1179.           
  1180.                              <string> <op> <string>
  1181.           
  1182.           where <op> is one of the operators
  1183.  
  1184.  
  1185.                                       14
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.                            USING THE 65C02 ASSEMBLER
  1192.  
  1193.  
  1194.  
  1195.           
  1196.                               =  Equality
  1197.                               #  Inequality
  1198.                               >  Greater than
  1199.                               <  Less than
  1200.      
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.                                       15
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.                            USING THE 65C02 ASSEMBLER
  1258.  
  1259.  
  1260.  
  1261.      3. THE OUTPUT LISTING
  1262.      
  1263.      
  1264.         The assembly listing is produced in pass 2. You can control whether
  1265.      it  appears  or  not,  whether  it  goes to screen or printer, and the
  1266.      amount of detail it contains.
  1267.      
  1268.      
  1269.      3.1 The source listing level
  1270.      
  1271.      
  1272.         The main control you have over the listing is through  the  "source
  1273.      listing  level".  This  is  a value in the range 0..3 that you can set
  1274.      either with the LST directive, the -L command  line  option,  or  with
  1275.      function keys 0 to 3 during the course of an assembly.
  1276.      
  1277.         The listing levels have the following meaning:
  1278.      
  1279.        0  This level suppresses all listing except the reporting of errors.
  1280.           
  1281.        1  This  level  will  list all source lines that originate in source
  1282.           files, but not the expansions of macros.
  1283.           
  1284.        2  This  level  lists  all  lines  from  source  files   and   macro
  1285.           expansions, but not Macro Programming Language statements such as
  1286.           AIF.
  1287.           
  1288.        3  This level lists all source lines.
  1289.           
  1290.         By  default,  the Assembler sets the source list level to 0, so all
  1291.      you will see will be error reports. You can change the default setting
  1292.      in the *ASSEMBLE command by using the "-L" option: thus
  1293.      
  1294.                               *ASSEMBLE SOURCE -L2
  1295.      
  1296.      would cause the Assembler to start with a default listing level of 2.
  1297.      
  1298.         Within the source, you can control the  list  level  with  the  LST
  1299.      directive. Thus:
  1300.      
  1301.                                      LST  1
  1302.      
  1303.      would set the list level to 1.
  1304.      
  1305.         Simply writing
  1306.      
  1307.                                       LST
  1308.      
  1309.      with no operand field will reset the value to the default, without you
  1310.      needing to build this value into the actual source.
  1311.      
  1312.         Additionally,  you  can  override  the  list  level in use while an
  1313.      assembly is in progress. Pressing one of function keys  0  to  3  will
  1314.      force  the  corresponding  list  level  to  be  adopted,  so that, for
  1315.  
  1316.  
  1317.                                       16
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.                            USING THE 65C02 ASSEMBLER
  1324.  
  1325.  
  1326.  
  1327.      example, you could force  the  Assembler  to  show  you  parts  of  an
  1328.      assembly  to  monitor  what was being done. Pressing one of these keys
  1329.      will "lock" the list level to that selected, so that LST directives in
  1330.      the source will not be  able  to  turn  the  listing  off  again.  The
  1331.      directives are noted, though, and you can return listing level control
  1332.      to them at any time by pressing CONTROL-L.        
  1333.      
  1334.      
  1335.      3.2 Source listing format
  1336.      
  1337.         The  listing begins with the source lines, including any code bytes
  1338.      they have generated.
  1339.      
  1340.         The first character on the line indicates where the line  was  read
  1341.      from.  If  it  came  from an INCLUDE file or a CODE file the character
  1342.      will be "I"; if the line is from a macro it will  be  "M".  Otherwise,
  1343.      the character is a space.
  1344.      
  1345.         The  next  element  is  the line number, reset to 1 at the start of
  1346.      each source file.
  1347.      
  1348.         Next comes the  address  field.  This  will  normally  contain  the
  1349.      current value of the address counter; in some directives, though, such
  1350.      as LST, it contains the value of the operand expression.
  1351.      
  1352.         Then comes a hexadecimal representation of the first 3 object bytes
  1353.      generated  by the line; this is followed by the source line itself. By
  1354.      default, if the source line generated more than 3 object bytes,  these
  1355.      will be listed on subsequent lines.
  1356.      
  1357.         For example, a listing line might show:
  1358.      
  1359.                         I   23 AB34:C9 0A      CMP  #10
  1360.      
  1361.      where  the  source  line is the 23rd line in an INCLUDE file and reads
  1362.      "CMP #10". The code bytes generated are $C9  and  $0A,  and  they  are
  1363.      planted starting at address $AB34.
  1364.      
  1365.         When  listing  a  source  line,  the  Assembler will expand any TAB
  1366.      characters it encounters. By default, TAB  positions  are  defined  at
  1367.      characters 8, 16, 25, 33, 41, 49, 57, 65, 73, 81, 89, 97, 115 and 123,
  1368.      with  the  first  character  of  the source line being numbered 1. The
  1369.      default TAB positions have been chosen to give a neat  listing  layout
  1370.      using labels of up to 6 characters in length and typical operand field
  1371.      sizes.  However,  the  first  few  TABs  are not positioned at regular
  1372.      intervals, so you may find that  you  cannot  easily  lay  out  tables
  1373.      within comments.
  1374.      
  1375.         You  can overcome any problems, and choose the layout most suitable
  1376.      for your source, with the TABS directive. This lets you  redefine  the
  1377.      TAB positions used: for example
  1378.      
  1379.                            TABS  9,17,25,33,41,49,57
  1380.      
  1381.  
  1382.  
  1383.                                       17
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.                            USING THE 65C02 ASSEMBLER
  1390.  
  1391.  
  1392.  
  1393.      would  set  TAB  stops  at  regular positions, with each field being 8
  1394.      characters wide. You can return to the default TAB stops at  any  time
  1395.      with the directive
  1396.      
  1397.                                       TABS
  1398.      
  1399.      with no operands.
  1400.      
  1401.         The Assembler can be customised to change the default TAB positions
  1402.      to any value you require: this is described in Appendix 5.
  1403.      
  1404.      
  1405.      3.3 Listing object code bytes
  1406.      
  1407.      
  1408.         As  mentioned  above,  the  first  three  code bytes generated by a
  1409.      source line are listed on that line, and any  others  will  appear  on
  1410.      subsequent  lines.  This  may produce a lot of output, particularly if
  1411.      you define lots of strings, so the Assembler gives you control on  how
  1412.      much it lists.
  1413.      
  1414.         The  amount  is  controlled  by the "code listing level". This is a
  1415.      value in the range  0..2  that  you  can  set  either  with  the  CLST
  1416.      directive or the -C command line option.
  1417.      
  1418.         The code listing levels have the following meaning:
  1419.      
  1420.             0  Only the first 3 bytes generated by a line are listed.
  1421.                
  1422.             1  All  bytes  are  listed  from  all  lines  except  the  CODE
  1423.                directive.
  1424.                
  1425.             2  All bytes are listed, however they are generated.
  1426.                
  1427.                
  1428.         By default, the Assembler sets the code list level to  1.  You  can
  1429.      change  the default setting in the *ASSEMBLE command by using the "-C"
  1430.      option: thus
  1431.      
  1432.                               *ASSEMBLE SOURCE -C0
  1433.      
  1434.      would cause the Assembler to start with a default code  listing  level
  1435.      of 0.
  1436.      
  1437.         Within  the source, you can control the code listing level with the
  1438.      CLST directive. Thus:
  1439.      
  1440.                                     CLST  2
  1441.      
  1442.      would set the list level to 2.
  1443.      
  1444.         Simply writing
  1445.      
  1446.                                       CLST
  1447.  
  1448.  
  1449.                                       18
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.                            USING THE 65C02 ASSEMBLER
  1456.  
  1457.  
  1458.  
  1459.      
  1460.      with no operand field will reset the value to the default, without you
  1461.      needing to build this value into the actual source.
  1462.      
  1463.      
  1464.      3.4 Symbol table listing format
  1465.      
  1466.         If the source listing level is not zero at the end of the assembly,
  1467.      the Assembler will list the symbol table, showing you the value of all
  1468.      the symbols defined in the source.
  1469.      
  1470.         The symbols are listed in alphabetical order, and only the first 13
  1471.      characters of each will be shown. The value of each symbol is shown in
  1472.      hexadecimal.
  1473.      
  1474.         If the value is shown as "????", the symbol was used  but  was  not
  1475.      defined.  If  the  value  is  "****", the symbol was defined more than
  1476.      once. A "-" character after the value indicates that  the  symbol  was
  1477.      defined, but was not used anywhere else in the source.
  1478.      
  1479.      
  1480.      3.5 Error reports
  1481.      
  1482.         The  Assembler will list all lines that generate errors, regardless
  1483.      of the listing level. The errors are  reported  with  self-explanatory
  1484.      text messages following the line.
  1485.      
  1486.         Where  appropriate, the Assembler will attempt to indicate where on
  1487.      the line the error  occurred.  The  text  you  might  see  would  look
  1488.      something like:
  1489.      
  1490.               ****** Err : Undeclared symbol at about character 19
  1491.      
  1492.         This  indicates  that  the  erroneous  symbol  is at about the 19th
  1493.      character in the line, which starts at character 1. Remember,  though,
  1494.      that  the number refers to the source line: the listing line will have
  1495.      expanded any TAB characters you used, and the  number  will  then  not
  1496.      correspond to what you see on the page.
  1497.      
  1498.      
  1499.      
  1500.      3.6 Output page control
  1501.      
  1502.      
  1503.         The  Assembler  provides a number of directives that you can use to
  1504.      specify the exact format of the output page, and to let you tailor the
  1505.      listing to your exact needs.
  1506.      
  1507.      
  1508.           3.6.1 Setting page dimensions
  1509.           
  1510.           The PAGE directive defines the size of the page you are using. It
  1511.           takes two parameters, which are the total depth of  the  page  in
  1512.           lines, and the width in characters you wish printed.
  1513.  
  1514.  
  1515.                                       19
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.                            USING THE 65C02 ASSEMBLER
  1522.  
  1523.  
  1524.  
  1525.           
  1526.           Thus,
  1527.           
  1528.                                  PAGE   66,132
  1529.           
  1530.           tells  the Assembler that the page is 66 lines deep, and that you
  1531.           wish lines to contain a maximum of 132 characters. The  Assembler
  1532.           will always allow a small gap at the end of the page to avoid the
  1533.           perforations, and will truncate any lines longer than the maximum
  1534.           width you specify.
  1535.           
  1536.           The  value of the width you define with PAGE becomes effective at
  1537.           once. The depth, though, is not used until the next  page  throw,
  1538.           so  you would normally follow the directive with a TTL or a SKP H
  1539.           directive.
  1540.           
  1541.           By default, the Assembler will print lines of  80  characters  on
  1542.           paper that is 66 lines deep. It moves to the top of a new page by
  1543.           sending a Form Feed ($0C) character to the printer.
  1544.           
  1545.           
  1546.           3.6.2 Setting the page title
  1547.           
  1548.           
  1549.           The TTL directive lets you set up a page title that is printed on
  1550.           the  top  of  every  listing  page.  The  title  can  be up to 20
  1551.           characters long, and can contain any printable text.
  1552.           
  1553.           For example,
  1554.           
  1555.                               TTL  'Screen Dumper'
  1556.           
  1557.           will print "Screen Dumper" at the top of each page.
  1558.           
  1559.           The TTL directive will cause a page throw to  occur  immediately,
  1560.           and the next page output will use the title it defines.
  1561.           
  1562.           
  1563.           3.6.3 Setting the timestamp
  1564.           
  1565.           
  1566.           If  you  are using a Master 128, the Assembler will automatically
  1567.           print the current date and time at the top of each  output  page,
  1568.           taking  the  values  from the built-in real-time clock. The other
  1569.           BBC models do not contain clocks, so the TIME directive lets  you
  1570.           simulate the effect by defining the string used.
  1571.           
  1572.           The  TIME  directive  allows  you  to define a string of up to 25
  1573.           characters that will appear in the page header.  The  string  can
  1574.           contain  any  printable characters: it is not constrained to be a
  1575.           date and time value, so you can use it  as  a  sub-title  if  you
  1576.           wish.
  1577.           
  1578.           For example, you could use
  1579.  
  1580.  
  1581.                                       20
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.                            USING THE 65C02 ASSEMBLER
  1588.  
  1589.  
  1590.  
  1591.           
  1592.                              TIME  'Friday at 1030'
  1593.           
  1594.           or
  1595.           
  1596.                               TIME  'First Module'
  1597.           
  1598.           
  1599.           The  directive is ignored on a Master 128, so there is no need to
  1600.           change a source that is being assembled on both a model B  and  a
  1601.           Master 128.
  1602.           
  1603.           It  is  possible  to  customise  the Assembler to use a real-time
  1604.           clock fitted to a machine other than a Master  128:  for  details
  1605.           see Appendix 5.
  1606.           
  1607.           
  1608.           3.6.4 Page layout directives
  1609.           
  1610.           
  1611.           There are a number of directives that let you lay the output page
  1612.           out  in  more  detail,  so you can delimit sections of source for
  1613.           easier inspection and configure  the  axact  appearance  of  each
  1614.           line.
  1615.           
  1616.           The  REP  directive  provides  a  convenient  way  of  separating
  1617.           sections of code in the listing. For example,
  1618.           
  1619.                                     REP  80
  1620.           
  1621.           will print a line of "*" characters in the listing for  you  (and
  1622.           takes  much  less  space in the source file than that line itself
  1623.           would).
  1624.           
  1625.           The CHR directive lets you change the character used to make  the
  1626.           line,  so  that,  for  example  you  could  select  lines  of "-"
  1627.           characters with
  1628.           
  1629.                                      CHR  -
  1630.           
  1631.           
  1632.           The SKP directive lets  you  break  the  listing  up  for  easier
  1633.           reading. For example,
  1634.           
  1635.                                      SKP  5
  1636.           
  1637.           would leave a 5 line space on the page. The format
  1638.           
  1639.                                      SKP  H
  1640.           
  1641.           causes  the  Assembler  to  start  a  new page. Note that the SKP
  1642.           directive itself will never  be  listed  unless  it  contains  an
  1643.           error.
  1644.           
  1645.  
  1646.  
  1647.                                       21
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.                            USING THE 65C02 ASSEMBLER
  1654.  
  1655.  
  1656.  
  1657.           
  1658.           
  1659.      3.7 Controlling the output destination
  1660.      
  1661.      
  1662.         By default, the Assembler sends the assembly listing to the screen,
  1663.      in  whatever mode you have selected. You can, though, choose to direct
  1664.      the assembly listing to a printer; or to output it to a file.
  1665.      
  1666.      
  1667.           3.7.1  Sending the listing to a printer
  1668.           
  1669.           
  1670.           You can  direct  output  to  the  currently-selected  printer  by
  1671.           specifying  the  "-P"  option  in  the  command  line.  Thus, for
  1672.           example,
  1673.           
  1674.                             *ASSEMBLE SOURCE -L2 -P
  1675.           
  1676.           would assemble from source file SOURCE and send the  listing,  at
  1677.           level 2, to the printer only.
  1678.           
  1679.           At  any  time  during  an  assembly,  you  can  change the output
  1680.           destination by pressing CONTROL-P. This will  switch  the  output
  1681.           destination  between printer and screen: you can do this as often
  1682.           as you wish.
  1683.           
  1684.           
  1685.           
  1686.           3.7.2 Sending the listing to a file
  1687.           
  1688.           
  1689.           You can direct the assembly listing to a file by using  the  "-F"
  1690.           option in the command line. Thus, for example,
  1691.           
  1692.                        *ASSEMBLE SOURCE -L1 -F:3.LISTING
  1693.           
  1694.           will  produce an assembly listing at level 1, and will send it to
  1695.           the file :3.LISTING only.
  1696.           
  1697.           Output sent to a file is laid out exactly as if it were going  to
  1698.           a  real  printer.  It will be broken up into pages, with the page
  1699.           depth and width controlled by the PAGE directive. After assembly,
  1700.           you can for example print the file with
  1701.           
  1702.                          <CTRL-B>
  1703.                          *TYPE :3.LISTING
  1704.                          <CTRL-C>
  1705.                          
  1706.           Any printer control codes that  you  may  send  with  the  SYSVDU
  1707.           directive  are not stored in the file, so you can output the file
  1708.           to any printer without the need to edit it out  unsuitable  codes
  1709.           first.
  1710.           
  1711.  
  1712.  
  1713.                                       22
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.                            USING THE 65C02 ASSEMBLER
  1720.  
  1721.  
  1722.  
  1723.           If  you have used the "-F" option, the action of CONTROL-P during
  1724.           assembly changes slightly. You can now use it  to  switch  output
  1725.           between  the  screen  and the file, allowing you, for example, to
  1726.           suppress listing of some parts of a source. It has no  effect  on
  1727.           any printer that you may have fitted.
  1728.           
  1729.           If  you  use both  the "-P" and "-F" options on the command line,
  1730.           only "-F" has effect.
  1731.           
  1732.           
  1733.           3.7.3 Printer control
  1734.           
  1735.           
  1736.           You will often need to send a sequence of control bytes  to  your
  1737.           printer  before  starting an assembly (for example to set it into
  1738.           condensed print mode). The assembler gives you  three  directives
  1739.           to accomplish this automatically: SYSVDU sends a control sequence
  1740.           on  both passes, and SYSVDU1 and SYSVDU2 do the same, but only on
  1741.           pass 1 or pass 2 respectively. If you  have  not  used  the  "-P"
  1742.           command  line option to produce a printed listing, the directives
  1743.           will not send any output to it: there is no need  to  alter  your
  1744.           source to suit the times when you are printing or not printing.
  1745.           
  1746.           To  output a control sequence, simply write the bytes as operands
  1747.           to one of the directives, exactly as you would do in BBC  Basic's
  1748.           VDU command. Thus
  1749.           
  1750.                               SYSVDU1  1,27,1,'E'
  1751.           
  1752.           sends  the  character  ESCAPE  (whose  ASCII  code is 27 decimal)
  1753.           followed by 'E' to the printer only, on pass 1 of the assembly.
  1754.           
  1755.           Note that you do not need first to send a code of "2" to activate
  1756.           printer output: the assembler itself ensures the bytes go to  the
  1757.           printer  if one is in use. The "1" codes in the example above act
  1758.           exactly as  in  BASIC's  VDU  command,  and  send  the  following
  1759.           character  to the printer only. You can if you wish use SYSVDU to
  1760.           write to both printer and screen: thus
  1761.           
  1762.                                 SYSVDU   'A','B'
  1763.           
  1764.           sends characters 'A' and 'B' to both. However, the DISP family of
  1765.           directives give you a much better means of outputting messages to
  1766.           the screen.
  1767.           
  1768.           The directives do not send any bytes to a listing file  that  you
  1769.           may  have  selected with the "-F" command line option. This means
  1770.           that you can safely print a listing file on any type  of  printer
  1771.           without  the  need  to  edit  out  possibly inappropriate control
  1772.           sequences first (but, of course, you may need to set the  printer
  1773.           up yourself before printing the listing).
  1774.           
  1775.  
  1776.  
  1777.  
  1778.  
  1779.                                       23
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.                            USING THE 65C02 ASSEMBLER
  1786.  
  1787.  
  1788.  
  1789.      4. DIRECTIVES DEFINING DATA AND CONSTANTS
  1790.      
  1791.      
  1792.         The  Assembler  contains  a  number of directives that allow you to
  1793.      define values in  the  object  file.  You  can  specify  byte  values,
  1794.      two-byte  or  word  values,  and  character  strings,  and also set up
  1795.      symbols to hold constants.
  1796.      
  1797.      
  1798.      4.1 Defining constants
  1799.      
  1800.      Assigning symbols to various constant values is a considerable help in
  1801.      writing assembly-level programs, both in terms of making a source more
  1802.      readable and also in helping when you need to change it.
  1803.      
  1804.      For example, you could refer to an Operating System routine by writing
  1805.      its address $FFEE every time, or you could declare a symbol OSWRCH  to
  1806.      stand for that name.
  1807.      
  1808.      You can declare symbols to use as constants with the EQU directive. In
  1809.      the example above, you would write
  1810.      
  1811.                               OSWRCH  EQU   $FFEE
  1812.      
  1813.      and then call the routine as, say
  1814.      
  1815.                                   JSR   OSWRCH
  1816.      
  1817.      You  can  write any numeric expression in the operand field of the EQU
  1818.      directive, but the expression must not contain any forward references.
  1819.      
  1820.      
  1821.      
  1822.      4.2 Byte and word directives
  1823.      
  1824.      There are 6 directives that plant byte and  word  values.  DFB  plants
  1825.      bytes,  and  DFW  and  DFDB  plant  word  values. For convenience, and
  1826.      compatibility with  other  assemblers,  the  directives  can  also  be
  1827.      written as DB, DW and DDB respectively.
  1828.      
  1829.      All the directives can be given one or more expressions in the operand
  1830.      field,  separated  by commas, and these expressions give the values of
  1831.      the bytes or words to be planted. If you specify a label in the  label
  1832.      field  of  the line, it is set to the address of the first byte of the
  1833.      first value planted.
  1834.      
  1835.      
  1836.      
  1837.           4.2.1 Byte directives
  1838.           
  1839.           
  1840.           The directive DFB (or its equivalent DB)  allows  you  to  define
  1841.           single-byte  values  which  are  written directly into the object
  1842.           file. The operand field is one or more expressions, each of which
  1843.  
  1844.  
  1845.                                       24
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.                            USING THE 65C02 ASSEMBLER
  1852.  
  1853.  
  1854.  
  1855.           should lie in the range 0..255 .
  1856.           
  1857.           For example,
  1858.           
  1859.                               DFB  1,2,$FF,FRED+1
  1860.           
  1861.           will write 4 bytes to the object file: the values will be  1,  2,
  1862.           255 and the value of FRED+1.
  1863.           
  1864.           
  1865.           4.2.2 Word directives
  1866.           
  1867.           
  1868.           The  directives  DFW  (or  its  equivalent  DW)  and DFDB (or its
  1869.           equivalent DDB)  allow you to  define  two-byte  or  word  values
  1870.           which  are  written  directly  into  the object file. The operand
  1871.           field of each is a list of one or more expressions, each of which
  1872.           should lie in the range 0..65535.
  1873.           
  1874.           The difference between the directives lies in the order in  which
  1875.           the  two  bytes are written to the object file. The DFW directive
  1876.           writes the bytes in low-byte, high-byte order; the DFDB directive
  1877.           writes them in high-byte, low byte order.
  1878.           
  1879.           Thus, for example,
  1880.           
  1881.                                DFW   $1234,$ABCD
  1882.           
  1883.           will output the bytes $34, $12, $CD, $AB to the  object  file  in
  1884.           that order, but
  1885.           
  1886.                                DFDB  $1234,$ABCD
  1887.           
  1888.           will output the bytes $12, $34, $AB, $CD.
  1889.           
  1890.           
  1891.           4.2.3 Using repeat counts
  1892.           
  1893.           
  1894.           Occasionally, you will need to use the byte or word directives to
  1895.           plant  a  number of bytes or words containing the same value. For
  1896.           example, you might need to write
  1897.           
  1898.                                DFB  5,5,5,5,5,5,5
  1899.           
  1900.           to plant 7 bytes containing the value 5.
  1901.           
  1902.           For small numbers of repeats, this is no problem, but it  can  be
  1903.           onerous if, say, you needed 49 bytes containing 5.
  1904.           
  1905.           The  Assembler  gives  you  a  very  convenient  shorthand way of
  1906.           repeating values in all  the  byte  and  word  directives.  Every
  1907.           expression  you  use can be prefixed with a "repeat count", which
  1908.           tells the Assembler to plant the value itself more than once. The
  1909.  
  1910.  
  1911.                                       25
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.                            USING THE 65C02 ASSEMBLER
  1918.  
  1919.  
  1920.  
  1921.           repeat count is specified in "[]" brackets: thus, to plant the 49
  1922.           bytes mentioned above, you could simply write
  1923.           
  1924.                                   DFB   [49]5
  1925.           
  1926.           Like the value itself, the repeat count can  be  any  expression,
  1927.           but it must not contain forward references. Thus you could write
  1928.           
  1929.                              DFB  [(COUNT+27)/2]$FF
  1930.           
  1931.           You  can  freely mix values with and without repeat counts in any
  1932.           of the byte and word directives.
  1933.           
  1934.           A repeat count value of zero will cause no bytes  at  all  to  be
  1935.           written to the object file.
  1936.           
  1937.           
  1938.      4.3 Character string directives
  1939.      
  1940.      
  1941.      The  four  directives  ASC,  CASC,  STR  and  CSTR  allow you to plant
  1942.      character string values into the object file.
  1943.      
  1944.      All the directives require you to specify a character string, enclosed
  1945.      in single- or double-quotes, in the operand field. If  you  include  a
  1946.      label  in  the  label  field of the line, it is given the value of the
  1947.      address of the first byte planted.
  1948.      
  1949.      
  1950.           4.3.1 The ASC and STR directives
  1951.           
  1952.           These directives plant simple strings in  the  object  file.  ASC
  1953.           plants  the  string exactly  as  you  specify  it; STR plants the
  1954.           string, and then  automatically  plants  a  carriage-return  byte
  1955.           (code $0D) immediately after it.
  1956.           
  1957.           Thus
  1958.           
  1959.                                    ASC  'ABC'
  1960.           
  1961.           plants the bytes $41, $42, $43 in the object file, and
  1962.           
  1963.                                    STR  'ABC'
  1964.           
  1965.           plants the bytes $41, $42, $43, $0D.
  1966.           
  1967.           
  1968.           4.3.2 The CASC and CSTR directives
  1969.           
  1970.           
  1971.           These  directives  plant  "counted strings" in the operand field.
  1972.           They are similar to ASC and STR, except that  the  bytes  planted
  1973.           are preceded by a single byte giving the length of the string. 
  1974.           
  1975.  
  1976.  
  1977.                                       26
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.                            USING THE 65C02 ASSEMBLER
  1984.  
  1985.  
  1986.  
  1987.           Thus, to use the same examples as above,
  1988.           
  1989.                                   CASC  'ABC'
  1990.           
  1991.           plants the bytes $03, $41, $42, $43 in the object file, and
  1992.           
  1993.                                   CSTR  'ABC'
  1994.           
  1995.           plants the bytes $04, $41, $42, $43, $0D.
  1996.           
  1997.           Note  that  the  count byte planted by CSTR includes the $0D byte
  1998.           that the directive adds itself.
  1999.           
  2000.           
  2001.           4.3.3 Planting special characters
  2002.           
  2003.           
  2004.           The strings you give as the operands to ASC, CASC, STR  and  CSTR
  2005.           must  of  course be made up of printable characters in the source
  2006.           file, but the Assembler allows you a way  of  specifying  control
  2007.           characters  and  characters with the most-significant-bit (bit 7)
  2008.           set to 1.
  2009.           
  2010.           To specify a control character, you should precede the  character
  2011.           itself with a "|" character. Thus, if you wish to plant the value
  2012.           of  CONTROL-A,  the  string  should  contain "|A". This method is
  2013.           identical to the way in which you specify control  characters  in
  2014.           Operating System commands such as *KEY.
  2015.           
  2016.           To specify a character with bit 7 (the most significant bit) set,
  2017.           precede it with a "^" character: thus, to plant an "A" with bit 7
  2018.           set, specify it in the string as "^A".
  2019.           
  2020.           For example,
  2021.           
  2022.                                  ASC  'A|AB^B'
  2023.           
  2024.           plants the bytes $41, $01, $42, $C2 in the object file.
  2025.           
  2026.           Should  you need to specify the "|" or "^" characters, you should
  2027.           double them in the string (i.e. write them as "||" and "^^")
  2028.           
  2029.           The Assembler does not  by  default  provide  a  means  to  plant
  2030.           characters  as  control  characters also with bit 7 set. However,
  2031.           you can use a configuration option described in Appendix 5 to let
  2032.           you do this: selecting the option makes the "~"  character  plant
  2033.           the  character  following  as a control character with bit 7 set.
  2034.           Thus
  2035.           
  2036.                                    ASC  "~A"
  2037.           
  2038.           would plant the byte $81 (i.e. a CONTROL-A with bit 7 set).
  2039.           
  2040.           
  2041.  
  2042.  
  2043.                                       27
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.                            USING THE 65C02 ASSEMBLER
  2050.  
  2051.  
  2052.  
  2053.      4.4 The HEX directive
  2054.      
  2055.      
  2056.         This directive is rather a hybrid of the DFB and ASC directives. It
  2057.      plants a series of byte values into the object file, but  you  specify
  2058.      the values as a string of hexadecimal digits.
  2059.      
  2060.         For example,
  2061.      
  2062.                                 HEX  '1234ABCD'
  2063.      
  2064.      plants the byte values $12, $34, $AB, $CD into the object file.
  2065.      
  2066.         The  string  you supply must contain valid hexadecimal digits (i.e.
  2067.      '0'..'9' and 'A'..'F'). You can give the letters in either  upper-  or
  2068.      lower-case.  If  the  string contains an odd number of characters, the
  2069.      Assembler will automatically add a '0' to make the  final  hexadecimal
  2070.      value complete.
  2071.      
  2072.      
  2073.      
  2074.      4.5 The CODE directive
  2075.      
  2076.      
  2077.         The  code  directive gives you a convenient way of including things
  2078.      like screen dumps or  already-compiled  relocatable  subroutines  into
  2079.      your programs.
  2080.      
  2081.         Suppose,  for  example,  you had prepared a mode 7 screen dump with
  2082.      some Teletext editor system, and wanted to use this as a  banner  page
  2083.      when  your  program  started.  One way of including this into the code
  2084.      would be to examine the dump and convert it into the  appropriate  DFB
  2085.      directives, planting each byte explicitly by hand. However, this might
  2086.      be a very time-consuming process, and would be very error-prone.
  2087.      
  2088.         Using CODE, though, removes the need to translate the dump into DFB
  2089.      or  similar  directives. If, for example, the dump was in file BANNER,
  2090.      writing
  2091.      
  2092.                                   CODE  BANNER
  2093.      
  2094.      would cause the Assembler to read it in and copy the bytes directly to
  2095.      the object file, without processing them in any way.
  2096.      
  2097.         By default, the listing will show only the first 3  bytes  included
  2098.      from  the  CODE  file,  since otherwise a considerable amount of paper
  2099.      might be used. If you do want to see all the bytes in the listing, use
  2100.      the CLST directive to set the code listing level to 2 before using the
  2101.      CODE directive itself.
  2102.      
  2103.         You cannot use the CODE  directive  within  a  macro,  or  from  an
  2104.      INCLUDE file.
  2105.  
  2106.  
  2107.  
  2108.  
  2109.                                       28
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.                            USING THE 65C02 ASSEMBLER
  2116.  
  2117.  
  2118.  
  2119.      5. OBJECT FILE CONTROL DIRECTIVES
  2120.      
  2121.      
  2122.         The  Assembler  contains  a  number  of directives that control the
  2123.      object file. They let you define the  actual  address  that  the  code
  2124.      generated  will run at, map symbol definitions into workspace, and set
  2125.      the load and execution addresses for the final result.
  2126.      
  2127.      
  2128.      5.1 Defining the current address
  2129.      
  2130.         In almost all programs you assemble, you  will  need  to  tell  the
  2131.      Assembler the actual address at which the resulting code is to run. It
  2132.      will then be able to assign the correct address values to labels.
  2133.      
  2134.         You define the current address with the ORG directive. For example,
  2135.      you could write
  2136.      
  2137.      
  2138.                               ORG    $1900
  2139.                               
  2140.      before  the  first code line in the source. This would set the address
  2141.      value to $1900, and the Assembler would produce  code  based  on  that
  2142.      address.
  2143.      
  2144.         You  can  specify  the  address  in  the  operand  field of the ORG
  2145.      directive as any expression you like:  however,  since  the  Assembler
  2146.      must  know  the  value to use on pass 1, the expression cannot contain
  2147.      forward references.
  2148.      
  2149.         Note that the ORG directive permits you to specify only a  two-byte
  2150.      or  16  bit  address  value.  Disc filing systems use a 32 bit address
  2151.      value to control which processor a file is to be loaded into,  and  to
  2152.      set  the  top two bytes with the Assembler you should use the LOAD and
  2153.      EXEC directives, described in section 5.4.
  2154.      
  2155.         You can use as many ORG directives as you wish within your  program
  2156.      source,  and  you  can  move the current address value to anywhere you
  2157.      wish. However, you should remember  that  the  ORG  directive  has  no
  2158.      effect on where in the object file bytes are written. Thus, the source
  2159.      lines
  2160.      
  2161.      
  2162.                               ORG   $1900
  2163.                               LDA   #1
  2164.                               ORG   $3000
  2165.                               LDA   #2
  2166.                               
  2167.      would  set  the  address to $1900, and write the two bytes for the LDA
  2168.      instruction to the object file. It then sets the address to $3000  and
  2169.      writes  the  bytes  for  the second LDA instruction: however, the four
  2170.      bytes will be contiguous in the object file - the Assembler  will  not
  2171.      generate  a  gap. You could use this effect, for instance, to write an
  2172.      object file containing many sections of overlay code  -  each  section
  2173.  
  2174.  
  2175.                                       29
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.                            USING THE 65C02 ASSEMBLER
  2182.  
  2183.  
  2184.  
  2185.      would  be assembled to run at the same address, but they would lie one
  2186.      after the other in the object file.
  2187.      
  2188.      If you do require to leave a gap in the object file, you can  use  the
  2189.      DS  directive  to  generate  the  required  gap  yourself (see section
  2190.      5.3.1). There is no way of making the Assembler move backwards in  the
  2191.      object file.
  2192.      
  2193.      
  2194.      5.2 Reading the current address
  2195.      
  2196.      
  2197.         You  can  use  the  value  of  the  current  address counter within
  2198.      expressions by referring to it with the special symbol "*".  This  can
  2199.      be  used exactly as any other symbol in expressions, so that, say, you
  2200.      could work out the size of a data table with
  2201.      
  2202.                               TABLE   DFB   1
  2203.                                       DFB   2
  2204.                                       DFB   3
  2205.                               T.SIZE  EQU   *-TABLE
  2206.                               
  2207.      where T.SIZE will be set  to  the  number  of  bytes  defined  in  the
  2208.      preceding table.
  2209.      
  2210.      5.3 Using dummy sections
  2211.      
  2212.      
  2213.         A  "dummy section" is a convenient way of laying out symbols within
  2214.      the workspace that your  program  needs.  For  example,  suppose  your
  2215.      program  needed  some  page zero workspace. You could build the actual
  2216.      numeric addresses into the source, but it's  much  better  programming
  2217.      practice to define some symbols to identify the locations.
  2218.      
  2219.         One  way  of  doing  this  would be to use the EQU directive, which
  2220.      simply sets up a symbol and gives it a value. Thus you could write
  2221.      
  2222.      
  2223.                               WORK0  EQU   $00
  2224.                               WORK1  EQU   $01
  2225.                               WORK2  EQU   $02
  2226.                               
  2227.      to set up three symbols. This is a perfectly adequate  technique,  but
  2228.      suffers  from  the disadvantage that you would have to change a lot of
  2229.      the source if, say, you ever wanted the page zero workspace  to  start
  2230.      at some place other than address $00.
  2231.      
  2232.         A better technique is to define workspace in a dummy section, which
  2233.      is  a  region  of  the source between DSECT and DEND directives. DSECT
  2234.      instructs the Assembler that  a  layout  is  being  defined:  it  will
  2235.      process  anything  that follows it, but it won't generate any code for
  2236.      the object file. All it will do is work out what addresses any  labels
  2237.      will take.
  2238.      
  2239.  
  2240.  
  2241.                                       30
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.                            USING THE 65C02 ASSEMBLER
  2248.  
  2249.  
  2250.  
  2251.         Thus, you could write the above example as
  2252.      
  2253.                                      DSECT
  2254.                               WORK0  DFB   0
  2255.                               WORK1  DFB   0
  2256.                               WORK2  DFB   0
  2257.                                      DEND
  2258.                               
  2259.         Here  each  of the workspace locations has been defined as one byte
  2260.      long with a DFB directive.  Since  the  Assembler  generates  no  code
  2261.      within  a  DSECT,  the  actual value you place in the operand field is
  2262.      quite arbitrary. This technique also lets you see clearly that  you've
  2263.      set  the  locations up as one-byte values. If you wished, say, to make
  2264.      them two-byte values, you could change the DFB directives to  DW.  The
  2265.      Assembler  would  then  allow  two bytes to each label, and the source
  2266.      would show this clearly.
  2267.      
  2268.         In the example above, we have implicitly taken advantage of how the
  2269.      Assembler handles the address value within a DSECT..DEND  block.  When
  2270.      it  meets  the  first DSECT in a source, the Assembler makes a note of
  2271.      the address value it is using in the code, and resets it to  zero  for
  2272.      the  DSECT..DEND  block.  When it meets the DEND, it resumes using the
  2273.      address it saved at the start.
  2274.      
  2275.         On the second occurrence of a DSECT, the effect is the same, except
  2276.      that now the address within the DSECT..DEND block resumes at the value
  2277.      it reached in the last block.
  2278.      
  2279.         If you don't wish to operate in this way, you can set  the  address
  2280.      value  with  the  DSECT..DEND  block  yourself with the ORG directive.
  2281.      Thus, if you wanted your page zero workspace to begin  at  some  other
  2282.      location, you could write the source as
  2283.      
  2284.                                      DSECT
  2285.                                      ORG   $70
  2286.                               WORK0  DFB   0
  2287.                               WORK1  DFB   0
  2288.                               WORK2  DFB   0
  2289.                                      DEND
  2290.                               
  2291.      
  2292.      
  2293.           5.3.1 The DS directive
  2294.           
  2295.           
  2296.           Quite  often  you  will  need to define a large area of workspace
  2297.           within a DSECT..DEND block, for example as a  source  line  input
  2298.           buffer.  The  DFB and DW directives are convenient ways of laying
  2299.           out byte and word values, but there are no built-in directives to
  2300.           lay out, say, a 256-byte buffer.
  2301.           
  2302.           To do this, you can use the DS directive, which lets you lay  out
  2303.           any  number  of  bytes. For example, to lay out a 256-byte buffer
  2304.           you could write
  2305.  
  2306.  
  2307.                                       31
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.                            USING THE 65C02 ASSEMBLER
  2314.  
  2315.  
  2316.  
  2317.           
  2318.                                      DSECT
  2319.                                      ORG    $A00
  2320.                               BUFFER DS     256
  2321.                                      DEND
  2322.                               
  2323.           The operand field of the DS directive  tells  the  Assembler  how
  2324.           much space you wish to lay out.
  2325.           
  2326.           Normally  the DS directive is used in DSECT..DEND blocks, but you
  2327.           can also use it in the code area of a program as  well.  In  this
  2328.           case,  the  Assembler  will write the appropriate number of bytes
  2329.           containing the value zero to the object file.
  2330.           
  2331.           
  2332.      5.4 Defining object load and execution addresses
  2333.      
  2334.      
  2335.         Every machine-code program on a BBC Computer needs to have  a  load
  2336.      address  and an execution address associated with it. These values are
  2337.      stored in the file's catalogue entry: when you then *RUN the file, the
  2338.      filing system will load it to memory starting at the load address, and
  2339.      will enter it with a JSR instruction going to the execution address.
  2340.      
  2341.         The addresses also tell the filing system whether the program is to
  2342.      be run on a second processor, or  on  the  BBC  Computer  itself.  The
  2343.      filing  system regards load and execution addresses as 4 byte (32 bit)
  2344.      values. The lower two bytes or  word  of  each  address  represent  an
  2345.      actual  address in memory and the top two bytes or word of the address
  2346.      is a value that indicates which processor the file is to be loaded on.
  2347.      The Assembler can handle only two-byte values in its arithmetic, so it
  2348.      is necessary to set the two parts of each address separately.
  2349.      
  2350.      
  2351.      
  2352.           5.4.1 Specifying the low word of the addresses
  2353.           
  2354.           
  2355.           There are two ways of setting up the low words of  the  addresses
  2356.           when  you  assemble  programs. By default, the Assembler will set
  2357.           the low words of both the load and the execution addresses to  be
  2358.           the  value  set by the first ORG directive that is not in a dummy
  2359.           section, and in many cases this is all you need do.
  2360.           
  2361.           If, though, you require something else, you can use the LOAD  and
  2362.           EXEC  directives  to  set  the low word of the load and execution
  2363.           addresses respectively. Thus, for example,
  2364.           
  2365.           
  2366.                                   LOAD  $1900
  2367.                                   EXEC  START
  2368.           
  2369.           would set the low word of the load address to be $1900,  and  the
  2370.           low  word  of  the  execution  address to be whatever address the
  2371.  
  2372.  
  2373.                                       32
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.                            USING THE 65C02 ASSEMBLER
  2380.  
  2381.  
  2382.  
  2383.           label START is defined as.
  2384.           
  2385.           
  2386.           5.4.2 Specifying the processor
  2387.           
  2388.           
  2389.           If the top word of the load address is $FFFF, the file is  loaded
  2390.           into  the BBC Computer's own memory, whether or not you are using
  2391.           a second processor. If the top word is 0, though, the  file  will
  2392.           be loaded into the second processor if you are using one.
  2393.           
  2394.           By default, the Assembler produces object files with the top word
  2395.           of  the addresses set to $FFFF, so the files will load to the BBC
  2396.           Computer's memory. The MSW directive,  though,  lets  you  change
  2397.           this value: thus
  2398.           
  2399.                                     MSW   0
  2400.           
  2401.           lets  you change the address to 0. You should always include this
  2402.           directive if you write programs to run on a second processor.
  2403.      
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.                                       33
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.                            USING THE 65C02 ASSEMBLER
  2446.  
  2447.  
  2448.  
  2449.      6. SOURCE FILE CONTROL DIRECTIVES
  2450.      
  2451.      
  2452.         The Assembler provides a number of directives  that  allow  you  to
  2453.      control the source files which you are assembling. This lets you split
  2454.      your source up into more than one file.
  2455.      
  2456.      
  2457.      6.1 Chaining source files
  2458.      
  2459.      
  2460.         If  you are writing a large program, you will find it convenient to
  2461.      split the source into a number of small files, rather than keeping  it
  2462.      in  one  large  one.  This approach not only makes editing easier, but
  2463.      also helps you structure the source to reflect the organisation of the
  2464.      program. Additionally, if you have a second processor, keeping  source
  2465.      files  to less than 14 kilobytes in size will give a very considerable
  2466.      increase in assembly speed (see section 1.5).
  2467.      
  2468.         You can instruct the Assembler to assemble multiple files with  the
  2469.      CHN directive. This tells it to close the current source file and open
  2470.      the one specified in the operand field.
  2471.      
  2472.         Thus, you could write
  2473.      
  2474.                                    CHN  FILE2
  2475.      
  2476.      as  the  last  line  in  FILE1.  The  Assembler  will close FILE1, and
  2477.      continue assembly with FILE2. Note that if the  CHN  directive  is not
  2478.      the last line in a file, anything following it will be ignored.
  2479.      
  2480.         You can use CHN as many times as you wish in an assembly.
  2481.      
  2482.      
  2483.      6.2 Including one file into another
  2484.      
  2485.      
  2486.         A  different  way  of  using  multiple  source  files is to use the
  2487.      INCLUDE directive.  This  tells  the  Assembler  to  start  assembling
  2488.      another  source  file;  unlike  CHN,  however,  the  first file is not
  2489.      closed. When the Assembler comes to the end of the included  file,  it
  2490.      resumes in the original file at the line after the INCLUDE directive.
  2491.      
  2492.         One  use  of  this directive might be to include a file of standard
  2493.      definitions or routines into a source. You might then write
  2494.      
  2495.                                 INCLUDE  STDSUBS
  2496.      
  2497.      to assemble the source of some standard routines.
  2498.      
  2499.         Lines that result from assembling an included file  are  marked  in
  2500.      the listing by having an 'I' in the first column.
  2501.      
  2502.         Note  that  you  cannot use an INCLUDE directive inside a file that
  2503.  
  2504.  
  2505.                                       34
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.                            USING THE 65C02 ASSEMBLER
  2512.  
  2513.  
  2514.  
  2515.      you  are  including  already.  Nor  can  you  use  the  CHN  and  CODE
  2516.      directives.
  2517.      
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.                                       35
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.                            USING THE 65C02 ASSEMBLER
  2578.  
  2579.  
  2580.  
  2581.      7. CONDITIONAL ASSEMBLY
  2582.      
  2583.      
  2584.         The  65C02  Assembler  has  full  conditional  assembly facilities,
  2585.      allowing you easily to change the source being compiled.
  2586.      
  2587.      
  2588.      7.1 Assembly conditional on expressions
  2589.      
  2590.      
  2591.         Conditional assembly that depends on the value of an expression  is
  2592.      achieved  by  using  the  IF, ELSE and FI directives. The most general
  2593.      form of construction is this:
  2594.      
  2595.      
  2596.                          
  2597.                          IF   <expr>
  2598.                             .
  2599.                             TRUE block
  2600.                             .
  2601.                          ELSE
  2602.                             .
  2603.                             FALSE block
  2604.                             .
  2605.                          FI
  2606.                          
  2607.                          
  2608.         <expr> can be any numeric expression, as described in section  2.2,
  2609.      but it must not contain any forward references. If <expr> is non-zero,
  2610.      the Assembler takes the condition as TRUE, and will assemble the lines
  2611.      in  the  TRUE  block.  On  coming  to  the ELSE it will ignore all the
  2612.      subsequent lines, until it reaches the FI; here assembly will continue
  2613.      normally once more.
  2614.      
  2615.         If <expr> is zero, the  condition  is  FALSE.  The  Assembler  will
  2616.      ignore  the  lines that follow until it reaches the ELSE; it then will
  2617.      assemble the lines in the FALSE block.
  2618.      
  2619.         If you wish, you can omit the ELSE and the FALSE block of code,  to
  2620.      form
  2621.      
  2622.                          
  2623.                          IF   <expr>
  2624.                             .
  2625.                             TRUE block
  2626.                             .
  2627.                          FI
  2628.                          
  2629.                          
  2630.         Here,  if  the  condition  is  FALSE, the Assembler will ignore all
  2631.      lines up to the FI, so no code is assembled in this case.
  2632.      
  2633.      
  2634.      
  2635.  
  2636.  
  2637.                                       36
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.                            USING THE 65C02 ASSEMBLER
  2644.  
  2645.  
  2646.  
  2647.      
  2648.         For example, you might have a symbol DEBUG.MODE defined at the very
  2649.      start of the source to show if debug code is to be assembled  or  not.
  2650.      This might be defined as
  2651.      
  2652.      
  2653.              DEBUG.MODE  EQU   -1    ;use -1 for TRUE, 0 for FALSE
  2654.              
  2655.              
  2656.      Then, throughout the rest of the source, you can put the debug code in
  2657.      an IF condition of the form
  2658.      
  2659.                          
  2660.                          IF   DEBUG.MODE
  2661.                             .
  2662.                             debug mode version
  2663.                             .
  2664.                          ELSE
  2665.                             .
  2666.                             non-debug mode version
  2667.                             .
  2668.                          FI
  2669.                          
  2670.         Depending  on  circumstances, you may wish to reverse the condition
  2671.      tested to include some code if debug mode is not selected. You can use
  2672.      the unary 1's complement or NOT operator here: thus
  2673.      
  2674.                          
  2675.                          IF   ~DEBUG.MODE     ;read as "IF NOT DEBUG.MODE"
  2676.                             .
  2677.                             non-debug mode version
  2678.                             .
  2679.                          FI
  2680.                          
  2681.      includes code if DEBUG.MODE is set to 0.
  2682.      
  2683.         The  IF..ELSE..FI  construction  can  also  be  written  using  the
  2684.      directives DO..ELSE..FIN (or with any combination of them)
  2685.      
  2686.      
  2687.      7.2 Assembly conditional on the existence of symbols
  2688.      
  2689.      
  2690.         Two  variants  of  the IF directive, IFDEF and IFNDEF, allow you to
  2691.      test for the existence or otherwise of symbols. IFDEF is TRUE  if  the
  2692.      symbol in the operand field does exist; IFNDEF is TRUE if it does not.
  2693.      
  2694.         Thus the example above might have been written as
  2695.      
  2696.      
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.                                       37
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.                            USING THE 65C02 ASSEMBLER
  2710.  
  2711.  
  2712.  
  2713.                          
  2714.                          IFDEF  DEBUG.MODE
  2715.                             .
  2716.                             debug mode version
  2717.                             .
  2718.                          ELSE
  2719.                             .
  2720.                             non-debug mode version
  2721.                             .
  2722.                          FI
  2723.                          
  2724.      where  the  mere  existence  of the symbol DEBUG.MODE would select the
  2725.      debug code, regardless of its value.
  2726.      
  2727.      
  2728.      7.3 Nesting conditionals
  2729.      
  2730.         The Assembler allows you to "nest" conditionals.  Within  a  nested
  2731.      condition,  an  ELSE directive will be associated with the immediately
  2732.      preceding IF, IFDEF or IFNDEF.
  2733.      
  2734.      
  2735.      7.4 Listing conditionals
  2736.      
  2737.         By default, the Assembler will list all the lines that it skips  in
  2738.      a conditional, printing an "S" in the address field.
  2739.      
  2740.         To  save  paper,  or  make  the  listing  clearer, you can suppress
  2741.      listing of skipped lines with the SFCOND directive, or  by  specifying
  2742.      the "-S" option in the command line. You can re-instate the listing of
  2743.      false conditional branches at any time with the LFCOND directive.
  2744.      
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.                                       38
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.                            USING THE 65C02 ASSEMBLER
  2776.  
  2777.  
  2778.  
  2779.      8. PROGRESS REPORTING
  2780.      
  2781.      
  2782.         The  Assembler supports several directives that allow you to output
  2783.      progress reports to the screen and to a printer or a listing  file  to
  2784.      show the course of an assembly.
  2785.      
  2786.      
  2787.      8.1 The DISP, DISP1 and DISP2 directives
  2788.      
  2789.         These  all  display  a message on the screen, and also send it to a
  2790.      printer or to a listing file. DISP displays the text on  both  passes;
  2791.      DISP1  and  DISP2  display  the  text  on pass 1 only and pass 2 only,
  2792.      respectively. You can use INFO as a synonym of DISP2 is you wish.
  2793.      
  2794.         The use of the directives is the same: for example, you might write
  2795.      
  2796.      
  2797.                          DISP  'Assembling debug code'
  2798.      
  2799.      
  2800.      to display
  2801.      
  2802.      
  2803.                            ---- Assembling debug code
  2804.      
  2805.      
  2806.      on the screen.
  2807.      
  2808.      
  2809.         The message you display can contain printable  text,  and  you  can
  2810.      also include some control characters. You specify them in the same way
  2811.      as  you  would  in  any  other  string,  by  preceding them with a "|"
  2812.      character. The control characters you can use are:
  2813.      
  2814.      
  2815.                          |M and |J  - start a new line
  2816.                          |G         - make a beep sound
  2817.                          
  2818.         For example
  2819.      
  2820.                            DISP   'Line 1|MLine 2|G'
  2821.      
  2822.      displays a 2 line message and rings the bell.
  2823.      
  2824.         Additionally, the text can contain  numeric  expressions  that  are
  2825.      evaluated  as  the  message is output. For example, this would let you
  2826.      output a message to report the size of a section of code.
  2827.      
  2828.         Within the text, you can specify an expression in one of two ways.
  2829.      
  2830.                                    %D(<expr>)
  2831.      
  2832.      will evaluate <expr> and display the result in decimal, and
  2833.  
  2834.  
  2835.                                       39
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.                            USING THE 65C02 ASSEMBLER
  2842.  
  2843.  
  2844.  
  2845.      
  2846.                                    %X(<expr>)
  2847.      
  2848.      will display it in hexadecimal.
  2849.      
  2850.         You  can  write  any  numeric  expression  you  wish   within   the
  2851.      parentheses, but it must not contain forward references.
  2852.      
  2853.         For example, to report the size of a section of code between labels
  2854.      START.CODE and END.CODE, use:
  2855.      
  2856.      
  2857.              DISP2  'Size of code is %X(END.CODE-START.CODE) bytes'
  2858.      
  2859.      
  2860.      
  2861.      8.2 The WAIT, WAIT1 and WAIT2 directives
  2862.      
  2863.      
  2864.         These output messages in the same way as DISP, DISP1 and DISP2, but
  2865.      then suspend the assembly until you press a key on the keyboard.
  2866.      
  2867.         You  could thus use these directives to enable you to change source
  2868.      discs during an assembly.
  2869.      
  2870.      
  2871.      8.3 The QUERY directive
  2872.      
  2873.      
  2874.         This  offers  a  convenient  way  of  setting  up  conditions   for
  2875.      conditional assembly.
  2876.      
  2877.         QUERY  operates  only  on  pass  1  of  the assembly. It displays a
  2878.      message on the screen in the same way as the  directives  above,  then
  2879.      waits  for  you  to  type  in a line. The line is treated as a numeric
  2880.      expression and evaluated, the result being set as  the  value  of  the
  2881.      symbol  specified  in  the  line's  label  field. If the expression is
  2882.      invalid, or  contains  a  forward  reference,  the  question  will  be
  2883.      repeated.
  2884.      
  2885.         For example, suppose that your source contains optional debug code,
  2886.      and you select this with IF conditions of the form
  2887.      
  2888.                          IF    DEBUG.MODE
  2889.                             .
  2890.                             debug code
  2891.                             .
  2892.                          FI
  2893.                          
  2894.      
  2895.         The  value of DEBUG.MODE would normally be -1 to select debug code,
  2896.      or 0 if it were not needed.
  2897.      
  2898.      
  2899.  
  2900.  
  2901.                                       40
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.                            USING THE 65C02 ASSEMBLER
  2908.  
  2909.  
  2910.  
  2911.         Rather than define DEBUG.MODE in the source, and thus have to  edit
  2912.      the  source  every  time  you  wished  to  change it, you can make the
  2913.      Assembler ask for the value at the start of an assembly. A  line  such
  2914.      as:
  2915.      
  2916.                       DEBUG.MODE  QUERY  'Use debug mode'
  2917.      
  2918.      will output the question
  2919.      
  2920.                               ---- Use debug mode?
  2921.      
  2922.      on pass 1. You can now type in
  2923.      
  2924.                                        -1
  2925.      
  2926.      to select debug code, or
  2927.      
  2928.                                        0
  2929.      
  2930.      to suppress it.
  2931.      
  2932.      
  2933.         Since  the line you type is an expression, and can contain symbols,
  2934.      you can make this more friendly by changing the source to include
  2935.      
  2936.                          YES   EQU   -1
  2937.                          NO    EQU   0
  2938.                          
  2939.      before the QUERY directive. Now you can reply either "YES" or "NO"  to
  2940.      the  question: the Assembler will evaluate the line and take the value
  2941.      of the symbol you type.
  2942.      
  2943.      
  2944.      
  2945.      8.4 The STOP directive
  2946.      
  2947.      
  2948.         STOP provides a useful  way  of  abandoning  an  assembly  part-way
  2949.      through.  It  operates  on  pass 1, and like DISP1, it displays a text
  2950.      message. Afterwards, though, it aborts the  assembly  with  the  error
  2951.      message "Stopped"
  2952.      
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.                                       41
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.                            USING THE 65C02 ASSEMBLER
  2974.  
  2975.  
  2976.  
  2977.      9. WRITING SIMPLE MACROS
  2978.      
  2979.      
  2980.         The  Assembler  contains a powerful macro facility, allowing you to
  2981.      write very complex and sophisticated macros. In this chapter, we shall
  2982.      examine the simpler aspects of macros.
  2983.      
  2984.         A macro is a way of producing a number of  Assembler  source  lines
  2985.      merely  by  specifying  its  name  in  the opcode field of a line. For
  2986.      example, your source might contain many occurrences of the lines:
  2987.      
  2988.                             LDA   VAR
  2989.                             CLC
  2990.                             ADC   #2
  2991.                             STA   VAR
  2992.                             
  2993.