home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / assembler / sasm / Docs / Manual < prev    next >
Encoding:
Text File  |  1995-10-02  |  151.9 KB  |  3,177 lines

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