home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / FORTRAN.ZIP / SBM.LST < prev    next >
Encoding:
File List  |  1991-01-10  |  54.9 KB  |  1,511 lines

  1.     
  2.     
  3.     
  4.     
  5.     
  6.     
  7.     
  8.     
  9.     
  10.     
  11.     
  12.     
  13.     
  14.     
  15.     
  16.     
  17.     
  18.     
  19.     
  20.     
  21.                              S B M     F O R T R A N
  22.     
  23.                               A FORTRAN answer to 'C'
  24.     
  25.     
  26.     
  27.     
  28.     
  29.                     The best road is designed by the traveller.
  30.     
  31.     
  32.     
  33.     
  34.     
  35.     
  36.                            Copyright (c) 1989-1991 by
  37.     
  38.                                    DUKE DAIGH
  39.     
  40.                           Pine Bluffs, Wyoming 82082-0631
  41.  
  42.  
  43.  
  44.     
  45.     
  46.                                    DISCLAIMER
  47.     
  48.     
  49.     
  50.         This is the initial release of SBM FORTRAN.  It is probable that there
  51.         are bugs.  It may NEVER be totally bug-free.  For this reason we make
  52.         the following statement.
  53.    
  54.         This program is supplied as-is.  The author disclaims all warranties,
  55.         expressed or implied. The author assumes no liability for damages which
  56.         might result from the use of this program.
  57.    
  58.         You are encouraged to freely distribute this package.  Mail copies to
  59.         friends.  Put  it up on other boards.  We only request that you
  60.         distribute only unmodified copies.
  61.    
  62.    
  63.         Direct all inquiries, suggestions, etc. to:
  64.    
  65.                             Duke Daigh
  66.                             P.O. Box 631
  67.                             Pine Bluffs, Wyoming  82082-0631
  68.  
  69.  
  70.  
  71.  
  72.                                   CONTENTS
  73.  
  74.     Introduction to SBM fortran. . . . . . . . . . . . . . . . . . . . iii
  75.     Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
  76.     Current status . . . . . . . . . . . . . . . . . . . . . . . . . . v
  77.  
  78.     Fortran statements . . . . . . . . . . . . . . . . . . . . . . . . 1-1
  79.     Statement lables . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
  80.     Symbolic names and keywords  . . . . . . . . . . . . . . . . . . . 1-1
  81.     Statement order  . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
  82.  
  83.     Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
  84.     Include  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
  85.  
  86.     Data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
  87.              Byte, Character, Integer*1, Logical . . . . . . . . . . . 1-3
  88.              Word, Integer, Integer*2  . . . . . . . . . . . . . . . . 1-3
  89.              Doubleword, Integer*4 . . . . . . . . . . . . . . . . . . 1-3
  90.              Character strings, ASCIIZ . . . . . . . . . . . . . . . . 1-3
  91.  
  92.     Quoted strings . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
  93.     Data declaration and initialization  . . . . . . . . . . . . . . . 1-5
  94.     Data statement . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
  95.  
  96.     OPEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
  97.              UNIT (5-255). . . . . . . . . . . . . . . . . . . . . . . 2-1
  98.              IOCB names  . . . . . . . . . . . . . . . . . . . . . . . 2-1
  99.              FILE  . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
  100.              ALIAS (alternate name for io unit). . . . . . . . . . . . 2-1
  101.              STATUS (old, new, append) . . . . . . . . . . . . . . . . 2-1
  102.              RECL  . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
  103.  
  104.     READ STATEMENTS  . . . . . . . . . . . . . . . . . . . . . . . . . 2-2
  105.            Unformatted . . . . . . . . . . . . . . . . . . . . . . . . 2-3
  106.            formatted . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
  107.            List directed . . . . . . . . . . . . . . . . . . . . . . . 2-4
  108.  
  109.            Next character from keyboard (NEXCHAR). . . . . . . . . . . 2-4
  110.  
  111.     WRITE STATEMENTS . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
  112.            Unformatted . . . . . . . . . . . . . . . . . . . . . . . . 2-5
  113.            formatted . . . . . . . . . . . . . . . . . . . . . . . . . 2-5
  114.            List directed . . . . . . . . . . . . . . . . . . . . . . . 2-6
  115.  
  116.            SHOW_CHAR (display a character on screen) . . . . . . . . . 2-6
  117.            CRLF  (write cr,lf to specified IOCB) . . . . . . . . . . . 2-6
  118.  
  119.     FORMAT STATEMENTS  . . . . . . . . . . . . . . . . . . . . . . . . 2-7
  120.            Field and edit descriptors. . . . . . . . . . . . . . . . . 2-7
  121.  
  122.     ARITHMETIC EXPRESSIONS . . . . . . . . . . . . . . . . . . . . . . 3-1
  123.            INC, DEC  (incrementing and decrementing variables. . . . . 3-1
  124.            ADD, SUB  (adding to, or subtracting from variables . . . . 3-1
  125.            Subscripts  . . . . . . . . . . . . . . . . . . . . . . . . 3-2
  126.  
  127.  
  128.  
  129.     
  130.     
  131.        CONTROL STATEMENTS
  132.               TEST, TEST Numeric. . . . . . . . . . . . . . . . . . . . . 4-1
  133.               Control flags . . . . . . . . . . . . . . . . . . . . . . . 4-1
  134.               Conditional transfers . . . . . . . . . . . . . . . . . . . 4-1
  135.    
  136.               Compare variable to constant, CMP . . . . . . . . . . . . . 4-2
  137.               Compare string to string  . . . . . . . . . . . . . . . . . 4-2
  138.               Unconditional transfers, GOTO, JMP  . . . . . . . . . . . . 4-2
  139.               WAIT  . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
  140.               PAUSE . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
  141.               STOP, CALL EXIT . . . . . . . . . . . . . . . . . . . . . . 4-2
  142.     
  143.               TABLE_LOOKUP  . . . . . . . . . . . . . . . . . . . . . . . 4-3
  144.     
  145.               IF statements . . . . . . . . . . . . . . . . . . . . . . . 4-4
  146.               Block IF  . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
  147.               Do-loops  . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
  148.     
  149.        RESERVED WORDS AND ARRAYS. . . . . . . . . . . . . . . . . . . . . 5-1
  150.               The command line (command tail) . . . . . . . . . . . . . . 5-1
  151.               Useful program constants  . . . . . . . . . . . . . . . . . 5-1
  152.    
  153.     
  154.        Miscellaneous Intrinsics . . . . . . . . . . . . . . . . . . . . . 6-1
  155.               COPY Array_1 to Array_2 . . . . . . . . . . . . . . . . . . 6-1
  156.               FIND_CHAR 'c', Array  . . . . . . . . . . . . . . . . . . . 6-1
  157.               END  Ignored by the compiler. . . . . . . . . . . . . . . . 6-1
  158.               Masking operations.  AND, XOR, OR . . . . . . . . . . . . . 6-1
  159.               SHIFT Shift a variable. . . . . . . . . . . . . . . . . . . 6-1
  160.               PARSE String, Keword  . . . . . . . . . . . . . . . . . . . 6-1
  161.               PARSE_ONLY String, Keword, 'char' . . . . . . . . . . . . . 6-1
  162.               LDA.  Load address  . . . . . . . . . . . . . . . . . . . . 6-2
  163.               UPCASE.  Convert string to upper case . . . . . . . . . . . 6-2
  164.     
  165.        SYSTEMS STUFF  . . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  166.               EXCLUDE_RTL . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  167.               LABEL  variable, word/byte. . . . . . . . . . . . . . . . . 6-3
  168.               PRESET data-type,variable . . . . . . . . . . . . . . . . . 6-3
  169.               SETFORM 'c' . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  170.               SETIF 'c' . . . . . . . . . . . . . . . . . . . . . . . . . 6-3
  171.    
  172.    
  173.        Ramdisk  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
  174.    
  175.        Known bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
  176.  
  177.  
  178.  
  179.  
  180.  
  181.                      INTRODUCTION TO SBM FORTRAN
  182.  
  183.     This manual describes  SBM FORTRAN.  SBM is based on American National
  184.     Standards Institute FORTRAN 77 language.  It is assumed that the reader
  185.     has knowledge of an existing FORTRAN language and is familiar with MSDOS
  186.     or PCDOS operating system.  This manual is not intended to teach
  187.     FORTRAN, but is intended to be used as reference material only.
  188.  
  189.     The original intention of SBM fortran was the author's answer to the 'C'
  190.     language. The cryptic nature of 'C', while appealing to many
  191.     programmers, leaves me cold. While I fully appreciate the power of the
  192.     'C' language (as with assembler), I felt that there was needed something
  193.     that would better suit my style.
  194.  
  195.     I also remember when I brought my first XT home. There were many
  196.     fortran-written utilities that I had on the Z-80 without which I felt
  197.     very helpless. By the time I had rounded up the money to buy the system,
  198.     I had none left for the software that I very sorely needed.  An
  199.     affordable compiler of an easily learned language seemed to the the
  200.     answer.  A good reason  for someone, such as I, to write SBM fortran.
  201.  
  202.     The powerful fortran systems that are now on the market are designed with
  203.     the high-level user in mind.  Program size is not important.  I needed
  204.     something that would generate about the same code as if I wrote the it in
  205.     assembler.
  206.  
  207.     This compiler operates by converting FORTRAN source code into assembler
  208.     instructions,  which are then converted into machine code using WASM, an
  209.     assembler written by ERIC TAUK, of Merengo, IL.  The result is a COM
  210.     file, which can then be run on any MSDOS based system.
  211.  
  212.     THIS IS VERSION 1.00. To most of us this means a system that works well
  213.     enough for the author, but sometimes awkward for the user. Here is a
  214.     problem. I am in the process of moving to Wyoming.  Here in Denver, I
  215.     have access to many excellent bulletin boards. In Wyoming, that will
  216.     not be the case. I must therefore release this version knowing that
  217.     there may be bugs.  Since I will no longer have easy access to the
  218.     boards, I will not longer have easy access to you, the user. I must
  219.     therefore go to a 'shareware' mode.
  220.  
  221.     To provide this connection, You must send me your name and mailing
  222.     address. That will make you a registered user. To receive ANY updates of
  223.     this compiler, you MUST be a registered user. At a minimum, I will
  224.     upgrade to provide some of the functions that I need. Registered users
  225.     will receive the first (or most recent) update. I most certainly need
  226.     your suggestions for improvements and bug removal. If you like this
  227.     compiler as I believe you will, your $20 contribution will be
  228.     appreciated.  Since I will no longer have access to the boards, that's
  229.     the only way that you can receive the update.
  230.  
  231.  
  232.  
  233.     MSDOS is a registered trademark of Microsoft Corporation.
  234.     PCDOS is a registered trademark of IBM Corporation.
  235.  
  236.  
  237.  
  238.  
  239.  
  240.                                    iii
  241.  
  242.  
  243.  
  244.     
  245.     
  246.        FEATURES OF SBM FORTRAN
  247.     
  248.        It is a compiler compiler.  It was conceived as a bootstrap system to
  249.        compile parts of itself.  That's why I refer to it as my answer to 'C'.
  250.     
  251.        You can insert assembler coding and macros.  You can invoke the standard
  252.        interrupts.  In other words, you can do anything with this compiler that
  253.        you can do in assembler.  In fact, some of the more complex modules of
  254.        the compiler are WRITTEN IN FORTRAN.  Any future refinements will be
  255.        written in fortran.
  256.     
  257.        The executable module is very compact and efficient compared to other,
  258.        higher-level compilers.
  259.     
  260.        It combines the simplicity of fortran coding with the power of the
  261.        assembler.
  262.     
  263.        You can operate it as you would any other F77 compiler and end up with
  264.        code that will usually run on any other F77 compiler.
  265.     
  266.        You can place more than one statement on each record.
  267.     
  268.        You can append comments to each statement.
  269.     
  270.        The compiled module uses buffered input, making it very fast. 
  271.        Pathnames are used so that  you can access data on other drives and
  272.        in other directories.
  273.     
  274.        All console/keyboard i/o can be re-directed.
  275.     
  276.        It has many powerful intrinsic operations, such as:  PARSE, COPY,
  277.        TABLE-LOOKUP, COMPARE, etc..
  278.     
  279.        You can do masking operations, such as AND, OR, XOR.
  280.     
  281.        You can shift variables left or right, by the number of bits that you
  282.        specify.
  283.     
  284.    
  285.    
  286.    
  287.    
  288.    
  289.    
  290.    
  291.    
  292.    
  293.    
  294.    
  295.    
  296.    
  297.    
  298.    
  299.    
  300.                                      iv
  301.  
  302.  
  303.  
  304.  
  305.  
  306.     CURRENT STATUS OF SBM FORTRAN
  307.  
  308.     BE VERY CAUTIOUS USING ANY SORTWARE!  Do not trust it!  Even if you
  309.     have been using it for awhile, mentally EDIT the output.  Does it look
  310.     reasonable?  You are the best judge.
  311.  
  312.     SBM fortran is not a  scientific compiler. i.e., it does not have
  313.     floating point.
  314.  
  315.     Integer*4 is there, but needs more hooks before it can be used.
  316.  
  317.     Arithmetic expressions are primitive, but gramatically correct and
  318.     transportable.  This feature will be upgraded to some extent.
  319.  
  320.     Needs more diagnostic messages.  SBM fortran is not just forgiving. It's
  321.     actually permissive.
  322.  
  323.     But, on the other hand, if you accept the above limitations, and write a
  324.     program using standard fortran coding techniques, it will work, and the
  325.     code can be put up and run under most other F77 compilers, without
  326.     modification.
  327.  
  328.  
  329.  
  330.  
  331.     FUTURE OF SBM FORTRAN
  332.  
  333.     SBM fortran was not, and is not intended to be a full-blown fortran
  334.     compiler. It is not intended to compete with the more powerful
  335.     systems.
  336.  
  337.     Integer*4 is one feature that will certainly be implememted. With large
  338.     integers, you can do quite a lot.  Accounting work and other related
  339.     types of work require precise calculations. Large integers makes that
  340.     precision possible. Instead of dollars and cents, you can carry
  341.     everything in total cents. i.e. $156.25 is 15625 cents. For output,
  342.     the format statement can direct that a decimal point be inserted (this
  343.     feature is already installed, but not yet usable).
  344.  
  345.     The compiler needs compile time and runtime error detection that it does
  346.     not now have. Some errors simply lock up the system.  That is something
  347.     that must be addressed in the first update.
  348.  
  349.     The direction of its future is mostly up to you.  I have some floating-
  350.     point routines that could be implemented, but I will probably not work in
  351.     that direction unless there's enough response.  The routines are in
  352.     another  fortran compiler of mine which I chose not to release at this
  353.     time.
  354.  
  355.  
  356.     There's  another feature, TONTO (trace-on, trace_off), that might also be
  357.     moved  from my other compiler.
  358.  
  359.                                     v
  360.  
  361.  
  362.  
  363.                                                                             1-1
  364.     
  365.        FORTRAN STATEMENTS
  366.     
  367.        There are two types of statements, executable and non-executable.
  368.     
  369.        Non-executable statements are used to describe the characteristics and
  370.        format of data.
  371.     
  372.        Executable statements specify actions that the program is to take
  373.        against, or for the welfare of the data, such as READ, WRITE, etc..
  374.     
  375.        Each source input line can be as long as 80 characters.  Statement
  376.        Continuations are permitted only on certain statements.  they are:
  377.                OPEN, FORMAT, data initialization.
  378.     
  379.        You can use statement labels to identify and reference individual
  380.        statements in a program.  You can label any statement but only labled
  381.        statements can be referenced.
  382.     
  383.     
  384.        SYMBOLIC NAMES AND KEYWORDS
  385.     
  386.        Symbolic names, chosen by the programmer, identify program variables and
  387.        statement lables.  A keyword is a pre-assigned identifier that you use to
  388.        specify a particular action that the program is to take. Keywords are
  389.        also known as RESERVED WORDs (see 5-1).
  390.     
  391.        A symbolic name is a sequence of one to 31 alphanumeric characters.
  392.     
  393.        When used to identify program variables, the first character must not be
  394.        numeric.  The name may consist of just about any printable character
  395.        except for + - * / ( ) ; | apostrophy or comma.  You cannot use reserved
  396.        words to identify program variables.
  397.     
  398.        Standard fortran labels consist of numeric lables only.  SBM fortran
  399.        allows either, except for lables of format statements, which must begin
  400.        with a numeric digit 0-9. Lables cannot begin with + - * ; |. Lables
  401.        cannot use ( ) [ ] apostrophy or comma.  Reserved words may be used as
  402.        lables.
  403.     
  404.        Statement lables must begin in column 1.  All other statements must begin
  405.        in  any column other than 1. By all means use column 7 if you wish to
  406.        adhere to an accepted standard.
  407.     
  408.        You can assign more than one lable to a statement if you wish.  In doing
  409.        so, you can refer to it by either label.
  410.     
  411.     
  412.        More than one statement may appear on each source input record by
  413.        terminating each (except the last) with the marker code '|'. (on most
  414.        keyboards this is uppercase backslash)  The format of the additional
  415.        statements is no different than the first, so don't forget to follow the
  416.        marker with at least one blank, unless it is to be a label.
  417.     
  418.     
  419.     
  420.        STATEMENT ORDER
  421.     
  422.        Doesn't matter. mix or match. the compiler will sort them out.
  423.  
  424.  
  425.  
  426.     1-2
  427.  
  428.     COMMENTS - You can use a semi-colon(;), an asterisk(*) or hyphen (-) in
  429.     column 1 to specify that the line is a comment. In addition, if you place
  430.     a ';' anywhere in the statement portion of a source line, the rest of
  431.     that statement will be treated as a comment. A blank line is also
  432.     considered to be a comment.
  433.  
  434.     Individual assembler code statements can be inserted anywhere by placing
  435.     a plus (+) in column 1.
  436.  
  437.  
  438.     INCLUDE
  439.  
  440.     Blocks of fortran statements, assembler code, and macros may be inserted
  441.     using the INCLUDE option.
  442.  
  443.     Syntax:    INCLUDE pathname   Pathname can name any file that is
  444.                                   currently on line, on any disk.
  445.  
  446.     To include assembler code or macros, the statement must have a '+' in
  447.     column 1 and the pathname must be in quotes.
  448.  
  449.     Example:  +   include 'maclib.asm'
  450.  
  451.  
  452.     A small macro library is provided to generate some of the code that the
  453.     compiler needs.  You may build one of your own choosing and insert it
  454.     using the + INCLUDE option.
  455.  
  456.  
  457.  
  458.  
  459.                                                                             1-3
  460.     
  461.        DATA TYPES
  462.     
  463.    *   SBM provides three data types: BYTE,  WORD and Doublewords.
  464.     
  465.        BYTE data occupies 8 bits (one byte) of memory and is normally only used
  466.        for ascii characters and strings, or logical variables, such as
  467.        programmer-specified switches and flags. You can use this data type for
  468.        numerical values, up to 255.
  469.     
  470.        WORD data are numbers that are whole positive, negative or zero-value
  471.        numbers. WORD data values occupy 16 bits (two bytes) of memory and can
  472.        contain numbers from -32,768 to 32,767. Although a word can hold a number
  473.        as large as 65,635, this implementation provides no standard way to
  474.        output the larger numbers.
  475.     
  476.    *   DOUBLEWORDs are 32-bit (integer*4) integers. The may contain numbers
  477.        within the range -2,147,483,648 to +2,147,483,647. Integer*4 data is very
  478.        useful for accounting applications where larger numbers are involved and
  479.        precision is required in transactions. For example, monitary amounts can
  480.        be set into integer*4 variables using total cents, rather than dollars
  481.        and cents. When the results are to be printed, a special feature of
  482.        integer*4 values allows you to insert decimal points where applicable.
  483.     
  484.     
  485.        In SBM FORTRAN, the following mean the same:
  486.     
  487.        CHARACTER, BYTE, INTEGER*1, LOGICAL       8-bit data.
  488.     
  489.        INTEGER, WORD, INTEGER*2                 16-bit data.
  490.     
  491.     
  492.        CHARACTER strings appear in memory as a collection of ASCII characters
  493.        terminated by a binary zero.  This zero terminator controls all
  494.        operations in which this data type is manipulated, such as compares,
  495.        copys, input-output, etc.. With the terminator, this is known as as
  496.        an ASCIIZ string.
  497.     
  498.     
  499.     
  500.     
  501.     *  Integer*4 is not totally implemented.  Some parts of it are. Some not.
  502.        I wouldn't recommend that you try it yet. It will be implemented in the
  503.        next update.
  504.  
  505.  
  506.  
  507.     1-4
  508.  
  509.     QUOTED STRINGS
  510.  
  511.     Over the years, we programmers have created a standard that would not be
  512.     acceptable to people other than programmers. That is, calling an
  513.     apostrophy a quote! When we think of quoted strings, we think of an ascii
  514.     string enclosed in apostrophies, not quotes. Don't know how this started,
  515.     but we all do it. Anyway, format statements sometimes require us to
  516.     specify a 'quoted' string for output. With this in mind, in this manual,
  517.     when we talk of a quoted string, we mean a string that is enclosed in
  518.     apostrophies.
  519.  
  520.     When entering a quoted string that we wish wish to contain an imbedded
  521.     quote, SBM FORTRAN requires that you use an ACTUAL quote(").  Standard
  522.     fortran wants you to use two apostrophies in a row.  We do it differently
  523.     here.
  524.  
  525.  
  526.  
  527.     example:  standard fortran requires:
  528.  
  529.               FORMAT('We sometimes don''t follow standards')
  530.  
  531.  
  532.  
  533.     We do it this way:
  534.  
  535.               FORMAT('We sometimes don"t follow standards')
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.                                                                             1-5
  543.     
  544.        DATA DECLARATION and INITIALIZATION
  545.     
  546.     
  547.        There are two modes in which you can declare variables, (1) declare and
  548.        (2) declare/initialize.
  549.     
  550.          (1) Declare.  The 'standard' declaration in which you specify the size
  551.          of individual elements and optionally set aside a specific amount of
  552.          memory to contain these elements in an array.
  553.     
  554.              Example:  INTEGER ELEV(20), DIST(20), SLOPE, DELTA(3)
  555.     
  556.        (2) Declare/initialize. This mode allows you to declare a variable or an
  557.        array and establish it's initial value(s). When initializing arrays, only
  558.        as much memory as needed to contain the given data will be allocated.
  559.        This statement can be continued. When used, this option must be the last
  560.        (or only) declaration on the source statement. You can, of course, put
  561.        multiple statements on one physical record. Examples:
  562.     
  563.            integer day/5/|   integer month/12/|   integer year/1948/
  564.     
  565.            integer*1 level(4), mace/3/
  566.     
  567.            character pathname/'c:sales.jan',0/
  568.     
  569.     
  570.          This statement is tricky.  If you forget the closing '/', the compiler
  571.          will search the rest of your source looking for one.
  572.     
  573.          Here's another example, taken right out of the compiler itself:
  574.     
  575.            character registers/
  576.              'AX',0,'BX',0,'CX',0,'DX',0,'SI',0,'DI',0,'BP',0
  577.              'AL',0,'BL',0,'CL',0,'DL',0,'AH',0,'BH',0,'CH',0
  578.              'DH',0,'[SI]',0,'[DI]',0,'[BX]',0,'[BP]',0,'$'/
  579.     
  580.        If you want to declare an array of a certain size but initialize only the
  581.        first portion, here's another example from the compiler:
  582.     
  583.            character outbuf(80)
  584.            data outbuf/'e:sbm.t$$',0/
  585.     
  586.     
  587.     
  588.        THE DATA STATEMENT
  589.     
  590.        This is an executable statement!  Most fortran reference manuals don't
  591.        admit it but it is.  Because of this fact, it can be used anywhere in
  592.        the program.  As you see above, you can initialize a variable or an
  593.        array with it.  You can also change data values on the fly. Over and
  594.        over.
  595.     
  596.        Here's a handy use of this feature:
  597.     
  598.           If(code.eq.4) DATA table/1,2,3,4,5/
  599.           If(code.eq.5) DATA table/6,7,8,9,0/
  600.  
  601.  
  602.  
  603.                                                                             2-1
  604.     
  605.        OPEN statement
  606.     
  607.        The OPEN statement establishes the connection between a fortran UNIT and
  608.        a file or device. You must issue this statement before any diskfile I/O
  609.        can be used. Note: you cannot close a file and re-open.
  610.     
  611.        syntax:
  612.     
  613.        OPEN(UNIT,ALIAS=buff-name,FILE='filespec',status='old/new/append',
  614.                                                                      RECL=nnn)
  615.     
  616.        where:
  617.     
  618.        UNIT is a numeric constant, in the range of 5-255.
  619.     
  620.        The unit number is converted to a control block name by appending the
  621.        number to 'IOCB_'. The unformatted input record can be referenced by this
  622.        name (as well as any alias that you may specify). Unit 10, for example
  623.        may be referenced by the name 'IOCB_10'. An example of this can be found
  624.        under UNFORMATTED READ.
  625.     
  626.        ALIAS is an alternate name by which the file can be addressed when
  627.        reading unformatted (raw) data. Raw mode, when used instead of formatted
  628.        or list-directed input results in much faster i\o. Unformatted i/o is
  629.        discussed more fully in READ statements. This parameter is optional.
  630.     
  631.     
  632.        FILE='filespec'. Pathnames can be used here. You may name a file that is
  633.        to be used, or specify a character array which contains an ASCIIZ
  634.        filespec. If the name itself is used here, it must be enclosed in quotes.
  635.        If an array containing the filespec is used, it must not be quoted.
  636.     
  637.     
  638.        STATUS='old/new/append'. If the file is to be created, use 'new'. If the
  639.        file is to be read/write, use 'old'. If you have an existing file that is
  640.        to be enlarged, use 'append'. If you use 'new', any existing file by that
  641.        name will be replaced. If you omit this parameter, 'old' is assumed. The
  642.        quotes are optional, for compatability.
  643.     
  644.     
  645.        RECL=nnn. SBM uses a buffered input system, resulting in very high-speed
  646.        input.  The buffering system uses two arrays.  one for the input buffer,
  647.        (into which is loaded blocks of non-predictable pieces) and the record
  648.        buffer which will contain only the individual record.  It is from the
  649.        record area that formatting takes place.  You can use the RECL option to
  650.        insure that no record exceeds a given size.  If this option is omitted,
  651.        record length defaults to 80.
  652.  
  653.  
  654.  
  655.     2-2
  656.  
  657.     READ STATEMENTS
  658.  
  659.     READ statements transfer data from a specified I/O unit to memory.  You
  660.     can reference both external and internal files.  The input data may be
  661.     any ASCII stream.
  662.  
  663.     Syntax:   READ(UNIT [,FMAT]) list
  664.  
  665.  
  666.     UNIT is one of:
  667.  
  668.         (1) An integer constant in the range of 5 to 255 that identifies an
  669.             external unit previously referenced in an OPEN statement.
  670.  
  671.         (2) An asterisk (*) specifying the default I/O unit (console).
  672.             May be redirected.
  673.  
  674.         (3) The name of an internal array (such as the input buffer)
  675.             containing data. This is the manner by which you can re-read
  676.             a data record.  explanation:  on any read, the data is read into
  677.             the input buffer as raw data.  If a format has been specified,
  678.             the record is transformed into the corresponding input fields.
  679.             But: even after formatting, the raw data is still in the input
  680.             buffer.
  681.  
  682.     FMAT is a parameter that specifies whether explicit or list-directed
  683.             formatting is to be applied. It may take either of the following
  684.             forms.
  685.  
  686.          (1) A statement label of a format statement. The statement label
  687.              must begin with a numeric character 0-9. The rest of the label
  688.              can be anything of your own choosing.
  689.  
  690.          (2) '*' that specifies list-directed formatting.
  691.  
  692.  
  693.     If FMAT is omitted, a 'null' read is performed, effectively passing over
  694.     an input record.  The unformatted contents of the record are not lost,
  695.     however, but are preserved in the input-output control buffer (IOCB).
  696.     The string is available by its IOCB name, and may be treated as any
  697.     other character array.
  698.  
  699.  
  700.     LIST names the variables, arrays, array elements and character strings
  701.     to which data will be transferred.
  702.  
  703.     If end of file is sensed, the logical variable 'EOF' is set to TRUE.
  704.  
  705.  
  706.  
  707.                                                                             2-3
  708.     
  709.        UNFORMATTED READ
  710.     
  711.     
  712.        Syntax:   READ(UNIT) list
  713.     
  714.        This is the most simple of the input statements.  It transfers one
  715.        record of binary data to the array 'list'.  No conversion takes place.
  716.        (A typical file of data information is stored as ASCII characters. No
  717.        conversion is required if all you want to do is to examine it.  It is
  718.        considered to be binary data)
  719.     
  720.     
  721.        If 'list' is omitted, one record is by-passed.  For that reason it is
  722.        sometimes referred to as a 'null' read, or 'by-pass' read.
  723.     
  724.        The contents of the record are available in the IOCB or under the ALIAS
  725.        that was specified in the 'open'.
  726.     
  727.        Here's an example of how you might use it to read and display a file.
  728.     
  729.     
  730.                 open(5,file='reform.for')
  731.            1000 read(5)
  732.                 if(eof) stop
  733.                 write(*) iocb_5
  734.                 goto 1000
  735.                 end
  736.     
  737.        Type this one in and try it. It will make your hair stand on end! If you
  738.        were to try this example on a large file, you can see that it wouldn't do
  739.        you much good. The output would fly by so fast that you couldn't read
  740.        most of it.
  741.  
  742.  
  743.  
  744.     2-4
  745.  
  746.     FORMATTED READ
  747.  
  748.     Syntax:   READ(UNIT,FMAT]) list
  749.  
  750.     This is a two-step operation.
  751.  
  752.     Step 1 reads the record into the IOCB (an unformatted read).
  753.  
  754.     Step 2 applies the formatting and transforms the ascii data into the
  755.     various input fields.
  756.  
  757.  
  758.  
  759.  
  760.     LIST-DIRECTED READ
  761.  
  762.     Syntax:   READ(UNIT,*) list
  763.  
  764.     Read statements are either unformatted or formatted. The difference in a
  765.     list-directed read is that the compiler is going to create a format for
  766.     itself, based on what kind of data we have in the 'list'.
  767.  
  768.     This is a two-step operation.
  769.  
  770.     Step 1 reads the record into the IOCB (an unformatted read).
  771.  
  772.     Step two applies the compiler-designed formatting and transforms the
  773.     ascii data into the various input fields.
  774.  
  775.  
  776.  
  777.  
  778.     NEXCHAR
  779.  
  780.     Reads a character from the keyboard.  Does not echo to the console. If
  781.     no character is ready, waits for operator to enter one.  The character
  782.     is available to the program in register AL.  Execution resumes.
  783.  
  784.     See 'testall.for' for a practical example. (NEXCHAR and WAIT are same)
  785.  
  786.  
  787.  
  788.                                                                             2-5
  789.     
  790.        WRITE STATEMENTS
  791.     
  792.        WRITE statements transfer data from memory to a specified I/O unit. You
  793.        can reference both external and internal files.
  794.     
  795.        Syntax:   WRITE(UNIT [,FMAT]) list
  796.     
  797.     
  798.     
  799.     
  800.     
  801.        UNFORMATTED WRITE
  802.     
  803.     
  804.        Syntax:   WRITE(UNIT) list
  805.     
  806.        This statement transfers one record of ascii data to UNIT. The data must
  807.        be terminated by a binary zero. No formatting takes place.
  808.     
  809.        If 'list' is present, it must be the name of an array.  If omitted, the
  810.        formatted contents of the IOCB is written.
  811.     
  812.        This is the form of output that you should use to insert control
  813.        characters, such as escape-sequences, extra line feeds, backspaces, etc.
  814.     
  815.        Example, from 'testall.for'
  816.     
  817.                 data outbuf/esc,'[2J',0/
  818.                 write(*) outbuf  ; clear the screen
  819.     
  820.     
  821.     
  822.     
  823.     
  824.        FORMATTED WRITE
  825.     
  826.        Syntax:   WRITE(UNIT,FMAT]) list
  827.     
  828.        This is a two-step operation and is the revese of formatted read.
  829.     
  830.        Step 1 formats the specified data fields from binary to decimal as
  831.        required and copies ascii data or quoted strings into the IOCB.
  832.     
  833.        Step 2 writes the contents of the IOCB to the specified UNIT.
  834.     
  835.  
  836.  
  837.  
  838.     2-6
  839.  
  840.     LIST-DIRECTED WRITE
  841.  
  842.     Syntax:   WRITE(UNIT,*) list
  843.  
  844.     In a list-directed write, a format is constructed by the compiler based
  845.     upon the data type of the various fields. Other than that, it is exactly
  846.     like the formatted write.
  847.  
  848.     While most compilers require that the first character of an output record
  849.     be used for carriage control, SBM fortran does not. When output is to be
  850.     directed to a printer, feel free to insert ascii control codes, 0Ch for
  851.     eject, 0Dh for double space.
  852.  
  853.  
  854.  
  855.  
  856.     SHOW_CHAR
  857.  
  858.     Display the character that is in the AL register.  You can use this
  859.     statement immediately after NEXCHAR.
  860.  
  861.  
  862.  
  863.  
  864.     SHOW_CHAR  'char'
  865.  
  866.     Display specific character.  The character can be a printable
  867.     character enclosed in quotes, or a hex constant.
  868.     Example:    show_char 8   gives us a back-space on the console.
  869.  
  870.  
  871.  
  872.  
  873.                                                                             2-7
  874.     
  875.        FORMAT STATEMENTS
  876.     
  877.        Format is a labled non-executable statement that specifies the format of
  878.        data being transferred between memory and i/o devices. It may appear
  879.        anywhere in the program. The first character of the label must be
  880.        numeric. The method by which formatting takes place is by the use of
  881.        field and edit descriptors with which the type and size of the various
  882.        data fields is specified and quoted strings for constant ascii data.
  883.     
  884.        Each field descriptor consists of letter which identifies the type of
  885.        data, followed by a number indicating the width of the data field. In
  886.        some cases the width is optional.
  887.     
  888.        Format control proceeds from left to right, matching each field
  889.        descriptor with each item in the i/o list.
  890.     
  891.        SBM uses 3 field descriptors, A, I, X
  892.     
  893.        Character data.
  894.        The 'A' field descriptor transfers character data.  It has the form
  895.     
  896.            A[w]
  897.     
  898.        If W is present the field width is w-characters. If omitted, the field
  899.        width is the size of the data item in the i/o list. The name in the list
  900.        can be any data type, character, logical or integer. On input, any
  901.        existing data is simply overlayed.
  902.     
  903.     
  904.        Integer data   I[w]
  905.     
  906.        If the output binary number, when converted to decimal, exceeds the
  907.        allocated space, the number will back-flow into the previous field,
  908.        replacing whatever the formatter just put there. (not like standard
  909.        fortran, which would fill the output field with asterisks. If enough of
  910.        you complain, I will comply with the standard).
  911.     
  912.     
  913.        Skip    [w]x
  914.     
  915.        Quoted strings.
  916.     
  917.     
  918.        Dollar sign descriptor  $
  919.     
  920.        Normally, all output records are terminated by a carriage return. The
  921.        dollar sign descriptor inhibits this action. The option is intended for
  922.        interactive I/O and is valid only for output statements. It permits user
  923.        response to appear on the same line as a prompt.
  924.     
  925.        example:   WRITE(*,*) 'Enter project number: ',$
  926.                   READ(*,*) PROJ
  927.     
  928.        When used, the dollar sign descriptor must the the last item of the
  929.        output statement.
  930.  
  931.  
  932.  
  933.                                                                             3-1
  934.     
  935.        ARITHMETIC EXPRESSIONS
  936.     
  937.        SBM fortran does not yet support more than a simple one-function
  938.        expression.  The simpler form of an expression, while requiring more
  939.        statements to complete some calculations, still maintains compatability
  940.        with higher-level compilers.
  941.     
  942.        Thus, we are limited to such statements as:
  943.     
  944.                 counter=counter+1
  945.                 range=limit-base
  946.                 etc..
  947.     
  948.        String expressions allow a little more versatility, such as:
  949.     
  950.                 filespec='c:modemuf.asm'
  951.                 letter='A'
  952.                 etc..
  953.     
  954.     
  955.        In addition to the above arithmetic statements, SBM fortran also supports
  956.        the following statements:
  957.     
  958.        INC, DEC      Add or subtract 1 from an integer variable.  This is the
  959.                      most efficient way to add or subtract the constant 1 from
  960.                      a variable.
  961.     
  962.                      example:    inc counter    ; add one to 'counter'
  963.                                  dec tally      ; subtract one from 'tally'
  964.     
  965.     
  966.     
  967.        ADD, SUB      Add or subtract constant or value from register from an
  968.                      integer variable.  This is much faster than standard
  969.                      fortran and uses less code.
  970.     
  971.                      example:    add index,10        ; add 10 to index.
  972.     
  973.                                  index=index+10      ; the usual, less
  974.                                                      ; efficient way.
  975.     
  976.     
  977.     
  978.  
  979.  
  980.  
  981.     3-2
  982.  
  983.     SUBSCRIPTING
  984.  
  985.  
  986.     Any variable may be accessed by using the variable name in a fortran
  987.     statement. To access variables in positions other than the first, you
  988.     must (1) use an integer offset or (2) use a subscript.
  989.  
  990.     An integer offset may be used by simply appending the variable name with
  991.     a plus-or-minus constant. Example: 'ARRAY+4' points to the fifth
  992.     position of a integer*1 or character array. If the array was integer*2,
  993.     it would point to the third position, since each element in an integer*2
  994.     array requires two positions. While this is not a standard fortran
  995.     method of accessing data, it is by far the most efficient.
  996.  
  997.     Subscripts, on the other hand, indicate the position of an element by
  998.     enclosing a subscript expression within a pair of parentheses.
  999.  
  1000.     The subscript expression can be an integer constant, and integer
  1001.     variable, or an integer variable plus-or-minus an integer constant.
  1002.  
  1003.       Examples: array(k), date(m+2), etc..
  1004.  
  1005.     Other informative examples can be found in the program 'TESTALL.FOR'.
  1006.  
  1007.  
  1008.     A word of caution: Do not allow the expression to go negative. You will
  1009.     access something, but who knows what...
  1010.  
  1011.  
  1012.  
  1013.                                                                             4-1
  1014.     
  1015.                                CONTROL STATEMEMTS
  1016.     
  1017.        There's no point in writing a program if you can't control what it does.
  1018.        Without flow control, a program would sequentially execute each of your
  1019.        statements and then blow up. That would be tacky.
  1020.     
  1021.        Fortran flow control statements provide a means of modifying the normal
  1022.        sequemntial flow of execution.
  1023.     
  1024.        Flow control statements are: TEST, COMPARE, CMP, DO, CONTINUE, GOTO,
  1025.        JMP, STOP and CALL EXIT. Some of these are not standard but all are
  1026.        handy.
  1027.     
  1028.     
  1029.     
  1030.        TEST
  1031.     
  1032.        Usage:  TEST VARIABLE, MASK
  1033.            or  TEST VARIABLE, NUMERIC
  1034.     
  1035.        You can test a variable using a mask, or TEST NUMERIC.
  1036.        
  1037.        When a TEST is performed, control flags are set, depending upon
  1038.        the results of the test. You must then use an if-statement or
  1039.        conditional jump. Control flags are: equal, not equal, zero,
  1040.        not zero, carry and not carry.
  1041.     
  1042.            (EQ), (NE), (ZR), (NZ), (CY), (NC),  (NUMERIC), (NOT.NUMERIC)
  1043.     
  1044.        CONDITIONAL JUMPs are JNC, JC, JZ, JNZ
  1045.     
  1046.        Using a MASK, you can see if a particular bit or any one of a group
  1047.        if bits is set.  It does this with a logical AND, and sets flags but
  1048.        changes nothing in memory.
  1049.     
  1050.          Example:  see if an integer is odd or even.
  1051.                            test(answer,1)
  1052.                            if(zr) goto even
  1053.                       (or) jz even
  1054.     
  1055.     
  1056.        To test an individual ascii character to determine whether it is
  1057.        numeric or not, use the following syntax:
  1058.     
  1059.        TEST VARIABLE, NUMERIC
  1060.     
  1061.        This checks an ascii character to see if it is within the range of
  1062.        '0' - '9'.  As a result of this test, the logical variable 'numeric'
  1063.        is set to either true or false.
  1064.     
  1065.                Example:  test(inbuf(1),numeric)
  1066.                          if(not.numeric) goto alpha
  1067.  
  1068.  
  1069.  
  1070.     4-2
  1071.  
  1072.                             CONTROL STATEMEMTS
  1073.  
  1074.  
  1075.     CMP variable, constant
  1076.  
  1077.     Compare a variable to a known value. This statement is identical to it's
  1078.     ASM equivalent. Subscripts are not permitted, but offsets can be used.
  1079.  
  1080.     Usage:  CMP  Name, 'A'
  1081.             CMP  Name+2,'B'
  1082.             CMP  Year, 99
  1083.  
  1084.     This statement essentially subtracts the constant from the variable, does
  1085.     not change any values in memory but, sets the control flags. You must
  1086.     then use a conditional jump for program control.
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.     COMPARE
  1093.  
  1094.     Compare a string of characters against a model. Not case sensitive,
  1095.     'TOKEN' should be upper case.
  1096.  
  1097.     Usage:  COMPARE KEWORD, 'TOKEN'
  1098.  
  1099.  
  1100.     Example, from the compiler.
  1101.  
  1102.     -   see if prefix 'byte' or 'word'
  1103.         compare keword,'BYTE'    ;
  1104.         if(eq) goto destin_ok    ; if 'byte' or 'word',
  1105.         compare keword,'WORD'    ; accept it as-is.
  1106.         if(eq) goto destin_ok    ;
  1107.  
  1108.  
  1109.     GOTO          Unconditional transfer of control.
  1110.     JMP           Same as GOTO
  1111.  
  1112.  
  1113.  
  1114.     WAIT
  1115.  
  1116.     Wait for operator. Program execution stops. When operator has pressed
  1117.     any key, execution resumes.
  1118.  
  1119.  
  1120.  
  1121.     PAUSE ['message']
  1122.  
  1123.     Stops, waits for operator. If message included, displays the message.
  1124.     Otherwise, displays the phrase 'FORTRAN PAUSE'. Execution of the program
  1125.     will continue with the press of any key.
  1126.  
  1127.  
  1128.     STOP, CALL EXIT
  1129.  
  1130.     Use either to close all files, update directory and return control
  1131.     to the operating system.
  1132.  
  1133.  
  1134.  
  1135.                                                                             4-3
  1136.     
  1137.        TABLE_LOOKUP
  1138.     
  1139.        Given a character string, tests to see if the string exists in a
  1140.        specified table. Each entry in the table must be enclosed within quotes
  1141.        and must be in upper case. each entry must be followed by binary zero.
  1142.        The table must be terminated by a '$'.
  1143.     
  1144.        If the given string is found to be present in the table, register CX
  1145.        indicates it's relative position in the array. i.e., in the table
  1146.        below, AX=1, BX=2, CX=3, etc.
  1147.     
  1148.        If the string cannot be found, CX=0 and carry-flag is set.
  1149.     
  1150.        Here's a sample table.
  1151.     
  1152.         character registers/
  1153.           'AX',0,'BX',0,'CX',0,'DX',0,'SI',0,'DI',0,'BP',0
  1154.           'AL',0,'BL',0,'CL',0,'DL',0,'AH',0,'BH',0,'CH',0
  1155.           'DH',0,'[SI]',0,'[DI]',0,'[BX]',0,'[BP]',0,'$'/
  1156.     
  1157.        The following example wants to see if the character string that is in
  1158.        the array 'keword' is any of the entries in the table 'registers'.
  1159.     
  1160.        -   see if a destination is register.
  1161.            table_lookup keword,registers
  1162.            if(nc) goto destin_ok
  1163.     
  1164.     
  1165.     
  1166.     
  1167.        TABLE_ADD
  1168.     
  1169.        Following a table-lookup operation, adds a string to a given table.
  1170.        While this is not a control statement, it is included here because it
  1171.        is frequently used immediately following a non-successful table_lookup.
  1172.     
  1173.        Example:  install the string in the array 'keword' in the table.
  1174.     
  1175.        -   new symbol, put it in table.
  1176.            table_add keword
  1177.     
  1178.  
  1179.  
  1180.  
  1181.     4-4
  1182.  
  1183.                             IF statements
  1184.  
  1185.     An IF statement conditionally executes one statement or a block of
  1186.     statements.
  1187.  
  1188.     The IF statement has the form:
  1189.  
  1190.       IF (exp) stmt
  1191.  
  1192.     Where exp is a logical or relational expression.
  1193.  
  1194.  
  1195.  
  1196.     In a LOGICAL IF statement, we have, as the result of a TEST or
  1197.     input/output operation, a condition of true(non-zero) or false(zero). The
  1198.     statement, or block of statements, will be executed only if the condition
  1199.     is true. In a logical IF, exp simply names the logical variable. In
  1200.     addition to the normal variable names, SBM fortran also allows the
  1201.     following:
  1202.  
  1203.                    (EQ), (NE), (ZR), (NZ), (CY), (NC)
  1204.  
  1205.           or    (EOF),  (NOT.EOF),  (NUMERIC), (NOT.NUMERIC)
  1206.  
  1207.     stmt can be any non-labled executable statement, but not another IF.
  1208.  
  1209.  
  1210.     The RELATIONAL IF statement performs an on-the-fly comparison of a
  1211.     variable to a known value.
  1212.  
  1213.     Character-strings can be compared, no matter what their length, but only
  1214.     for EQ or NE. Other operators may be used, but use with caution. The
  1215.     comparison is NOT case sensitive.
  1216.  
  1217.     The relational IF has the following syntax:
  1218.  
  1219.           IF (VARIABLE.OP.Constant) stmt
  1220.  
  1221.     where  OP will be EQ, NE, LT, GT, LE, GE
  1222.  
  1223.     Constant may be (1) numeric,
  1224.                       (2) Ascii character (excluding ';' and '|') , or
  1225.                       (3) AsciiZ string.
  1226.  
  1227.  
  1228.  
  1229.                                                                             4-5
  1230.     
  1231.        There are two types of  IF statements:
  1232.     
  1233.           o  The single IF
  1234.     
  1235.           o  The block IF
  1236.     
  1237.           (The arithmetic IF is not supported by SBM fortran)
  1238.     
  1239.        The single IF statement conditionally executes a single statement. It
  1240.        has the form
  1241.     
  1242.          IF (exp) stmt
  1243.     
  1244.        where:
  1245.          exp is a logical expression.
  1246.     
  1247.          stmt is a single, not continued, fortran statement.
  1248.  
  1249.  
  1250.  
  1251.     4-6
  1252.  
  1253.  
  1254.     The block IF conditionally executes blocks of statements. It has the
  1255.     following form:
  1256.  
  1257.     IF (exp) THEN
  1258.        block
  1259.  
  1260.     ELSE
  1261.        block
  1262.  
  1263.     ENDIF
  1264.  
  1265.     where:
  1266.       exp is a logical expression.
  1267.  
  1268.     THEN must appear on the same line.
  1269.  
  1270.     block is a series of statements, none of which can be another block-IF.
  1271.  
  1272.     The ENDIF terminates the block-IF construct.
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.                                                                             4-7
  1280.     
  1281.     
  1282.        There are two types of data which can be compared in an IF statement,
  1283.        numeric or literal. Literals are recognized by the presence of quotes.
  1284.        Here are some examples:
  1285.     
  1286.     
  1287.        * Author used the following program to test out and debug IF statements.
  1288.        integer ibuf
  1289.        write(*,*) 'enter a number: ',$
  1290.        read(*,*) ibuf
  1291.        if(ibuf.eq.100) then
  1292.        write(*,*) '---------------'
  1293.        write(*,*) 'number is equal'
  1294.        else
  1295.        write(*,*) 'number is NOT equal'
  1296.        endif
  1297.        if(ibuf.lt.100) write(*,*) 'number is LT 100'
  1298.        if(ibuf.le.100) write(*,*) 'number is also LE  100'
  1299.        if(ibuf.gt.100) write(*,*) 'number is GT 100'
  1300.        if(ibuf.ge.100) write(*,*) 'number is also GE 100'
  1301.        stop
  1302.     
  1303.           - - - - - - - - - - - - - - - - - - - - - - - -
  1304.     
  1305.        ; this program reformats a WASM LST file to straight ASM format. You
  1306.        ; might want to do this to have a source that has the macros expanded.
  1307.     
  1308.               open(5,file=infile,status='old',recl=132,alias=inbuf)
  1309.        loupe  read(inbuf)
  1310.               if(eof) stop
  1311.               if(inbuf.eq.20h)    goto loupe
  1312.               if(inbuf.eq.'L')    goto loupe
  1313.               if(inbuf+22.eq.20h) goto loupe
  1314.               write(1) inbuf+26
  1315.               jmp loupe
  1316.     
  1317.  
  1318.  
  1319.  
  1320.     4-8
  1321.  
  1322.  
  1323.     DO Statement
  1324.  
  1325.     Here you can specify that a block of statements be executed for a
  1326.     specific number of times.
  1327.  
  1328.  
  1329.     Syntax:   DO label index=first,last
  1330.  
  1331.     where: label is a numeric statement label of a CONTINUE statement which
  1332.            is forward from this statement.
  1333.  
  1334.            index is an integer*2 variable that will be set, and then
  1335.            incremented.
  1336.  
  1337.            first is an integer constant.
  1338.  
  1339.            last is an integer constant.
  1340.  
  1341.  
  1342.  
  1343.  
  1344.     CONTINUE statement
  1345.  
  1346.     Used only in conjunction with the DO statement, this statement is labled
  1347.     and is used as the terminator of the block of statements to be executed.
  1348.  
  1349.  
  1350.     Example:  from "testall.for"
  1351.  
  1352.               do 809 counter=1,10
  1353.               write(16,309) counter
  1354.           309 format('test output record',i3)
  1355.           809 continue
  1356.  
  1357.  
  1358.  
  1359.                                                                             5-1
  1360.     
  1361.        RESERVED KEYWORDS and ARRAYS
  1362.     
  1363.        FORTRAN has many keywords that are meaningful to the compiler, such as
  1364.        IF, READ, WRITE, etc..  In addition to the standard list of reserved
  1365.        keywords, SBM fortran includes some options not provided in other
  1366.        systems:
  1367.     
  1368.     
  1369.        LDA, EXCLUDE, WAIT, JMP, JNC, JC, JZ, JNZ, AND, XOR, OR, SHIFT,
  1370.        SETFORM, SETIF, SHOW_CHAR, INCLUDE, UPCASE, INC, DEC, TEST,
  1371.        ADD, SUB, CMP, LABEL, PARSE, COPY, NEXCHAR, TABLE_LOOKUP, TABLE_ADD,
  1372.        COMPARE, FIND_CHAR, CRLF, PRESET.
  1373.     
  1374.        YOU CANNOT USE RESERVED WORDS AS VARIABLE NAMES, although any of them
  1375.        may be used as statement lables.
  1376.     
  1377.     
  1378.        In addition to the above reserved words, we also have the following
  1379.        arrays, which are  considered as reserved words:
  1380.     
  1381.        COMMAND, CONSOLE, INFILE, WORKBUF, OUTFILE, WORKBUF2.
  1382.     
  1383.     
  1384.     
  1385.        THE COMMAND LINE
  1386.     
  1387.        One of the problems facing the high-level programmer is how to access the
  1388.        data that we entered at the system prompt. SBM fortran sets this data
  1389.        where it can be easily used. The command tail can be located in the
  1390.        character array COMMAND. From there it can be parsed or otherwise used
  1391.        just like any other character array. In addition, the first two tokens
  1392.        are parse into INFILE (alias WORKBUF) and OUTFILE (alias WORKBUF2) and
  1393.        may be used as filenames in the OPEN statement.
  1394.     
  1395.        The advanced programmer will find these options to be of significant
  1396.        value.
  1397.     
  1398.     
  1399.        PROGRAM CONSTANTS
  1400.     
  1401.     
  1402.        Rather than using numerical equivalents for commonly needed constants,
  1403.        you may choose from the following list of pre-assigned symbolic names.
  1404.     
  1405.           CR        Carriage return.  Use instead of 0Dh, 13 decimal.
  1406.           LF        Line feed. Use instead of 0Ah, 10 decimal.
  1407.           ESC       Escape.  For ansi screen control, 1Bh, 27 decimal.
  1408.           FF        Form feed.  To eject the page in printer files.
  1409.           TAB
  1410.           BS        Back space.
  1411.           COMMA     Equivalent to 2Ch.
  1412.           QUOTE     Equivalent to 27h.
  1413.           QUOTES    Equivalent to 22h.
  1414.           False     Equivalent to binary zero.
  1415.           True      Equivalent to binary 1.
  1416.  
  1417.  
  1418.  
  1419.                                                                             6-1
  1420.        MISCELLANEOUS INTRINSIC FUNCTIONS
  1421.     
  1422.    
  1423.    
  1424.        COPY Array_1, Array_2
  1425.     
  1426.        Copies a character string to another array. Can be indexed.
  1427.     
  1428.    
  1429.    
  1430.     
  1431.        FIND_CHAR  'c', Array
  1432.     
  1433.        Searches a character string until the specified character is located.
  1434.     
  1435.    
  1436.        END    Optional for compatability. Ignored by the compiler.
  1437.     
  1438.     
  1439.    
  1440.        AND, XOR, OR  Masking operations
  1441.    
  1442.        Usage:  AND variable,mask.  Mask is hex constant, register, memory.
  1443.    
  1444.    
  1445.    
  1446.     
  1447.        SHIFT         Shift a variable, left or right.
  1448.     
  1449.        Usage:  SHIFT VARIABLE [,nbits]
  1450.     
  1451.        Shifts the variable the number of bits specified. If nbits absent, shift
  1452.        the variable one bit right. Otherwise you must specify the number of
  1453.        shifts. If nbits is preceded by a minus sign, shift is to the left.
  1454.     
  1455.                     Example:  shift 'number' one bit right.
  1456.                               SHIFT NUMBER
  1457.     
  1458.                     nother:   shift 'number' 3 bits left.
  1459.                               SHIFT NUMBER,-3
  1460.     
  1461.        If you  wish to shift only one bit left, it can be more efficiently
  1462.        done by adding the number to itself.  It accomplishes the same result.
  1463.     
  1464.                     Example:  ibuf=ibuf+ibuf
  1465.     
  1466.                     or better yet:   ax=ibuf
  1467.                                      add ibuf,ax
  1468.  
  1469.  
  1470.  
  1471.     6-2
  1472.  
  1473.     MISCELLANEOUS INTRINSIC FUNCTIONS
  1474.  
  1475.  
  1476.  
  1477.  
  1478.     PARSE STRING, KEY  [, 'delims']
  1479.  
  1480.     Given the ascii STRING, isolate the first token. Copy the isolated token
  1481.     to KEY and shift STRING left to remove the token KEY. Delimiters are
  1482.     blank, comma or equals. Carry is set if no data available to parse (EOR).
  1483.  
  1484.     You can specify an  additional list of delimiters to be used.
  1485.  
  1486.     Example:  Consider the string 'now is the-time'
  1487.  
  1488.         parse string,keword,'(/-+'
  1489.  
  1490.     After the parse,  keword will be 'now'
  1491.                       string will be 'is the-time'
  1492.  
  1493.                       carry is not set.
  1494.  
  1495.  
  1496.     PARSE_ONLY String, Keword, 'char'
  1497.  
  1498.     Parse until a specific character is found. We ignore the standard
  1499.     delimiters. In fact, the standard delimiters (including blanks) are
  1500.     passed to the 'keword' array.
  1501.  
  1502.     Example:  As above, the string 'now is the-time'
  1503.  
  1504.         parse_only string, keword,'-'
  1505.  
  1506.     After the parse,  keword will be 'now is the'
  1507.                       string will be 'time'
  1508.  
  1509.  
  1510.  
  1511.     LDA           Load address to a register:      LDA VARIABLE, REG
  1512.  
  1513.  
  1514.     UPCASE        Convert a character string to upper case.
  1515.  
  1516.                   Usage:  UPCASE String
  1517.  
  1518.  
  1519.  
  1520.                                                                             6-3
  1521.        SYSTEMS STUFF
  1522.    
  1523.        Things on this page are of no value to users.  They are included here
  1524.        only for Author's convenience.
  1525.    
  1526.    
  1527.        LABEL  variable, word/byte. Allows alias in system modules.  Must be
  1528.               issued immediately before the data decalaration statement.
  1529.    
  1530.        PRESET data-type,variable   Establish name and type in symbol
  1531.                       table for external variable.  data type is byte/word.
  1532.    
  1533.        SETFORM 'c'    Change default character in format name. Normally
  1534.                       fmt_nnn.  Changes the 't'.  Sample: fma_001.
  1535.    
  1536.        SETIF 'c'      Change default character in if-labels. Normally
  1537.                       true_000.  Changes first '0'.  Sample: true_a01.
  1538.    
  1539.        Example of the above two.       SETFORM a|   SETIF a
  1540.  
  1541.  
  1542.  
  1543.                                                                             7-1
  1544.     
  1545.        Greater speed can be realized by using a ramdisk.  To take advantage
  1546.        of this feature, include in your autoexec.bat file the following:
  1547.     
  1548.           SET RAMDISK=d
  1549.     
  1550.        Where 'd' is your ramdisk drive.  i.e. SET RAMDISK=E
  1551.     
  1552.     
  1553.     
  1554.        In the batch files, notice the commands SET BATCH=TRUE and
  1555.        SET BATCH=.
  1556.     
  1557.        These two commands are used by the compiler to determine the course
  1558.        or action when the requested source file cannot be found.  They are of
  1559.        no concern for normal operations and should not be disturbed.
  1560.    
  1561.  
  1562.  
  1563.  
  1564.                                                                              8-1
  1565.        KNOWN BUGS
  1566.    
  1567.        I am aware of the following bugs.  If I take time to correct them
  1568.        now, I may not get this system on the boards before I move to Wyoming.
  1569.        They will be addressed in the next update.
  1570.    
  1571.    
  1572.        1.  If you re-define a variable, you get no error message but all
  1573.        sorts of seemingly unrelated problems.
  1574.    
  1575.    
  1576.        2. if(inbuf.eq.';')                                SBM.ASM(get_record)
  1577.        Input takes the ';' as begin comment, thereby truncating the statement.
  1578.    
  1579.