home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1995 / ARCHIVE95.iso / discs / shareware / share_46 / sasm / Docs / Manual < prev    next >
Text File  |  1994-04-03  |  165KB  |  3,436 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.                      SSSSS     AAAA
  15.                     SS        AA  AA
  16.                      SS      AA    AA   SSSSS     mmm  mmm
  17.                       SSSS   AA    AA  SS        mm mmmm mm
  18.                          SS  AAAAAAAA   SSSSS   mm   mm   mm
  19.                          SS  AA    AA       SS  mm   mm   mm
  20.                      SSSSS   AA    AA   SSSSS   mm   mm   mm
  21.  
  22.  
  23.                                      Version 1.54
  24.  
  25.  
  26.  
  27.                       The Simple Assembler for the Archimedes
  28.  
  29.  
  30.  
  31.                        Copyright David Holden 1991,92,93,94
  32.  
  33.  
  34.                                 _______
  35.                            ____|__     |               (R)
  36.                         --|       |    |-------------------
  37.                           |   ____|__  |  Association of
  38.                           |  |       |_|  Shareware
  39.                           |__|   o   |    Professionals
  40.                         -----|   |   |---------------------
  41.                              |___|___|    MEMBER
  42.  
  43.  
  44.  
  45.  
  46.  
  47.                                     CONTENTS
  48.                                                             Page
  49.                    Preliminaries
  50.                          Introduction             ........   1
  51.                          Licence to Use           ........   2
  52.                          How to Register          ........   2
  53.                          Advantages of Registration ......   2
  54.                          Licence to Copy          ........   3
  55.  
  56.                    Using SAsm
  57.                          Use with floppy discs    ........   4
  58.                          Command line syntax      ........   5
  59.                          Null Parameters          ........   6
  60.                          Source Filenames         ........   7
  61.                          Reconciliation of Wildcards .....   8
  62.                          Order of Assembly        ........   9
  63.                          Length of Source File    ........   9
  64.                          Line number space        .........  9
  65.                          A short demonstration    ........   10
  66.  
  67.                    The Source File
  68.                          Source File Syntax       ........   11
  69.                          General                  ........   11
  70.                          Important warning        ........   11
  71.                          Warnings and Errors      ........   12
  72.                          Comments                 ........   12
  73.                          Descriptive text         ........   13
  74.                          Large source files       ........   14
  75.                          Basic keywords accepted  ........   14
  76.                          Directives               ........   15
  77.                          Basic variables          ........   16
  78.                            #ORG                   ........   16
  79.                            #SIZE                  ........   16
  80.                            #END                   ........   16
  81.                            #TYPE                  ........   17
  82.                            #OBJ                   ........   17
  83.                            #ERRFILE               ........   17
  84.                            #LIB                   ........   17
  85.                            #VERBOSE               ........   17
  86.                            #QUIET                 ........   18
  87.                            #INCLUDE               ........   18
  88.                            #INSERT                ........   19
  89.                            #AREA                  ........   19
  90.                          Multiple data areas      ........   21
  91.                            #LISTON                ........   22
  92.                            #LISTOF                ........   22
  93.                            #NOENHANCE             ........   22
  94.                            #ENHANCE               ........   22
  95.                            #XREF                  ........   22
  96.                            #NOXREF                ........   22
  97.                            #XRFILE                ........   23
  98.                            #SWION                 ........   24
  99.                            #SWIOFF                ........   24
  100.                            #CLI                   ........   24
  101.                            #LABELFILE             ........   25
  102.  
  103.  
  104.  
  105.  
  106.                                     CONTENTS
  107.                                                             Page
  108.  
  109.  
  110.                          Defining registers etc.  ........   26
  111.                          Defining constants       ........   26
  112.                          Conditional Assembly     ........   27
  113.                          LDM/STM with Writeback   ........   28
  114.                          Assembly Loops           ........   28
  115.                          Using the OSET variable  ........   29
  116.                          Assembly Listing         ........   30
  117.                          Creating a Listing file  ........   31
  118.                          Listing file directives  ........   31
  119.                          Scope of listing         ........   31
  120.  
  121.                    Labels
  122.                          Global Labels            ........   32
  123.                          Local Labels             ........   32
  124.                          Local Label Scope        ........   32
  125.                          Local Label Example      ........   34
  126.                          Forward Branch to 00     ........   34
  127.  
  128.                    Enhanced 2nd Operand           ........   35
  129.  
  130.                    Extra Mnemonics
  131.                            DW and DD              ........   36
  132.                            DB                     ........   37
  133.                          Basic variables and DB   ........   38
  134.                            ADRL                   ........   39
  135.                            MOVL                   ........   39
  136.                            DIV                    ........   40
  137.  
  138.                    Macros
  139.                          Macro Functions - Pro/Con  ......   42
  140.                          Expanded Macros - Pro/Con  ......   42
  141.                          Macro Names              ........   42
  142.  
  143.                    Expanded Macros
  144.                          Defining expanded macros ........   43
  145.                          Macro parameters         ........   43
  146.                          Local labels in macros   ........   44
  147.                          Special features         ........   44
  148.                          Examples                 ........   45
  149.                          Errors in expanded macros .......   46
  150.  
  151.                    Macro Functions
  152.                          General                  ........   47
  153.                          Built-in Functions       ........   47
  154.                            FNgap                  ........   48
  155.                            FNset                  ........   48
  156.                            FNadr                  ........   48
  157.                            FNmov                  ........   48
  158.  
  159.  
  160.  
  161.                                     CONTENTS
  162.                                                             Page
  163.  
  164.                    The Macro Library
  165.                          Using the Macro Library  ........   49
  166.                          The 'L' parameter        ........   49
  167.                          The 'V' parameter        ........   50
  168.                          SAsm$Lib OS variable     ........   50
  169.                          Preparing a Library      ........   51
  170.                          Length of Library file   ........   51
  171.  
  172.                    SAsm and the Desktop
  173.                          New features             ........   52
  174.                          Using from the desktop   ........   53
  175.  
  176.                    Problems and Questions
  177.                          Reporting and diagnostic ........   54
  178.                          Speed of operation       ........   55
  179.                          Memory usage             ........   55
  180.                          Notes on Local Labels    ........   56
  181.                          Common problems          ........   56
  182.  
  183.                          Release History          ........   60
  184.                          Registration Form        ........   Endpiece
  185.  
  186.  
  187.                                                                    Page 1
  188.  
  189.  
  190.                              -=O=-  INTRODUCTION  -=O=-
  191.  
  192.       A long time ago when I found I needed more facilities than the Basic
  193.       assembler offers I tried Acorn's AASM. My personal opinion of AASM is
  194.       that it is overpriced, clumsy and, for many purposes, LESS powerful
  195.       than the (free!) Basic assembler. I therefore decided to write my own,
  196.       provisionally titled BAsm. As usual it had to be fitted in with other
  197.       things, and meanwhile I needed an assembler. I continued to use the
  198.       Basic assembler for short utilities and AASM for longer ones. Soon I
  199.       found I was using AASM less and less as I gradually added bits to the
  200.       Basic assembler to give the additional facilities I needed.
  201.  
  202.       To make life easier I wrote a 'pre-processor' for the Basic assembler
  203.       as a stop-gap until I finished BAsm. Gradually it was improved and
  204.       with each improvement the need for BAsm receded and work on it assumed
  205.       a lower priority. Eventually my stop-gap program assumed a life of
  206.       it's own and had become so powerful that it could do just about
  207.       everything I wanted. At this point I realised it would be useful to
  208.       others as well. I re-wrote the program, making lot's of improvements,
  209.       and named it SASM - Simple ASseMbler for the Archimedes
  210.  
  211.       Don't be put off by the word 'Simple'. Unless you are re-writing
  212.       Impression SAsm will probably fulfil all your needs. Simple is
  213.       intended to describe its ease of use. Its main limitation is that it
  214.       cannot produce output in AOF (Acorn Object Format) for linking to 'C'
  215.       or other languages. If you want to write in 'C' I'm afraid you are
  216.       stuck with ObjAsm or !AS (APDL disc B150) until I get around to
  217.       finishing BAsm. It also cannot assemble Floating Point opcodes
  218.       although you could add Macros to do this. If you really must use them
  219.       (I've never found the need) ask and I will try to include them.
  220.  
  221.       SAsm is not actually an assembler. It is a pre-processor for the Basic
  222.       assembler. Don't worry about this. As far as the user is concerned
  223.       SAsm works with Text source files and behaves like a 'proper'
  224.       assembler. It has lots of facilities that the Basic assembler normally
  225.       lacks, local labels, multi-file assembly, error reovery, etc. yet at
  226.       the same time the syntax will be familiar to anyone who has used the
  227.       Basic assembler. You also have the power of Basic available with its
  228.       Mathematical, Conditional Assembly and Expression Evaluation abilities
  229.  
  230.       If you are not an expert at using the Basic assembler I suggest you
  231.       read the file 'Tutorial'. It won't teach you to write machine code but
  232.       it explains the use of Macro Function and Conditional Assembly with
  233.       the Basic assembler helps you understand SAsm better. (SAsm actually
  234.       has another, better, Macro system as well as Basic style Functions).
  235.  
  236.       Please read carefully the 'Licence to Use' and 'Licence to Copy'
  237.       before you use/copy SAsm.
  238.  
  239.  
  240.                              David Holden
  241.                              39 Knighton Park Road
  242.                              Sydenham
  243.                              London SE26 5RN
  244.                              081 778 2659
  245.  
  246.                                                                    Page 2
  247.  
  248.                   SAsm is SHAREWARE, it is NOT Public Domain
  249.  
  250.           ssss  h   h   aaa   rrrr   eeeee  w      w   aaa   rrrr   eeeee
  251.          s      h   h  a   a  r   r  e      w      w  a   a  r   r  e
  252.           ssss  hhhhh  a   a  rrrr   eeee   w  w   w  a   a  rrrr   eeee
  253.               s h   h  aaaaa  r  r   e      w  w   w  aaaaa  r  r   e
  254.           ssss  h   h  a   a  r   r  eeeee   ww  ww   a   a  r   r  eeeee
  255.  
  256.  
  257.                          -=O=-  LICENCE TO USE  -=O=-
  258.  
  259.       This program is distributed as SHAREWARE. It is NOT Public Domain. This
  260.       means that you are only licensed to use it for a period of THIRTY DAYS.
  261.       At the end of that time you must either stop using it or REGISTER.
  262.       Failure to comply with this condition is a Breach of Copyright and is
  263.       now recognised in almost all countries as an offence.
  264.  
  265.       Use of ANY version of SAsm for any TRAINING or EDUCATIONAL purposes
  266.       without payment of the Registration Fee is ABSOLUTELY FORBIDDEN.
  267.  
  268.  
  269.                          -=O=-  HOW TO REGISTER  -=O=-
  270.  
  271.       Registration costs just Eight Pounds. I have made the last page of this
  272.       Manual a Registration Form. Please use it when you register as it helps
  273.       me to keep my records tidy. Fill it in, preferably adding comments, and
  274.       post it to me. Don't forget your cheque for Eight Pounds. Write as much
  275.       as you wish, I do take notice of comments and suggestions.
  276.  
  277.       Each assembler for the ARM processor will produce slightly different hex
  278.       values for the same assembler mnemonics. SAsm leaves its 'fingerprints'
  279.       on the code produced. I can tell if a program was assembled using SAsm.
  280.       I will take action against ANYONE who uses SAsm and distributes code
  281.       WITHOUT REGISTRATION in breach of this licence
  282.  
  283.  
  284.              Advantages of Registration
  285.              --------------------------
  286.       The first advantage is that you will not, of course, be breaking the
  287.       law. Registration costs just eight pounds, so it's not expensive.
  288.       However there are some material advantages.
  289.  
  290.       When you register you will receive your personal copy of the latest
  291.       version of SAsm which can use external Macro Libraries This enables SAsm
  292.       to load Macros automatically during assembly. You will also receive the
  293.       tools which will let you create Macro Libraries. This makes your code
  294.       simpler because you don't need to include all the macro definitions
  295.       within it before you call them.
  296.  
  297.       You will also have the right to FREE UPDATES. Once you have registered
  298.       you can return your ORIGINAL copy of SAsm to me with a stamped, self
  299.       addressed label at any time for a copy of the latest version. To take
  300.       advantage of this offer you MUST return your original disc with your
  301.       personal copy of SAsm, not just a blank disc. You will also be entitled
  302.       to free or very low cost upgrades to any future assemblers or compilers
  303.       that I produce even if these are not part of the SAsm 'family'.
  304.                                                                    Page 3
  305.  
  306.  
  307.                          -=O=-  LICENCE TO COPY  -=O=-
  308.  
  309.       If you are a Sysop or run a PD or Shareware library READ THIS CAREFULLY.
  310.  
  311.  
  312.       1.   The Author retains full copyright to this program and all
  313.            the material and documentation associated with it.
  314.  
  315.       2.   Any private individual may GIVE copies of the UNREGISTERED
  316.            version of SAsm to his/her friends. Only PD or Shareware
  317.            libraries and BBS's which have been given permission by the
  318.            Author are permitted to distribute SAsm. Any distribution by
  319.            any organisation or for any reward whatsoever whether in fee
  320.            or in kind without permission is forbidden and will be
  321.            treated as Breach of Copyright even if the fee is merely
  322.            intended to cover costs.
  323.  
  324.       3.   You may not make any changes to the program or documentation
  325.            and you must include the Examples directory and its contents
  326.            and the Tutorial, Manual and all other associated files.
  327.  
  328.       4.   You may not make any charge for this program or for any
  329.            additional material you supply. You may charge a reasonable
  330.            fee to cover copying, media, postage, overheads, etc.
  331.  
  332.       5.   You may not under any circumstances distribute copies of any
  333.            registered version of SAsm. These can be distinguished
  334.            because they display the name of the registered user after
  335.            the copyright message whereas the version which may be
  336.            freely distributed displays the word 'UNREGISTERED'.
  337.  
  338.       6.   You must not distribute any version of the 'MakeLib'
  339.            application. This is for the use of Registered users ONLY.
  340.  
  341.  
  342.       If you have any problems or suggestions for improvements to SAsm please
  343.       write or phone. If you write with an enquiry please enclose an SAE. If
  344.       you prefer to telephone I am normally available on weekday evenings.
  345.  
  346.                                David Holden
  347.                                39 Knighton Park Road
  348.                                Sydenham
  349.                                London SE26 5RN
  350.  
  351.                                081 778 2659
  352.  
  353.       SAsm was produced by a member of the Association of Shareware
  354.       Professionals (ASP) who want to make sure that the Shareware principle
  355.       works for you. If you are unable to resolve a Shareware related problem
  356.       with an ASP member by contacting the member directly, ASP may be able
  357.       to help. The ASP Ombudsman can help you resolve a dispute or problem
  358.       with an ASP member, but does not provide technical support for members'
  359.       products. Please write to the ASP Ombudsman at 545 Grover Road,
  360.       Muskegon, MI 49442-9427, U.S.A.  or send a CompuServe message via
  361.       CompuServe Mail to ASP Ombudsman 70007,3536 or FAX 616-788-2765.
  362.                                                                    Page 4
  363.  
  364.  
  365.                              -=O=-  USING SASM  -=O=-
  366.  
  367.       SAsm is a 'Transient' program. This means that when it is invoked by
  368.       typing it's name at the OS '*' prompt it is loaded from disc and Run.
  369.       This is not normally a problem because SAsm is quite compact, about
  370.       25K. If you have a hard disc put SAsm in your Library directory. If you
  371.       have only a single floppy drive then copy SAsm to each working disc, it
  372.       won't take up much disc space.
  373.  
  374.       From version 1.30 onward you will find two versions of SAsm on the
  375.       distribution disc. One is the transient application and this is
  376.       probably the best way to use SAsm if you have a hard disc as you can
  377.       simply copy it to your Library directory and it will automatically Run
  378.       whenever you type its name. The other version is a Relocatable Module
  379.       called SAsmMod. This will be the preferred method if you don't have a
  380.       hard disc. Just load the Module by double-clicking on it and it will
  381.       then run from the RMA whenever you type 'SASM' in exactly the same way
  382.       as the transient program runs from disc. The only disadvantage of the
  383.       Module is that it will take up an extra 25K or so of RAM in the RMA.
  384.  
  385.       Note that the Module version of SAsm does not actually run from the
  386.       RMA. When you invoke it the program code is copied down to &8000 and
  387.       run from there. It will therefore have the amount of RAM available that
  388.       you have set for the 'Next Slot' in the Task window.
  389.  
  390.       I anticipate that a version of SAsm with a complete desktop 'front end'
  391.       will appear in the near future but for the present you can run it from
  392.       within a 'Task' window if you wish.
  393.  
  394.  
  395.                Use from floppy discs
  396.                ---------------------
  397.       Although SAsm will obviously operate much faster from a hard disc it is
  398.       perfectly satisfactory when used on a machine without one. In fact it
  399.       was deliberately designed with floppy disc operation in mind. If you
  400.       have enough memory then you could create a large RAM disc to hold all
  401.       your files. The disadvantage of this is that if you modify the source
  402.       files and suffer some sort of crash before you remember to save the
  403.       modified files to disc you could lose part of your work.
  404.  
  405.       Because SAsm uses only fast block file operations to load the source
  406.       and save the object files it will still operate quite fast from floppy
  407.       discs. If you use the Module version of SAsm this will save the time
  408.       overhead of loading the assembler itself each time.
  409.  
  410.       The slowest file operations are associated with error, listing and
  411.       label cross-reference files as these are written line by line. The
  412.       obvious solution is therefore to direct all of these to the RAM disc
  413.       where the operations will be very much faster than a floppy. As these
  414.       files are normally only needed temporarily it will not matter if they
  415.       are lost. To further reduce disc access time you could save the object
  416.       file to the RAM disc and copy your macro library (if used) there.
  417.  
  418.                                                                    Page 5
  419.  
  420.  
  421.                Command line syntax
  422.                -------------------
  423.       The full syntax of the command string for SAsm is;
  424.  
  425.        SASM <source file list> [object filename] [error filename] [LXVQSNFA]
  426.  
  427.       Only <source file> is compulsory, the others are optional. This means
  428.       after *SASM leave one or more spaces and then type the name of your
  429.       source file(s). You can have as many as you like, separated by commas.
  430.       The full meaning of <source file list> is quite complex and for the
  431.       complete explanation read the section titled 'Source Filenames'.
  432.  
  433.       Because SAsm uses spaces a delimiters between command line fields you
  434.       must NOT put any spaces in your source file list.
  435.  
  436.       After the source file(s) leave a space then type the name of the Object
  437.       File. This is the name that will be given to your assembled code when
  438.       it is saved. If you don't type an Object Filename SAsm will assemble
  439.       all the files but won't save the finished product. It may seem strange
  440.       that you should wish to do this but if you just want to check for
  441.       errors or find out how long the finished code is it can be useful.
  442.  
  443.       The next parameter is the name of the Error File. Unlike the Basic
  444.       assembler SAsm will display error messages and try to continue with
  445.       assembly if it can. If you have many errors the first ones will soon
  446.       scroll off the screen and get lost. If you define a name for an error
  447.       file all the error messages will be sent to the file. This can be
  448.       loaded them into your Editor with the source code in another window so
  449.       you can find and correct them. If you use a Task Window you could
  450.       'capture' error messages in this but a separate error file is neater.
  451.  
  452.       After the three filenames you can type one or more single letter
  453.       parameters or 'switches'. These can be in in upper or lower case. If
  454.       you use more than one they should be separated by spaces. Most of these
  455.       duplicate or interreact with Directives in the files and so the
  456.       descriptions here are rather brief because more information will be
  457.       found in the section on Directives.
  458.  
  459.       The 'X' parameter will cross reference (X-ref) all labels in the source
  460.       and report any duplicates. If a duplicate is found a warning message is
  461.       displayed with the name of the label and the line number at which it
  462.       occurs. You can include this each time but normally it is only needed
  463.       the first time you link all your files as sometimes a duplicate label
  464.       is perfectly valid. For example I often use 'loop' or 'bak' repeatedly
  465.       and don't want a screen full of warnings. You can create a list of
  466.       duplicate names as a file by use of the #XRFILE directive (see later).
  467.  
  468.       'L' is used to force SAsm NOT to load any Macro definitions from the
  469.       Library, even if one exists. See the section on the Macro Library for
  470.       an explanation of this.
  471.  
  472.       'V' will make SAsm 'verbose' when loading Expanded Macros from a
  473.       Library. As each macro is loaded it's name is displayed. This is not
  474.       normally needed but it is included in case you want to check whether
  475.       SAsm is using a macro defined in the file or from the Library.
  476.                                                                    Page 6
  477.  
  478.  
  479.       'A' makes SAsm produce an Assembler Listing file. If 'A' is followed by
  480.       a filename this will be used, otherwise it will be saved to the current
  481.       directory with the name 'ListFile'. If you do wish to use the default
  482.       name for a listing file make sure that the 'A' command is the last item
  483.       on the line, otherwise it will 'grab' the next parameter as a filename.
  484.       You will find more information on assembler listing files later.
  485.       (NB- The more obvious 'L' isn't used for a listing file because it was
  486.       already allocated by the time this feature was included.)
  487.  
  488.       'F' formats an assembler listing file with labels at the left and
  489.       instructions indented.
  490.  
  491.       'S' switches on processing of SWI names. This is described fully in the
  492.       section on the SWION/SWIOFF directives.
  493.  
  494.       'Q' makes SAsm Quit after pre-processing is complete but before
  495.       assembly. This is useful if you get a serious error during assembly as
  496.       it lets you produce a listing without the possibility of a complete
  497.       'crash' during assembly.
  498.  
  499.       'N' will list all global label Names after pre-processing. This will be
  500.       in the form of list on the screen in alphabetical order. This switch
  501.       will stop a label cross-reference check so don't use 'X' and 'N' at the
  502.       same time. As this list is likely to be rather long you can use the
  503.       LABELFILE directive to save it to a file if you wish
  504.  
  505.  
  506.                Null Parameters
  507.                ---------------
  508.       You will notice that these names must appear in order. So what do you
  509.       do if you want an error file but no object file?, or a X-ref but no
  510.       Error or Object file? If these switches are defined within the source
  511.       there is no problem but most of the time this will not be the case as
  512.       you would only need x-ref or listing files for de-bugging purposes.
  513.       To permit switches to be used at the command line when one or more of
  514.       the file names is not present SAsm accepts the ~ character or any
  515.       filename beginning with ~ as the equivalent of no filename.
  516.  
  517.       For example, to assemble the source file 'My_Prog' without producing an
  518.       object file but listing all errors in the file 'Errors' you could use -
  519.  
  520.          *SASM  MyProg  ~  Errors
  521.  
  522.       If you use the '~' character in the object filename position you will
  523.       not get an object file even if a name is defined in the source file.
  524.       There is therefore a further alternative. If you use '!' as an object
  525.       filename SAsm will only produce an object file if the name is defined
  526.       in the source. The '!' character is interpreted as 'only produce an
  527.       object file when an OBJ directive exists'. This permits you to use
  528.       switches and an object file without needing to type a source file name.
  529.  
  530.                                                                    Page 7
  531.  
  532.  
  533.                Source Filenames
  534.                ----------------
  535.       The source filename list can be a single filename or a series of names
  536.       separated by commas. DON'T use spaces to separate the names because
  537.       SAsm regards a space as a field delimiter. This is important because if
  538.       you do use a space between source filenames and if SAsm is able to
  539.       successfully assemble the first file(s) the next name will be taken as
  540.       the object filename. This will result in the code being saved with this
  541.       name which will DESTROY the source file of the same name. Normally this
  542.       can't happen because the fact that some of the files aren't loaded will
  543.       produce errors but it could, so beware!
  544.  
  545.       Most users will probably use a 'make' file with 'INCLUDE' filenames to
  546.       assemble a project but you should understand the full command line
  547.       syntax to ensure that you know exactly how SAsm operates with
  548.       wildcarded filenames.
  549.  
  550.       To assemble the files  Start, Middle and End  in that order into the
  551.       object file  Code  you would use;
  552.  
  553.          *SASM  Start,Middle,End  Code
  554.  
  555.       This assumes the files are in the Currently Selected Directory (CSD).
  556.       Each name can of course have a path as well. If you have some standard
  557.       sub-routines called Subs in directory $.Source.Routines you could use;
  558.  
  559.          *SASM  Start,Middle,$.Source.Routines.Subs,End  Code
  560.  
  561.       SAsm loads the files in the order in which the names appear and treats
  562.       them as if they were one big file. You can therefore break the source
  563.       up into small chunks and sub routines which are easily edited. You may
  564.       find you have lots of standard routines that you want to assemble with
  565.       your program and you can put these in one or more separate files and
  566.       assembles them with each project.
  567.  
  568.       The easiest way to avoid all this typing is to program a function key
  569.       with the command. For the previous example if you type;
  570.  
  571.          *Key 5 *SASM Start,Middle,$.Source.Routines.Subs,End Code|M
  572.  
  573.       you need only press F5 to assemble your code. This saves the repetitive
  574.       typing but as the length of a function key string is limited to 255
  575.       characters it may not be enough to accommodate a long list of
  576.       path/filenames. SAsm therefore accepts wildcards in the source file
  577.       list. If you use a common part in all the filenames for a project this
  578.       feature can often enable you to assemble all the required files with
  579.       just a single wildcarded name.
  580.                                                                    Page 8
  581.  
  582.  
  583.                Reconciliation of Wildcards
  584.                ---------------------------
  585.       It might appear that no 'filtering' of wildcards in filenames is
  586.       necessary. If you put all the source files in sub-directory 'Source' of
  587.       the CSD then typing  *SASM  Source.*  Code  would assemble them all
  588.       into the object file Code with no problems. In real life things aren't
  589.       that simple. For example, if you make an alteration to one of your
  590.       source files but want to keep the original in case the change doesn't
  591.       work (always to be advised!). You make the alterations, change the name
  592.       of the original, and assemble the code. The only problem is that SAsm
  593.       would assemble BOTH files, the original and the new. You could avoid
  594.       this problem by moving the original to another directory but this would
  595.       soon become very tedious.
  596.  
  597.       SAsm has a rigid system of deciding which files to assemble. This was
  598.       designed to work with the way I write my source files. If you don't
  599.       like it let me know and I will try to accommodate your preferences but
  600.       please try my way first, it's the result of a lot of experience and you
  601.       might find you like it.
  602.  
  603.       SAsm works it's way through the list in order. It first finds all the
  604.       names which fit the wildcarded first name in your file list.
  605.  
  606.       SAsm rejects any file that doesn't have a filetype of 'Text' (FFF) or
  607.       'Data' (FFD). This avoids trying to load a previous object file or
  608.       other non-source file if it was saved to the same directory. As all
  609.       text editors on the Archimedes save output as 'Text' by default this
  610.       should not be a problem. If you do import a file from some other source
  611.       then its type will probably be 'Data' and if not you can easily change
  612.       it. If you get a 'File not found' error but can see that the file
  613.       exists it is probably because its filetype is not &FFF or &FFD.
  614.  
  615.       The remaining files which fit the wildcarded name are then examined and
  616.       loaded IN ALPHABETICAL ORDER. Any file which has a digit 0-9 at the end
  617.       of its name is examined and if it has the same name as the previous
  618.       file but with a different number it is ignored.
  619.  
  620.       What this means is that if you give all your source files a name ending
  621.       in a number the file with the LOWEST number will be loaded and the rest
  622.       ignored. This works because the lowest number is also the first
  623.       alphabetically. I start out at 99 and work my way down, so each version
  624.       is progressively called Name_99, Name_98, Name_97 etc. This system
  625.       operates beautifully with TWIN (Acorns non-desktop text editor) because
  626.       if I type 'Name*' as the filename to load into TWIN it will load the
  627.       one with the lowest number, ie. the latest. Within the desktop the
  628.       latest version will always be the first file in the directory viewer.
  629.  
  630.       When all the files with names which fit a wildcarded filename have been
  631.       loaded SAsm will get the next name on the list and so on until all the
  632.       names have been dealt with.
  633.  
  634.                                                                    Page 9
  635.  
  636.  
  637.                Order of Assembly
  638.                -----------------
  639.       Remember that SAsm assembles the files which can be matched to each
  640.       wildcarded name alphabetically. To return to the previous list with
  641.       'Start, Middle and End' if you use '*' to match all of these files then
  642.       they will be assembled in the order 'End, Middle, Start' which is not
  643.       what is required. As it is normally only the first and sometimes last
  644.       files whose order is important it is fairly easy to ensure that they
  645.       are assembled in the correct order by placing an extra digit at the
  646.       start of the name. For example renaming the files 'aStart, Middle,
  647.       zEnd' would ensure that they are assembled in the correct order while
  648.       retaining meaningful names.
  649.  
  650.       Since SAsm expands and reconciles wildcarded filenames in this way you
  651.       don't need any complicated 'make' utilities to assemble a long list of
  652.       source files. In fact the additional facilities offered by the INCLUDE
  653.       directive make this even simpler.
  654.  
  655.  
  656.                Length of Source Files
  657.                ----------------------
  658.       Because SAsm loads all the files into memory at once in might seem that
  659.       the total length of these files could not exceed the usual 640K (or
  660.       whatever you have set 'Next Slot' to) which is available as a Task. In
  661.       fact this is not the case. As SAsm loads each file it removes all the
  662.       spare spaces and assembler comments. If, like me, you indent every line
  663.       and use lots of comments you will probably find your source files
  664.       shrink to about 60% of their original size. Even allowing for the
  665.       memory required for variables, the assembler commands etc. you should
  666.       find that SAsm can load over 1MB of source with the usual 640K slot. If
  667.       you are writing programs which need more than this then perhaps you
  668.       should be writing your own assembler and trying to sell it to me!
  669.  
  670.  
  671.                Line number space
  672.                -----------------
  673.       When the pre-processed code is passed to the Basic assembler it must be
  674.       given line numbers so that Basic can understand it. This means that 3
  675.       bytes must be added to the start of each line. If there is not enough
  676.       room for this SAsm will attempt to relocate the file in memory. This is
  677.       unlikely to happen unless you have more than about 10,000 lines.
  678.  
  679.       It is possible that there isn't enough RAM available for relocation and
  680.       in this case SAsm will be unable to continue. If this happens there are
  681.       two possible solutions. The simplest is to make more RAM available.
  682.       Bring up the Task Manager window on the desktop and increase the size
  683.       of the 'Next Task' allocation. On a 1Mb machine you may need to 'kill
  684.       off' some tasks to be able to do this. If you cannot make more RAM
  685.       available you will need to reduce the number of lines in your source
  686.       file. There is no point in removing comments, column indents etc.
  687.       because by the time this error occurs they will all have been stripped
  688.       by SAsm anyway. However each line removed saves only three bytes so you
  689.       will need to remove a lot of them to make any real difference.
  690.  
  691.                                                                    Page 10
  692.  
  693.                A short demonstration
  694.                ---------------------
  695.       Copy the file SAsm and the complete 'Example' directory to a blank disc
  696.       in drive 0. Now press F12 to leave the desktop or CTRL-F12 to open a
  697.       Task Window and type 'MOUNT :0' at the OS '*' prompt. To assemble the
  698.       demonstration program type;
  699.  
  700.                SASM  Example.H*  Hello
  701.  
  702.       The disc drive will start and after the SAsm copyright line you should
  703.       see the messages;
  704.  
  705.                Loading Source Files:
  706.                Example.Hello_A
  707.                Example.Hello_B
  708.                Example.Hello_C_50
  709.                Pre-processing completed - starting assembly
  710.  
  711.                Pass 1
  712.  
  713.                Pass 2
  714.  
  715.                0 Errors
  716.                Code &xx bytes - Saved as 'Hello'
  717.  
  718.       You will find that a new file 'Hello' has appeared on the disc. To run
  719.       this program, which just displays a couple of messages, type 'Hello'.
  720.  
  721.       If you examine the contents of the directory Examples you will find
  722.       that as well as  Hello_A, Hello_B and Hello_C_50 (and several other
  723.       files) there is Hello_C_52. Since this file has a higher number than
  724.       Hello_C_50 it was ignored.
  725.  
  726.       Now repeat the exercise but hold down the SHIFT key when you press
  727.       RETURN after entering the SAsm command line as previously. Everything
  728.       will seem as before but this time when you type *Hello to RUN the
  729.       Object code some of the messages will be different. This is a simple
  730.       example of Conditional Assembly, some of the code being changed if the
  731.       SHIFT key is held down during asssembly.
  732.  
  733.       I suggest that you load these three files into Edit and examine them.
  734.       They are not a good example of compact or well written code but they do
  735.       illustrate the layout of a multiple SAsm source file. You will notice
  736.       the use of the Conditional Assembly section which produces the two
  737.       different versions. Note also that branch instructions can be used to a
  738.       label in another file demonstrating that labels are global.
  739.  
  740.       You will also see the use of a Macro Function 'print_string'. This
  741.       would be more efficiently coded using OS_Write0 but it illustrates how
  742.       Macros Functions are written and used.
  743.  
  744.       The files 'Local' and 'Immed' are examples to illustrate the use of
  745.       local labels, SAsm's simplified 2nd operand instructions and Expanded
  746.       Macro's. These may be assembled and examined in a similar manner.
  747.                                                                    Page 11
  748.  
  749.                           -=O=-  THE SOURCE FILE  -=O=-
  750.  
  751.  
  752.                Source file Syntax
  753.                ------------------
  754.       I will assume that the reader is familiar with the Basic Assembler.
  755.       Reference will be made to it and attention drawn to differences between
  756.       it and SAsm where they occur. Although the syntax used by SAsm is
  757.       similar to the Basic Assembler this applies only to the actual assembly
  758.       language itself. You can forget about square brackets, OPT, P%, O% and
  759.       all the things that are necessary before you can use the Basic
  760.       Assembler. The biggest change is that if you have previously used the
  761.       Basic Editor the source files for SAsm, like all assemblers, are TEXT
  762.       files and must NOT have line numbers.
  763.  
  764.       One of the nice features of SAsm is this similarity. This isn't an
  765.       accident. Firstly SAsm actually uses the Basic assembler to do much of
  766.       the work. Secondly it was designed from the start to be a 'step up'
  767.       from the Basic assembler so even it's most advanced features will be
  768.       very quickly mastered by anyone who is familiar with the Archimedes
  769.       'built-in' assembler.
  770.  
  771.       You won't therefore need to spend ages learning a whole new language
  772.       and you will be able to convert your old Basic assembler programs into
  773.       SAsm format very easily and quickly. Normally this takes only a few
  774.       minutes with a straightforward program.
  775.  
  776.  
  777.                General
  778.                -------
  779.       In the following section you will find references to various commands
  780.       being separated by spaces. In general if your Editor uses a Tab
  781.       character (ascii 9) to separate text into columns this character will
  782.       also be accepted. This may not be specified each time to avoid constant
  783.       repetition. If you do find that a Tab character won't work but a space
  784.       will please tell me and I'll try to make it work.
  785.  
  786.       In this Manual references are made to the 'hash' character '#' (the
  787.       character above the '3' on the main keyboard). If that appeared in your
  788.       printout as a  pound sign then your printer is set to the English
  789.       character set so you will just have to read the file as if it had
  790.       printed a hash. There are no pound characters in this Manual.
  791.  
  792.  
  793.                Important Warning
  794.                -----------------
  795.       SAsm makes use of the Basic integer variables O%, P% and Q%
  796.  
  797.       O% and P% are used conventionally by the basic assembler. Q% defines
  798.       the OPT setting during assembly. It is therefore vital that you do NOT
  799.       use or manipulate any of these variables unless you are absolutely sure
  800.       of what you are doing.
  801.  
  802.       Similarly the upper case names ADDR, TYPE, OSET and SIZE are reserved
  803.       words and must not be used as Basic variables.
  804.  
  805.                                                                    Page 12
  806.  
  807.  
  808.                Warnings and Errors
  809.                -------------------
  810.       In the following sections reference will be made to Warnings, Errors
  811.       and Fatal Errors.
  812.  
  813.       Warnings are issued if SAsm finds you have omitted or wrongly placed a
  814.       directive. The code will still be assembled and saved. Warnings will
  815.       not be written to the Error file.
  816.  
  817.       Errors are faults from which SAsm can recover but which make the code
  818.       useless. Unlike the Basic assembler SAsm will try to continue after an
  819.       error as there may be others to report, but the assembled code will not
  820.       be viable so no Object file will be produced. However if a Listing file
  821.       was specified then this will be produced.
  822.  
  823.       If SAsm finds an error in the first pass it will not attempt a second
  824.       pass. You may therefore need two attempts to correct all the errors.
  825.  
  826.       A Fatal Error is an error from which SAsm cannot recover or which is so
  827.       serious that there is no point in continuing. An error in a Macro
  828.       Function or a missing file are examples of Fatal Errors.
  829.  
  830.  
  831.                Comments
  832.                --------
  833.       SAsm defines a comment as EVERYTHING on a line after a semi-colon ';'
  834.       or a backslash '\'. SAsm therefore conforms to the syntax used by most
  835.       assemblers which differs from the Basic assembler. The Basic assembler
  836.       is almost unique in using the colon ':' as a statement delimiter. While
  837.       SAsm still recognises ':' and allows more than one mnemonic on a line
  838.       Basic regards ':' as the end of a comment and tries to assemble
  839.       anything on the line after a ':', even if the ':' is in a comment. For
  840.       example the following line using the Basic assembler;
  841.  
  842.           mov r1,#0 : \ mov r1,#1 : mov r2,#2
  843.  
  844.       would be assembled as  mov r0,#0  followed by  mov r2,#2  The middle
  845.       instruction would be ignored because Basic recognises the '\' and
  846.       regards it as a comment but continues assembling when it finds the ':'
  847.       later in the line. Using SAsm you would get ONLY  mov r1,#1  as
  848.       everything on the line after the '\' is a comment.
  849.  
  850.       The exception to this is where a semi colon (;) is not preceded by a
  851.       space or a Tab character (ascii 9). This has been done so that you can
  852.       use ';' in Basic PRINT statements to display information during
  853.       assembly. If you do use ';' in a line to define a comment make sure
  854.       that it is preceded by a space or a Tab or it will cause an error.
  855.  
  856.       If you want to use more text than can be fitted into a normal comment
  857.       then see the next section.
  858.                                                                    Page 13
  859.  
  860.                Descriptive text
  861.                ----------------
  862.       Sometimes you may want to put a block of descriptive text somewhere in
  863.       a source file. This is often required before a major routine to
  864.       describe what it does, entry conditions, register state on exit, etc.
  865.       Normally this is done by preceding each line of the text with a ';' or
  866.       '\' but this is rather tedious, and it's easy to miss a ';' and get
  867.       assembler errors. It is also a nuisance if you want to edit it later
  868.       because you must fiddle about with all the ;'s if you reformat it.
  869.  
  870.       Most high level compilers permit blocks of descriptive text between
  871.       certain markers and the text is ignored by the compiler. This is very
  872.       convenient and I have therefore introduced this feature into SAsm using
  873.       the curly brackets, { and }, as the delimiters.
  874.  
  875.       The { must be the first non space character on a line. Everything up to
  876.       the terminating } will then be completely ignored. The opening { can be
  877.       followed by text on the same line or on a line of its own.
  878.  
  879.       There is an important proviso with the closing bracket. It MUST be
  880.       preceded by a space, Tab, or be the first character on a line. If this
  881.       is not done it won't be recognised as terminating a descriptive text
  882.       insert and you'll get errors.
  883.  
  884.       The reason for this is that these two characters may also be used to
  885.       'blank out' sections of code you don't want to assemble. Instead of
  886.       needing a ';' in front of every line you can enclose the entire block
  887.       between { and }. This makes it a lot easier to avoid assembling
  888.       debugging code, etc. when you no longer need it but to restore it
  889.       simply when you do. If you use this feature for this purpose then, if
  890.       the requirement for a space before the closing } did not exist, there
  891.       would be a problem with LDM and STM instructions where the register
  892.       list is enclosed in the same characters. If you make sure that you
  893.       don't have a space before the closing } with your LDM and STM
  894.       instructions (not difficult) then you can use these characters to blank
  895.       out code containing those instructions.
  896.  
  897.       To make this even easier SAsm will ignore a closing } if it is the
  898.       first character on a line (unless, of course, it is actually the
  899.       terminator of a pair of {}'s). This would be an error under all normal
  900.       circumstances so it would never exist naturally. If you do use this
  901.       feature to blank out a section of code then to bring the code back into
  902.       use you need only delete (or 'comment out') the opening {, the closing
  903.       one will be ignored.
  904.  
  905.       Obviously if a } with a preceding space exists in the section you want
  906.       to blank out then you may get unexpected errors. The most likely cause
  907.       of this is a } in a comment, but this should be easy to check.
  908.  
  909.       In normal use only problems you are likely to encounter is if you
  910.       forget the closing } or if you don't precede it with a space. In this
  911.       case SAsm will either completely wipe out all the code up to the next
  912.       closing } it finds, which will probably produce a whole series of
  913.       errors, or it will quit with a Fatal Error if it comes to the end of
  914.       the file before it finds a closing }.
  915.                                                                    Page 14
  916.  
  917.  
  918.                Large source files
  919.                ------------------
  920.       Archimedes basic can load files in text format and this is the way that
  921.       SAsm normally operates. However Basic always insists upon numbering
  922.       programs in this format in 10's. The trouble with this is that Basic
  923.       can't accept line numbers greater than about 65,000 so this would limit
  924.       the maximum source file size to around 6500 lines. This only applies to
  925.       programs in text format, if the program is numbered in 1's instead of
  926.       10's then it can be over 65,000 lines long which is big enough for any
  927.       eventuality.
  928.  
  929.       For this reason if a file is longer than about 6500 lines it is
  930.       necessary for SAsm to tokenise it instead of leaving this process to
  931.       Basic. This is completely automatic, smaller programs will be left
  932.       untouched and larger ones will be tokenised. However in order to
  933.       simplify the SAsm code and to make the operation as fast as possible
  934.       this routine is not nearly as comprehensive as the system used by basic
  935.       itself. This is not normally a problem as most of the Basic keywords
  936.       would never be used in an assembler source file. All of the graphics
  937.       commands and many others have been omitted and will produce errors if
  938.       they are used.
  939.  
  940.       There is a possible conflict between the Basic operators AND, EOR and
  941.       OR and the assembler mnemonics AND, EOR and ORR. In theory the SAsm
  942.       tokeniser can distinguish between these when used as mnemonics and when
  943.       used as operators but circumstances could exist where it could become
  944.       confused. Obviously this can't happen if the mnemonics are written in
  945.       lower case. In fact with larger programs you are advised to use lower
  946.       case for ALL mnemonics as this makes the tokenising very much faster.
  947.  
  948.       There is also room for confusion if you use any variables with names
  949.       that include Basic keywords. Basic itself will always recognist
  950.       'theORy' as a variable but the SAsm tokeniser might, under some
  951.       circumstances, try to tokenise the 'OR'. With well written source code
  952.       this shouldn't be a problem as normally variables have lower case
  953.       letters or use capitals as word delimiters but you should be aware of
  954.       the possibility of problems.
  955.  
  956.  
  957.                Basic keywords accepted
  958.                -----------------------
  959.       These are the only Basic keywords that can be used in an SAsm source
  960.       file longer than 6500 lines. There is no reason why others can't be
  961.       added, I just couldn't think of any reason to include them. If you do
  962.       have a real need then please tell me.
  963.  
  964.       ABS, AND, ASC, CALL, CASE, DATA, DEF, DIV, ELSE, ENDCASE, ENDIF,
  965.       ENDPROC, ENDWHILE, EOR, EVAL, FALSE, FN, FOR, GET, IF, INKEY, INSTR,
  966.       LEFT$, LOCAL, MID$, MOD, NEXT, NOT, OF, ON, OR, OTHERWISE, PRINT, PROC,
  967.       READ, REM, REPEAT, RESTORE, RIGHT$, SPC, STEP, STR$, STRING$, SYS,
  968.       THEN, TO, TRUE, UNTIL, VAL, WHEN, WHILE
  969.  
  970.                                                                    Page 15
  971.  
  972.  
  973.                Directives
  974.                ----------
  975.       It is possible to include 'Directives' in your source. In fact some
  976.       directives are necessary for the proper operation of SAsm. Any line in
  977.       which the first non-space character is '#' is a directive. If SAsm
  978.       doesn't recognise what follows the '#' it will assume it is a valid
  979.       Basic statement and the line after the '#' will be passed to Basic.
  980.  
  981.       You can use SAsm without any preliminary directives in your source
  982.       file. Unlike the Basic assembler you can begin by writing mnemonics
  983.       straight away. If you do this SAsm will start assembling your code to
  984.       run from '0000'. This doesn't matter as SAsm will normally produce
  985.       position independent code unless you have included specific references
  986.       to addresses within your source.
  987.  
  988.       The '#' character can have spaces before and after it to improve
  989.       legibility if you wish, they will be ignored, but it MUST be the first
  990.       non-space character on the line. Directives should be the only item on
  991.       the line although you may include comments.
  992.  
  993.       All directives are case insensitive. Where a directive is to be passed
  994.       to Basic it's case and syntax must conform to that required by Basic.
  995.       Where a comment is included in a directive which is to be passed to
  996.       Basic it can still be preceded by ';' or '\' rather than REM, but see
  997.       the note under 'Comments' above.
  998.  
  999.       There must be at least one space after a directive where it is followed
  1000.       by one or more parameters.
  1001.  
  1002.  
  1003.                Directives and Basic variables
  1004.                ------------------------------
  1005.       Because of the way that SAsm passes unrecognised 'directives' to Basic
  1006.       this could create difficulties if you use any of the SAsm directives as
  1007.       Basic variables. This will not of itself cause problems, for example,
  1008.       there is no reason why you could not have a register called 'org'.
  1009.       However you should be careful how you define such items, eg. using -
  1010.  
  1011.                # include = 7
  1012.  
  1013.       to set a Basic variable 'include' to 7 would create difficulties
  1014.       because SAsm would recognise 'include' as one of its own directives and
  1015.       try to interpret it. However -
  1016.  
  1017.                # fred = 6 : include = 7
  1018.  
  1019.       would be OK, because SAsm wouldn't recognise 'fred'. Similarly -
  1020.  
  1021.                # include=7
  1022.                # include%=7
  1023.                # include_it = 7
  1024.  
  1025.       would also be OK because in all cases there is no space following
  1026.       'include' as required by SAsm.
  1027.                                                                    Page 16
  1028.  
  1029.  
  1030.       In general you are advised to avoid using any SAsm directives as
  1031.       variables or constants because this could be a source of strange
  1032.       errors. Remember also that all SAsm directives are case insensitive so
  1033.       this would apply to include, INCLUDE, Include, etc.
  1034.  
  1035.       The upper case versions of the directives ADDR, TYPE and SIZE, are
  1036.       reserved words and must not be used as variables anywhere in your code.
  1037.  
  1038.  
  1039.                #ORG
  1040.  
  1041.       Defines the address the code will be assembled to run at. The syntax is
  1042.       # ORG <number> where <number> is a valid address. <number> will be
  1043.       assumed to be in hex whether or not it is preceded by a '&' character.
  1044.  
  1045.       If no #ORG directive is found assembly will start at location 0 and a
  1046.       warning message will be displayed. The #ORG directive must obviously
  1047.       appear before the first assembler statement. If an #ORG directive is
  1048.       found after this a warning message will be displayed and the code will
  1049.       be assembled to start at location 0. This does not apply if you have
  1050.       defined TYPE (see later) as 'Absolute', 'Module' or 'Utility' because
  1051.       these filetypes, which are the most commonly used, all have 'standard'
  1052.       load and execution addresses.
  1053.  
  1054.       There must be at least one space between the word 'org' and the number
  1055.       which follows. This applies to all the following directives.
  1056.  
  1057.       Note - ORG replaces the ADDR directive used in early versions. ADDR is
  1058.       still supported for backwards compatibility but ORG should be used in
  1059.       new work as ADDR may be dropped in the future.
  1060.  
  1061.  
  1062.                #SIZE
  1063.  
  1064.       This advises SAsm of the expected size of the code so it can reserve a
  1065.       large enough buffer for it. The full syntax is #SIZE <number> where
  1066.       <number> is the estimated maximum size of the code. <number> will be
  1067.       assumed to be in hex whether or not it is preceded by a '&' character.
  1068.  
  1069.       If there is no #SIZE directive before the first assembler statement a
  1070.       warning will be given and 64K will be allocated for the code. Any #SIZE
  1071.       directives after the first assembler statement will be ignored.
  1072.  
  1073.  
  1074.                #END
  1075.  
  1076.       This takes no parameters and should be placed at the end of your
  1077.       assembler and before any Macro Function definitions. Anything after
  1078.       #END will be passed to Basic without the need for a '#' at the
  1079.       beginning of the line. When SAsm finds #END it assumes it has reached
  1080.       the end of the code and everything else is Macro Function definitions
  1081.  
  1082.       If DEFFN is found at the start of a line indicating that a Macro
  1083.       Function definition has been found before an #END directive a warning
  1084.       will be given and all subsequent lines will be passed to Basic.
  1085.                                                                    Page 17
  1086.  
  1087.  
  1088.                #TYPE
  1089.  
  1090.       This defines the filetype you wish your assembled code to have. Syntax
  1091.       is #TYPE <filetype> where <filetype> is a valid Archimedes filetype. If
  1092.       <filetype> is a number it should be in hex, though it need not be
  1093.       preceded by a '&' character. If it is a textual representation of a
  1094.       filetype it may or may not be in quotes, for example -
  1095.  
  1096.                      # type FF8
  1097.                      # type "Absolute"
  1098.                      # type Module
  1099.  
  1100.       If you do not include #TYPE the assembled code will be saved as an
  1101.       absolute block of memory with no filetype. The most common filetypes
  1102.       are &FFC for a position independent Utility, &FF8 for an Application to
  1103.       be loaded and Run at &8000 and &FFA for a Relocatable Module.
  1104.  
  1105.       Unlike the previous examples #TYPE can appear anywhere in the source.
  1106.       If more than one #TYPE directive appears the last one will be used.
  1107.  
  1108.  
  1109.                #OBJ
  1110.  
  1111.       Defines the name of the Object file. The syntax is #OBJ <filename>
  1112.       where <filename> can be any valid path/filename. If you type an object
  1113.       name at the Command Line it will override any #OBJ directive. You can
  1114.       therefore include an #OBJ directive in the source but assemble a
  1115.       different version if you choose by typing an Object name at the CLI.
  1116.  
  1117.  
  1118.                #ERRFILE
  1119.  
  1120.       Followed by a path/file name this defines the error filename to be
  1121.       used. Again an error filename typed at the command line will override
  1122.       this directive.
  1123.  
  1124.  
  1125.                #LIB
  1126.  
  1127.       Defines the Library file to be used. LIB should be followed by a
  1128.       path/file name. This overrides any Library defined in the SAsm$Lib
  1129.       variable.
  1130.  
  1131.       Using #LIB without a filename will force SAsm NOT to use a Library and
  1132.       so is equivalent to the command line 'L' switch.
  1133.  
  1134.  
  1135.                # VERBOSE
  1136.  
  1137.       Equivalent to the command line 'V' switch to force display of names of
  1138.       macros inserted from a Library. The advantage over the 'V' command line
  1139.       switch is that it can be inserted at any point and so need not show all
  1140.       the expanded macros, only those used after the directive is used.
  1141.  
  1142.                                                                    Page 18
  1143.  
  1144.  
  1145.                # QUIET
  1146.  
  1147.       Switches off display of macro names. You can use this with 'verbose' as
  1148.       often as you wish to switch on and off display of expanded macro names.
  1149.  
  1150.  
  1151.                #INCLUDE
  1152.  
  1153.       This allows additional files to be 'included' as well as the ones
  1154.       specified at the command line. The word INCLUDE should be followed by
  1155.       at least one space and then a single filename. Unlike files loaded from
  1156.       the command line only the first file which matches the required name
  1157.       will be used and no checks will be made on its filetype.
  1158.  
  1159.       The INCLUDE directive in SAsm is different from its equivalent in 'C'.
  1160.       SAsm does NOT 'insert' the file at the point at which the directive
  1161.       occurs. There is another directive INSERT which performs this function
  1162.       but this is not intended to be used for assembler source files.
  1163.  
  1164.       INCLUDE creates a 'queue' of INCLUDE filenames. When it reaches the end
  1165.       of the current file it goes to this list and loads the first name in
  1166.       the queue. When that file has been dealt with it loads the next name
  1167.       and so on until the queue is empty. If one of the 'include' files
  1168.       contains more INCLUDE directives these names are added to the END of
  1169.       the queue. When the queue is empty SAsm returns to the filenames
  1170.       specified at the command line and carries on as before. INCLUDE files
  1171.       can therefore have further INCLUDE directives which can contain their
  1172.       own INCLUDE's and so on.
  1173.  
  1174.       If you have a complex program which consists of lots of small pieces of
  1175.       code and sub-routines you can create a 'master' file which will contain
  1176.       the #ORG, #TYPE etc. directives and then a list of #INCLUDE directives
  1177.       to define the files required to make up the program. This operates in
  1178.       the same way as 'Make' files for other assemblers and compilers. SAsm
  1179.       will simply load each INCLUDE file in your 'primary' file in the order
  1180.       in which you have listed them. As INCLUDE files are subject to similar
  1181.       discrimination to filenames typed at the command line the 'trailing
  1182.       number suffix' system can be used to assemble the latest versions.
  1183.  
  1184.       For example, a file containing just the following would assemble the
  1185.       named files with the lowest trailing numbers in the chosen order.
  1186.  
  1187.                # type     Absolute
  1188.                # size     1000
  1189.                # include  start_*
  1190.                # include  middle_*
  1191.                # include  end_*
  1192.  
  1193.                                                                    Page 19
  1194.  
  1195.  
  1196.                #INSERT
  1197.  
  1198.       This is used to 'insert' the file whose name follows into the code at
  1199.       that point. Unlike INCLUDE it is inserted directly into the code at the
  1200.       point at which the directive occurs. No filetype checking is carried
  1201.       out and only the first file found with a matching name is loaded.
  1202.  
  1203.       The file is not inserted during preprocessing but during assembly. It
  1204.       therefore cannot contain SAsm format assembler source but would
  1205.       normally consist of data required by the code. This could be sprites,
  1206.       screen images, templates, text or any other form of data. It could even
  1207.       be pre-assembled machine code although this is not likely to be usual.
  1208.  
  1209.       To reduce disc access the assembler merely 'makes room' on the first
  1210.       pass and actually loads the data on the second. Code or data following
  1211.       an INSERT directive will automatically be double-word aligned in case
  1212.       the file is of 'odd' size.
  1213.  
  1214.  
  1215.                #AREA
  1216.  
  1217.       This is intended to simplify setting up Data Area consisting of a
  1218.       series of bytes or words to be accessed using LDR Rx,[<reg>,#<offset].
  1219.       Normally this is done by reserving an area of memory in some way and
  1220.       defining each individual offset line like this -
  1221.  
  1222.           .my_data   db *80,?      ;reserve 80 bytes
  1223.  
  1224.           # first  = 4
  1225.           # second = 8
  1226.           # third  = 12
  1227.  
  1228.       and so on. You would then use instructions such as -
  1229.  
  1230.           ADR R8,label             ;make R8 point to the data
  1231.           LDR R4,[R8,#second]
  1232.           STR R2,[R8,#third]
  1233.  
  1234.       The problem with this method of setting up a data area is that every
  1235.       offset must be calculated 'by hand' and if you make a mistake the data
  1236.       can become corrupted during the running of the program. Also if you
  1237.       want to change the size of an item, for example, to increase a byte
  1238.       sized item to a word, then every other offset will need to be
  1239.       recalculated. Not only tedious but easily leading to mistakes.
  1240.  
  1241.       The AREA directive is designed to make this type of data area much
  1242.       easier to define. It automatically sets the value of each offset and
  1243.       calculates and allocates the amount of space required. The syntax is
  1244.       very simple, but you will need to take careful note of exactly how it
  1245.       works to avoid errors.
  1246.  
  1247.       At present (version 1.53) this directive works perfectly but it may not
  1248.       be very 'robust' and so it is possible that if you use it wrongly you
  1249.       might get strange errors. I will try to introduce more error trapping
  1250.       in future and add some extra features.
  1251.  
  1252.                                                                    Page 20
  1253.  
  1254.       A data area is declared by the #AREA directive and this is followed by
  1255.       the name to be used to refer to it and the size of the first item, eg -
  1256.  
  1257.           # area  my_data  4
  1258.  
  1259.       'my_data' will then become a normal Global Label and can be addressed
  1260.       just like any other label. You can use LDR/STR instructions with it if
  1261.       you wish or ADR/ADRL to make a register point to it.
  1262.  
  1263.       The important part comes next. Following the first line you can
  1264.       introduce a series of 'pointers' into this data area, defining the size
  1265.       of each as you do so. Note that unlike the normal method of doing this
  1266.       you define the SIZE of each item, not its offset from the start. To
  1267.       reproduce the previous example using the AREA directive -
  1268.  
  1269.           # area   my_data  4
  1270.  
  1271.                first    4
  1272.                second   4
  1273.                third    4
  1274.  
  1275.           # ea
  1276.  
  1277.       Note that the AREA block is terminated by an #EA (End Area) directive.
  1278.  
  1279.       This will produce exactly the same results as the previous example but
  1280.       it is MUCH easier to set up. Instead of working out the offset of each
  1281.       pointer all you need to do is to follow its name with the size of the
  1282.       item that you want to put there. In this example each item will have
  1283.       four bytes allocated. If you wanted single bytes you would use -
  1284.  
  1285.  
  1286.           # area   my_data  1
  1287.  
  1288.                first    1
  1289.                second   1
  1290.                third    1
  1291.  
  1292.           # ea
  1293.  
  1294.       Obviously sizes can be mixed. Note that te number in the first
  1295.       declaration line defines the size of the first item which would
  1296.       normally be accessed by -
  1297.  
  1298.           LDR R0,[<reg>]    or    LDR R0,[my_data]
  1299.  
  1300.       As this item has an offset of 0 there is no need to define one for it.
  1301.       If you really do want to always refer to the first item with an offset
  1302.       then simply set the 'size' of this item to '0' so that the pointer
  1303.       defined on the following line will have an offset of 0.
  1304.  
  1305.       If you mix the sizes of items within a data area you may need to reset
  1306.       the pointer to ensure that word size section will be word aligned. This
  1307.       can be done in the normal way with an ALIGN instruction. In fact this
  1308.       instruction works differently when used in this context but its action
  1309.       is the same as usual.
  1310.  
  1311.                                                                    Page 21
  1312.  
  1313.       To illustrate this using mixed sizes as in the previous example -
  1314.  
  1315.           # area   my_data  1
  1316.  
  1317.                first    1
  1318.             align
  1319.                second   4
  1320.                third    4
  1321.  
  1322.           # ea
  1323.  
  1324.       This will ensure that 'second' and 'third' have word aligned values.
  1325.  
  1326.       Note that this will ONLY be true if the START of the data area is word
  1327.       aligned. This will normally be the case but if in doubt use 'align' on
  1328.       the line BEFORE the #AREA directive. Similarly if you have used odd
  1329.       sizes items in your data area you should follow it with 'align' to
  1330.       ensure that any code or data which follows is word aligned.
  1331.  
  1332.       Within the confines of an AREA directive, ie. between #area and #ea,
  1333.       only the structures shown above are permitted. No assembler mnemonics
  1334.       or any other directives or statements are permitted. Items must be
  1335.       placed one per line exactly as shown. You can have comments, preceded
  1336.       by the usual ';' or '\', either following an item on the same line or
  1337.       on lines of their own. You can have blank lines if you wish.
  1338.  
  1339.       If any line in an AREA begins with a '#' character that will terminate
  1340.       the area. In fact, you don't really need an #ea directive, # on its own
  1341.       will do. However you are advised to use #ea for clarity. If an AREA
  1342.       operation is terminated before the end because of an error you may get
  1343.       various error messages depending upon exactly what the cause was. You
  1344.       may also get an '#EA directive found when not in Data Area' message.
  1345.  
  1346.       At present the data in the area is not preset to any value. I may add a
  1347.       feature to do this at some time in the future.
  1348.  
  1349.  
  1350.                Multiple data areas
  1351.                -------------------
  1352.       You may have realised that every offset defined by the AREA directive
  1353.       becomes a Global Variable. This makes it possible to define a series of
  1354.       identical data areas and use the same offsets to access them. This
  1355.       would be particularly useful in programs which operate upon more than
  1356.       one set of data at the same time.
  1357.  
  1358.       To return to the previous example if you subsequently used -
  1359.  
  1360.           .label_2  db *40,?
  1361.  
  1362.       to reserve some space for a second area. Now -
  1363.  
  1364.                ADRL R8, label_2
  1365.                LDR R1,[R8,#second]
  1366.  
  1367.       will address an identical offset in the second area.
  1368.  
  1369.  
  1370.                                                                    Page 22
  1371.  
  1372.                #LISTON
  1373.  
  1374.       This will create a file which will contain an assembler listing. It may
  1375.       be followed by an 'F' which will produce a 'formatted' listing. The
  1376.       listing file will not start at the beginning of the source code but at
  1377.       the point at which the LISTON directive occurs. (See later section on
  1378.       Assembler Listing)
  1379.  
  1380.  
  1381.                #LISTOFF
  1382.  
  1383.       Marks the point at which the assembler listing file will cease.
  1384.  
  1385.  
  1386.                #LISTFILE
  1387.  
  1388.       Sets the name to be used for an assembler listing file.
  1389.  
  1390.  
  1391.                #NOENHANCE
  1392.  
  1393.       Switches off the second operand enhancements (see later). Included for
  1394.       untidy programmers who insist upon using instructions like MOV 1,2.
  1395.  
  1396.  
  1397.                #ENHANCE
  1398.  
  1399.       Switches second operator enhancements on again. This is the default.
  1400.  
  1401.  
  1402.                #XREF
  1403.  
  1404.       Switches on label cross reference. Once again the advantage of this
  1405.       over the 'X' switch is that it only takes effect from the point at
  1406.       which it appears.
  1407.  
  1408.  
  1409.                #NOXREF
  1410.  
  1411.       Switches off label cross reference. Can be used as often as required
  1412.       with the previous command to toggle x-ref on and off.
  1413.  
  1414.       There is an obvious interaction between the 'X' command line parameter,
  1415.       the XREF directive and this directive. The x-ref will begin at the XREF
  1416.       directive unless the 'X' command line parameter is used, in which case
  1417.       it will start at the beginning of the first file. It will finish at the
  1418.       NOXREF directive if one appears, if not at the end of the last file.
  1419.  
  1420.       XREF and NOXREF can appear more than once in the files. The function
  1421.       will simply be switched on or off as they are encountered. Beware of
  1422.       leaving NOXREF directives scattered in your files. They could cause the
  1423.       x-ref to be disabled without you realising it and therefore prevent
  1424.       duplicate labels from being revealed.
  1425.                                                                    Page 23
  1426.  
  1427.  
  1428.                #XRFILE
  1429.  
  1430.       Followed by a filename this sets the name to be used for the label
  1431.       x-ref file if this is required. If duplicate labels are to be saved as
  1432.       a file they will not be displayed on screen, only the total number of
  1433.       duplicated names found will be shown. If no x-ref filename directive
  1434.       appears the listing will appear only on screen. If the XRFILE directive
  1435.       appears without a following filename then the default filename of
  1436.       'xr_file" will be used.
  1437.  
  1438.       When shown on screen SAsm prints a message in the form -
  1439.  
  1440.         Warning : Duplicate label '<label>' at line <line number>
  1441.  
  1442.       where <label> is the duplicated label and <line number> is the number
  1443.       of the line on which the duplicate was found. There is no need to show
  1444.       the name of the file in which the duplicate was found because this will
  1445.       already have been displayed as SAsm loaded it. However when a duplicate
  1446.       list is saved as a file these filenames don't appear and so the name of
  1447.       the file in which each duplicate was discovered will also be shown.
  1448.  
  1449.       Note that this directive doesn't actually initiate the x-ref function.
  1450.       It just ensures that if the operation is enabled either from the
  1451.       command line or by the XREF directive then a file will be created. The
  1452.       directive must appear before the first label in the file or the file
  1453.       will not be created until the directive does appear. The obvious place
  1454.       for it is at the start of the file so that if you do invoke the x-ref
  1455.       function at any time the file will be available.
  1456.  
  1457.  
  1458.                                                                    Page 24
  1459.  
  1460.  
  1461.                #SWION
  1462.  
  1463.       This switches on processing of SWI names. Normally if you wish to use
  1464.       the textual version of a SWI it must be enclosed in double quotes, eg
  1465.  
  1466.           SWI "OS_WriteC"
  1467.  
  1468.       Once this command or the command line 'S' switch has been used there is
  1469.       no need for the quotes, so you can simply use -
  1470.  
  1471.           SWI OS_WriteC
  1472.  
  1473.       It will also interpret any SWI number beginning with a '0' as a hex
  1474.       number, so that 'SWI 020' would be number 20 hex, 32 decimal, and not
  1475.       20 decimal.
  1476.  
  1477.       There are potential problems with this system which is why it is not
  1478.       made the default but must be deliberately activated. SAsm assumes that
  1479.       the parameter following a SWI instruction is a string if the first
  1480.       character is an upper case letter (A-Z). This works because the names
  1481.       of all Archimedes SWI calls begin with a capital letter. So far as I am
  1482.       aware this also applies to all third-party modules. If a name begins
  1483.       with a lower case letter it will not be recognised and will produce an
  1484.       error. The more likely problem would arise if you define constants for
  1485.       some SWI numbers. All will be well if you give these names beginning
  1486.       with a lower case letter but if a name begins with a capital letter
  1487.       SAsm would regard it as a text version of a SWI and this would again
  1488.       produce an error.
  1489.  
  1490.       In general you should not experience any difficulties if you ensure
  1491.       that if you do wish to use a SWI name which begins with a lower case
  1492.       letter you enclose its name in quotes and if you define constants for
  1493.       any SWI numbers you make sure that their name does not begin with a
  1494.       capital letter.
  1495.  
  1496.  
  1497.                #SWIOFF
  1498.  
  1499.       Switches off SWI name processing described above.
  1500.  
  1501.  
  1502.                #CLI
  1503.  
  1504.       Anything on the line after this directive will be passed DIRECTLY to
  1505.       the Archimedes operating system Command Line Interpreter. It is
  1506.       equivalent to a '*' command used in a Basic program. It is not like the
  1507.       Basic 'OSCLI' command as no substitution is carried out first. You
  1508.       should not put comments on the line after a #CLI directive.
  1509.  
  1510.                                                                    Page 25
  1511.  
  1512.  
  1513.                #LABELFILE
  1514.  
  1515.       The 'N' command line switch has already been described. This switch
  1516.       will produce a sorted list on screen of all the global labels that SAsm
  1517.       finds in the source files. Obviously this list can be very long and so
  1518.       the LABELFILE directive allows the label list to be sent to a file.
  1519.  
  1520.       As with other filename directives it should be followed by at least one
  1521.       space and then a path/file name. If the directive appears but without a
  1522.       following name then the default name 'LabelFile' will be used.
  1523.  
  1524.       This directive does not actually initiate a label listing, it just
  1525.       ensures that if you do want one it will go to a file and not to the
  1526.       screen. You can therefore place it in your source and if you do need a
  1527.       label listing at any time it will be in the form of a file. If the list
  1528.       is to be sent to a file the message-
  1529.  
  1530.                Creating label list file '<filename>'
  1531.  
  1532.       will be displayed and the label list will not be displayed on screen.
  1533.  
  1534.       As with the screen display of labels they are arranged one per line in
  1535.       alphabetical order. The 'sorting' of names is case sensitive so 'Exit'
  1536.       will come before 'exit' and 'aAdvark' before 'aadvark'.
  1537.  
  1538.       As well as the 'N' switch there is a 'shortcut' which will produce a
  1539.       label list. If you hold down both SHIFT keys as you press RETURN when
  1540.       you type the SAsm command line this will initiate a label list just as
  1541.       if you had used the 'N' switch. As usual whether the list is to screen
  1542.       or a file will depend upon whether you have included the LABELFILE
  1543.       directive or not.
  1544.  
  1545.                                                                    Page 26
  1546.  
  1547.  
  1548.                Defining Registers
  1549.                ------------------
  1550.       To simplify writing code it is normal to give the C.P.U. registers
  1551.       names and define various other constants. In Basic this is done by
  1552.       assigning the chosen name a number using the syntax  <name>=<number>.
  1553.       The same method is used with SAsm except that you must precede your
  1554.       definitions with '#'. For example, to define register 5 as 'count' and
  1555.       register 6 as 'flag'
  1556.  
  1557.                                # count = 5
  1558.                                # flag = 6
  1559.  
  1560.       or alternatively
  1561.  
  1562.                                # count=5:flag=6
  1563.  
  1564.       R13,R14 and R15 are pre-defined as 'sp', 'link' and 'pc' in upper and
  1565.       lower case as these are the normal definitions for these registers. All
  1566.       registers are pre defined as their equivalent 'r' and 'R' numbers.
  1567.       Basic doesn't recognise a number like 'r4' as meaning register number 4
  1568.       except when it is an assembler operand. If you try to pass 'r4' as a
  1569.       parameter an error would be generated. With SAsm you can use r0-r15 or
  1570.       R0-R15 as they have been pre defined.
  1571.  
  1572.       You can use this method to define SWI's, offsets in a data area, in
  1573.       fact anything you wish. Since these are normal Basic variables you can
  1574.       use integer and string variables if required.
  1575.  
  1576.  
  1577.                Defining constants
  1578.                ------------------
  1579.       Most source code begins with a long list of constant definitions. For
  1580.       example, you will probably want to give names to registers, use
  1581.       variables to define the size of data areas and buffers, string
  1582.       variables for program version and support file names etc. This could,
  1583.       of course, be done as described above with a series of '#' statements
  1584.       but it is more elegant to use a standard Basic procedure.
  1585.  
  1586.       Remember that everything after the #END statement is just normal Basic.
  1587.       Therefore you can write a perfectly ordinary procedure after #END to
  1588.       define all your constants. Then, at the start of the first file, before
  1589.       the first assembler statement, put a call to this procedure, eg.
  1590.  
  1591.                # PROCdefine
  1592.  
  1593.       This will call the procedure and define all your constants.
  1594.  
  1595.       There is one unusual feature of SAsm that you must remember. Everything
  1596.       from the start of the file up to the END directive is within the
  1597.       assembler loop. As it is a two pass assembler all constant declarations
  1598.       and procedures are enacted before each assembler pass. In the previous
  1599.       example PROCdefine would also be called before the second pass. This is
  1600.       not normally of any consequence unless you have deliberately altered a
  1601.       variable at some stage in the program. If you have done so you should
  1602.       be aware that it will be reset before the second pass.
  1603.                                                                    Page 27
  1604.  
  1605.  
  1606.                Conditional Assembly
  1607.                --------------------
  1608.       This works as with the Basic assembler. The most common method is using
  1609.       IF THEN, (ELSE), ENDIF.  If you are unfamiliar with this technique
  1610.       please read the 'Tutorial' file which explains it.
  1611.  
  1612.       With SAsm there is no need to bother with assembler brackets, etc. Just
  1613.       put '#' in front of the lines which form the conditional block.
  1614.  
  1615.                # IF <condition> THEN
  1616.                   .........            ; some code
  1617.                   .........
  1618.                   .........
  1619.                # ELSE
  1620.                   .........            ; the alternative code
  1621.                   .........
  1622.                   .........
  1623.                # ENDIF
  1624.  
  1625.       Don't forget the 'THEN' at the end of the 'IF' line. The 'ELSE' section
  1626.       is of course optional.
  1627.  
  1628.       If an error occurs in a conditional section you may find subsequent
  1629.       'ELSE found without IF' or 'ENDIF found without IF' errors occurring.
  1630.       This is not significant, it just means the assembler has 'forgotten' it
  1631.       was in a conditional section when the original error was discovered.
  1632.  
  1633.       There is no reason why you cannot use other methods for more complex
  1634.       multiple choice options. For example the CASE statement could be used.
  1635.  
  1636.                # CASE <condition> OF
  1637.                # WHEN <condition 1>
  1638.                   .........            ; some code
  1639.                   .........
  1640.                   .........
  1641.                # WHEN <condition 2>
  1642.                   .........            ; some code
  1643.                   .........
  1644.                   .........
  1645.                # WHEN <condition 3>
  1646.                   .........            ; some code
  1647.                   .........
  1648.                   .........
  1649.                # OTHERWISE
  1650.                   .........            ; the alternative code
  1651.                   .........
  1652.                   .........
  1653.                # ENDCASE
  1654.  
  1655.       The OTHERWISE section is, of course, optional.
  1656.  
  1657.                                                                    Page 28
  1658.  
  1659.  
  1660.                LDM and STM instructions with Writeback
  1661.                ---------------------------------------
  1662.  
  1663.       The LDM/STM instructions are primarily used for stack management
  1664.       although they can be used for multiple register transfer to and from
  1665.       memory. Usually they will be used with Writeback in the form -
  1666.  
  1667.                LDMIA <reg> !,{ <register list> }
  1668.  
  1669.       Using the Basic assembler it is necessary to leave a space between
  1670.       <reg> and the '!' character. If this is not done then the Basic
  1671.       assembler isn't bright enough to interpret the instruction correctly
  1672.       and assumes that you are using some sort of contorted indirection to
  1673.       define your pointer register and tries to interpret the '!' as an
  1674.       indirection operator. This means that something like -
  1675.  
  1676.                STMIA sp !,{pc,link}
  1677.  
  1678.       is required with a space before the '!'
  1679.  
  1680.       On the assumption that you are probably not doing anything like this
  1681.       SAsm permits the use of the '!' character without an intervening space
  1682.       so that the more natural -
  1683.  
  1684.                STMIA sp!,{pc,link}
  1685.  
  1686.       is permitted.
  1687.  
  1688.  
  1689.  
  1690.                Assembly Loops
  1691.                --------------
  1692.       When using the Basic assembler it is common to use FOR-NEXT loops to
  1693.       fill an area of memory, eg.
  1694.  
  1695.                ........            ;normal code
  1696.                ]                   :REM exit assembler
  1697.                FOR I%=0 TO 255
  1698.                [ OPT PASS
  1699.                EQUB &FF            ;fill 256 bytes with &FF
  1700.                ]
  1701.                NEXT
  1702.                [ OPT PASS          ;back to assembler again
  1703.                ........            ;normal code
  1704.  
  1705.       You could still use this method with SAsm if you wish but it is simpler
  1706.  
  1707.                ........            ;normal code
  1708.                # FOR I%=0 TO 255
  1709.                EQUB &FF
  1710.                # NEXT
  1711.                ........            ;normal code again
  1712.  
  1713.       In fact SAsm has a much better way to fill an area of memory with a
  1714.       value by using the DB mnemonic.
  1715.                                                                    Page 29
  1716.  
  1717.  
  1718.                Using the OSET variable
  1719.                -----------------------
  1720.       With the Basic assembler it is sometimes required to 'poke' values into
  1721.       a data area after assembly. Alternatively you may wish to modify some
  1722.       data in some way. Ad you will be aware of the address of the start of
  1723.       your code in memory, the offset used by the O% variable and you will
  1724.       presumably have inserted a label at some convenient point as a marker
  1725.       you would be able to calculate the exact location that you wish to
  1726.       change. With SAsm the actual address of a location is hidden from the
  1727.       user and so the variable OSET is set to give you a 'base' to use for
  1728.       these purposes.
  1729.  
  1730.       During assembly OSET is set in such a way that OSET+<label> where
  1731.       <label> is any normal global label will point to the location IN MEMORY
  1732.       of <label>. For example, to 'poke' the string 'version$' into the
  1733.       location defined by the label 'version' you would use -
  1734.  
  1735.           # $(OSET+version) = version$
  1736.  
  1737.       You can, of course, add an offset to <label> if you wish. For example,
  1738.       to 'blank' 256 bytes from the label 'buffer' you could use -
  1739.  
  1740.           # FOR I%=buffer TO buffer+255
  1741.           # ?(OSET+I%)=0
  1742.           # NEXT
  1743.  
  1744.       Both of these examples are, of course, contrived and the same results
  1745.       could be more efficiently be produced by other means.
  1746.  
  1747.       The most likely use for this would be to 'disguise' some text in your
  1748.       code in some way. This makes it possible to compose it in plain
  1749.       language when writing the code but garble it after assembly.
  1750.  
  1751.  
  1752.                                                                    Page 30
  1753.  
  1754.  
  1755.                Assembly Listing
  1756.                ----------------
  1757.       SAsm will not normally produce an assembly listing. Not only would this
  1758.       obscure any Error or Warning messages it also slows down assembly.
  1759.  
  1760.       It can be useful to to see exactly what has happened to the source code
  1761.       after pre-processing. For example, to check that a macro has been
  1762.       expanded or a complex DB statement properly interpreted. SAsm has no
  1763.       provision for displaying an assembler listing on screen. This could be
  1764.       done by altering the OPT setting, directly manipulating the variable
  1765.       Q%, and programmers experienced in using the Basic assembler will be
  1766.       able to do this. This is not normally to be advised. Instead SAsm
  1767.       allows an assembler listing file to be created. This can be loaded into
  1768.       a text editor and examined at leisure. Two different layouts are
  1769.       available, Standard and Formatted.
  1770.  
  1771.       The Standard format produces a 'compact' listing with no spare spaces
  1772.       or column indenting. This makes the code rather cramped and difficult
  1773.       to read but it will be less than half the size of a Formatted file.
  1774.       This method may be best if you are using floppy discs and require a
  1775.       listing of all or a large part of your code.
  1776.  
  1777.       The Formatted listing produces a file with labels in the left hand
  1778.       column. Mnemonics are indented by 24 spaces and the operands indented
  1779.       by a further eight places. This makes the code much easier to read but
  1780.       it will probably double or treble the size of the file.
  1781.  
  1782.       In both cases only lines containing assembler are reproduced and all
  1783.       comments are stripped. All other lines, including blank lines, are
  1784.       ignored. There is therefore no direct line-to-line correlation with the
  1785.       original source file(s). (I'll include a switch to change this later).
  1786.  
  1787.       The listing file is not saved as a 'block' but is written one line at a
  1788.       time so the operation is slower than other SAsm file operations. Using
  1789.       a hard disc or RAM disc even a large file will only take one or two
  1790.       second but with a floppy disc it could take several. The message
  1791.       'Creating listing file' will appear at the start of the operation and
  1792.       it's end is signalled when the message 'Pre processing completed -
  1793.       starting assembly' appears.
  1794.  
  1795.  
  1796.                Creating a listing file
  1797.                -----------------------
  1798.       Listing files are created by typing the parameters at the command line,
  1799.       by inserting suitable directives, or by a combination of both methods.
  1800.  
  1801.       The command line parameter is 'A' (for Assembler). This should be
  1802.       followed by the filename required. Remember that whatever follows the
  1803.       'A' parameter will become the filename so if, for example, you also
  1804.       want a label cross-reference and type an 'X' after the 'A' you won't
  1805.       get a x-ref but you will get a listing file called 'X'.
  1806.  
  1807.       If you don't follow the 'A' with a filename and it is the last
  1808.       parameter typed then the default name of 'ListFile' will be used and
  1809.       the file will be created in the Currently Selected Directory on the
  1810.       current filing system.
  1811.                                                                    Page 31
  1812.  
  1813.  
  1814.       Assuming that no other directives are used this will result in a
  1815.       listing file consisting of all the source files used. If you have also
  1816.       used the 'F' parameter then this will be a Formatted file, if not it
  1817.       will be in the compact format.
  1818.  
  1819.  
  1820.                Listing file directives
  1821.                -----------------------
  1822.       Assembler listing files can be produced instead of or in addition to
  1823.       Object and/or Error files.
  1824.  
  1825.       There are three directives which relate to listing files, these are
  1826.       LISTON, LISTOFF and LISTFILE. As their names imply these are used to
  1827.       define the start point in the code from which a listing file will be
  1828.       created, the end point at which the listing file will finish, and the
  1829.       name to be given to the file.
  1830.  
  1831.       LISTFILE should, of course, be followed by the path/name you wish to
  1832.       assign to the file. As the listing file is not created until all source
  1833.       files have been loaded it does not matter where in the source the
  1834.       LISTFILE directive appears. If there is more than one LISTFILE
  1835.       directive the last one found will apply. Any filename typed at the
  1836.       command line will override a directive filename and in this case a
  1837.       message to this effect will be displayed.
  1838.  
  1839.       By default a listing file will begin with the first assembler statement
  1840.       and finish with the END directive. Most of the time you will only need
  1841.       to see a small part of the code and so LISTON and LISTOFF are used to
  1842.       mark the beginning and end of the file.
  1843.  
  1844.       If LISTON is followed by an 'F' or if an 'F' parameter was used at the
  1845.       command line then the file will be formatted.
  1846.  
  1847.       Note that LISTFILE of itself does not produce a listing file, it merely
  1848.       defines the filename which will be used if a file is required.
  1849.  
  1850.  
  1851.                Scope of a listing file
  1852.                -----------------------
  1853.       It is important to understand exactly how these commands and directives
  1854.       work in order to ensure that you get a listing of the required section
  1855.       of code. By default the listing file starts with the first assembler
  1856.       statement and stops with the END statement. These start and end points
  1857.       are modified each time SAsm encounters a LISTON or LISTOFF directive.
  1858.       If there is more than one of either or both then the last one
  1859.       encountered will be the one which applies.
  1860.  
  1861.       It is therefore possible if a LISTON directive is encountered after the
  1862.       last LISTOFF directive for the required start of the listing to
  1863.       apparently be after the end. In this case SAsm will not be able to
  1864.       produce the file and will simply display an error message.
  1865.  
  1866.       If there is no LISTON directive the listing file will begin at the
  1867.       first assembler directive and continue until the LISTOFF directive. If
  1868.       there is no LISTOFF directive it will begin at the LISTON directive and
  1869.       continue until the END directive.
  1870.                                                                    Page 32
  1871.  
  1872.  
  1873.                                -=O=-  LABELS  -=O=-
  1874.  
  1875.                Global Labels
  1876.                -------------
  1877.       All labels and constants are common throughout all files. It is
  1878.       important to remember this or some very strange things can happen. With
  1879.       SAsm you don't need to declare labels external, they are ALWAYS global.
  1880.  
  1881.       Adding the suffix 'X' to the command line invokes the label cross
  1882.       reference. This will check all labels and report multiple definitions.
  1883.  
  1884.       For reasons previously explained multiple definitions of a label are
  1885.       classed as Warnings only and not Errors. If like me you repeatedly use
  1886.       labels like 'loop' or 'bak' to form short loops you will need to
  1887.       visually check the list of duplicates for 'foreign' names.
  1888.  
  1889.  
  1890.                Local Labels
  1891.                ------------
  1892.       Since it could become tedious to invent names for all the labels you
  1893.       need to make short jumps and loops a system of 'Local Labels' has been
  1894.       included. These are defined in exactly the same way as normal labels,
  1895.       ie. by preceding the label with a full stop. Local labels MUST be
  1896.       defined at the start of the line, which is good practice anyway, and
  1897.       consist of a two digit decimal number 00-99.
  1898.  
  1899.       You are advised to read the following section carefully and ensure that
  1900.       you understand exactly how this system operates. It's perfectly
  1901.       straightforward and easy to use but if you don't use it properly you
  1902.       will get repeated errors or branches to the wrong destination.
  1903.  
  1904.  
  1905.                Local label scope
  1906.                -----------------
  1907.       You start each 'set' of local labels with a label '00'  When SAsm finds
  1908.       label 00 if 'forgets' all previous local labels. You can therefore use
  1909.       the numbers 00 to 99 repeatedly and each local label will only apply
  1910.       within its own section. Each time you start a new section of code or
  1911.       sub-routine make the first label in that section 00  You can use label
  1912.       00 even where a label is not actually needed to ensure that the scope
  1913.       of the current set of local labels is ended.
  1914.  
  1915.       Local labels can ONLY be used with Branch (or BL) and as the second
  1916.       operand in LDR and STR instructions, with or without conditions, and
  1917.       with the ADR or ADRL pseudo-opcode. They cannot be used within Macro
  1918.       Functions but they can be used in Expanded macros.
  1919.  
  1920.       You will soon find that you will use local labels for all the loops and
  1921.       short jumps in a section, using meaningful labels where appropriate.
  1922.       This makes the code much easier to follow because the 'real' labels
  1923.       which define entry points and complete routines stand out.
  1924.  
  1925.                                                                    Page 33
  1926.  
  1927.  
  1928.                Using local lables
  1929.                ------------------
  1930.       There are some features of local labels which you should be aware of.
  1931.       Firstly they cannot be used as the operand of some instructions or
  1932.       psuedo opcodes. As has already been mentioned they can be used with all
  1933.       branch instructions, ADR, ADRL, LDR and STR. They cannot be passed as
  1934.       parameters to functions or expanded macros. They cannot be used in
  1935.       Macro Functions or anywhere after the END directive.
  1936.  
  1937.       A local label only has a meaningful value when used in the correct
  1938.       manner within its own 'scope'. If you define labels 00, 01 and 02 in
  1939.       one section then an attempt to branch to 03 within that section will
  1940.       produce an error, not a branch to 03 in the previous or next section.
  1941.  
  1942.       Although there are up to 100 individual labels available in any section
  1943.       this is far more than you should ever need. I find it best to divide
  1944.       each set into sub-sections so that each loop or sub-sub-routine has its
  1945.       own sub-set of labels. The first would use 00-09, the next 10-19, then
  1946.       20-29 etc. This not only makes the code easier to read it ensures that
  1947.       there are plenty of 'spare' labels in each set if I need to add extra
  1948.       code later. You don't, of course, need to define the labels in any
  1949.       particular order provided you start at 00, it just looks neater and
  1950.       makes it easier to follow the 'flow' of the code. This is because a
  1951.       branch to a low number will go back to the beginning of the section and
  1952.       to a high number forward to the end.
  1953.  
  1954.       Local labels are not checked by the x-ref routine. If you accidentally
  1955.       use the same local label within its 'set' you will get the same
  1956.       problems as can exist with any other duplicate label. This should not
  1957.       be a problem in practice, especially if you define labels in numeric
  1958.       order, because each set of labels will normally fit within a couple of
  1959.       'screens' of code and any duplicate or out of sequence labels can be
  1960.       plainly seen.
  1961.  
  1962.       The maximum number of 'sets' of local labels allowed is over 2700,
  1963.       which should be enough for any eventuality.
  1964.  
  1965.                                                                    Page 34
  1966.  
  1967.  
  1968.                Example
  1969.                -------
  1970.       Any Branch instruction will only reach back to the last 00 label and
  1971.       forward to (but not including) the next. There can be no overlapping of
  1972.       local label 'sets'. The following example should make this clear.
  1973.  
  1974.  
  1975.         .00    ........        ; some code
  1976.                ........
  1977.         .01    ........
  1978.                ........
  1979.                ........
  1980.         .02    BNE 01          ; This will branch BACK to the last 01
  1981.                ........
  1982.                ........
  1983.         .00    ........        ; This starts a new section of labels
  1984.                BGT 01          ; Branch FORWARD to 01 in this section
  1985.                ........
  1986.                ........
  1987.         .01    ........
  1988.                BEQ 02          ; This will produce an error as 02 is
  1989.                ........        ; not defined in this section
  1990.                ........
  1991.                BLT 00          ; Branch BACK to the last 00
  1992.         .00    ........        ; Start another section
  1993.                ........
  1994.                ADR r1,00       ; Put address of the LAST 00 in R1
  1995.                ADR r2,01       ; put address of the NEXT 01 in R2
  1996.                ........
  1997.         .01    ........
  1998.  
  1999.  
  2000.  
  2001.                Forward branch to 00
  2002.                --------------------
  2003.       Consider this short piece of code;
  2004.  
  2005.                cmp r0,#32
  2006.                bne 00
  2007.                ........        ;code to be skipped if r0 not 32
  2008.                ........
  2009.         .00    ........        ;rest of code
  2010.  
  2011.       This won't work. The branch would go BACKWARDS to the last 00. You can
  2012.       NEVER branch forward to a 00 label.
  2013.  
  2014.       There are two ways to produce the desired result. You you could insert
  2015.       a 'dummy' label somewhere before the branch instruction to 'reset' the
  2016.       local label system, for example -
  2017.  
  2018.         .00    cmp r0,#32
  2019.                bne 01
  2020.                ........
  2021.                ........        ;code to be skipped if r0 not 32
  2022.         .01    ........        ;rest of code
  2023.                                                                    Page 35
  2024.  
  2025.  
  2026.       The 00 label is not used but it resets the local label system so that
  2027.       the branch is correctly interpreted.
  2028.  
  2029.       An alternative is to insert a label specifically for the forward branch
  2030.       just before the next 00 label.
  2031.  
  2032.                cmp r0,#32
  2033.                bne 90
  2034.                ........
  2035.                ........        ;code to be skipped if r0 not 32
  2036.         .90                    ;empty line with just a label
  2037.         .00    ........        ;rest of code
  2038.  
  2039.       Remember that a local label must be defined at the beginning of the
  2040.       line. With the Basic assembler you could use -
  2041.  
  2042.         .label_1 mov r0,#4 : mov r1,#5 : .label_2
  2043.  
  2044.       This will still work with SAsm but NOT if the second label is a local
  2045.       label. From the earlier example you can see that -
  2046.  
  2047.         .90 : .00
  2048.  
  2049.       wouldn't work. The two labels must be on separate lines.
  2050.                                                                    Page 36
  2051.  
  2052.  
  2053.                          -=O=-  ENHANCED 2nd OPERAND  -=O=-
  2054.  
  2055.       This operates on the second operand of instructions CMP, MOV, TST and
  2056.       TEQ. It will work whether or not the instruction is conditional but it
  2057.       can NOT be used with CMN or MVN (yet!). For it to work there must be a
  2058.       space between the opcode and the first operand.
  2059.  
  2060.       The aim is to make it easier when the second operand is an immediate
  2061.       value rather than another register. The Basic assembler requires the
  2062.       second operand to have a leading '#' character for it to be recognised
  2063.       as an immediate value. SAsm will accept this but will also recognise
  2064.       most immediate numeric operands.
  2065.  
  2066.       If the second operand begins with a digit 0-9, an '&', a '%' or is
  2067.       enclosed in double quotes SAsm will assume that it is an immediate
  2068.       value whether or not it is preceded by '#'. There is also no need to
  2069.       use the Basic 'ASC' prefix if a character is enclosed in double
  2070.       quotation marks. For example -
  2071.  
  2072.             SAsm                   Basic Assembler equivalent
  2073.  
  2074.           cmp r0,"A"                    cmp r0,#ASC"A"
  2075.           mov r0,020                    mov r0,#&20
  2076.           mov r2,"z"+1                  mov r2,#ASC"z"+1
  2077.           mov r2,1+"z"  !Error - won't recognize "z" as an ascii value
  2078.           cmpne r0,13                   cmpne r0,#13
  2079.           teq r0,"m"                    teq r0,#ASC"m"
  2080.           cmp r0,%110                   cmp r0,#%110
  2081.           mov r0,&A4                    mov r0,#&A4
  2082.           mov r0,0A4                    mov r0,#&A4
  2083.           mov r0,A4   !Error - A4 won't be recognised as an immediate number
  2084.  
  2085.       As you can see this makes the code easier to read and also avoids
  2086.       errors when you forget to include the '#'.
  2087.  
  2088.       Note that you can ONLY use these shortcuts when the number is obviously
  2089.       an immediate value. If it is a variable you must still use the '#'.
  2090.  
  2091.       WARNING - With this system an actual number in the second operand
  2092.       position is always assumed to be an immediate value. If you really DO
  2093.       mean a register you will have problems. For example, the instruction
  2094.       'mov 1,3' is interpreted by the Basic assembler as 'copy the contents
  2095.       of register r3 into register r1' but by SAsm as 'load register r1 with
  2096.       the immediate value 3'.
  2097.  
  2098.       To avoid this sort of ambiguity it is usual when writing ARM code to
  2099.       always prefix register numbers with 'r' or 'R', but this is not
  2100.       compulsory and the Basic assembler doesn't require it. If you have
  2101.       fallen into bad habits and just use a simple register number then you
  2102.       will have problems.
  2103.  
  2104.       There are two possible solutions. Firstly you could mend your ways and
  2105.       refer to registers properly like everyone else. Secondly you could use
  2106.       the #NOENHANCE directive to disable this feature.
  2107.  
  2108.                                                                    Page 37
  2109.  
  2110.                          -=O=-  EXTRA MNEMONICS  -=O=-
  2111.  
  2112.  
  2113.       These are not actually mnemonics but are macros which are expanded by
  2114.       the preprocessor. They are written into the code just like normal
  2115.       opcodes and so this distinction can normally be ignored. One important
  2116.       difference is that unlike all normal mnemonics some CANNOT have
  2117.       conditional suffixes.
  2118.  
  2119.       Some of these call the built-in macro functions and reference should be
  2120.       made to these for further clarification if required.
  2121.  
  2122.       They may all be written in upper or lower case like normal assembler
  2123.       mnemonics.
  2124.  
  2125.  
  2126.                DW and DD
  2127.                ---------
  2128.       These are expansions of the normal EQUD and EQUW codes and in fact are
  2129.       translated into these when expanded. The main advantage is that DW and
  2130.       DD can be used to reserve a series of words or double words and not
  2131.       just one at a time. These follow the mnemonic as a comma separated
  2132.       list. For example -
  2133.  
  2134.           DD 1,2,3,4,5,6
  2135.  
  2136.       would be expanded by the preprocessor to -
  2137.  
  2138.           EQUD 1:EQUD 2:EQUD 3:EQUD 4:EQUD 5:EQUD 6
  2139.  
  2140.       which can save a lot of typing.
  2141.  
  2142.       Because the line will actually become longer, which is obvious from
  2143.       looking at the above example, it is possible for these codes (and the
  2144.       DB mnemonic which follows) to cause the line to expand beyond the
  2145.       permitted limit of 255 characters. You should therefore avoid putting
  2146.       too many items on a single line.
  2147.  
  2148.       If any of the numbers begin with a zero SAsm will assume that the
  2149.       number is in hex format, whether or not it is preceded by an '&'
  2150.       character. for example '20' would be decimal 20 but '020' would be
  2151.       translated as &20, eg. hex 20 which is decimal 32.
  2152.  
  2153.                                                                    Page 38
  2154.  
  2155.  
  2156.                DB
  2157.                --
  2158.       This is a general purpose macro which replaces EQUB and EQUS and also
  2159.       allows an area of memory to be reserved for data and preset to any
  2160.       value if required.
  2161.  
  2162.       In it's simplest form DB acts exactly like DW and DB but with byte
  2163.       sized sections as a multiple EQUB. However if the parameter is a string
  2164.       enclosed in double quotes it acts like EQUS. These can be mixed in the
  2165.       same DB command which makes defining strings mixed with control codes
  2166.       much easier. For example -
  2167.  
  2168.           DB 7,"This is some text",10,13,"A new line",0
  2169.  
  2170.       would be expanded to -
  2171.  
  2172.       EQUB 7:EQUS"This is some text":EQUB 10:EQUB 13: EQUS"A new line":EQUB 0
  2173.  
  2174.       As with DW and DD beware of allowing the line to become too long.
  2175.  
  2176.       Again numbers beginning with a zero will be regarded as hexadecimal.
  2177.  
  2178.       DB can be used with a multiplier to reserve an area of memory and set
  2179.       it to any value. If a parameter begins with '*' then the following
  2180.       number is taken as a multiplier and the number after that as the value
  2181.       to be inserted. For example -
  2182.  
  2183.           DB *100,32           (which could also be written as DB *100," " )
  2184.  
  2185.       would reserve the next 100 bytes of memory as a data area and load them
  2186.       with the value 32, a space character.
  2187.  
  2188.       This can be mixed in with strings and single bytes and can be used
  2189.       rather like SPC or STRING$ in Basic.
  2190.  
  2191.       For example -
  2192.  
  2193.           DB "1",*10,32,*8,".",*10,32,"First Menu Item",0
  2194.  
  2195.       would be expanded to the zero terminated string -
  2196.  
  2197.           1          ........          First Menu Item
  2198.  
  2199.       One advantage of this is that the multiplier need not be an actual
  2200.       number but could be an expression. This makes it a lot easier to change
  2201.       the size of data areas or the length of strings by simply altering the
  2202.       value of the variable.
  2203.  
  2204.       If you just wish to reserve an area of memory and do not need it to be
  2205.       set to any particular value then using a question mark as the value
  2206.       after the multiplier will do so. For example
  2207.  
  2208.           DB  *100,?
  2209.  
  2210.       would reserve 100 bytes but leave the area set to whatever random data
  2211.       already existed there.
  2212.                                                                    Page 39
  2213.  
  2214.  
  2215.                Basic variables and DB
  2216.                ----------------------
  2217.       It is possible to use variables instead of constants with DB. With the
  2218.       Basic assembler you could use -
  2219.  
  2220.                EQUD <var1> : EQUB <var2> : EQUB <var3>
  2221.  
  2222.       so with SAsm you could use -
  2223.  
  2224.                DB <var1>, <var2>, <var3>
  2225.  
  2226.       You will notice that the previous examples using strings have shown an
  2227.       immediate string enclosed in double quotes. With the Basic assembler it
  2228.       is possible to use a Basic string variable with EQUS, eg.
  2229.  
  2230.                EQUS version$
  2231.  
  2232.       In earlier versions of SAsm this couldn't be done with DB but it is now
  2233.       permitted. SAsm will recognise any variable ending in the '$' character
  2234.       as a string so the 'DB variable$' will now equate to EQUS variable$.
  2235.       You can also use string concatenation, eg.
  2236.  
  2237.                DB prog_name$ + version$
  2238.                DB prog_name$ + " Version "+version$
  2239.                DB prog_name$ + STR$(version_number)
  2240.                DB "A String"+CHR$(7)
  2241.  
  2242.       although in the last case it would actually be neater to use -
  2243.  
  2244.                DB "A String",7
  2245.  
  2246.       For string concatenation to work with immediate strings the '+' must
  2247.       IMMEDIATELY follow the closing quotes as in the above examples.
  2248.  
  2249.       Immediate strings must be enclosed in double quotes. It would be
  2250.       possible to modify SAsm to allow single quotes as in many other
  2251.       assemblers but this would then make it impossible to permit this
  2252.       character inside immediate strings.
  2253.  
  2254.       SAsm will not recognise Basic strings defined with the '$' indirection
  2255.       indicator. With the Basic assembler you could use -
  2256.  
  2257.                EQUS $location%
  2258.  
  2259.       which would use the cr terminated string at 'location%'. This won't
  2260.       work using DB but it is so unlikely that it would be needed that I
  2261.       don't regard this as a problem. There may be other combinations of
  2262.       variables that won't work with DB, if you do have any problems please
  2263.       tell me.
  2264.  
  2265.                                                                    Page 40
  2266.  
  2267.  
  2268.                ADRL
  2269.                ----
  2270.       This is a two instruction 16 bit ADR directive. It takes the same
  2271.       parameters as the normal ADR directive, that is the syntax is -
  2272.  
  2273.           ADRL <register>,<location>
  2274.  
  2275.       ADRL will always assemble two instructions when <location> is greater
  2276.       then the current address. This is because the exact position of
  2277.       <location> will not be determined until the second pass. However if
  2278.       <location> is before the current address it's position will already be
  2279.       known and so a single instruction will be assembled whenever possible.
  2280.  
  2281.       If code length or speed is important you could use the ADR instruction
  2282.       until you get an 'out of range' error to ensure that no superfluous
  2283.       instructions are included.
  2284.  
  2285.       Note that there MUST be a space between ADRL and <register> and that it
  2286.       CAN now be made conditional
  2287.  
  2288.  
  2289.                MOVL
  2290.                ----
  2291.       This is a method of loading a large immediate number into a register. A
  2292.       series of ADD or SUB instructions will be assembled to load the value.
  2293.  
  2294.       The syntax is MOVL <register>,<number>. If <number> begins with a zero
  2295.       it will be regarded as hexadecimal. <number> can of course be positive
  2296.       or negative. If it is negative then MVN instructions may be used by the
  2297.       macro but DO NOT adjust the number to allow for this as is required by
  2298.       the normal MVN instruction. The macro will make all the adjustments
  2299.       necessary so just write the actual number you require.
  2300.  
  2301.       This macro is fairly simple and does not always produce the most
  2302.       efficient code for loading a given value. If speed or code length is
  2303.       paramount it may often be possible to reduce the number of operations
  2304.       by hand coding.
  2305.  
  2306.       Note that there MUST be a space between MOVL and <register> and that it
  2307.       CAN now be made conditional
  2308.  
  2309.                                                                    Page 41
  2310.  
  2311.  
  2312.                DIV
  2313.                ---
  2314.  
  2315.       This macro will perform a 32 bit integer division. The full syntax is;
  2316.  
  2317.           DIV <dividend reg>,<divider reg>,<quotient reg>,<temp reg>
  2318.  
  2319.       It therefore requires four DIFFERENT registers as its parameters and
  2320.       you are responsible for loading the correct values into the registers
  2321.       before using DIV. The results returned are;
  2322.  
  2323.           <quotient reg> = <dividend reg> DIV <divider reg>
  2324.           <dividend reg> = <dividend reg> MOD <divider reg>
  2325.  
  2326.       The <temp reg> is used for working only and will be corrupted.
  2327.  
  2328.       For example, to divide a number in R0 by a number in R1 and return the
  2329.       result in R2 using R3 as temporary workspace use;
  2330.  
  2331.           div r0,r1,r2,r3
  2332.  
  2333.       On exit r1 will be unchanged and r0 will contain the remainder if the
  2334.       number did not divide exactly.
  2335.  
  2336.       Note that there MUST be a space between DIV and <register> and that
  2337.       because it expands to a large section of code it CANNOT be made
  2338.       conditional.
  2339.  
  2340.  
  2341.                Note -
  2342.  
  2343.       I have received 'complaints' informing me that DIV doesn't work and
  2344.       just gives error messages. It does work perfectly. Most of these
  2345.       complaints turned out to be from people who hadn't read (or hadn't
  2346.       understood) the instructions. The parameters passed to DIV are the
  2347.       numbers of the REGISTERS it will use NOT the actual numbers to be
  2348.       divided. You are responsible for writing code to load the actual values
  2349.       into these registers before using DIV to do the division. There is also
  2350.       no error checking. If you try to do something silly like divide by zero
  2351.       you could end up with your code either crashing or going into an
  2352.       infinite loop.
  2353.  
  2354.       If you want a 'general purpose' division routine then I suggest you
  2355.       write a sub-routine (or expanded macro) which deals with all of these
  2356.       things and uses DIV to do the actual work.
  2357.  
  2358.                                                                    Page 42
  2359.  
  2360.  
  2361.                                -=O=-  MACROS  -=O=-
  2362.  
  2363.  
  2364.       Sasm supports two types of Macros. Expanded Macros and Macro Functions.
  2365.       There are advantages and disadvantages with each type. Both can be
  2366.       included in your Macro Library.
  2367.  
  2368.  
  2369.                Macro Functions - Pro/Con
  2370.                -------------------------
  2371.       These are normal Basic Functions and their use and format is fully
  2372.       described in the 'Tutorial'. They have two disadvantages. Firstly
  2373.       because they are Basic Functions you must include assembler brackets,
  2374.       OPT setting, etc. and forward branches are awkward. Secondly it is not
  2375.       possible to use any of the special features of SAsm such as local
  2376.       labels, db, adrl, movl, etc. within a Macro Function. Also you cannot
  2377.       call or define an Expanded Macro from within a Macro Function.
  2378.  
  2379.       A serious disadvantage is that SAsm cannot recover from an error in a
  2380.       Macro Function. Such errors are always Fatal and will produce an error
  2381.       message giving a line number that does not exist in the file.
  2382.  
  2383.       The first advantage is that this type of macro is not 'expanded' by the
  2384.       pre processor so that no matter how many times you call it it doesn't
  2385.       take any more memory. The second advantage is a consequence of this and
  2386.       will only apply if you use a Macro Library without a hard disc. This is
  2387.       because a Macro Function only appears once, at the end of the code, and
  2388.       so only one disc access to load it from the Library will be required.
  2389.  
  2390.  
  2391.                Expanded Macros - Pro/Con
  2392.                -------------------------
  2393.       These are short sections of code which are physically inserted into the
  2394.       file each time the Macro is invoked. The big advantage with this method
  2395.       is that you can use all the special features of SAsm, local labels,
  2396.       etc. You can also call Macro Functions or other Expanded Macros from
  2397.       within this type of macro.
  2398.  
  2399.       Because Expanded Macros become part of the normal code SAsm can
  2400.       normally recover from errors in them in the same way as it can recover
  2401.       from most other errors.
  2402.  
  2403.       The disadvantage is that an Expanded Macro must be defined before it is
  2404.       used, although it can be defined in your Macro Library. Also as the
  2405.       macro code is inserted into your source each time it is used more
  2406.       memory is required although this unlikely to be a problem in practice.
  2407.  
  2408.  
  2409.                Macro Names
  2410.                -----------
  2411.       Because Macro Functions and Expanded Macros are completely different
  2412.       they can have the same name. You can even have Expanded Macros and
  2413.       Macro Functions with the same name in your Library. SAsm will sort out
  2414.       which to use.
  2415.                                                                    Page 43
  2416.  
  2417.                        -=O=-  EXPANDED MACROS  -=O=-
  2418.  
  2419.  
  2420.       An Expanded Macro must be defined before it is used. If you use a Macro
  2421.       Library it may be defined there and SAsm will load it from the Library.
  2422.  
  2423.       If you define a macro in your source file and one of the same name
  2424.       exists in the Library then the macro in the source file will be used in
  2425.       preference to the one in the Library.
  2426.  
  2427.  
  2428.                Defining Macros
  2429.                ---------------
  2430.       An expanded macro is defined as follows.
  2431.  
  2432.                # SM  <name>
  2433.                ........            \
  2434.                ........             > Normal SAsm code
  2435.                ........            /
  2436.                # EM
  2437.  
  2438.       and invoked by -
  2439.  
  2440.                @ <name>
  2441.  
  2442.       In each case <name> is the name given to the macro and, with any
  2443.       parameters, is case sensitive. As with other SAsm directives the '#'
  2444.       used by #SM (Start Macro) and #EM (End Macro) must be the first
  2445.       non-space characters on the line.
  2446.  
  2447.       The '@' character should be the first non-space character on the line
  2448.       or, if the line starts with a label, the first non space character
  2449.       after the label. There must not be ANYTHING on the line after the macro
  2450.       call except a comment, which is defined in the usual way by preceding
  2451.       it with ';' or '\'.
  2452.  
  2453.       Whenever SAsm encounters a '@' it will match the following name with
  2454.       any previously defined macros. When it finds one it will physically
  2455.       insert a copy of the code into the file. If there are any LOCAL labels
  2456.       in a macro they will be unique within that definition, but all
  2457.       non-local labels will be global.
  2458.  
  2459.  
  2460.                Macro Parameters
  2461.                ----------------
  2462.       You can pass parameters of almost any type to an Expanded Macro. The
  2463.       full syntax of the defining line of the start of a macro is -
  2464.  
  2465.           # sm  <name> <param name 1> , <param name 2> , <param name 3> ....
  2466.  
  2467.       and of the calling line -
  2468.  
  2469.           @ <name>  <param value 1> , <param value 2> , <param value 3> ....
  2470.  
  2471.       where <name> is the actual name given to the macro, <param name> is the
  2472.       name given to each parameter and <param value> is the value that each
  2473.       parameter will be assigned when the macro is expanded.
  2474.                                                                    Page 44
  2475.  
  2476.  
  2477.       A parameter is actually a Global Variable and should conform to the
  2478.       variable type that Basic would use for the type of value that it will
  2479.       hold. It can be an Integer, String or Floating Point variable. The
  2480.       parameter passed must be suitable for that type of variable. It need
  2481.       not be a constant value. Any expression which can be evaluated during
  2482.       assembly to the correct type of variable may be used.
  2483.  
  2484.       There must be at least one space between <name> and the first parameter
  2485.       and parameters are separated by commas.
  2486.  
  2487.       In fact you will recognise that the syntax has deliberately been made
  2488.       identical to the way that parameters are passed to Basic Functions and
  2489.       Procedures except that there are no brackets.
  2490.  
  2491.  
  2492.                Local Labels in Expanded Macros
  2493.                -------------------------------
  2494.       You can use local labels in expanded macros and these should conform to
  2495.       the syntax used elsewhere. You MUST start any local labels in a macro
  2496.       definition with '00' to ensure that the labels used will be unique.
  2497.  
  2498.       When the macro expansion ends the 'flow' of local labels in the main
  2499.       code before the macro was used will be restored. A macro, with its own
  2500.       set of local labels, can therefore exist within the area of 'normal'
  2501.       local labels without confusion. In practical terms this simply means
  2502.       that provided you ensure that any local labels used in a macro start
  2503.       with '00' you can ignore the fact that a macro exists for the purposes
  2504.       of local labels in the main code.
  2505.  
  2506.       Similarly if expanded macros are 'nested' then any local labels defined
  2507.       will be unique within that invocation and the labels in the 'calling'
  2508.       macro will branch around labels in the called macro.
  2509.  
  2510.       Remember that, like all non local labels, any other labels defined in
  2511.       an expanded macro will become global and will assume the value assigned
  2512.       in the current invocation.
  2513.  
  2514.  
  2515.                Special features of Expanded macros
  2516.                -----------------------------------
  2517.       The most obvious advantage of expanded macros is that you can take
  2518.       advantage of all the special features of SAsm when using them. The
  2519.       ADRL, MOVL DB, DW and DD pseudo-ops can all be used if required.
  2520.  
  2521.       You can call Macro Functions and other Expanded Macros can be invoked
  2522.       from within macros. Expanded Macros can be 'nested' to a maximum depth
  2523.       of twenty. In theory this could be greater but I couldn't think of any
  2524.       possible (non-contrived) circumstance when I would need more than four
  2525.       or five so I limited it to twenty.
  2526.  
  2527.       Expanded Macros must NOT be invoked recursively. This would obviously
  2528.       set up an infinite loop which would cause all available memory to be
  2529.       filled. This is another reason for limiting the nesting of macros
  2530.       because if this is done by accident an error will be flagged long
  2531.       before this stage is reached.
  2532.  
  2533.                                                                    Page 45
  2534.  
  2535.  
  2536.                Example
  2537.                -------
  2538.       This is an example of how you could use a macro to print a string at
  2539.       any location on the screen. Note that as usual I have used more spaces
  2540.       than are actually necessary to make things clearer.
  2541.  
  2542.           # SM   print_tab  x_pos , y_pos , display$
  2543.                  swi  256+31
  2544.                  swi  256+x_pos
  2545.                  swi  256+y_pos
  2546.                  swi  OS_WriteS
  2547.                  equs display$
  2548.                  equb 0
  2549.                  align
  2550.           # EM
  2551.  
  2552.       The operation of the code should be obvious. Firstly there is the
  2553.       equivalent of 'VDU 31, x_pos, y_pos' to position the text cursor where
  2554.       required. OS_WriteS is then used to print the text which is placed in
  2555.       memory immediately after it.
  2556.  
  2557.       So, to print 'This is a test' at column 10, line 4 you would use
  2558.  
  2559.           @  print_tab  10,4,"This is a test"
  2560.  
  2561.       To illustrate nesting macros the following example splits this
  2562.       procedure into two separate macros, one of which uses the other.
  2563.  
  2564.           # SM  do_tab  x , y
  2565.                 swi  256+31
  2566.                 swi  256+x
  2567.                 swi  256+y
  2568.           # EM
  2569.  
  2570.           # SM  print_tab  x_pos , y_pos , display$
  2571.                 @ do_tab  x_pos, y_pos
  2572.                 swi  OS_WriteS
  2573.                 equs display$
  2574.                 equb 0
  2575.                 align
  2576.           # EM
  2577.  
  2578.       This would be used in exactly the same way as the previous example, but
  2579.       note that as 'print_tab' uses 'do_tab' then 'do_tab' must be defined
  2580.       before it can be used in 'print_tab'.
  2581.  
  2582.           @  print_tab  10,4,"This is a test"
  2583.  
  2584.       Would give the same results, and in this instance the code actually
  2585.       assembled would be exactly the same.
  2586.  
  2587.                                                                    Page 46
  2588.  
  2589.  
  2590.       In fact, it could be split still more. Leaving the macro 'do_tab' as
  2591.       previously defined;
  2592.  
  2593.           # SM  print_string  string$
  2594.                 swi OS_WriteS
  2595.                 equs string$
  2596.                 equb 0
  2597.                 align
  2598.           # EM
  2599.  
  2600.           # SM  print_tab  x_pos , y_pos , display$
  2601.                 @ do_tab  x_pos,y_pos
  2602.                 @ print_string  display$
  2603.           # EM
  2604.  
  2605.       Once again exactly the same actual code would be assembled.
  2606.  
  2607.  
  2608.                Errors in Expanded macros
  2609.                -------------------------
  2610.       SAsm will normally be able to recover from errors in expanded macros.
  2611.       In this case the error message will be slightly different from normal
  2612.       and in the form;
  2613.  
  2614.       Error <error message> at line <number> in Macro <macro name> at line
  2615.       <line number> in file <file name>
  2616.  
  2617.       The line number in the file will be the line where the macro was
  2618.       invoked. The line number within the macro will be the offset from the
  2619.       start of the macro where the error occurred. If this was the invoking
  2620.       line then the error will be shown as having occurred in line 0.
  2621.  
  2622.       This can appear a bit strange if the macro invokes other macros. When
  2623.       the error happens the macro has been expanded, so the line number may
  2624.       be greater than the apparent size of the macro. For instance, in the
  2625.       final example shown above if an error occurred in the line which
  2626.       invoked 'print_string' in the macro 'print_tab' the error would be
  2627.       shown as having occurred not at line 2, but at line 5.
  2628.  
  2629.       This is not normally a problem is practice because the actual error can
  2630.       usually be discovered by inspection but I may improve upon it in a
  2631.       later version.
  2632.  
  2633.                                                                    Page 47
  2634.  
  2635.  
  2636.                            -=O=-  MACRO FUNCTIONS  -=O=-
  2637.  
  2638.                General
  2639.                -------
  2640.       Macro Functions are defined and used exactly as in the Basic assembler.
  2641.       If you don't know how this works I refer you to the 'Tutorial'.
  2642.  
  2643.       Briefly a Macro Function is a Basic Function who's definition, as with
  2644.       functions in a normal Basic program, must appear after the #END
  2645.       directive. You use it by simply writing  FN<name>, where <name> is the
  2646.       name of your function, in your assembler source. Most Macro Functions
  2647.       will require parameters and these are passed by being enclosed in
  2648.       brackets after the function name in the usual way.
  2649.  
  2650.       You must remember when defining a Macro Function that when it is called
  2651.       you have quit the assembler and are back in 'normal' Basic. As a macro
  2652.       will probably include assembly code statements you will need to use the
  2653.       square brackets and define the OPT setting to re-enter assembler.
  2654.  
  2655.       SAsm uses two variables to define the OPT setting, Q% and PASS. You can
  2656.       therefore use either of these when defining Macro Functions although I
  2657.       suggest that you use PASS as its purpose is more obvious. The only time
  2658.       you need to depart from this is if you are using a forward branch in
  2659.       the macro. In this case you will need to define a two-pass loop within
  2660.       the macro and so you MUST define your own OPT variable. In theory you
  2661.       could modify PASS because although it is set by SAsm at the beginning
  2662.       of each assembler pass it is not actually used, but it is probably
  2663.       safer to use an independent variable. However it is very important that
  2664.       you do NOT modify in any way the Basic Integer variable Q%.
  2665.  
  2666.       WARNING - You cannot use the SAsm 'extra' mnemonics DB, DW, DD, DIV,
  2667.       ADRL, MOVL or the enhanced immediate 2nd operands in Functions. These
  2668.       are ONLY available in the main body of the code or within Expanded
  2669.       Macros before the #END directive. You can call functions FNadr, FNmov,
  2670.       FNdiv and FNset as alternatives if required. These will be retained in
  2671.       later versions for this purpose.
  2672.  
  2673.       These restrictions will not be removed in later versions of SAsm since
  2674.       whenever possible you are advised to use Expanded Macros instead.
  2675.  
  2676.  
  2677.                The Built-In Functions
  2678.                ----------------------
  2679.       SAsm has a number of pre-defined Macro Functions and the following
  2680.       section describes them. Do not to use them in new work except when
  2681.       called from within other Macro Functions as the extra mnemonics ADRL,
  2682.       MOVL, DIV, DB, DW and DD should be used instead.
  2683.  
  2684.       As well as the functions described there are two others FNadrc and
  2685.       FNmovc. These should not be used directly and so are not documented but
  2686.       do not create your own functions with these names or conditional ADRL
  2687.       and MOVL will not work correctly.
  2688.  
  2689.       NOTE - The old functions FNdb, FNdw and FNdd have now been deleted.
  2690.                                                                    Page 48
  2691.  
  2692.  
  2693.                FNgap ( <size> )
  2694.                ----------------
  2695.       Defines a gap in the code for use as a data area of <size> bytes. The
  2696.       memory is not pre set to any value. If <size> is not exactly divisible
  2697.       by 4 and you intend to follow FNgap with an opcode you should use ALIGN
  2698.       to ensure that further assembly occurs on a word boundry. Use 'DB' for
  2699.       preference unless within a Macro Function.
  2700.  
  2701.  
  2702.                FNset ( <size>,<value> )
  2703.                ------------------------
  2704.       Similar to FNgap except that the memory is preset to <value>. Use the
  2705.       DB mnemonic in preference wherever possible.
  2706.  
  2707.  
  2708.                FNadr ( <register>,<location> )
  2709.                -------------------------------
  2710.       FNadr is an expansion of the ADR pseudo-opcode. Its syntax is the same
  2711.       except that the parameters must be enclosed in brackets. It can reach
  2712.       any byte within 64K or within 256K if <location> falls on a word
  2713.       boundry. If <location> is a forward reference FNadr always assembles
  2714.       two instruction. If a backward reference FNadr assembles a single
  2715.       instruction if possible and two only if absolutely necessary.
  2716.  
  2717.       This is equivalent to the ADRL expanded mnemonic which should be used
  2718.       in preference.
  2719.  
  2720.  
  2721.                FNmov ( <register>,<value> )
  2722.                ----------------------------
  2723.       This is an expansion of the MOV opcode to load a register with an
  2724.       immediate value. Unlike the normal MOV this will generate sufficient
  2725.       ADD opcodes after the initial MOV to load any 32 bit number. If <value>
  2726.       is a negative number then MVN and SUB will be used. Note that when
  2727.       using negative numbers you do not need to subtract 1 as you do with
  2728.       MVN. eg. to load r3 with -123456 just use  FNmov (3,-123456)
  2729.  
  2730.       Use the MOVL mnemonic for preference unless within a Macro Function.
  2731.  
  2732.                                                                    Page 49
  2733.  
  2734.  
  2735.                           -=O=- THE MACRO LIBRARY  -=O=-
  2736.  
  2737.  
  2738.          --** This facility is available only to REGISTERED users **--
  2739.  
  2740.  
  2741.                Using the Macro Library
  2742.                -----------------------
  2743.       The Registered version of SAsm can record every Macro Function or
  2744.       Expanded Macro call in your source file.
  2745.  
  2746.       If it is an Expanded Macro and it has not been previously defined
  2747.       somewhere in your code then it can be loaded from a special Library
  2748.       file and inserted in the source.
  2749.  
  2750.       If it is a Macro Function it will be checked against the definitions
  2751.       found after the #END directive. If one or more definitions cannot be
  2752.       found it will try to load the missing definitions from a Library file.
  2753.  
  2754.       For Macro Functions the Library is only checked after all the source
  2755.       files have been loaded so a Macro Function in a source file will
  2756.       'override' a macro of the same name in the Library.
  2757.  
  2758.       If an Expanded Macro is defined in the source file it will be used in
  2759.       preference to one of the same name in the Library. If a macro is
  2760.       defined part way through the source files then any calls to that macro
  2761.       before it is defined will be loaded from the Library and those after
  2762.       will use the version in the source file.
  2763.  
  2764.  
  2765.                The 'L' parameter
  2766.                -----------------
  2767.       If you are using a hard disc this operation is so fast that the only
  2768.       way you know it is happening is that SAsm will tell you that it is
  2769.       loading Macro Functions or that the Library isn't required. If you are
  2770.       using a single floppy drive you may have your Library file on another
  2771.       disc. When you know that no Library macros are required it is annoying
  2772.       to have to change discs and allow SAsm to satisfy itself that the
  2773.       (probably misspelt) missing Macro isn't in the Library. You can
  2774.       therefore add the suffix 'L' to your command line to tell SAsm NOT to
  2775.       use the Library, even if SAsm$Lib (see later) is defined.
  2776.  
  2777.                                                                    Page 50
  2778.  
  2779.  
  2780.                Use of the 'V' parameter
  2781.                ------------------------
  2782.       If you have used the 'V' (verbose) parameter then as each Expanded
  2783.       Macro is being searched for a message is displayed. Normally this takes
  2784.       the form -
  2785.  
  2786.           Searching Library for Macro <macro name> - Loaded
  2787.  
  2788.       But if the macro cannot be found in the Library it will say -
  2789.  
  2790.           Searching Library for Macro <macro name> - Not found in Library
  2791.  
  2792.       At this stage a missing macro will not be classed as an error but it
  2793.       will become one during assembly because the macro will be missing.
  2794.  
  2795.  
  2796.                The SAsm$Lib OS variable
  2797.                ------------------------
  2798.       To tell SAsm that a Library exists you should either create an OS
  2799.       variable 'SAsm$Lib' with the path/file name of the Library or use the
  2800.       #LIB directive within the source file. To use the SAsm$Lib variable
  2801.       type at the OS '*' prompt 'Set SAsm$Lib <filename>' where <filename> is
  2802.       the path/file name of your Macro Library or put this command in your
  2803.       !Boot file. You can of course have more than one Macro Library and just
  2804.       change SAsm$Lib to refer to the one in current use.
  2805.  
  2806.       When SAsm can't find a macro definition in the source files it has
  2807.       loaded it will check to see if a Library has been defined. If it is it
  2808.       will extract the 'index' which MakeLib has created. This will be
  2809.       checked against any missing definition and if these appear in the
  2810.       Library they will be included.
  2811.  
  2812.       If SAsm can't find the definition of a macro in the source files and
  2813.       the 'L' parameter hasn't been used but a Library hasn't been defined
  2814.       then an Error message will be displayed. If you are sure that all the
  2815.       required macros exist in the source it is best to use the 'L' parameter
  2816.       to ensure that this doesn't happen.
  2817.  
  2818.                                                                    Page 51
  2819.  
  2820.  
  2821.                Preparing a Macro Library
  2822.                -------------------------
  2823.       First create a source file of Macro Functions and/or Expanded Macros.
  2824.       These are macro definitions definitions exactly like the ones you would
  2825.       normally use in your source files.
  2826.  
  2827.       Each Expanded Macro should begin with the #SM directive and end with
  2828.       the #EM directive.
  2829.  
  2830.       In earlier versions of SAsm it was stated that each Macro Function
  2831.       definition should end with an '=' as the first character on a line but
  2832.       this is no longer required.
  2833.  
  2834.       On your program disc you will find an application called 'MakeLib'.
  2835.       Copy this to a blank disc and *MOUNT the disc or copy it to the Library
  2836.       directory of your hard disc. Now at the OS '*' prompt type;
  2837.  
  2838.         *MakeLib  <source filename>  <Library filename>
  2839.  
  2840.       where <source filename> is the full path/file name of your Macro
  2841.       definition file and <Library filename> is the path/file name that you
  2842.       wish to call the actual Library file that SAsm will use.
  2843.  
  2844.       MakeLib will load your Macro source file and prepare it for use by
  2845.       SAsm. Once MakeLib has created the Library file the original source is
  2846.       no longer required but you should of course keep it so that you can add
  2847.       new macros and update your Library in the future.
  2848.  
  2849.       The present version of MakeLib can only accept a single source file but
  2850.       I intend to improve it to accept wildcards in a similar manner to SAsm.
  2851.  
  2852.  
  2853.                Length of Library file
  2854.                ----------------------
  2855.       The source for your Library file can be any length and can have as many
  2856.       comments ay you like. As with normal SAsm source files these will all
  2857.       be stripped before the routines are added to the actual Library.
  2858.  
  2859.       The Library file can hold about 200 Macro definitions which should be
  2860.       enough for anyone. I suggest that in practice you only put the macros
  2861.       you frequently require in your Library and use INCLUDE files for those
  2862.       only rarely needed. This will make the search time shorter and also
  2863.       probably allow you to put your Library on your normal working disc if
  2864.       you are using a single floppy.
  2865.  
  2866.                                                                    Page 52
  2867.  
  2868.                         -=O=-  SASM AND THE DESKTOP  -=O=-
  2869.  
  2870.       SAsm was originally intended to be used at the OS command line prompt.
  2871.       However the introduction of good text editors such as !Zap and other
  2872.       tools now make it possible to to develop programs within the Archimedes
  2873.       desktop. Although SAsm is still not integrated into the desktop
  2874.       environment Versions after 1.40 have features which help them to be
  2875.       used in this way.
  2876.  
  2877.  
  2878.                The new features
  2879.                ----------------
  2880.       The changes which have been introduced are described in the section on
  2881.       directives. They enable all of the parameters which previously had to
  2882.       be typed at the command line (and more) to be inluded in the file as
  2883.       Directives. This should mean that only the name of a single 'make' file
  2884.       needs to be typed and this file can contain all other data needed to
  2885.       assemble the program. The next step is to write a desktop 'front end'
  2886.       for SAsm which will enable programs to be assembled within the desktop
  2887.       in a similar manner to Acorns (unbelievably expensive) DDE and this
  2888.       will be appearing soon (I hope!).
  2889.  
  2890.       Even without the 'front end' you can now use SAsm within the desktop
  2891.       very easily and assemble projects by clicking on a single 'Obey' file.
  2892.       You will not now need to set the CSD as you will be able to use the
  2893.       <Obey$Dir> OS variable to define the 'start point' of your project
  2894.       directory structure.
  2895.  
  2896.  
  2897.                Using SAsm from the Desktop
  2898.                ---------------------------
  2899.       You can now include everything needed to assemble an extensive project
  2900.       in a single short 'make' file. This would normally be a text file and
  2901.       will contain all the preliminary directives (org, size, type, etc) plus
  2902.       directives to define the object and error filenames and the library to
  2903.       be used. Following these will come a list of Include files to be
  2904.       assembled.
  2905.  
  2906.       The main advantage of this system for desktop use is that it enables an
  2907.       Obey file to run SAsm. For example, to assemble a desktop project you
  2908.       should set up a directory structure as shown.
  2909.  
  2910.                                   root
  2911.                                    |
  2912.                                    |
  2913.                       ----------------------------
  2914.                      |                            |
  2915.                    source                        !app
  2916.  
  2917.       The 'root' directory would contain your 'make' file and the Obey file
  2918.       which will run it. It need not, of course, be the actual root directory
  2919.       of a disc, it is just the root directory of your project. The !App
  2920.       directory will be the RiscOS application directory for your project.
  2921.       The 'Source' directory will contain all of your source files. You
  2922.       could, of course, also have other directories to hold special library
  2923.       files, error files, notes, etc. if required.
  2924.  
  2925.                                                                    Page 53
  2926.  
  2927.       Assuming the Make file is simply called 'Make' the Obey file would
  2928.       contain just two lines -
  2929.  
  2930.                Set   Project$Dir <Obey$Dir>
  2931.                Sasm  <Project$Dir>.Make
  2932.  
  2933.       When you double-click on this file it will atomatically create an OS
  2934.       variable 'Project$Dir (or whatever you want) and set it to 'Obey$Dir',
  2935.       ie. to the 'root' directory of your project. It will then Run SAsm
  2936.       (either from the RMA if you have loaded the Module version or from
  2937.       disc) with the filename of the Make file.
  2938.  
  2939.       The Make file should define the various parameters to assemble the
  2940.       program using the <Project$Dir> variable. Alternatively you could set
  2941.       the OS variable using the CLI directive from within the Make file. It
  2942.       would also contain directives to define the error file, library and
  2943.       object file, for example -
  2944.  
  2945.                # errfile <Project$Dir>.err
  2946.                # obj     <Project$Dir>.!App.!Runimage
  2947.  
  2948.       and the files to be assembled would be -
  2949.  
  2950.                # include <Project$Dir>.source.first_*
  2951.                # include <Project$Dir>.source.second_*
  2952.                # include <Project$Dir>.source.third_*
  2953.  
  2954.       or whatever they are called. Note that you can still use the
  2955.       'descending trailing digits' wildcard to assemble the latest version.
  2956.  
  2957.       Your Make file need not, of course, be in the 'root' directory, it
  2958.       could be in the source directory if you prefer, (it is, technically,
  2959.       just another source file).
  2960.  
  2961.       If you don't have a hard disc you will probably prefer to have your
  2962.       source files (and certainly the error file) on the RAM disc. As SAsm
  2963.       doesn't create any temporary files you don't need much spare space.
  2964.  
  2965.       To assemble a project in this way just double-click on the Obey file.
  2966.       You will have to wait for the new 'front end' to have messages trapped
  2967.       in a desktop window, at present they'll just appear in a Command
  2968.       window.
  2969.  
  2970.  
  2971.       You can, of course, use SAsm in a 'Task' window but this means you will
  2972.       need to define directories and type filenames again. In fact this is
  2973.       the way that I normally use it but I am accustomed to operating with
  2974.       set directories. The biggest advantage of using a task Window is that
  2975.       if SAsm does crash the Wimp will normally allow you to close the
  2976.       window, thus killing the task. This is very useful when I'm using SAsm
  2977.       for development work on SAsm where this can happen. A disadvantage of a
  2978.       Task Window is that on ARM 2 machines it does slow up operation.
  2979.  
  2980.                                                                    Page 54
  2981.  
  2982.                       -=O=-  PROBLEMS and QUESTIONS  -=O=-
  2983.  
  2984.  
  2985.       At present SAsm is entirely Command Line driven and doesn't have a
  2986.       desktop 'front end'. There is no reason why this can't be done, in fact
  2987.       a P.D. version has already been written by Ainsley Pereira and you may
  2988.       have found a copy of this with your copy of SAsm. As soon as I feel
  2989.       that the 'core' program is stable I shall write one so that you can
  2990.       work entirely within the desktop if you wish.
  2991.  
  2992.  
  2993.                IMPORTANT
  2994.                ---------
  2995.       I'm continually trying to improve SAsm. PLEASE tell me if you have any
  2996.       problems, even if you haven't registered. It's only by acting on your
  2997.       bug reports and suggestions that I can keep improving it.
  2998.  
  2999.  
  3000.                Reporting and diagnosing problems
  3001.                ---------------------------------
  3002.       Tell me which version of SAsm you are using. You may have experienced a
  3003.       'bug' which has already been fixed. It can save me a lot of time trying
  3004.       to reproduce an error which can't occur on a later version. Ideally
  3005.       send the version of SAsm that you are using. I may no longer have a
  3006.       copy of that version (there have been quite a few updates!)
  3007.  
  3008.       Please send a copy of the source file(s) that caused the problem,
  3009.       preferably all files not just the one that gave the error, plus any
  3010.       error files generated or other information. Especially I need to know
  3011.       exactly how the program failed, 'it wouldn't work with this' isn't very
  3012.       helpful! If you use SAsm in a Task Window then if you can please 'Save'
  3013.       the contents and include it. If you don't normally run SAsm from a Task
  3014.       Window then if possible please do so that you can send me the file.
  3015.  
  3016.       Try to create listing and error files. If SAsm produces an uncorrupted
  3017.       listing file it indicates the problem isn't in preprocessing. This
  3018.       doesn't mean that something in preprocessing isn't causing a problem
  3019.       for the assembler, but it does indicate that any problem will probably
  3020.       be easy to spot and solve. Sometimes SAsm will produce a valid listing
  3021.       or error file but it's type will be Data and not Text. Once again this
  3022.       is a valuable pointer to the likely source of the problem.
  3023.  
  3024.       You may find you can produce a perfectly good listing file by using a
  3025.       'null' object filename (~) even though you can't get an object file. If
  3026.       you can do this you may be able to examine it and discover the problem.
  3027.  
  3028.       You may feel that all this isn't necessary because I should be able to
  3029.       reproduce the problems that you have experienced. Unfortunately this
  3030.       may not be so. I have sometimes been sent source code which assembled
  3031.       perfectly when I tried it. On one occaision it wouldn't work on the
  3032.       users machine because he was trying to run it in a P.D. Task Window
  3033.       program using RiscOS 2 and it was the Task Window that was crashing,
  3034.       not SAsm. There was no way that I could have reproduced this except
  3035.       that the user enclosed a screen 'grabbed' from the desktop and I
  3036.       recognised the non standard window.
  3037.                                                                    Page 55
  3038.  
  3039.  
  3040.       I use SAsm a lot myself and so it -*should*- be bug free because it
  3041.       gets a lot of testing, not least because I use it to assemble SAsm
  3042.       itself. However like most programmers I write code in a fairly
  3043.       consistent way and to a regular format. I use some features a lot, some
  3044.       rarely and others almost never. Experience has shown that there is
  3045.       always someone who does something that I have never thought of. Often
  3046.       this is quite legitimate, sometimes downright weird, but it just
  3047.       introduces a variation that I haven't allowed for. Most modifications
  3048.       to SAsm consist of 'fixes' and improvements to accommodate the way that
  3049.       other people write code.
  3050.  
  3051.  
  3052.       One possibility that can happen with both SAsm and the Basic asembler
  3053.       is that labels, constants and register names are all 'normal' global
  3054.       variables. Most assemblers, such as Acorns AAsm, treat register names,
  3055.       labels and constants differently. You must therefore be careful not to
  3056.       use the same name for more than one item. It is very easy to define a
  3057.       label and a register or an offset into a data area with the same name
  3058.       and disastrous consequences.
  3059.  
  3060.       You may find that with a complex program it is best to use some sort of
  3061.       prefix or suffix for data offsets and registers. Using names like r_ptr
  3062.       for a register and d_offset for a data area offset will avoid this sort
  3063.       of problem. Another solution is to use upper case names (beware the
  3064.       SAsm reserved variables) or names beginning with a capital letter for
  3065.       constants. As most constants will be integers a good solution is to
  3066.       make them all Basic integer variables by ending the name with % because
  3067.       'number' and 'number%' are different variables. No doubt you will
  3068.       devise your own method of sorting the various names into easily
  3069.       identified categories.
  3070.  
  3071.       If you suspect that this might be the trouble then list out all your
  3072.       labels to a file and check them against register names and constants.
  3073.       That's why this function was included and it can save a lot of time.
  3074.  
  3075.  
  3076.  
  3077.       If all else fails there is one final thing you can try. The registered
  3078.       version of SAsm can save the fully processed data as a file before
  3079.       assembly. You can do this either by using a 'p' parameter at the
  3080.       command line or, instead of simply pressing RETURN when you type the
  3081.       command, hold down both SHIFT keys and press the keypad ENTER. This
  3082.       will stop any assembly taking place and will save the whole file with
  3083.       whatever you had assigned as the object filename.
  3084.  
  3085.       This function was included for my own purposes when debugging SAsm
  3086.       itself. The resulting file is difficult to understand but it may help
  3087.       you (or me) to discover what is happening.
  3088.                                                                    Page 56
  3089.  
  3090.  
  3091.                Speed of operation
  3092.                ------------------
  3093.       The two questions I am most often asked about SAsm are 'what language
  3094.       is it written in?' and 'how fast is it?'.
  3095.  
  3096.       These can most easily be answered together. SAsm is written in machine
  3097.       code using SAsm. Each version is assembled using the previous version.
  3098.       The source code is then changed to take advantage of any new features
  3099.       and re-assembled. I therefore test SAsm by 'self assembling' the
  3100.       distributed version.
  3101.  
  3102.       The source for SAsm consists of more than 7000 lines split over eight
  3103.       files. These are loaded from disc, assembled, and the source file saved
  3104.       to disc in less than seven seconds on an A440 with an ARM 2 processor
  3105.       and an ST506 hard disc or about three seconds on an A5000. These times
  3106.       assume operation direct from the CLI and are slightly longer if a Task
  3107.       window is used. I think this is fast enough for most purposes.
  3108.  
  3109.       Naturally if you didn't have a hard disc the time taken would be quite
  3110.       a bit longer but as SAsm can easily use a RAM disc this shouldn't be a
  3111.       serious problem unless you are trying to write long programs on a 1Mb
  3112.       machine. Unlike most assemblers and compilers SAsm doesn't use much
  3113.       memory for its own purposes.
  3114.  
  3115.  
  3116.                Memory usage
  3117.                ------------
  3118.       SAsm does not use any Heap or WimpSlot calls. It works with whatever
  3119.       memory you have chosen to give it by way of the 'Next' slider on the
  3120.       Task Display. I don't intend to change this in the CLI driven program
  3121.       because I feel that this is something that should be under the
  3122.       operators control. If you are writing machine code you are not a novice
  3123.       user and should be capable of managing such things.
  3124.  
  3125.       Whichever version of SAsm you are using the SAsm application code
  3126.       itself will be located at &8000. After the application code space is
  3127.       allocated for data areas used by SAsm. A 16K 'buffer' is then allowed
  3128.       and the first file is loaded above this space. This will probably be
  3129.       about 50K above the start of the 'slot' at &8000 and this is the only
  3130.       RAM normally used by SAsm. As the file is processed it is copied down
  3131.       to the start of this buffer. Obviously the 'tail' of the processed file
  3132.       will eventually overlay the beginning of the 'raw' file, but this is
  3133.       not of any consequence. When the first file has been processed a new
  3134.       16K buffer is allocated after its end and the next file is loaded and
  3135.       processed. This continues until all the files are completed.
  3136.  
  3137.       With smaller programs this is then passed to Basic in this form for
  3138.       assembly. However Basic can't cope with untokenised programs in excess
  3139.       of about 6500 lines, so anything larger than this must be tokenised by
  3140.       SAsm. If this is necessary you will see a message to this effect.
  3141.  
  3142.                                                                    Page 57
  3143.  
  3144.  
  3145.                Some notes on Local Labels
  3146.                --------------------------
  3147.       I shall describe briefly how SAsm handles local labels as is is
  3148.       possible, although unlikely, for it to conflict with other variables.
  3149.  
  3150.       You will be aware that Basic does not permit variable names to begin
  3151.       with a number. SAsm therefore adds a two letter prefix to each local
  3152.       label. This is given a wide spread to speed up access by Basic. The
  3153.       prefix starts at 'zz' and reduces to 'Az', then 'zy' to 'Ay' etc. The
  3154.       label prefix is reset each time a '00' label is encountered. You can
  3155.       see exactly how this works by examining any Listing file where local
  3156.       labels have been used. Where local labels are used in expanded macros a
  3157.       similar method is used but with a three character prefix.
  3158.  
  3159.       The system is simple and is designed to be very fast for Basic to use.
  3160.       However it is possible for conflicts to exist if you have defined a
  3161.       label or other variable in this form, eg. a variable 'xy10' could cause
  3162.       problems. To avoid this you are strongly advised to ensure that your
  3163.       own variables and labels don't use this form, eg. 'xy_10' couldn't
  3164.       possibly cause a problem.
  3165.  
  3166.  
  3167.                The most common problems
  3168.                ------------------------
  3169.       There are a few 'features' of SAsm which can cause trouble. Some are
  3170.       minor bugs that are not important once you know about them and will be
  3171.       fixed when I have time. Others are errors which can occur because of
  3172.       changes in the syntax used by SAsm. I will record some of the queries
  3173.       which have been raised by users in the hope that it will avoid others
  3174.       experiencing the same problems.
  3175.  
  3176.       Before you decide that it's a bug in SAsm that's making things go wrong
  3177.       PLEASE read through these and assure yourself that none of them could
  3178.       possibly apply. Most of the 'problem code' that I am sent displays one
  3179.       or more of these errors.
  3180.  
  3181.       Because of the way in which SAsm operates it does not have perfect
  3182.       control over assembly and there will always be things which can make it
  3183.       crash. As time goes on these are slowly being eliminated and the error
  3184.       trapping is being improved so that things which could cause a crash or
  3185.       a 'lock up' in earlier versions are now either accepted or just give an
  3186.       error message.
  3187.  
  3188.  
  3189.       1.  There MUST be a space between the mnemonic and the first operand for
  3190.           many of SAsm's functions to work. This is not always essential with
  3191.           the Basic assembler but it is good practice so I make no apologies.
  3192.  
  3193.       2.  MOVL, ADRL and DIV are actually macro's and not assembler mnemonics.
  3194.           ADRL and MOVL can be made conditional but because DIV expands to
  3195.           many lines of code with internal compare instructions it cannot.
  3196.  
  3197.       3.  Make sure that you start every set of local labels with '00'.
  3198.                                                                    Page 58
  3199.  
  3200.  
  3201.       4.  You cannot use local labels, DB, DW, DD, ADRL, MOVL, DIV or any of
  3202.           the enhanced second operator functions after the #END directive.
  3203.           This means you can't use them within Macro Functions. You can,
  3204.           however, use them within Expanded Macros because these are defined
  3205.           before the #END statement.
  3206.  
  3207.       5.  Because DB, DW and DD instructions may expand considerably they can
  3208.           cause a 'line too long' error if you put too much on one line.
  3209.  
  3210.       6.  SAsm removes redundant spaces and comments as it processes a file
  3211.           but other operations expand it. Normally the contraction is greater
  3212.           than the expansion so the file shrinks. As each file is loaded a 16K
  3213.           'overhead' is allowed in case the file does grow. Normally this is
  3214.           plenty but in extreme cases of large individual files without spare
  3215.           spaces or comments the program could crash. I will add routines to
  3216.           guard against this when I get time but I do not regard it as a
  3217.           serious fault because a major aim of SAsm is to let you split up and
  3218.           spread out your source files.
  3219.  
  3220.       7.  SAsm regards a ';' as defining a comment so if you insert a line of
  3221.           Basic which has a PRINT statement that includes the ';' character
  3222.           with a preceding space it will be 'cut off'.
  3223.  
  3224.       8.  There must be a CR or LF at the end of the last line of each file.
  3225.           Check this by loading the file into your editor and pressing
  3226.           CTRL-Down Arrow to move the cursor or caret to the end of the file.
  3227.           It should be on a blank line below the last line. If it appears at
  3228.           the end of the last line there isn't a final terminator and you'll
  3229.           have problems.
  3230.  
  3231.       9.  SAsm can abort with an error if there is not enought space for line
  3232.           numbers. This is because after SAsm has finished with the files
  3233.           Basic will need to add 3 bytes to each line for the line number and
  3234.           length byte. The solution is to make more memory available.
  3235.  
  3236.       10. SAsm can quit with a fatal error giving a line number much greater
  3237.           than the length of the file where the error occurred. Usually this
  3238.           means that the error happened inside a Macro Function. This is
  3239.           always a problem with Basic Functions and Procedures and there is no
  3240.           simple solution. Often the only way of discovering the actual error
  3241.           is to examine every FN call in the file in which the error occurred.
  3242.           The filename given will be the name of the file from which the
  3243.           function was called, and if the function is used elsewhere the most
  3244.           probable cause is an error in one of the parameters passed. If it
  3245.           persists you could try splitting up the offending file into smaller
  3246.           sections to help you to 'zero in' on the problem.
  3247.                                                                    Page 59
  3248.  
  3249.  
  3250.       11. If SAsm 'crashes' for any reason (it can happen, although the things
  3251.           causing it are slowly being eliminated) then it can leave the error
  3252.           or x-ref file open. Normally if there is a fatal error these files
  3253.           are closed but obviously if SAsm itself crashes this may not happen.
  3254.           You are unlikely to be aware of this until you try to run SAsm again
  3255.           when the 'file open' error will occur as SAsm tries to open an error
  3256.           file which is already open. IN THEORY you should just get a 'beep'
  3257.           and a warning message telling you that the error file was open and
  3258.           assembly will proceed. (If this does happen then you will actually
  3259.           have lost the first error message although the error will have been
  3260.           counted). Source or Object files cannot be left open because these
  3261.           are only accessed as whole files. The error could occur with a
  3262.           listing file but this is unlikely. It is possible that some filing
  3263.           systems may not return the 'standard' error number and so this error
  3264.           won't be intercepted. In this case the program will go into an
  3265.           infinite loop because every time it tries to report the 'file open'
  3266.           error it will generate ...... a file open error! If this happens
  3267.           when you are using a Task Window try pressing F12 and typing 'SHUT'.
  3268.  
  3269.       12. The parameters passed to the DIV macro are the register numbers it
  3270.           will use, not the values operated upon. You are responsible for
  3271.           loading the values into the respective registers before using the
  3272.           macro. Don't forget that these registers will be altered afterwards.
  3273.           This macro has no error checking. If you try to divide by zero or do
  3274.           something else stupid it may crash or go into an infinite loop. It
  3275.           works well, but it's dumb, so it's up to you to use it properly.
  3276.  
  3277.       13. SAsm does not mind whether you use LF (ascii 10) or CR (ascii 13)
  3278.           characters at the end of each line. Most Archimedes text editors use
  3279.           LF's but some, such as StrongEd, can use either or even a LF/CR
  3280.           combination as is used on PC's. SAsm will not work with a LF/CR or
  3281.           CR/LF combination. All textural output from SAsm such as Listing and
  3282.           Error files conforms to the standard Archimedes format of a LF
  3283.           terminating each line.
  3284.  
  3285.       14. If assembly appears to stop part way through the code check that you
  3286.           haven't put an #END directive before the real end. This can happen
  3287.           if you re-arrange the order of the files or if the last file is
  3288.           loaded out of sequence.
  3289.  
  3290.       15. Check that wildcarded filenames only apply to one file or you will
  3291.           get some files assembled twice! This can cause the previous error.
  3292.  
  3293.       16  If you have a data area and the first 'instruction' immediately
  3294.           following this is ADRL then you MUST ensure that the end of the data
  3295.           area is ALIGN'ed. Otherwise the address might be calculated from an
  3296.           'odd' base which will introduce errors.
  3297.  
  3298.       17  The Basic Tokenising routine is NOT comprehensive. It should cope
  3299.           with all simple Basic constructs of the type likely to be used in an
  3300.           assembler source file. In theory it should distinguish between AND
  3301.           and EOR when used as mnemonics or as operators. If in doubt use the
  3302.           lower case versions of the mnemonics.
  3303.  
  3304.                                                                    Page 60
  3305.  
  3306.  
  3307.                            -=O=-  RELEASE HISTORY  -=O=-
  3308.  
  3309.               1.0      Oct. 91     First release
  3310.  
  3311.               1.1      Nov. 91     Functionally as 1.0
  3312.                                    Bug fixes
  3313.                                    X-ref and Macro Library functions re-written
  3314.  
  3315.               1.2      Nov. 91     Bug fixes
  3316.                                    Much improved error handling
  3317.                                    INCLUDE directive added
  3318.  
  3319.               1.21     Jan 92      Restrictions on INCLUDE directive with
  3320.                                    Shareware version removed.
  3321.  
  3322.               1.22     Mar 92      Improved error handler
  3323.  
  3324.               1.23     May 92      Minor bug fixes
  3325.  
  3326.               1.24     June 92     Line numbering system rewritten, dramatic
  3327.                                    speed increase for large files
  3328.                                    Line number space relocation added
  3329.  
  3330.               1.25     July 92     adrl, movl, div, db, dw, dd, added
  3331.                                    Enhanced immediate 2nd operand
  3332.  
  3333.               1.26     Feb 93      Bug in adrl in some examples of 1.25 fixed.
  3334.                                    No public release of this version.
  3335.  
  3336.               1.30     Mar 93      Expanded macros introduced.
  3337.                                    db *xx,? to reserve area without setting
  3338.                                    New Makelib tool for expanded macros
  3339.                                    Module provided so SAsm can now be run from
  3340.                                    the RMA for floppy disc users.
  3341.  
  3342.               1.31     Apr 93      ADRL and MOVL can be conditional
  3343.  
  3344.               1.32     Jun 93      Bug fixed in expanded macro stack.
  3345.  
  3346.               1.41     Aug 93      #obj, #lib, #errfile, #cli, #verbose, #quiet,
  3347.                                    #xref and #noxref directives introduced.
  3348.                                    Tab characters accepted as delimiters.
  3349.  
  3350.               1.42     Sep 93      Bug with DB, DD and DW in upper case fixed.
  3351.                                    Bug with comment on Macro call line fixed.
  3352.                                    'Line Too Long' trapped during preprocessing
  3353.  
  3354.               1.43     Dec 93      Expanded macro call permitted after label
  3355.                                    Minor bug fixes
  3356.  
  3357.               1.44     Dec 93      #enhance and #noenhance directives introduced
  3358.  
  3359.               1.45     Dec 93      Bug in macro call with no params fixed
  3360.                                                                    Page 61
  3361.  
  3362.  
  3363.               1.46     Dec 93      'P' parameter introduced
  3364.                                    #insert directive introduced
  3365.  
  3366.               1.50     Jan 94      x-ref list to file
  3367.                                    x-ref bug fix with label same as opcode
  3368.                                    Assembler listing file
  3369.                                    Added short help text
  3370.                                    SWI name processing
  3371.                                    Local labels with LDR and STR
  3372.                                    String variables accepted by DB
  3373.                                    'Q' switch added to quit before assembly
  3374.                                    'N' switch added to list label names
  3375.                                    #LABELFILE to send labels to file
  3376.  
  3377.               1.51     Mar 94      Minor bug in #SWION fixed
  3378.                                    reg! permitted without space for LDM/STM
  3379.                                    More improvements to error trapping
  3380.                                    DIV now included in unregistered version
  3381.  
  3382.               1.52     Mar 94      Filetypes Module and Utility don't need ORG
  3383.                                    Bug with obj filename starting with '!' fixed
  3384.                                    Added 'demo' application
  3385.  
  3386.               1.53     Mar 94      Labels now listed alpahbetically, not reverse
  3387.                                    FNdb, FNdd, FNdw removed
  3388.                                    #AREA directive introduced
  3389.                                    Descriptive text between { and } allowed
  3390.                                    OSET variable implemented
  3391.                                    Bug in trapping open Error File error fixed
  3392.  
  3393.               1.54     Apr 94      Basic tokenising introduced with large files
  3394.                                    Corrected bug with ':' in INCLUDE filenames
  3395.  
  3396.  
  3397.  
  3398.                        Registration Form for SAsm
  3399.  
  3400.  
  3401.       Please complete this and post it with your cheque for Eight Pounds to;
  3402.  
  3403.       David Holden,  39 Knighton Park Road,  Sydenham,  London SE26 5RN
  3404.       ____________________________________________________________________
  3405.       Name and Address:
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.       ____________________________________________________________________
  3414.       Where did you obtain SAsm:
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.       ____________________________________________________________________
  3423.       Have you had any problems:
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.       ____________________________________________________________________
  3435.       What additional features would you like:
  3436.