The OPT keyword denotes how the following block of assembler should be handled. It relates to every block separately, so you must put the OPT keyword at the start of each block. For example:

  FOR loop% = 0 TO 2 STEP 2
    P% = code%
    [ OPT loop%

      ... some basic initialization stuff here ...

    IF computer_is_networked% THEN
        OPT loop%

        ... network code ...
        OPT loop%

        ... non-network code ...

    [ OPT loop%

      ... the rest of the code ...
This is a rough example showing how different bits of code can be utilised depending upon the current conditions (and the code need not be the same number of instructions either!); and it shows how you must use the OPT keyword - even if you only have one loop. However the power and complexity of BASIC can be utilised to build up all kinds of fancy code.



The OPT parameters have the following meanings:

   Bit 0 - Produce a listing during the compilation

   Bit 1 - Report errors, such as unresolved references

   Bit 2 - Offset assembly, if code is compiled for
           execution at a different place to where it
           currently is.

   Bit 3 - Range check, will report if the code being
           compiled overshoots the memory allocated.

   Bit 4 - Enables the 'new' instructions.
           A list of them is here.

   Bit 8 - If set, the SWI "OS_SynchroniseCacheAreas" is not
           called after compilation.
           (does anybody know when this was introduced? RISC OS 3.7?)

   Option    List  Err   Offs  RChk
   OPT  0    No    No    No    No     <-- First pass
   OPT  1    Yes   No    No    No
   OPT  2    No    Yes   No    No     <-- Second pass
   OPT  3    Yes   Yes   No    No
   OPT  4    No    No    Yes   No
   OPT  5    Yes   No    Yes   No
   OPT  6    No    Yes   Yes   No
   OPT  7    Yes   Yes   Yes   No
   OPT  8    No    No    No    Yes    <-- Alt. first pass
   OPT  9    Yes   No    No    Yes
   OPT 10    No    Yes   No    Yes    <-- Alt. second pass
   OPT 11    Yes   Yes   No    Yes
   OPT 12    No    No    Yes   Yes
   OPT 13    Yes   No    Yes   Yes
   OPT 14    No    Yes   Yes   Yes
   OPT 15    Yes   Yes   Yes   Yes

   OPT 16    No list, no error reporting, no offset assembly,
             no range check, but will use new instructions.

   ...through to...

   OPT 31    List, error reporting, offset assembly, range
             checking, and uses the new instructions.

   The first two option codes indicated are common values
   used when compiling code.

   The alternative option codes are identical, except that
   range checking is enabled. This is useful for reporting
   if the code is larger than the space allocated.

   To include new instructions in a program, instead of
     FOR loop% = 0 TO 2 STEP 2
       P% = code%
       [ OPT loop%

   You would do:
     FOR loop% = 16 TO 18 STEP 2
       P% = code%
       [ OPT loop%



New instructions

The RISC OS 3.80 assembler allowed extended instructions, but this can cause problems in code (is "BXR0" a branch to label XR0, or is it a thumb instruction?). So RISC OS 4 now has this selectable with a bit in the options.

A lot of the functionality here is duplicated by Darren Salt's ExtBASasm module. To give you an example, the instruction in italics is NOT supported by ExtBASasm (there's only one). The rest are...

Links take you to places where you can find out more about the linked instruction.

The new instructions are:

ARM7 / StrongARM extensions

Thumb Co-processor 32 bit Floating point maths Miscellanea Many thanks to Matthias Siefert for his help.

Return to assembler index
Copyright © 2004 Richard Murray