home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ibmtsonih / tsnalpdoc.txt < prev    next >
Text File  |  2020-01-01  |  117KB  |  3,714 lines

  1. # LIST CC UNN REM 112
  2.  ,FONT 1 27 9
  3.  ,PRINT 100
  4.  ,END
  5. 1************************************************************
  6.  *                                                          *
  7.  *                                                          *
  8.  *                                                          *
  9.  *                                                          *
  10.  *                                                          *
  11.  *                                                          *
  12.  *                                                          *
  13.  *                                                          *
  14.  *                                                          *
  15.  *                                                          *
  16.  *                                                          *
  17.  *                                                          *
  18.  *                                                          *
  19.  *                                                          *
  20.  *                                                          *
  21.  *                                                          *
  22.  *                                                          *
  23.  *                                                          *
  24.  *                                                          *
  25.  *                                                          *
  26.  *                                                          *
  27.  *                                                          *
  28.  *           ALP: Assembly Language Preprocessor            *
  29.  *                                                          *
  30.  *                       User's Guide                       *
  31.  *                                                          *
  32.  *                                                          *
  33.  *                  Computer Center Branch                  *
  34.  *       Division of Computer Research and Technology       *
  35.  *              National Institutes of Health               *
  36.  *                                                          *
  37.  *                                                          *
  38.  *                                                          *
  39.  *                                                          *
  40.  *                                                          *
  41.  *                                                          *
  42.  *                                                          *
  43.  *                                                          *
  44.  *                                                          *
  45.  *                                                          *
  46.  *                                                          *
  47.  *                                                          *
  48.  *                                                          *
  49.  *                                                          *
  50.  *                                                          *
  51.  *                                                          *
  52.  *                                                          *
  53.  *                                                          *
  54.  *                                                          *
  55.  *                                                          *
  56.  *                                                          *
  57.  *                                                          *
  58.  *                                                          *
  59.  ************************************************************
  60.  
  61.  
  62.                                       Version 6.19    5/10/88
  63. 1
  64. 1                    Level 2 Software Support
  65.                       (Revised November 1986)
  66.  
  67.  This software product, or a  certain  portion  of  it,  has  been
  68.  assigned Level 2 support status.  The Level 2 designation is made
  69.  by the Computer Center for  any  of  three  reasons:   First,  an
  70.  entire  software  product  may  be designated Level 2 if it is in
  71.  test  status,  or  the  Center  determines  that  rapid   problem
  72.  resolution  and long-term product availability can not be ensured
  73.  with the vendor  support  available.   Second,  an  interface  to
  74.  specific   peripheral   hardware   devices  (e.g.,  terminals  or
  75.  plotters) will receive Level 2 support, even if the remainder  of
  76.  the  product  is  designated  Level  1.   Third,  an interface to
  77.  processors not at the NIH Computer Utility (e.g., microprocessors
  78.  or  other  computer  installations) will receive Level 2 support,
  79.  even if the remainder of the product is designated Level 1.
  80.  
  81.  If a hardware device/terminal is not  specifically  mentioned  in
  82.  the  documentation  for  this  product,  no  interface  to  it is
  83.  supported (even as  Level  2).   While  unsupported  devices  may
  84.  sometimes  function  with  the  interfaces provided, any problems
  85.  encountered are wholly the user's responsibility.   This  support
  86.  policy  is  necessary  in order to provide services for the large
  87.  number of devices (e.g.,  terminals,  plotters,  microprocessors)
  88.  commonly  owned/used  by  end users.  It is not practical for the
  89.  NIH  Computer  Center  to   be   familiar   with   the   hardware
  90.  characteristics  of the myriad devices that can take advantage of
  91.  these services.
  92.  
  93.  Users of this product should be fully aware that Level 2 software
  94.  support  provides  documentation, non-critical Programmer Trouble
  95.  Report (PTR) service, and limited  INTERFACE  preannouncement  of
  96.  changes,   but  does  not  guarantee  continued  availability  or
  97.  conversion assistance if this software  is  discontinued  by  the
  98.  vendor or the Computer Center.
  99.  
  100.  In addition, no Programmer  Assistance  and  Liaison  (PAL)  Unit
  101.  consulting  will  be available on questions pertaining to the use
  102.  of or problems with software  receiving  Level  2  support.   The
  103.  Computer  Center  will  accept  PTRs  for  problems  if  they are
  104.  accompanied by all of the documentation necessary  for  diagnosis
  105.  and   resolution.    When   the   Computer  Center  staff  member
  106.  responsible for the problem area described in a PTR for a product
  107.  receiving Level 2 support receives all pertinent documentation on
  108.  the problem, the staff member will frequently act as a  technical
  109.  guide with the burden of the work remaining with the user.
  110.  
  111.  Resolving or circumventing problems with software receiving Level
  112.  2  support  may  require  resources  (e.g., hardware/terminals or
  113.  source code) that are not available to the Computer Center staff.
  114.  Since the Computer Center is often completely unfamiliar with the
  115.  specific devices/terminals involved, the vendor may be  the  sole
  116.  source  of  vital  information required for problem resolution or
  117.  circumvention.  For this reason, the "Critical"  designation  for
  118.  PTRs  is  not  applicable  and will be disregarded by the Center.
  119.  Once a PTR and all supporting documentation is  received  by  the
  120.  Computer  Center, the work to get a resolution is a mutual effort
  121.  of the user, the Computer Center and the  author  or  vendor  for
  122.  products  designated  to  receive  Level  2  support.   Since the
  123.  Computer Center must rely  on  the  cooperation/interest  of  the
  124. 1vendor/developer  of a product, it is possible that some problems
  125.  may never be resolved.
  126.  
  127.  The effects of this reduced  support  from  the  Computer  Center
  128.  should be thoroughly considered before incorporating any software
  129.  receiving Level 2 support into critical applications.  It must be
  130.  stressed that the proper functioning or long-term availability of
  131.  software receiving Level 2 support cannot be  guaranteed  by  the
  132.  Computer Center.
  133.  
  134.  The following chart outlines Computer Center  services  available
  135.  for  software receiving Level 2 support.  For further information
  136.  on Levels of software and how to submit PTRs, see the appropriate
  137.  section  of the Computer Center Users Guide.  If questions remain
  138.  on this policy, contact the PAL Unit Consulting Desk of  the  NIH
  139.  Computer Center.
  140.  
  141.  
  142.  
  143.  SERVICE                            LEVEL 2 SOFTWARE SUPPORT
  144.  
  145.  CONSULTING (PAL DESK)
  146.    a) personal visit                        No
  147.    b) telephone                             No
  148.                                          (Users will have to rely
  149.                                          on technical documentation
  150.                                          provided by the Computer
  151.                                          Center and their own
  152.                                          resources)
  153.  
  154.  PROGRAMMER TROUBLE REPORT (PTR)            Yes
  155.  
  156.  "CRITICAL" PTR DESIGNATION                 No
  157.  
  158.  REFUNDS                                    Yes
  159.  
  160.  DOCUMENTATION                              Yes
  161.  
  162.  TRAINING                                   Resources
  163.                                             permitting
  164.  SOFTWARE MAINTENANCE
  165.   a) Currency maintained with respect       Resources
  166.      to new versions and facilities         permitting
  167.   b) Formal change testing (Test Job        No
  168.      Stream)
  169.   c) Informal change testing                Yes
  170.   d) Guarantee of orderly, fully            No
  171.      documented conversion if product
  172.      is discontinued
  173.   e) Preannouncement in INTERFACE of        Resources
  174.      all new facilities                     permitting
  175.   f) Preannouncement in INTERFACE of        Resources
  176.      changes which cause old versions       permitting
  177.      of programs to function
  178.      incorrectly or differently
  179.   g) Preannouncement in INTERFACE of        Yes
  180.      discontinuance of support or changes
  181.      in support status (Level)
  182.   h) Preventive and corrective fixing       Resources
  183.      by Computer Center staff               permitting
  184. 1
  185.                          Table of Contents
  186.  
  187.  
  188.  
  189.  
  190.  
  191.     I. Introduction . . . . . . . . . . . . . . . . . . . . . .  1
  192.  
  193.    II. The ALP Language . . . . . . . . . . . . . . . . . . . .  3
  194.  
  195.         Input format  . . . . . . . . . . . . . . . . . . . . .  3
  196.         Comment convention  . . . . . . . . . . . . . . . . . .  3
  197.         Statement differentiation . . . . . . . . . . . . . . .  4
  198.         Compound statements . . . . . . . . . . . . . . . . . .  5
  199.         Predicates  . . . . . . . . . . . . . . . . . . . . . .  6
  200.  
  201.   III. ALP Statements . . . . . . . . . . . . . . . . . . . . .  8
  202.  
  203.         Conditional and alternative statements  (IF). . . . . .  8
  204.         Loop statements (DO). . . . . . . . . . . . . . . . . .  9
  205.         Case selection  (CASE). . . . . . . . . . . . . . . . . 14
  206.         Predicate selection (SELECT). . . . . . . . . . . . . . 16
  207.         Loop control mechanisms (EXIT and NEXT) . . . . . . . . 18
  208.         Branching (GOTO and RGOTO). . . . . . . . . . . . . . . 20
  209.         Control of base register assignment (USE) . . . . . . . 21
  210.         Inline data (DATA)  . . . . . . . . . . . . . . . . . . 22
  211.         Conditional assembly  (ASM) . . . . . . . . . . . . . . 23
  212.         Including ALP code in macros  (MACRO) . . . . . . . . . 26
  213.         Reversion to BAL  (BAL) . . . . . . . . . . . . . . . . 28
  214.         Block Comments (COMMENT). . . . . . . . . . . . . . . . 29
  215.         Listing format control (TITLE,SUBTITLE,EJECT,SPACE) . . 30
  216.  
  217.    IV. Non-Control Extensions . . . . . . . . . . . . . . . . . 32
  218.  
  219.     V. The Implementation of ALP  . . . . . . . . . . . . . . . 34
  220.  
  221.    VI. ALP Syntax . . . . . . . . . . . . . . . . . . . . . . . 35
  222.  
  223.   VII. ALP Readability Macros . . . . . . . . . . . . . . . . . 39
  224.  
  225.  VIII. Macros for Environment Enhancement . . . . . . . . . . . 41
  226.  
  227.        AREA and AREAEND . . . . . . . . . . . . . . . . . . . . 42
  228.        DEBLANK  . . . . . . . . . . . . . . . . . . . . . . . . 45
  229.        EDIT . . . . . . . . . . . . . . . . . . . . . . . . . . 47
  230.        EXI  . . . . . . . . . . . . . . . . . . . . . . . . . . 49
  231.        MCLC, MMVC, MNC, MOC and MXC . . . . . . . . . . . . . . 51
  232.        MFC  . . . . . . . . . . . . . . . . . . . . . . . . . . 52
  233.        MTC  . . . . . . . . . . . . . . . . . . . . . . . . . . 53
  234.        MTR  . . . . . . . . . . . . . . . . . . . . . . . . . . 54
  235.        MTRT . . . . . . . . . . . . . . . . . . . . . . . . . . 55
  236.        MZC  . . . . . . . . . . . . . . . . . . . . . . . . . . 56
  237.        DF . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
  238.        SF . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
  239.        TF . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
  240.        ZF . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
  241. 1
  242.  
  243.        OSCALL . . . . . . . . . . . . . . . . . . . . . . . . . 61
  244.        OSENTER  . . . . . . . . . . . . . . . . . . . . . . . . 62
  245.        OSEXIT . . . . . . . . . . . . . . . . . . . . . . . . . 63
  246.        OSSETUP  . . . . . . . . . . . . . . . . . . . . . . . . 64
  247.        OPENP  . . . . . . . . . . . . . . . . . . . . . . . . . 66
  248.        CBDELINK . . . . . . . . . . . . . . . . . . . . . . . . 67
  249.        CBDLINKH . . . . . . . . . . . . . . . . . . . . . . . . 69
  250.        CBDLINKT . . . . . . . . . . . . . . . . . . . . . . . . 70
  251.        CBLINK . . . . . . . . . . . . . . . . . . . . . . . . . 72
  252.        CBLINKH  . . . . . . . . . . . . . . . . . . . . . . . . 73
  253.        CBLINKT  . . . . . . . . . . . . . . . . . . . . . . . . 74
  254.  
  255.    IX. ALP Coding Hints . . . . . . . . . . . . . . . . . . . . 75
  256.  
  257.     X. Sample Program . . . . . . . . . . . . . . . . . . . . . 76
  258.  
  259.    XI. Using ALP at NIH . . . . . . . . . . . . . . . . . . . . 80
  260.  
  261.   XII. References . . . . . . . . . . . . . . . . . . . . . . . 82
  262. 1                           - 1 -
  263.  
  264.  
  265.                        I. INTRODUCTION
  266.  
  267.       The choice of the proper vehicle  --  assembly  language  or
  268.  higher-level language -- for writing so-called "systems programs"
  269.  is  a  subject  of  constant  debate  (1,2).   With a few notable
  270.  exceptions (3,4), the trend has  been  toward  continued  use  of
  271.  assembly  languages,  generally  those  provided  by  vendors  of
  272.  computer  systems.   Fortunately,  the  field  is now well enough
  273.  explored  that   most   assemblers   are   relatively   powerful,
  274.  incorporating  macro  or preprocessor facilities such as symbolic
  275.  substitution, conditional assembly, etc.  Given the  architecture
  276.  of  most  currently-available  hardware  and  the  orientation of
  277.  assemblers toward that hardware, very little  has  been  done  to
  278.  provide  sophisticated  control  or data structures.  Considering
  279.  that until fairly recently  this  was  also  the  case  even  for
  280.  compiler-level languages, perhaps it is not too surprising.
  281.  
  282.       For better  or  worse,  systems  being  implemented  at  the
  283.  assembly  language  level have -- inevitably -- grown in size and
  284.  complexity.  This is one of the major  factors  (along  with  the
  285.  desire  to  work in terms closer to the nature of the application
  286.  being developed)  that  led  to  the  evolution  of  higher-level
  287.  languages.   It  has  also  fostered  the  investigation  of more
  288.  powerful tools  for  building  systems  whose  implementation  is
  289.  constrained,  for  one  reason or another, to the use of assembly
  290.  language.   The  various  approaches  taken  have  included  more
  291.  powerful macro facilities, compilers for languages which  can  be
  292.  straightforwardly  and  efficiently  translated (some into object
  293.  code, others into assembly  source),  highly-optimized  compilers
  294.  which  attempt to relieve the concerns about staying close to the
  295.  underlying hardware, and preprocessors which provide capabilities
  296.  similar to those available with macro systems but with  increased
  297.  flexibility.   It  is  a  tool  of  this  last type which will be
  298.  described below.
  299.  
  300.      Our  search  for  a  means  of   making   assembly   language
  301.  programming easier began in the first place because we were faced
  302.  with  a  large project which we had already decided would be done
  303.  in assembly language.  This was due to the environment  in  which
  304.  the  end result would operate, efficiency considerations, and the
  305.  lack of any reasonable alternative, as well  as  experience  with
  306.  previous  versions  of  the system.  It was obvious, though, that
  307.  features not provided by the available assemblers  would  greatly
  308.  improve  both  the speed with which the project could proceed and
  309.  its eventual maintenance and  enhancement.   The  most  realistic
  310.  goal  was  to provide better control structures, perhaps assembly
  311.  language's most serious deficiency.  In addition,  we  sought  to
  312.  improve  the  overall reliability of the new system by minimizing
  313.  the chances of certain types of coding and logic errors which are
  314.  encouraged by the scarcity of good  control  structures  and  the
  315.  consequent  requirement  for  explicit  branching,  labels,  etc.
  316.  Hence  some  form of "structured" programming technique seemed to
  317.  be indicated.
  318. 1                           - 2 -
  319.  
  320.  
  321.       For reasons of practicality, we preferred to  use  something
  322.  already developed and in use.  A preprocessor (AL) which provided
  323.  many  of  the  features we were looking for had been developed by
  324.  Edward C.  Haines at MITRE, and we decided to use that as a  base
  325.  (portions of this document are taken from the original  reference
  326.  (5)).  The salient features of AL were that it provided:
  327.  
  328.       . "predicates" for condition testing
  329.       . an "IF ... THEN ... ELSE ..." structure
  330.       . "WHILE ... DO ..." and "DO ... UNTIL ..."
  331.       . a "COUNT" statement for iterative loops
  332.       . a conditional branching capability
  333.  
  334.       in addition, it allowed:
  335.  
  336.       . free-form input, with label and statement delimiters
  337.       . comments
  338.       . transparent use of regular assembly language
  339.  
  340.       After acquiring the source for AL and examining it, we  made
  341.  a number of enhancements.  These include:
  342.  
  343.       . extension of predicates to allow grouping
  344.       . generalization of the loop control structures into
  345.         .. DO-WHILE   / WHILE-DO
  346.         .. DO-UNTIL   / UNTIL-DO
  347.         .. DO-FOR     / FOR-DO  (replacing AL's "COUNT")
  348.         .. DO-FOREVER / FOREVER-DO (replacing AL's "LOOP")
  349.       . addition of CASE and SELECT statements
  350.       . generalization of explicit branching to allow
  351.         .. GOTO (replacing AL's "BIF")
  352.         .. RGOTO (for register form of branch)
  353.       . improved loop controls
  354.         .. EXIT
  355.         .. NEXT
  356.       . local control  of  base  register  assignment  for  DSECTs
  357.         through USE
  358.       . access to  conditional  assembly  facilities  through  the
  359.         ASM statements
  360.       . support for ALP code in macros through the MACRO statement
  361.       . substitution of '<'/'>' and 'BEGIN'/'END' for AL's use  of
  362.         parentheses as compound statement delimiters
  363.       . recording of nesting level and display on listing
  364.       . automatic indentation according to nesting level
  365.       . provision for title and subtitle control as well as  eject
  366.         and space
  367.       . allowance for presence of  macro  variables  (i.e.   those
  368.         beginning with "&") in operand fields
  369.       . acceptance of macro and sequence symbols as labels
  370.       . limited optimization of internally-generated branches
  371.  
  372.       Fortunately,  AL  proved  to  be  a  reasonable  basis   for
  373.  expansion.   Our  task  would  have  been far greater had we been
  374.  forced to start from scratch.
  375. 1                           - 3 -
  376.  
  377.  
  378.                      II. THE ALP LANGUAGE
  379.  
  380.       Following sections will describe each ALP statement in  some
  381.  detail.  A syntax description in augmented BNF  is  contained  in
  382.  section VI.
  383.  
  384.  
  385.  INPUT FORMAT
  386. +____________
  387.  
  388.       ALP resembles PL/I in some respects.  Programs are  composed
  389.  of  statements,  separated by semi-colons (';').  Source code may
  390.  be entered in free form in columns  1-72  (columns  73-80  should
  391.  contain  some sort of sequence information).  The program must be
  392.  terminated with an "END" statement (i.e.   "END;").   Labels  are
  393.  delimited  by  a colon (':'), and multiple labels may appear on a
  394.  single statement.  Otherwise, labels obey assembler  conventions.
  395.  That  is, they must be one to eight characters in length, consist
  396.  of 'A'-'Z', '0'-'9', '$', '@', or '#', and  begin  with  'A'-'Z',
  397.  '$', '@', or '#'.
  398.  
  399.       In order to allow for sequence  symbols,  set  symbols,  and
  400.  labels  into  which  macro  variables are to be substituted, '.',
  401.  '&', '(', and ')' are also allowed.  Ampersands should be doubled
  402.  in order to prevent confusion with the AND operator.
  403.  
  404.  Examples:
  405.  
  406.   program:
  407.  
  408.       S1; S2; S3; END;
  409.  
  410.   labeling:
  411.  
  412.       LABEL: S;
  413.       L1: L2: S;
  414.       .SEQ: AGO .SEQ2;
  415.       &&CHAR: SETC 'ABC';
  416.       X&&Y(2)Z: DC H'0';
  417.  
  418.  
  419.  COMMENT CONVENTION
  420. +__________________
  421.  
  422.       Like PL/I, ALP allows comments wherever a  blank  is  legal.
  423.  However,  the  delimiting  mechanism  is  quite  different.   ALP
  424.  comments  begin  with  a percent sign ('%') and are terminated by
  425.  the end of the input line.
  426.  
  427.  
  428.  Examples:
  429.  
  430.            LA  R1,2;  % THIS IS A COMMENT
  431.  
  432.  Block comments are also supported, see section III.
  433. 1                           - 4 -
  434.  
  435.  
  436.  STATEMENT DIFFERENTIATION
  437. +_________________________
  438.  
  439.       There are two types of ALP statements, which, unless  stated
  440.  otherwise  will  be  treated  equivalently  in  the  rest of this
  441.  document.  The  first  type  consists  of  those  beginning  with
  442.  keywords  meaningful  to  ALP,  which  it  processes.  The second
  443.  consists of those which ALP does not recognize and passes  on  to
  444.  the  assembler  on the assumption that they are BAL statements or
  445.  macro calls.
  446.  
  447.       In the latter type, the usual  assembler  conventions  about
  448.  operand fields apply, with three changes:
  449.  
  450.    1. Comments must be entered  as  described  above  --  a  blank
  451.       signals only the end of the field, not the start of comments
  452.       as well.
  453.  
  454.    2. If an ampersand ('&') is to appear in an operand other  than
  455.       inside a quoted string, it must be doubled to distinguish it
  456.       from  ALP's predicate conjunction operator (see below).  For
  457.       example:
  458.  
  459.            LA REG,&&CON;
  460.            LA REG,=C'&STRING';
  461.  
  462.    3. Since ALP  input  is  free  form,  the  only  place  special
  463.       continuation  is  required  is  when  operand fields must be
  464.       split across line boundaries.  In such cases, end the  first
  465.       part of the field with an underscore -- it will be continued
  466.       with  the next non-blank character (ignoring any intervening
  467.       comments) and the underscore will be discarded.  If a quoted
  468.       string  must  be  broken,  end  the  first   part   with   a
  469.       quote-underscore  pair and continue with a quote on the next
  470.       line.  The underscore, any intervening blanks, and  the  two
  471.       extra quotes will be discarded.  For example:
  472.  
  473.            TPUT MESSAGE,_
  474.                 LENGTH;
  475.  
  476.       and
  477.  
  478.            DC C'THIS IS A LONG CONSTANT '_
  479.                'WHICH WILL BE CONTINUED';
  480. 1                           - 5 -
  481.  
  482.  
  483.  COMPOUND STATEMENTS
  484. +___________________
  485.  
  486.       Simple statements may be combined into  compound  statements
  487.  by   enclosing   them   in   angle  brackets  ("<"  and  ">")  or
  488.  "BEGIN"-"END" symbols and separating them with semicolons.
  489.  
  490.  
  491.  Examples:
  492.  
  493.       <S1; S2; S3>
  494.  
  495.       BEGIN
  496.          S1;
  497.          S2;
  498.          S3;
  499.          END
  500.  
  501.  
  502.  Spacing is irrelevant, except that  there  must  be  a  delimiter
  503.  (such  as a blank) following the "BEGIN" and preceding the "END".
  504.  Also, there is no semicolon required preceding the "END" or  ">".
  505.  However,  a  semicolon  must follow a compound statement wherever
  506.  one is required after a simple statement.
  507.  
  508.       Although "BEGIN"-"END"  and  "<"-">"  are  generally  inter-
  509.  changeable, special consideration must be taken in two cases:
  510.  
  511.  1) An  "END"  bracket  must  never  be  labeled.   An  acceptable
  512.     equivalent  is  a  labeled  null   statement   preceding   the
  513.     terminating bracket.  For example:
  514.  
  515.       BEGIN
  516.          statement;
  517.          statement;
  518.          label: ;
  519.          END
  520.  
  521.  2) If the  final  statement  in  a  group  of  statements  to  be
  522.     bracketed  has  no  operands,  a  semicolon  must  precede the
  523.     terminating "END" or the "<"/">" form must be used to  prevent
  524.     the "END" from being mistaken for an operand on the statement.
  525. 1                           - 6 -
  526.  
  527.  PREDICATES
  528. +__________
  529.  
  530.       The concept necessary for most control structures  is   that
  531.  of  predicate.   A  predicate  is  a  sequence of statements that
  532.  produces a truth value.  On  the  System/370,  testing  of  truth
  533.  conditions  is accomplished  by  setting  a  condition code (with
  534.  an instruction such as  a  comparison)  and  then   conditionally
  535.  branching   on   the  status   of   the   condition   code.   The
  536.  instructions that set the condition code are sometimes,  but  not
  537.  often,   what   people   logically  want   to  think  of  as  the
  538.  predicate.   The  execution  of  conditional  branches  is almost
  539.  always not what people want  to  think  about  (cf Dijkstra(6)).
  540.  
  541.      In ALP, a simple predicate  is  a  sequence  of  instructions
  542.  (possibly  empty)  that  defines  a  condition  code  setting.  A
  543.  predicate is then a  Boolean  combination  of  simple  predicates
  544.  involving the operators '&' ("AND"), '|' ("OR"), and '^' ("NOT").
  545.  The   conditional  branches  (and  unconditional  branches  where
  546.  necessary) are implied by the control statements.  The programmer
  547.  is, for the most part, freed from worrying about  what  condition
  548.  code value(s) will be set and how to test them.
  549.  
  550.  *****************************************************************
  551.       A number  of  macros  have  been  provided  to  improve  the
  552.  readability of ALP programs and to provide additional information
  553.  for  ALP's use in determining condition tests, etc.  They will be
  554.  used freely in the examples that follow:  see sections  VII   and
  555.  VIII for complete information.   Note that use of these macros is
  556.  not required.
  557.  *****************************************************************
  558.  
  559.  Examples:
  560.  
  561.   simple predicate:
  562.  
  563.       <CLI  BUFFER,C'*'>
  564.  
  565.       <L R15,RETCODE; RZ R15>
  566.  
  567.   predicate:
  568.  
  569.       ^<CLI BUFFER,C' '>
  570.  
  571.       <CLC WORD,=C'ERROR'> & <RNP R15> | <TM EBITS,X'80'>
  572.  
  573.       <<CLC WORD,=C'ERROR'> & <RNP R15>> | <TM EBITS,X'80'>
  574.  
  575.       Grouping is such that a&b|c&d is interpreted as a&(b|(c&d));
  576.  there is no operator precedence, but grouping  of  predicates  in
  577.  angle  brackets  is  allowed.   IF,  DO, etc.  should not be used
  578.  within a predicate because  they  introduce  uncertainty  in  the
  579.  condition actually being tested.  The way in which predicates are
  580.  evaluated  does  not  always  insure that all instructions in the
  581.  predicate  are  executed.   Thus,  care  should  be  taken   that
  582.  processing  does  not depend on the execution of all instructions
  583.  in  a  predicate  involving  Boolean   combinations   of   simple
  584.  predicates.
  585. 1                           - 7 -
  586.  
  587.  
  588.       The appropriate condition code test is determined  from  the
  589.  op-code  of  the  last statement of the predicate; if the name is
  590.  not recognized, the default is '=' (equal, or  zero).   The  test
  591.  can  be  explicitly specified by using a special statement of the
  592.  form:
  593.  
  594.       CC ccstring
  595.  
  596.  where ccstring is composed of characters from the set
  597.  
  598.       0 = E Z   1 L M   2 P H   3 O   N ^
  599.  
  600.       These are used as in the form of the extended  mnemonics  of
  601.  the  assembler except that they specify the "truth" condition (as
  602.  opposed  to  the  branch  condition)  and  any   combination   of
  603.  characters is allowed.
  604.  
  605.       Since equality is the appropriate truth condition  for  most
  606.  predicates,   only   non-standard   cases   are  coded  into  the
  607.  preprocessor.  These are:  OPENP (NZ), TF (NZ), TM (NZ), TS (NZ),
  608.  TRT (NZ), RM (M), RZ (Z), RP (P), RMZ (NP), RMP (NZ),  RZP  (NM),
  609.  RNM (NM), RNZ (NZ), RNP (NP), RNMZ (P), RNMP (Z), RNZP (M).
  610. 1                           - 8 -
  611.  
  612.  
  613.                      III. ALP STATEMENTS
  614.  
  615.  
  616.  CONDITIONAL AND ALTERNATIVE STATEMENTS
  617. +______________________________________
  618.  
  619.      Conditional and alternative statements are  provided  by  the
  620.  IF-THEN-ELSE statement.  Its format is:
  621.  
  622.      IF predicate THEN statement ELSE statement
  623.  
  624.  where the "ELSE" clause is optional.
  625.  
  626.  
  627.  Examples:
  628.  
  629.      IF <LH R2,0(R1); RP R2> THEN STH R2,BLKSIZE;
  630.  
  631.  at assembly time would appear (subject to label differences) as:
  632.  
  633.         LH  R2,0(R1)
  634.         LTR R2,R2
  635.         BNP @0001
  636.         STH R2,BLKSIZE
  637.   @0001 ----
  638.  
  639.  
  640.      IF  <L R2,0(,R3); RZ R2>
  641.      THEN LA R3,1
  642.      ELSE LA R3,2;
  643.  
  644.  would generate:
  645.  
  646.         L   R2,0(R3)
  647.         LTR R2,R2
  648.         BNZ @0001
  649.         LA  R3,1
  650.         B   @0002
  651.   @0001 LA  R3,2
  652.   @0002 ----
  653.  
  654.  
  655.  NOTE:  If  a  simple  statement  without  operands  (such  as  an
  656.  operand-less   machine  op-code  or  macro  call)  comprises  the
  657.  predicate or the "THEN" clause in an "IF  ...   THEN  ...   ELSE"
  658.  construct,  it  must be enclosed in '<'/'>' bracketing symbols to
  659.  prevent the following  keyword  ('THEN'  or  'ELSE')  from  being
  660.  interpreted as an operand of the statement.
  661.  
  662.  *****************************************************************
  663.  Note that ALP-generated labels begin with a commercial  "at-sign"
  664.  ('@').   Labels  generated outside macro definitions will consist
  665.  of an at-sign followed by  a  four-digit  decimal  integer  (e.g.
  666.  @0001).   Labels  generated inside a macro (see the discussion of
  667.  support for ALP code in macros) will involve a special symbol  so
  668.  that   multiple  invocations  of  the  macro  will  not  generate
  669.  duplicate labels (e.g.  @&@001).
  670.  *****************************************************************
  671. 1                           - 9 -
  672.  
  673.  
  674.  LOOP STATEMENTS
  675. +_______________
  676.  
  677.       There are four sets of loop-producing statements:
  678.  
  679.       . DO-WHILE   and  WHILE-DO
  680.       . DO-UNTIL   and  UNTIL-DO
  681.       . DO-FOR     and  FOR-DO
  682.       . DO-FOREVER and  FOREVER-DO
  683.  
  684.       The two forms differ in  the  position  of  the  test  which
  685.  terminates  the  loop:   whether  it comes after (as in the first
  686.  form) or before (as in the second) the body  of  the  loop.   The
  687.  format of the first set is:
  688.  
  689.      WHILE predicate DO statement
  690.  
  691.             or
  692.  
  693.      DO statement WHILE predicate
  694.  
  695.  
  696.  
  697.  Examples:
  698.  
  699.      WHILE ^<CR R3,R11> DO <MVI 0(R3),C' '; AI R3,1>;
  700.  
  701.  generates:
  702.  
  703.   @0001   CR   R3,11
  704.           BE   @0002
  705.           MVI  0(R3),C' '
  706.           LA   R3,1(,R3)
  707.           B    @0001
  708.   @0002   ----
  709.  
  710.  
  711.  
  712.      DO <MVI 0(R3),C' '; AI R3,1> WHILE ^<CR R3,R11>;
  713.  
  714.  generates:
  715.  
  716.   @0001   MVI  0(R3),C' '
  717.           LA   R3,1(,R3)
  718.           CR   R3,R11
  719.           BNE  @0001
  720. 1                           - 10 -
  721.  
  722.  
  723.       The DO-UNTIL set is similar to the DO-WHILE set except  that
  724.  the "sign" of the test is reversed.  Its format is:
  725.  
  726.      DO statement UNTIL predicate
  727.  
  728.             or
  729.  
  730.      UNTIL predicate DO statement
  731.  
  732.  
  733.  
  734.  Examples:
  735.  
  736.      DO <LR R1,R2; L R2,0(,R1); LA R2,0(,R2)>
  737.      UNTIL <C ADR,EADR(R2); CC H>;
  738.  
  739.  translates to:
  740.  
  741.   @0001   LR   R1,R2
  742.           L    R2,0(,R1)
  743.           LA   R2,0(,R2)
  744.           C    ADR,EADR(R2)
  745.           BNH  @0001
  746.   @0002   ----
  747.  
  748.  
  749.  
  750.      UNTIL <C ADR,EADR(R2); CC H>
  751.      DO <LR R1,R2; L R2,0(,R1); LA R2,0(,R2)>;
  752.  
  753.  generates:
  754.  
  755.   @0001   C    ADR,EADR(R2)
  756.           BH   @0002
  757.           LR   R1,R2
  758.           L    R2,0(,R1)
  759.           LA   R2,0(,R2)
  760.           B    @0001
  761.   @0002   ----
  762. 1                           - 11 -
  763.  
  764.  
  765.       A simple loop counting mechanism is provided by  the  DO-FOR
  766.  set.   The  number  of  times  the  loop  is  to  be  executed is
  767.  determined by the  value  of  a  specified  register  (set  by  a
  768.  previous  statement)  on  entry  to  the  loop.   The register is
  769.  decremented once per cycle until it is zero.  The format is:
  770.  
  771.      DO statement FOR register
  772.  
  773.             or
  774.  
  775.      FOR register DO statement
  776.  
  777.  
  778.  
  779.  Examples:
  780.  
  781.       DO <IC R1,0(R11); BAL R9,PCHAR; AI R11,1> FOR R12;
  782.  
  783.  translates to:
  784.  
  785.   @0001   IC   R1,0(R11)
  786.           BAL  R9,PCHAR
  787.           LA   R11,1(,R11)
  788.           BCT  R12,@0001
  789.  
  790.  
  791.  
  792.       FOR R12 DO <IC R1,0(R11) ; BAL R9,PCHAR; AI R11,1>;
  793.  
  794.  generates:
  795.  
  796.           LTR  R12,R12
  797.           BNP  @0002
  798.   @0001   IC   R1,0(R11)
  799.           BAL  R9,PCHAR
  800.           LA   R11,1(,R11)
  801.           BCT  R12,@0001
  802.   @0002   ----
  803. 1                           - 12 -
  804.  
  805.  
  806.       The last  of  the  loop  control  structures  are  also  the
  807.  simplest:   a  "do-once"  structure  and  an  infinite loop, with
  808.  responsibility for escaping from it placed on the programmer.
  809.  
  810.  The format of the "do-once" is:
  811.  
  812.       DO statement
  813.  
  814.       This form is useful where the statement is  a  compound  one
  815.  containing  EXIT statements (described in a later section), which
  816.  permit escape from the compound  statement.   Similarly,  a  NEXT
  817.  statement (see below) occurring in such a compound statement will
  818.  cause control to be transfered to the start of the statement.
  819.  
  820.  
  821.  The format of the infinite loop is:
  822.  
  823.       DO statement FOREVER
  824.  
  825.              or
  826.  
  827.       FOREVER DO statement
  828.  
  829.  
  830.  
  831.  Examples:
  832.  
  833.       DO <AI  R2,1> FOREVER;
  834.  
  835.               and
  836.  
  837.       FOREVER DO <AI  R2,1>
  838.  
  839.  both translate to:
  840.  
  841.   @0001  LA  R2,1(,R2)
  842.          B   @0001
  843. 1                           - 13 -
  844.  
  845.  
  846.       The WHILE-DO/DO-WHILE, UNTIL-DO/DO-UNTIL, and  FOR-DO/DO-FOR
  847.  constructs,  as  well as the "do-once" form, may also be followed
  848.  by an optional "THEN statement".  This allows  the  specification
  849.  of  action to be taken if and only if control "falls through" the
  850.  DO (e.g.  when the  register  specified  in  a  FOR-DO  construct
  851.  becomes zero), but not if  control  is  transfered  via  an  EXIT
  852.  statement.  FOREVER-DO/DO-FOREVER cannot take a THEN clause.
  853.  
  854.  Example:
  855.  
  856.       DO BEGIN
  857.          ...
  858.          EXIT;
  859.          ...
  860.          END
  861.       THEN BEGIN
  862.          ...
  863.          END;
  864.  
  865.  
  866.  NOTE:  Introduction of THEN as part of the DO construct  requires
  867.  care  in  the  nesting of statements under certain circumstances.
  868.  Nesting of DO's within DO's can cause confusion of THEN's in  the
  869.  same  way that nesting of IF's can cause confusion of ELSE's.  In
  870.  either case bracketing symbols must be used to prevent  attaching
  871.  the dependent clause to the inner statement instead of the outer.
  872. 1                           - 14 -
  873.  
  874.  
  875.  CASE SELECTION
  876. +______________
  877.  
  878.       The CASE  statement  permits  the  selection  of  an  action
  879.  designated by the value of a register.  Its format is:
  880.  
  881.       CASE register MAX expression  MIN expression;
  882.          case-label: statement;
  883.          ...
  884.          ENDCASE
  885.  
  886.       The case to be executed is designated by the contents of the
  887.  specified register.  This  index  must  be  a  multiple  of  four
  888.  greater  than  or  equal  to  zero and be contained in a register
  889.  other than register zero.  A maximum value (used  to  generate  a
  890.  branch table, but not checked at execution time) is required, and
  891.  may  be  any  valid previously defined assembler expression which
  892.  evaluates to a multiple of four greater than the  minimum  value.
  893.  A  minimum  value  (also  used  to  generate the branch table) is
  894.  optional, has a  default  value  of  0,  and  may  be  any  valid
  895.  previously defined assembler expression.  The case to be executed
  896.  is  designated  by  the value of the "case-label" assigned to it.
  897.  Each  such  label  consists  of  an  assembler  expression,   two
  898.  expressions separated by the keyword "THRU", or a series of these
  899.  two types separated by commas.  As shown above, the case label is
  900.  separated  from  the statement making up the case by a colon.  If
  901.  duplicate or overlapping case labels are specified, the last  one
  902.  takes  precedence.   This  allows  a default action to be defined
  903.  which will take effect  if  a  case  is  specified  for  which  a
  904.  statement was not otherwise provided.  If a default action is not
  905.  provided,  a program check (invalid op-code) will occur if a case
  906.  is specified for which no statement was entered.
  907.  
  908.  Example:
  909.  
  910.       CASE R15 MAX 16;
  911.          0: ;
  912.          4,16: LA R15,4;
  913.          8 THRU 12: LA R15,8;
  914.          ENDCASE;
  915.  
  916.  translates to:
  917.  
  918.          B   @0001(R15)
  919.   @0001  B   @0002
  920.          B   @0003
  921.          B   @0004
  922.          B   @0004
  923.          B   @0003
  924.   @0003  LA  R15,4
  925.          B   @0002
  926.   @0004  LA  R15,8
  927.   @0002  ----
  928.  
  929. 1                           - 15 -
  930.  
  931.  
  932.       The CHECK option may be used in a CASE statement to  specify
  933.  that  the  minimum and maximum values are to be checked.  An ELSE
  934.  clause may be added after the ENDCASE to specify the action to be
  935.  taken for an out of bounds value.  If no ELSE clause is used,  an
  936.  operation exception will occur for an invalid value.
  937.  
  938.  Example:
  939.  
  940.       CASE R15 MAX 16 MIN 4 CHECK;
  941.          4,16: LA R15,4;
  942.          8 THRU 12: LA R15,8;
  943.          ENDCASE
  944.       ELSE ABEND 1234,DUMP;
  945.  
  946.  translates to:
  947.  
  948.          C   R15,=A(4)
  949.          BL  @0004
  950.          C   R15,=A(16)
  951.          BH  @0004
  952.          B   @0001-4(R15)
  953.   @0001  B   @0002
  954.          B   @0003
  955.          B   @0003
  956.          B   @0002
  957.   @0002  LA  R15,4
  958.          B   @0005
  959.   @0003  LA  R15,8
  960.          B   @0005
  961.   @0004  ABEND 1234,DUMP
  962.   @0005  ----
  963.  
  964.       The CASE  statement  may  also  have  a  THEN  clause  which
  965.  functions in the same manner as for the DO statement.   The  THEN
  966.  clause must follow an ELSE clause, if present.
  967. 1                           - 16 -
  968.  
  969.  PREDICATE SELECTION
  970. +___________________
  971.  
  972.       The SELECT statement is analogous to the CASE  statement  in
  973.  that  it  allows  the  selection  of  an action designated by the
  974.  validity of a specified condition.  In the  CASE  statement  this
  975.  condition  is  the  equality of the specified register to a value
  976.  given in the "case-label".  In the SELECT statement the condition
  977.  is the truth of one or more predicates which take  the  place  of
  978.  CASE "case-label"s.  The format is:
  979.  
  980.       SELECT;
  981.          predicate: statement;
  982.          ...
  983.          ENDSEL
  984.  
  985.       Execution of the statement is as follows: each predicate  is
  986.  evaluated in turn and,  if  true,  its  associated  statement  is
  987.  executed.   The  sequential nature of this process means that the
  988.  execution of a selected statement can influence the  truth  of  a
  989.  predicate  forming the selection-label on a later statement.  For
  990.  example:
  991.  
  992.       LI R1,1;
  993.       SELECT;
  994.          <C R1,=F'1'>: <LI R1,2>;
  995.          <C R1,=F'2'>: <LI R1,3>;
  996.          ENDSEL;
  997.  
  998.  
  999.  As in the previous example, multiple elements  of  the  selection
  1000.  list  may  be  executed  in  turn.   The SELECT FIRST form of the
  1001.  construct specifies that  only  the  first  statement  for  whose
  1002.  predicate  is  true will be executed, and no others "below" it --
  1003.  regardless of the fact that their predicates may  also  be  true.
  1004.  Applying this option to the example above:
  1005.  
  1006.       LI R1,1;
  1007.       SELECT FIRST;
  1008.          <C R1,=F'1'>: <LI R1,2>;
  1009.          <C R1,=F'2'>: <LI R1,3>;
  1010.          ENDSEL;
  1011.  
  1012.  In this case, only the first selected case ("LI R1,2")  would  be
  1013.  executed, since no other predicates would be tested.
  1014. 1                           - 17 -
  1015.  
  1016.       An additional option, applicable to SELECT FIRST form  only,
  1017.  allows specification of an action to be performed if no predicate
  1018.  in the selection-list is true.  Its form is as follows:
  1019.  
  1020.       SELECT FIRST;
  1021.          predicate: statement;
  1022.          ...
  1023.          ENDSEL
  1024.       ELSE statement
  1025.  
  1026.  Example:
  1027.  
  1028.       LI R1,0;
  1029.       SELECT FIRST;
  1030.          <C R1,=F'1'>: <LI R1,2>;
  1031.          <C R1,=F'2'>: <LI R1,3>;
  1032.          ENDSEL
  1033.       ELSE LI  R1,4;
  1034.  
  1035.       A THEN clause may also be appended to  a  SELECT  statement.
  1036.  The  statement  following  THEN  is  executed  if  control "falls
  1037.  through" to the end of the statement but not if an EXIT statement
  1038.  is used.  For example;
  1039.  
  1040.       SELECT FIRST;
  1041.          <C R1,=F'1'>: <LI R1,2>;
  1042.          <C R1,=F'2'>: <LI R1,3>;
  1043.          ENDSEL
  1044.       ELSE LI R1,4
  1045.       THEN MH R1,=H'10000';
  1046.  
  1047.  NOTE:  Although the effect of  the  SELECT  FIRST  ...   ELSE  is
  1048.  easily  obtained  with  IF-THEN-ELSEs,  the  SELECT  construct is
  1049.  generally more readable, and may  clarify  the  processing  being
  1050.  carried out.
  1051. 1                           - 18 -
  1052.  
  1053.  LOOP CONTROL MECHANISMS
  1054. +_______________________
  1055.  
  1056.       In  order  to  reduce  the  necessity  for  coding  explicit
  1057.  branches, ALP provides ways to escape from and reenter a  control
  1058.  structure.  The first is the EXIT statement, whose complete  form
  1059.  is:
  1060.  
  1061.       EXIT FROM label IF predicate
  1062.  
  1063.  where the "FROM label" and "IF predicate" clauses are optional.
  1064.  
  1065.  Examples:
  1066.  
  1067.       EXIT;
  1068.       EXIT FROM BLOCK1;
  1069.       EXIT IF <RP 15>;
  1070.       EXIT FROM BLOCK1 IF <RP 15>;
  1071.  
  1072.  NOTE: If both are specified, the FROM clause must precede the  IF
  1073.  clause.
  1074.  
  1075.       When used inside a loop  construct  (DO-WHILE,  etc.),  EXIT
  1076.  causes   control  to  be  transfered  to  the  first  instruction
  1077.  following  the  loop  (bypassing  any  THEN  clause).   The  EXIT
  1078.  statement may also be used inside a CASE or SELECT  statement  to
  1079.  terminate execution of the case.
  1080.  
  1081.       An EXIT without a FROM clause causes a transfer  of  control
  1082.  to  the  first  instruction  immediately  following the construct
  1083.  containing the EXIT.  An EXIT followed by a FROM clause causes  a
  1084.  transfer  of  control  to  the  first  instruction  following the
  1085.  construct whose label is specified  in  the  FROM  clause.   Both
  1086.  forms   may  be  modified  by  the  IF  clause  to  provide  both
  1087.  conditional and unconditional EXITs.
  1088.  
  1089.  Examples:  (target labels are shown only for reference)
  1090.  
  1091.       BLOCK1: DO BEGIN
  1092.          ...
  1093.          BLOCK2: DO BEGIN
  1094.             ...
  1095.             EXIT; % TO TARGET1
  1096.             ...
  1097.             EXIT FROM BLOCK1; % TO TARGET2
  1098.             ...
  1099.             END;
  1100.          TARGET1: ...
  1101.          ...
  1102.          END;
  1103.       TARGET2: ...
  1104.  
  1105.  
  1106.       FOREVER DO BEGIN
  1107.          LA R2,1(,R2);
  1108.          EXIT IF <CR R2,R3>;
  1109.          MVI 0(R2),C'*';
  1110.          END;
  1111. 1                           - 19 -
  1112.  
  1113.       In an analogous manner, the NEXT statement,
  1114.  
  1115.       NEXT OF label IF predicate
  1116.  
  1117.  causes transfer of control, conditionally or unconditionally,  to
  1118.  the  point  at which the next iteration of the construct named by
  1119.  "label" begins (e.g.  to the "BCT" in a "FOR" structure).  If  no
  1120.  OF  clause is specified, the next iteration of the innermost loop
  1121.  is begun.  In a  CASE  or  SELECT  statement,  a  NEXT  causes  a
  1122.  transfer of control back to the point of case selection.
  1123.  
  1124.  
  1125.  
  1126.  Examples:
  1127.  
  1128.       WHILE <L R2,0(,R2); CR R2,R3; CC NE>
  1129.       DO <NEXT IF RZ R5; AI R4,1>;
  1130.  
  1131.       CASE R15 MAX 8;
  1132.          0: ;
  1133.          4: <NEXT IF LTR R3,R3; CALL ERROR>;
  1134.          8: CALL ERROR2;
  1135.          ENDCASE;
  1136.  
  1137.       SELECT;
  1138.          <C R2,=F'1'>: <LI R2,2; NEXT>;
  1139.          <C R2,=F'2'>: <AI R2,1>;
  1140.          ENDSEL;
  1141.  
  1142.       BLOCK1: DO BEGIN
  1143.          BLOCK2: DO BEGIN
  1144.             ...
  1145.             NEXT; % NEXT ITERATION OF BLOCK2
  1146.             ...
  1147.             NEXT OF BLOCK1; % NEXT ITERATION OF BLOCK1
  1148.             ...
  1149.             END WHILE <CR R2,R3>;
  1150.          END WHILE <RP R1>;
  1151.  
  1152.  
  1153.  
  1154.  NOTE:  If an EXIT or NEXT statement occurs in the THEN clause of
  1155.  a DO, CASE or SELECT statement, it applies to the containing
  1156.  statement.
  1157.  
  1158.  NOTE:  It is possible to code statements like:
  1159.  
  1160.       IF predicate THEN EXIT;
  1161.  
  1162.  However, this causes less efficient code to be generated than  if
  1163.  the EXIT statement had been used in the form
  1164.  
  1165.       EXIT IF predicate;
  1166.  
  1167.  Hence the latter form is recommended.  This is equally  true  for
  1168.  the NEXT statement.
  1169. 1                           - 20 -
  1170.  
  1171.  BRANCHING
  1172. +_________
  1173.  
  1174.      The final control statement, an admission of our  failure  to
  1175.  write completely structured programs, is an explicit branch.  Its
  1176.  format is:
  1177.  
  1178.      GOTO label IF predicate
  1179.  
  1180.  A branch-register form is also available:
  1181.  
  1182.      RGOTO register IF predicate
  1183.  
  1184.  where the "IF" clauses in both forms are optional.
  1185.  
  1186.  
  1187.  
  1188.  Examples:
  1189.  
  1190.       GOTO  X;
  1191.  
  1192.  translates to:
  1193.  
  1194.       B  X
  1195.  
  1196.  
  1197.  
  1198.       RGOTO  REG;
  1199.  
  1200.  generates:
  1201.  
  1202.       BR  REG
  1203.  
  1204.  
  1205.  
  1206.       GOTO X2 IF <TM 0(R1),X'40'>;
  1207.  
  1208.  generates:
  1209.  
  1210.       TM  0(R1),X'40'
  1211.       BNZ X2
  1212.  
  1213.  
  1214.  
  1215.       RGOTO REG2 IF <SI R3,1; RZ R3>;
  1216.  
  1217.  generates:
  1218.  
  1219.       BCTR R3,0
  1220.       LTR  R3,R3
  1221.       BZR  REG2
  1222.  
  1223.  
  1224.  
  1225.  NOTE:  "GOTO/RGOTO ...  IF ..."  generates  more  efficient  code
  1226.  than  "IF  ...  THEN GOTO/RGOTO ...", and is therefore preferable
  1227.  (even though the latter may be easier to think of).
  1228. 1                           - 21 -
  1229.  
  1230.  
  1231.  CONTROL OF BASE REGISTER ASSIGNMENT FOR DSECTS
  1232. +______________________________________________
  1233.  
  1234.       Control of base register assignment for DSECTs through USING
  1235.  and DROP assembler statements, while not difficult, is frequently
  1236.  not easy to relate to the processing being performed.  ALP's  USE
  1237.  statement  allows  explicit  use  of  a  data  structure  for the
  1238.  duration of a single statement  --  simple  or  compound  --  and
  1239.  automatically provides the appropriate USING and DROP directives.
  1240.  Its format is:
  1241.  
  1242.       USE register AS dsect-name IN statement
  1243.  
  1244.  
  1245.  
  1246.  Example:
  1247.  
  1248.       USE R12 AS MSGBLK IN L R11,MSGLEN;
  1249.  
  1250.  translates to:
  1251.  
  1252.       USING MSGBLK,R12
  1253.       L     R11,MSGLEN
  1254.       DROP  R12
  1255.  
  1256.  
  1257.  
  1258.       Multiple "register AS dsect-name" units  may  be  specified,
  1259.  using commas as separators.
  1260.  
  1261.  
  1262.  
  1263.  Example:
  1264.  
  1265.       USE R1 AS PARMBLK1, R2 AS PARMBLK2 IN BEGIN
  1266.          L  R3,PARM1;
  1267.          L  R4,PARM2
  1268.          END;
  1269.  
  1270.  generates:
  1271.  
  1272.       USING PARMBLK1,R1
  1273.       USING PARMBLK2,R2
  1274.       L     R3,PARM1
  1275.       L     R4,PARM2
  1276.       DROP  R1,R2
  1277. 1                           - 22 -
  1278.  
  1279.  INLINE DATA
  1280. +___________
  1281.  
  1282.       The DATA statement may be used to branch around data  values
  1283.  which  are included with executable code for purposes of clarity.
  1284.  The general form is
  1285.  
  1286.       DATA statement
  1287.  
  1288.  Examples:
  1289.  
  1290.       DATA CON: DC F'99'
  1291.  
  1292.  translates to
  1293.  
  1294.          B   @0001
  1295.  CON     DC  F'99'
  1296.  @0001   ...
  1297.  
  1298.  
  1299.        DATA BEGIN
  1300.           CONS:
  1301.           DC F'99';
  1302.           DC F'999';
  1303.           END
  1304.  
  1305.  translates to
  1306.  
  1307.          B   @0001
  1308.  CONS    DC  F'99'
  1309.          DC  F'999'
  1310.  @0001   ...
  1311. 1                           - 23 -
  1312.  
  1313.  
  1314.  CONDITIONAL ASSEMBLY
  1315. +____________________
  1316.  
  1317.       While it is, of course,  possible  to  use  the  assembler's
  1318.  conditional  assembly  facilities in a straightforward way, it is
  1319.  often more convenient to have ALP generate the necessary sequence
  1320.  symbols, take  care  of  isolation  of  labels  generated  within
  1321.  conditional  assembly  blocks,  and  so  on.   The ASM statements
  1322.  provide these capabilities.  The most often used ASM statement is
  1323.  the ASM IF:
  1324.  
  1325.       ASM IF (condition) THEN statement ELSE statement
  1326.  
  1327.  where the "ELSE" clause is optional.
  1328.  
  1329.  
  1330.  
  1331.  Examples:
  1332.  
  1333.       ASM IF ('&TYPE' EQ 'EMPTY') THEN statement;
  1334.  
  1335.  translates to:
  1336.  
  1337.         AIF (NOT ('&TYPE' EQ 'EMPTY')).@0001
  1338.         statement
  1339.  .@0001 ANOP
  1340.  
  1341.  
  1342.  
  1343.       ASM IF (&&V EQ &&X) THEN statement1 ELSE statement2;
  1344.  
  1345.  generates:
  1346.  
  1347.         AIF (NOT (&V EQ &X)).@0001
  1348.         statement1
  1349.         AGO .@0002
  1350.  .@0001 ANOP
  1351.         statement2
  1352.  .@0002 ANOP
  1353.  
  1354.  
  1355.  
  1356.  NOTE:  If "statement1" in the "...  THEN ...  ELSE ..." form is a
  1357.  simple statement without operands (e.g.   a  macro  call  without
  1358.  operands,  an  assembler  op-code without operands, etc.) then it
  1359.  should be bracketed with '<'/'>' symbols to  prevent  the  'ELSE'
  1360.  from being interpreted as an operand of the statement.
  1361. 1                           - 24 -
  1362.  
  1363.  
  1364.  Most other ALP statements are available in the  ASM  form  in  an
  1365.  analogous way.
  1366.  
  1367.  . ASM WHILE (condition) DO statement THEN statement
  1368.  . ASM UNTIL (condition) DO statement THEN statement
  1369.  . ASM DO statement WHILE (condition) THEN statement
  1370.  . ASM DO statement UNTIL (condition) THEN statement
  1371.  . ASM DO statement THEN statement
  1372.  . ASM FOREVER DO statement
  1373.  . ASM DO statement FOREVER
  1374.  . ASM CASE set-expression;
  1375.       case-list: statement;
  1376.       ...
  1377.       ENDCASE
  1378.    THEN statement
  1379.  . ASM CASE set-expression;
  1380.       case-list: statement;
  1381.       ...
  1382.       ENDCASE
  1383.    ELSE statement
  1384.    THEN statement
  1385.  . ASM SELECT;
  1386.       (condition): statement;
  1387.       ...
  1388.       ENDSEL
  1389.    THEN statement
  1390.  . ASM SELECT FIRST;
  1391.       (condition): statement;
  1392.       ...
  1393.       ENDSEL
  1394.    THEN statement
  1395.  . ASM SELECT FIRST;
  1396.       (condition): statement;
  1397.       ...
  1398.       ENDSEL
  1399.    ELSE statement
  1400.    THEN statement
  1401.  . ASM FOR seta-variable FROM seta-expression BY seta-expression
  1402.      TO seta-expression DO statement THEN statement
  1403.  . ASM DO statement FOR seta-variable BY seta-expression
  1404.      TO seta-expression THEN statement
  1405.  . ASM EXIT
  1406.  . ASM EXIT FROM sequence-symbol
  1407.  . ASM EXIT IF (condition)
  1408.  . ASM EXIT FROM sequence-symbol IF (condition)
  1409.  . ASM NEXT
  1410.  . ASM NEXT OF sequence-symbol
  1411.  . ASM NEXT IF (condition)
  1412.  . ASM NEXT OF sequence-symbol IF (condition)
  1413.  . ASM GOTO sequence-symbol
  1414.  . ASM GOTO sequence-symbol IF (condition)
  1415. 1                           - 25 -
  1416.  
  1417.  
  1418.  Notable points are
  1419.  
  1420.  . "condition" represents a valid SETB expression.
  1421.  . the THEN clause is optional with all statements except ASM IF.
  1422.  . FROM, BY and TO are provided with ASM FOR to define the  limits
  1423.    of the loop.  The defaults are 1, 1 and infinity, respectively.
  1424.    If   negative  numbers  are  used,  they  must  be  written  as
  1425.    "0-number", in honor of  the  assembler  restriction  on  unary
  1426.    operators.  FROM is not valid with ASM DO FOR.
  1427.  . The selection value in the ASM CASE statement  may  also  be  a
  1428.    SETC   expression  in  quotes.   If  this  is  done,  the  case
  1429.    identifiers must also be SETC expressions in quotes.
  1430.  . MAX and MIN are not used with ASM CASE.
  1431.  . There is no ASM RGOTO statement.
  1432.  . ASM IF may also be written  as  ASMIF  for  compatability  with
  1433.    earlier versions.
  1434. 1                           - 26 -
  1435.  
  1436.  INCLUDING ALP CODE IN MACROS
  1437. +____________________________
  1438.  
  1439.       Although macros are  frequently  used  for  describing  data
  1440.  structures or for small common code segments containing little or
  1441.  no  control  structure,  this  is  not  always the case.  In such
  1442.  instances it is desirable to  write  them  in  ALP  in  order  to
  1443.  continue  to maintain consistency and preserve the goals of using
  1444.  a  structured  language.   ALP's  MACRO  statement   allows   the
  1445.  definition  of assembler macros which may contain ALP constructs.
  1446.  Its format is:
  1447.  
  1448.       MACRO  macro-label: macro-name macro-operands;
  1449.          GBLx and LCLx declarations
  1450.          macro-body
  1451.          MEND
  1452.  
  1453.  where:
  1454.  
  1455.       macro-label is the (optional) label to be placed on
  1456.       the first statement of the macro, and is of the form
  1457.       &&identifier
  1458.  
  1459.       macro-name is the name of the macro
  1460.  
  1461.       macro-operands is an (optional) operand field which
  1462.       names the symbolic operands of the macro, in the form
  1463.       &&identifier,&&identifier,...
  1464.  
  1465.  
  1466.  Example:
  1467.  
  1468.       MACRO &&LABEL: ZAP &&P1,&&P2;
  1469.          GBLA &&X;
  1470.          COPY NAMES;
  1471.          &&LABEL: IF <RP &&P1> THEN <ZR &&P1>
  1472.          ELSE <LCR &&P2,&&P1>;
  1473.          MEND;
  1474.  
  1475.  generates
  1476.  
  1477.           MACRO
  1478.  &LABEL   ZAP   &P1,&P2
  1479.           GBLA  &X
  1480.           COPY  NAMES
  1481.           LCLC  &@
  1482.  &@       SETC  '&SYSNDX'
  1483.  &LABEL   LTR   &P1,&P1
  1484.           BNP   @&@001
  1485.           SR    &P1,&P1
  1486.           B     @&@002
  1487.  @&@001   LCR   &P2,&P1
  1488.  @&@002   ...
  1489.  
  1490.  
  1491.  NOTE:   The  doubling  of  ampersands  ('&')  is  necessary,   as
  1492.  described  in section II, to prevent confusion with the predicate
  1493.  operator "AND".
  1494. 1                           - 27 -
  1495.  
  1496.  
  1497.       All GBLx and LCLx declarations and any COPY statements which
  1498.  copy in such statements must be  grouped  immediately  after  the
  1499.  MACRO header.  This is because a local set symbol must be defined
  1500.  so that ALP-generated labels do not result in duplicate labels if
  1501.  a  macro  is  invoked  more  than  once.   Assembler restrictions
  1502.  require  that  all  set   symbol   declarations   precede   other
  1503.  statements,  and  ALP  picks the point at which to define its own
  1504.  set symbol by detecting the first statement which is not a  GBLx,
  1505.  LCLx,  or COPY.  Another consequence of this is that a COPY which
  1506.  copies in executable code MUST be preceded by a  dummy  statement
  1507.  of some sort to prevent premature generation of the ALP local set
  1508.  symbol.  For example:
  1509.  
  1510.       MACRO EXAMPLE;
  1511.          GBLA &&X;
  1512.          ; % TO FOOL ALP
  1513.          COPY CODE; % TO COPY IN EXECUTABLE CODE
  1514.          MEND;
  1515.  
  1516.  
  1517.  ALP may also be used to process macros to be stored in  assembler
  1518.  macro  libraries.   To  facilitate  this,  ALP  will pass through
  1519.  unchanged any ./ control cards which occur in the  input  stream.
  1520.  Thus, output from ALP may be passed directly to IEBUPDTE.
  1521. 1                           - 28 -
  1522.  
  1523.  REVERSION TO BAL
  1524. +________________
  1525.  
  1526.       While  most  assembler  code  can  be  written  within   the
  1527.  framework  of  ALP, it may occasionally be necessary to revert to
  1528.  BAL mode.  The ALP statement "BAL;" will cause  the  preprocessor
  1529.  to  enter  a  transparency  mode, in which card images are simply
  1530.  copied from the input stream to the output stream.  BAL  mode  is
  1531.  terminated when "ALP;" appears as the first non-blank symbol on a
  1532.  line.  Any text beyond the "BAL;" on the same  line  is  ignored.
  1533.  The format of the statement is:
  1534.  
  1535.       BAL;
  1536.       bal-code
  1537.       ALP;
  1538.  
  1539.  
  1540.  
  1541.  Examples:
  1542.  
  1543.       BAL;
  1544.            MACRO
  1545.       &L   ADD   &A,&B,&C
  1546.            L  15,&A
  1547.            A  15,&B
  1548.            ST 15,&C
  1549.            MEND
  1550.       ALP;
  1551.  
  1552.  
  1553.       BAL;
  1554.        IF  &L1,&L2
  1555.       ALP;
  1556. 1                           - 29 -
  1557.  
  1558.  BLOCK COMMENTS
  1559. +______________
  1560.  
  1561.       The comment statement is an alternate  way  of  including  a
  1562.  large block of comments in an ALP program.  All lines following a
  1563.  "COMMENT;"  statement  are ignored.  Normal processing is resumed
  1564.  when "ALP;" appears as the first non-blank character on  a  line.
  1565.  The  advantage  of  COMMENT over normal comments is that WYLBUR's
  1566.  ALIGN and JUSTIFY  commands  may  be  used  since  there  are  no
  1567.  extraneous characters on the comment lines.
  1568.  
  1569.  Example:
  1570.  
  1571.       COMMENT;
  1572.  
  1573.       Normally a long-winded  explanation  of  some  part  of  the
  1574.       program would appear here.
  1575.  
  1576.       ALP;
  1577. 1                           - 30 -
  1578.  
  1579.  
  1580.  LISTING FORMAT CONTROL
  1581. +______________________
  1582.  
  1583.       Several conventions were adopted to  allow  control  of  the
  1584.  SYSPRINT  listings  of  both ALP and the assembler.  These are as
  1585.  follows:
  1586.  
  1587.  . The indentation of each line is automatically adjusted to be  3
  1588.    times  the nesting level at the start of the line.  The nesting
  1589.    level is the number of unterminated BEGIN, <, CASE, SELECT  and
  1590.    MACRO statements.
  1591.  
  1592.  . Blank lines are ignored by ALP, and may thus be used to  format
  1593.    input  source.   They  are  not passed on to the assembler, and
  1594.    hence have no effect on its output.
  1595.  
  1596.  . If ALP is being used  in  conjunction  with  the  assembler,  a
  1597.    post-processor   extracts  location  counter  values  from  the
  1598.    assembler listing and adds them to the ALP listing.   In  order
  1599.    for this process to work properly,  the  input  lines  must  be
  1600.    sequence  numbered in ascending order in columns 73 through 80.
  1601.    Special care must be taken  with  COPY  statements  outside  of
  1602.    macros as they will disrupt the sequencing.  Sequence fields of
  1603.    all  blanks  or all zeroes are ignored.  The IEBUPDTE statement
  1604.    ./ NUMBER NEW1=0,INCR=0 may be used to cause  sequence  numbers
  1605.    of all zeroes to be placed in a COPY module.
  1606.  
  1607.  . ALP provides limited support for the assembler directive SPACE.
  1608.    The  ALP  listing  is  arbitrarily spaced up two lines, and the
  1609.    SPACE and its operands (if any -- no checking for  validity  is
  1610.    performed) are passed on to the assembler.
  1611.  
  1612.  . ALP processes the EJECT assembler directive by causing  a  page
  1613.    eject and passing the EJECT (and any operands -- no checking is
  1614.    done) on to the assembler.
  1615.  
  1616.  . ALP accepts the assembler directive TITLE.   The  operands  are
  1617.    stored for printing at the top of each page, and with the TITLE
  1618.    op-code  are  passed on to the assembler.  No validity checking
  1619.    is performed, but there should be only one operand -- a  quoted
  1620.    string.   If  a  label  is  present,  it  is also passed to the
  1621.    assembler.  Note that there is an  assembler  requirement  that
  1622.    only  one  such  "deck  name"  be present in any assembly.  The
  1623.    default title is a standard ALP heading.
  1624.  
  1625.  . ALP supports a SUBTITLE statement.  The operands, which  should
  1626.    consist  of  a single quoted string, are stored for printing at
  1627.    the top of each page immediately below the current title.   The
  1628.    SUBTITLE  is converted to a TITLE directive and passed with its
  1629.    operands to the assembler.  The default  subtitle  is  a  blank
  1630.    line.
  1631.  
  1632.  . ./ (IEBUPDTE) control cards cause a page eject.
  1633. 1                           - 31 -
  1634.  
  1635.  
  1636.  NOTE:  SPACE, EJECT, TITLE,  and  SUBTITLE  are  all  treated  as
  1637.  regular  assembly  language  statements  --  no special notice is
  1638.  taken that they also influence formatting of the source listings.
  1639.  Hence some care must be taken in their placement in  the  source.
  1640.  For example,
  1641.  
  1642.           IF predicate THEN BEGIN
  1643.              statements
  1644.              END
  1645.           ELSE
  1646.           EJECT;
  1647.           BEGIN
  1648.              statements
  1649.              END;
  1650.  
  1651.  will cause the EJECT to form the body of the ELSE clause and  not
  1652.  the  desired  BEGIN-END  block.   It  is  also not permissible to
  1653.  separate  CASE  or  SELECT   components   with   format   control
  1654.  statements.
  1655. 1                           - 32 -
  1656.  
  1657.  
  1658.                     IV. NON-CONTROL EXTENSIONS
  1659.  
  1660.  
  1661.      Some non-control extensions are provided by ALP in an attempt
  1662.  to improve the conceptual environment in which  one  programs  at
  1663.  the  assembly language level.  There are several notions that are
  1664.  fairly well established in the machine instruction  set  and  the
  1665.  basic assembly language.  These include word, halfword, byte, and
  1666.  register  operations.   A  very  important data type not directly
  1667.  covered is the bit.  Bit operations  are  adequately  handled  by
  1668.  byte  instructions, but what is missing is a clear identification
  1669.  that one is dealing  with  bits.   AL  provided  three  'extended
  1670.  mnemonics',  TB,  SB, and ZB for test bit, set bit, and zero bit.
  1671.  These allowed writing code as if  the  machine  had  instructions
  1672.  with  byte  and  bit addressing rather than having to think about
  1673.  the  appropriate  mask  to  use  with  a   particular   kind   of
  1674.  instruction.   However,  there  were  several  problems with this
  1675.  approach, and we decided that the ability to use symbolic  masks,
  1676.  etc.   was  more  important.   Hence  these  macros  appear  in a
  1677.  modified form or not at all.
  1678.  
  1679.      A very important set of instructions in the 360/370  are  the
  1680.  byte  string instructions.  Unfortunately, the notion provided at
  1681.  the BAL level is rather poor.  One problem  is  that  the  length
  1682.  field  in  the instruction is one less than the effective length.
  1683.  Another problem is that the BAL format confuses the length  field
  1684.  with  the  base register field of the first operand.  This latter
  1685.  problem is  solved  by  separating  out  the  length  field.   AL
  1686.  provided  the  MOVE  instruction  instead  of  MVC  and  the COMP
  1687.  instruction instead  of  CLC;  these  names  also  emphasize  the
  1688.  importance  and  generality  of  these  instructions  rather than
  1689.  confusing one  with  "logical  character".   Since  ALP  provides
  1690.  extended macros for more than just MVC and CLC, we elected to use
  1691.  mnemonics  closer to the original ones.  Note that these extended
  1692.  facilities provide more than just modification of the format.
  1693.  
  1694.      Certain  other  operations  are  clarified  with  appropriate
  1695.  mnemonics.  For example:  ZR (for Zero Register),  RP,  RZ,  etc.
  1696.  for Register Plus, Zero, and so on (all generate an LTR but imply
  1697.  different condition code tests), and ZI (for Zero Immediate -- an
  1698.  NI   with   255-bitvalue   mask).    Macros  useful  in  ALP  for
  1699.  clarification purposes are listed below.  Not  all  are  actually
  1700.  required (see the end of section II for those that are built into
  1701.  the  translator), but all have been found useful.  Note that some
  1702.  AL macros have been changed or replaced, and others (due  to  our
  1703.  own preferences) discarded.
  1704. 1                           - 33 -
  1705.  
  1706.  
  1707.        AI - Add Immediate
  1708.        CI - Compare Immediate
  1709.       CIL - Compare Immediate Logical
  1710.        DI - Divide Immediate
  1711.        LI - Load Immediate
  1712.       LQS - Load Quoted String
  1713.        LT - Load and Test
  1714.        MI - Multiply Immediate
  1715.        RM - Register Minus
  1716.       RMP - Register Minus or Plus
  1717.       RMZ - Register Minus or Zero
  1718.       RNM - Register Not Minus
  1719.      RNMP - Register Not Minus or Plus
  1720.      RNMZ - Register Not Minus or Zero
  1721.       RNP - Register Not Plus
  1722.       RNZ - Register Not Zero
  1723.      RNZP - Register Not Zero or Plus
  1724.        RP - Register Plus
  1725.        RZ - Register Zero
  1726.       RZP - Register Zero or Plus
  1727.        SI - Subtract Immediate
  1728.         Z - Zero
  1729.        ZB - Zero Byte
  1730.        ZH - Zero Halfword
  1731.       ZHB - Zero High Byte
  1732.      ZHBR - Zero High Byte Register
  1733.        ZI - Zero Immediate
  1734.        ZR - Zero Register
  1735.       EXI - Execute immediate
  1736.      EDIT - Generate edit mask and ED/EDMK instruction
  1737.      MCLC - Multiple Compare Logical Characters
  1738.      MMVC - Multiple Move Characters
  1739.       MNC - Multiple AND Characters
  1740.       MOC - Multiple OR Characters
  1741.       MXC - Multiple Exclusive-OR Characters
  1742.       MFC - Multiple Fill Characters
  1743.       MTR - Multiple Translate
  1744.      MTRT - Multiple Translate and Test
  1745.       MZC - Multiple Zero Characters
  1746.        DF - Define Flags
  1747.        SF - Set Flags
  1748.        TF - Test Flags
  1749.        ZF - Zero Flags
  1750.   DEBLANK - Deblank a string
  1751.     OPENP - Check for successful open
  1752.  
  1753.       See sections VII and VIII for  further  information  on
  1754.  these macros.
  1755. 1                           - 34 -
  1756.  
  1757.  
  1758.                    V. THE IMPLEMENTATION OF ALP
  1759.  
  1760.  
  1761.       ALP has been implemented as a preprocessor to  the  standard
  1762.  OS/360  assembler,  using  macros  within  the  assembler in some
  1763.  instances to enhance readability.  The preprocessor is written in
  1764.  PL/I using recursive descent, and  is  approximately  3100  lines
  1765.  long.   The post-processor for extracting location counter values
  1766.  is also written in PL/I and is approximately 365 lines long.
  1767.  
  1768.       ALP,  the  assembler  and  the  post-processor  are  usually
  1769.  invoked in sequence by a small control program, allowing the  two
  1770.  tasks  to be executed as one job step.  Cataloged procedures (see
  1771.  section XI) have been developed for using ALP.
  1772. 1                           - 35 -
  1773.  
  1774.  
  1775.                         VI. ALP SYNTAX
  1776.  
  1777.  
  1778.                            Notation
  1779.  
  1780.  
  1781.  
  1782.  Non-terminal  symbols  are  lower  case  identifiers  (which  may
  1783.  include a "dash")
  1784.  
  1785.  Terminal symbols are either upper  case  identifiers  or  special
  1786.  symbols enclosed in quotation marks
  1787.  
  1788.  ->     means "is defined as"
  1789.  
  1790.  |      indicates alternatives
  1791.  
  1792.  "  "   means must be entered as is
  1793.  
  1794.  (  )   indicates an optional occurrence (0 or 1 times)
  1795.  
  1796.  (  )*  indicates multiple optional occurrences (0 or more times)
  1797.  
  1798.  <  >   indicates a required selection  of  one  of  the  enclosed
  1799.         alternatives
  1800.  
  1801.  <  >*  indicates a required selection  of  one  or  more  of  the
  1802.         enclosed alternatives
  1803.  
  1804.  
  1805.  
  1806.  Some non-terminals are left undefined.  Their meaning  should  be
  1807.  obvious from their names.
  1808. 1                           - 36 -
  1809.  
  1810.  
  1811.  program -> statements ";" END ";"
  1812.  
  1813.  statements -> statement (";" statement)*
  1814.  
  1815.  statement -> (label ":")* <compound-statement | simple-statement>
  1816.  
  1817.  compound-statement -> "<" statements ">"
  1818.                      | BEGIN  statements  END
  1819.  
  1820.  simple-statement -> if | case | select | loop | goto | exit | next
  1821.                    | mapping | data | conditional-assembly | macro
  1822.                    | format-control | bal | cc | bal | comment
  1823.  
  1824.  
  1825.  if -> IF predicate THEN statement (ELSE statement)
  1826.  
  1827.  
  1828.  case -> CASE  register-id  (case-option)* ";"
  1829.          case-list
  1830.          ENDCASE
  1831.          (ELSE statement)
  1832.          (THEN statement)
  1833.  
  1834.  case-option -> MAX expression
  1835.               | MIN expression
  1836.               | CHECK
  1837.  
  1838.  case-list -> <case-label-list ":" statement ";">*
  1839.  case-label-list -> case-label ("," case-label)*
  1840.  case-label -> expression (THRU expression)
  1841.  
  1842.  
  1843.  select -> SELECT (FIRST) ";"
  1844.            selection-list
  1845.            ENDSEL
  1846.            (ELSE statement)
  1847.            (THEN statement)
  1848.  
  1849.  selection-list -> <predicate ":" statement ";">*
  1850.  
  1851.  
  1852.  loop -> <WHILE | UNTIL> predicate DO statement (THEN statement)
  1853.        | DO statement <WHILE | UNTIL> predicate (THEN statement)
  1854.        | FOR register-id DO statement (THEN statement)
  1855.        | DO statement FOR register-id (THEN statement)
  1856.        | DO statement (THEN statement)
  1857.        | FOREVER DO statement
  1858.        | DO statement FOREVER
  1859.  
  1860.  
  1861.  goto -> <GOTO | RGOTO> target (IF predicate)
  1862.  
  1863.  
  1864.  exit -> EXIT (FROM label) (IF predicate)
  1865. 1                           - 37 -
  1866.  
  1867.  
  1868.  
  1869.  next -> NEXT (OF label) (IF predicate)
  1870.  
  1871.  
  1872.  mapping -> USE register AS dsect-id ("," register AS dsect-id)*
  1873.             IN statement
  1874.  
  1875.  data -> DATA statement
  1876.  
  1877.  conditional-assembly -> asm-if | asm-case | asm-select | asm-loop
  1878.                        | asm-goto | asm-exit | asm-next
  1879.  
  1880.  asm-if -> ASM IF setb-expression THEN statement (ELSE statement)
  1881.  
  1882.  asm-case -> ASM CASE set-expression ";"
  1883.              asm-case-list
  1884.              ENDCASE
  1885.              (ELSE statement)
  1886.              (THEN statement)
  1887.  
  1888.  asm-case-list -> <asm-case-label-list ":" statement ";">*
  1889.  asm-case-label-list -> asm-case-label ("," asm-case-label)*
  1890.  asm-case-label -> set-expression (THRU set-expression)
  1891.  
  1892.  asm-select -> ASM SELECT (FIRST) ";"
  1893.                asm-selection-list
  1894.                ENDSEL
  1895.                (ELSE statement)
  1896.                (THEN statement)
  1897.  
  1898.  asm-selection-list -> <setb-expression ":" statement";">*
  1899.  
  1900.  asm-loop -> ASM <WHILE | UNTIL> setb-expression
  1901.              DO statement (THEN statement)
  1902.            | ASM DO statement <WHILE | UNTIL> setb-expression
  1903.              (THEN statement)
  1904.            | ASM FOR seta-variable (FROM seta-expression)
  1905.              (BY seta-expression) (TO seta-expression)
  1906.              DO statement (THEN statement)
  1907.            | ASM DO statement FOR seta-variable (BY seta-expression)
  1908.              (TO seta-expression) (THEN statement)
  1909.            | ASM DO statement (THEN statement)
  1910.            | ASM FOREVER DO statement
  1911.            | ASM DO statement FOREVER
  1912.  
  1913.  asm-goto -> ASM GOTO sequence-symbol (IF setb-expression)
  1914.  
  1915.  asm-exit -> ASM EXIT (FROM sequence-symbol) (IF setb-expression)
  1916.  
  1917.  asm-next -> ASM NEXT (OF sequence-symbol) (IF setb-expression)
  1918.  
  1919.  macro -> MACRO (macro-label) macro-name (macro-operands)
  1920.  
  1921.  macro-label -> "&&"label":"
  1922.  
  1923.  macro-operands -> "&&"identifier (",&&"identifier)*
  1924. 1                           - 38 -
  1925.  
  1926.  
  1927.  format-control -> EJECT
  1928.                    SPACE ( integer )
  1929.                    TITLE "'" title "'"
  1930.                    SUBTITLE "'" subtitle "'"
  1931.  
  1932.  
  1933.  bal ->  BAL;
  1934.          bal-segment
  1935.          ALP;
  1936.  
  1937.  comment ->  COMMENT;
  1938.              text
  1939.              ALP;
  1940.  
  1941.  cc ->  CC  condition-code-string
  1942.  condition-code-string -> <N | "^" | 0 | "=" | E | Z | 1 | L | M |
  1943.                             2 | P | H | 3 | O>*
  1944.  
  1945.  
  1946.  predicate -> ("^")* <statement | "<" predicate ">">
  1947.             | predicate "&" predicate
  1948.             | predicate "|" predicate
  1949.  
  1950.  
  1951.  comment ->  "%" text "end-of-line"
  1952. 1                           - 39 -
  1953.  
  1954.  
  1955.                   VII.  ALP READABILITY MACROS
  1956.  
  1957.  
  1958.  In the description that follows,
  1959.  
  1960.      r  is a register
  1961.      a  is any relocatable expression that is valid in an
  1962.         instruction
  1963.      c  is a constant
  1964.  
  1965.  
  1966.  Macro             Name                     Code Generated
  1967.  
  1968.  AI   r,c          Add Immediate            LA   r,c(,r)
  1969.  
  1970.  AI   0,c          Add Immediate            AL   0,=A(c)
  1971.  
  1972.  
  1973.  CI   r,c          Compare Immediate        C    r,=A(c)
  1974.  
  1975.  CIL  r,c          Compare Immediate        CL   r,=A(c)
  1976.                    Logical
  1977.  
  1978.  DI   r,c          Divide Immediate         D    r,=A(c)
  1979.  
  1980.  LI   r,c          Load Immediate           LA   r,c
  1981.  
  1982.  LQS  rx,ry,'str'  Load Quoted String       LA   rx,=C'str'
  1983.                                             LA   ry,length
  1984.  
  1985.  LT   r,a          Load and Test            L    r,a
  1986.                                             LTR  r,r
  1987.  
  1988.  MI   r,c          Multiply Immediate       MH   r,=AL2(c)
  1989.  
  1990.  RM   r            Register Minus           LTR  r,r
  1991.  
  1992.  RMP  r            Register Minus or Plus   LTR  r,r
  1993.  
  1994.  RMZ  r            Register Minus or Zero   LTR  r,r
  1995.  
  1996.  RNM  r            Register Not Minus       LTR  r,r
  1997.  
  1998.  RNMP r            Register Not Minus       LTR  r,r
  1999.                    or Plus
  2000.  
  2001.  RNMZ r            Register Not Minus       LTR  r,r
  2002.                    or Zero
  2003.  
  2004.  RNP  r            Register Not Plus        LTR  r,r
  2005.  
  2006.  RNZ  r            Register Not Zero        LTR  r,r
  2007.  
  2008.  RNZP r            Register Not Zero        LTR  r,r
  2009.                    or Plus
  2010. 1                           - 40 -
  2011.  
  2012.  
  2013.  
  2014.  RP   r            Register Plus            LTR  r,r
  2015.  
  2016.  RZ   r            Register Zero            LTR  r,r
  2017.  
  2018.  RZP  r            Register Zero or Plus    LTR  r,r
  2019.  SI   r,1          Subtract Immediate       BCTR r,0
  2020.  
  2021.  SI   r,2          Subtract Immediate       BCTR r,0
  2022.                                             BCTR r,0
  2023.  
  2024.  SI   r,c          Subtract Immediate       SL   r,=A(c)
  2025.  
  2026.  Z    r,a          Zero                     SR   r,r
  2027.                                             ST   r,a
  2028.  
  2029.  Z    ,a           Zero                     XC   a(4),a
  2030.  
  2031.  ZB   r,a          Zero Byte                SR   r,r
  2032.                                             STC  r,a
  2033.  
  2034.  ZB   ,a           Zero Byte                MVI  a,0
  2035.  
  2036.  ZH   r,a          Zero Halfword            SR   r,r
  2037.                                             STH  r,a
  2038.  
  2039.  ZH   ,a           Zero Halfword            XC   a(2),a
  2040.  
  2041.  ZHB  a            Zero High Byte           MVI  a,0
  2042.  
  2043.  ZHBR r            Zero High Byte Register  LA   r,0(,r)
  2044.  
  2045.  ZHBR 0            Zero High Byte Register  N    0,=XL4'00FFFFFF'
  2046.  
  2047.  ZI   a,c          Zero Immediate           NI   a,255-(c)
  2048.  
  2049.  ZR   r            Zero Register            SR   r,r
  2050. 1                           - 41 -
  2051.  
  2052.  
  2053.             VIII. Macros for Environment Enhancement
  2054.  
  2055.  
  2056.                          Conventions
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  Macro operands are described using the following terms:
  2062.  
  2063.     cexpr4     - denote expressions which evaluate to  a  constant
  2064.                  to be held in 4 bits
  2065.  
  2066.     cexpr8     - denote expressions which evaluate to  a  constant
  2067.                  to be held in 8 bits
  2068.  
  2069.     relexpri   - denotes a relocatable expression that is valid as
  2070.                  a storage address in an instruction
  2071.  
  2072.     symbol     - an identifier acceptable to the assembler
  2073.  
  2074.     reg        - any register
  2075.  
  2076.     preg       - any register except 0
  2077. 1                           - 42 -
  2078.  
  2079.  
  2080.    AREA, AREAORG and AREAEND - Define a structured storage area
  2081. +  ____________________________________________________________
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  AREA and AREAEND are used to define an area of storage  which  is
  2087.  structured  into  smaller  named  components.   AREA  begins  the
  2088.  definition,  DSs  and  DCs  follow,  and  AREAEND  terminates the
  2089.  definition.
  2090.  
  2091.  AREAORG is used to ORG back to the start  of  the  area  so  that
  2092.  fields  may  be  overlaid.   The  length  of the area will be the
  2093.  maximum attained.
  2094.  
  2095.  
  2096.  
  2097.  <symbol> AREA alignment<,DSECT=NO>
  2098.  
  2099.  
  2100.  
  2101.      symbol               symbol
  2102.  
  2103.          The name of the total storage area.  The length attribute
  2104.          will be correctly set.
  2105.  
  2106.  
  2107.      alignment            X,H,F,D,0X,0H,0F,0D
  2108.  
  2109.          Specifies the boundary alignment for the  area.   Default
  2110.          is X (byte alignment).
  2111.  
  2112.  
  2113.      DSECT=NO
  2114.  
  2115.          Indicates that the area is not to be a DSECT.
  2116.  
  2117.  
  2118.  
  2119.  <symbol> AREAEND <alignment>
  2120.  
  2121.  
  2122.  
  2123.      symbol               symbol
  2124.  
  2125.          A symbol which is to be EQUed to the length of the area.
  2126.  
  2127.  
  2128.  
  2129.      alignment            X,H,F,D,0X,0H,0F,0D
  2130.  
  2131.          Specifies the boundary alignment for the end of the area.
  2132.          Default is what was specified in the AREA macro.
  2133. 1                           - 43 -
  2134.  
  2135.  
  2136.  
  2137.  <symbol> AREAORG <alignment>
  2138.  
  2139.  
  2140.  
  2141.      symbol               symbol
  2142.  
  2143.          A symbol which is to be EQUed to the  current  length  of
  2144.          the area.
  2145.  
  2146.  
  2147.      alignment            X,H,F,D,0X,0H,0F,0D
  2148.  
  2149.          Specifies boundary alignment for the end of this  overlay
  2150.          of  the  area.  Default is what was specified in the AREA
  2151.          macro.
  2152.  
  2153.  
  2154.  
  2155.  NOTE:
  2156.  
  2157.     Area definitions may be nested.  DSECT=NO is  implied  at  the
  2158.     inner levels.
  2159.  
  2160.  
  2161.  
  2162.  EXAMPLE:
  2163.  
  2164.      WA      AREA     F
  2165.      WATEMP  DS       F
  2166.      WABYTE  DS       X
  2167.      WAHALF  DS       H
  2168.      WASIZE  AREAEND
  2169. 1                           - 44 -
  2170.  
  2171.  EXAMPLE:
  2172.  
  2173.      WA       AREA     F
  2174.      WATEMP   DS       F
  2175.      WA2      AREA     D
  2176.      WABYTE   DS       X
  2177.      WAHALF   DS       H
  2178.      WA2SIZE  AREAEND
  2179.      WAHALF2  DS       H
  2180.      WASIZE   AREAEND
  2181.  
  2182.         generates
  2183.  
  2184.      WA       DSECT
  2185.      WATEMP   DS       F
  2186.      WA2      DS       OD
  2187.      WABYTE   DS       X
  2188.      WAHALF   DS       H
  2189.               DS       OD
  2190.      WA2SIZE  EQU      *-WA2
  2191.      WAHALF2  DS       H
  2192.               DS       OF
  2193.      WASIZE   EQU      *-WA
  2194.      prevsect CSECT
  2195.  
  2196.      where "prevsect" is the previous CSECT name
  2197. 1                           - 45 -
  2198.  
  2199.  
  2200.  
  2201.                     DEBLANK - Deblank a string
  2202. +                   __________________________
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  The DEBLANK macro removes leading and/or trailing blanks  from  a
  2208.  string.
  2209.  
  2210.  
  2211.  
  2212.  <symbol> DEBLANK loc-reg,len-reg<,work-reg><,TYPE=symbol>
  2213.                 <,NULL=NO><,ZERO=NO><,LABEL=symbol><,FILL=char>
  2214.                 <,FILADDR=byte>
  2215.  
  2216.  
  2217.  
  2218.      loc-reg              preg
  2219.  
  2220.          Specifies the  starting  address  of  the  string  to  be
  2221.          deblanked.
  2222.  
  2223.  
  2224.      len-reg              reg
  2225.  
  2226.          Specifies the length  of  the  string  to  be  deblanked.
  2227.          After  the  termination  of the macro, this register will
  2228.          contain the new length of the deblanked string.
  2229.  
  2230.  
  2231.      work-reg             preg
  2232.  
  2233.          Provides a work register to be used in the search.   More
  2234.          efficient  code  may  be  generated  if  this register is
  2235.          provided.
  2236.  
  2237.  
  2238.      TYPE=symbol          LEFT, RIGHT, or BOTH
  2239.  
  2240.          Specifies  elimination  of  leading  (LEFT)  or  trailing
  2241.          (RIGHT) blanks, or both (BOTH).  Default is RIGHT.
  2242.  
  2243.  
  2244.      NULL=NO
  2245.  
  2246.          The NO condition specifies that the resulting string will
  2247.          never be 0.  More efficient code may be generated if this
  2248.          option is specified.
  2249.  
  2250.  
  2251.      ZERO=NO
  2252.  
  2253.          The NO condition specifies that  the  value  in  the  len
  2254.          register  will  never  be  0.  More efficient code may be
  2255.          generated if this option is specified.
  2256. 1                           - 46 -
  2257.  
  2258.  
  2259.  
  2260.      LABEL=symbol         relexpri
  2261.  
  2262.          The location to receive control if the  resulting  string
  2263.          has a length of zero.
  2264.  
  2265.      FILL=char            cexpr8
  2266.  
  2267.          Used to specify  a  character  other  than  blank  to  be
  2268.          stripped.
  2269.  
  2270.      FILADDR=byte         relexpri
  2271.  
  2272.          Used to specify the  location  of  the  character  to  be
  2273.          stripped.  May not be used with FILL.
  2274.  
  2275.  
  2276.  RETURNS:
  2277.  
  2278.      loc-reg =  location of deblanked string
  2279.  
  2280.      len-reg =  length of deblanked string
  2281. 1                           - 47 -
  2282.  
  2283.  
  2284.         EDIT - Generate edit mask and ED/EDMK instruction
  2285. +       _________________________________________________
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  EDIT is used to create both an appropriate mask string or editing
  2291.  numeric data and the  ED  or  EDMK  instruction  to  perform  the
  2292.  requested operation.
  2293.  
  2294.  
  2295.  
  2296.  <symbol> EDIT to-field,from-field<,to-length><,from-length>
  2297.                <,CALC=NO><,DIGITS=n><,MARK=YES>
  2298.  
  2299.  
  2300.  
  2301.      to-field             relexpri or (preg)
  2302.  
  2303.          The address of the field to  contain  the  edited  source
  2304.          digits.  It must be an even number of bytes in length.
  2305.  
  2306.  
  2307.      from-field           relexpri or (preg)
  2308.  
  2309.          The address of the field containing the source digits  to
  2310.          be  EDITed  to  the to-field.  It must contain sufficient
  2311.          digits to satisfy the implicit (or  explicit)  length  of
  2312.          the to-field.
  2313.  
  2314.  
  2315.      to-length            cexpr4
  2316.  
  2317.          An explicit specification of the length of the  to-field.
  2318.          It  must  be  specified  if  the to-field is presented in
  2319.          base-displacement form.  If specified  it  will  override
  2320.          the implicit length for the to-field.
  2321.  
  2322.  
  2323.      from-length          cexpr4
  2324.  
  2325.          An  explicit  specification  of   the   length   of   the
  2326.          from-field.   It  must  be specified if the from-field is
  2327.          specified in base-displacement  form.   If  specified  it
  2328.          overrides the implicit length for the from-field.
  2329.  
  2330.      CALC=NO
  2331.  
  2332.          Indicates that the addresses specified  are  to  be  used
  2333.          exactly  as  is  for  the  from-  and  to-fields  in  the
  2334.          generated  ED  or EDMK instruction.  If not specified the
  2335.          macro will calculate the offset in the from-field to  use
  2336.          in the ED or EDMK instruction.
  2337. 1                           - 48 -
  2338.  
  2339.  
  2340.      DIGITS=n             cexpr4
  2341.  
  2342.          Specifies the minimum number of significant digits to  be
  2343.          produced.
  2344.  
  2345.      MARK=YES
  2346.  
  2347.          Indicates that an EDMK instruction should  be  generated.
  2348.          Register  1  will  then  point  to  the first significant
  2349.          character in the edited field.  If  the  field  does  not
  2350.          produce a significatn digit, register 1 will point to the
  2351.          low order character of the edited field.
  2352. 1                           - 49 -
  2353.  
  2354.  
  2355.                 EXI and EXORG - Execute immediate
  2356. +               _________________________________
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  EXI permits the instruction to be executed by an  EX  instruction
  2362.  to be coded at the same place in the source program.
  2363.  
  2364.  
  2365.  
  2366.  <symbol> EXI ex-reg,opcode,operand1,operand2,<DECR=YES>,
  2367.               <INCR=YES>
  2368.  
  2369.  
  2370.  
  2371.      ex-reg               reg
  2372.  
  2373.          The register to be used as the first operand  of  the  EX
  2374.          instruction.
  2375.  
  2376.  
  2377.      opcode               valid assembler opcode
  2378.  
  2379.          Operation code of the instruction to be executed.
  2380.  
  2381.  
  2382.      operand1
  2383.  
  2384.          The first operand of the instruction to be executed.
  2385.  
  2386.  
  2387.      operand2
  2388.  
  2389.          The second operand of the instruction to be
  2390.          executed.
  2391.  
  2392.  
  2393.      DECR=YES
  2394.  
  2395.          Specifies that the register is to be decremented  by  one
  2396.          before the EX instruction.
  2397.  
  2398.      INCR=YES
  2399.  
  2400.          Specifies that the register is to be incremented  by  one
  2401.          after  the  EX  instruction.   The  condition code is not
  2402.          affected.
  2403. 1                           - 50 -
  2404.  
  2405.  
  2406.  
  2407.  NOTES:
  2408.  
  2409.      1.  The opcode to be executed may not be a macro unless it is
  2410.          one of the following:  MCLC, MMVC, MNC,  MOC,  MTC,  MTR,
  2411.          MTRT,  MXC,  MZC.   When  one of these is used, N=1 and a
  2412.          length of zero are forced.
  2413.  
  2414.      2.  An EXORG must be included  within  addressable  range  in
  2415.          order to assemble the instructions to be executed.
  2416.  
  2417.      3.  If an instruction  occurs  more  than  once,  EXORG  will
  2418.          assemble only one copy.
  2419. 1                           - 51 -
  2420.  
  2421.  
  2422.  
  2423.                     Extended Length Facilities
  2424. +                   __________________________
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  These macros generate inline  code  to  provide  extended  length
  2430.  facilities.  These macros provide an optional N=count  operand to
  2431.  allow  the  writer to specify the exact number of instructions to
  2432.  be generated.  If   N=count   is  not  present,  and  the  length
  2433.  operand  is  an  unsigned  integer or a SETA symbol, then as many
  2434.  instructions as are required for the  specified  length  will  be
  2435.  generated.  If  N=count  is not present and the length operand is
  2436.  not  an  unsigned integer or SETA symbol, then one instruction is
  2437.  generated.
  2438.  
  2439.  
  2440.  
  2441.                 MCLC, MMVC, MNC, MOC, and MXC
  2442.  
  2443.  
  2444.  
  2445.  <symbol> opcd  oper1,oper2,length<,N=count><,ZERO=NULL>
  2446.  
  2447.  
  2448.  
  2449.      opcd                 MCLC, MMVC, MNC, MOC, or MXC
  2450.  
  2451.  
  2452.      oper1                relexpri or (preg)
  2453.  
  2454.          The address of the 1st operand.
  2455.  
  2456.  
  2457.      oper2                relexpri or (preg)
  2458.  
  2459.          The address of the 2nd operand.
  2460.  
  2461.  
  2462.      length
  2463.  
  2464.          The number of bytes affected.
  2465.  
  2466.  
  2467.      N=count              unsigned integer or SETA symbol
  2468.  
  2469.          The number of instructions to be generated.
  2470.  
  2471.      ZERO=NULL
  2472.  
  2473.          Specifies that no instructions are to be generated if len
  2474.          is  zero.   Normally  a  single  instruction   would   be
  2475.          generated.
  2476. 1                           - 52 -
  2477.  
  2478.  
  2479.                         MFC - Fill a field
  2480. +                       __________________
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  The MFC macro will fill a field with the specified charater.
  2486.  
  2487.  
  2488.  
  2489.  <symbol> MFC   loc,len<,FILL=char><,N=count><,ZERO=NULL>
  2490.  
  2491.  
  2492.  
  2493.      loc                 relexpri or (preg)
  2494.  
  2495.          The address of the field to be filled.
  2496.  
  2497.  
  2498.      len
  2499.  
  2500.          The length of the field to be filled.
  2501.  
  2502.  
  2503.      FILL=char            cexpr8
  2504.  
  2505.          The character to fill the field with.  Default is
  2506.          blank (C' ')
  2507.  
  2508.  
  2509.      N=count              unsigned integer or SETA symbol
  2510.  
  2511.          The number of instructions to be generated.
  2512.  
  2513.      ZERO=NULL
  2514.  
  2515.          Specifies that no instructions are to be generated if len
  2516.          is zero.
  2517. 1                           - 53 -
  2518.  
  2519.  
  2520.                         MTC - Test a field
  2521. +                       __________________
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  MTC tests a field for all zero (or other specified value) bytes.
  2527.  
  2528.  
  2529.  
  2530.  <symbol> MTC loc,len<,FILL=char><,N=count><,ZERO=NULL>
  2531.  
  2532.  
  2533.  
  2534.      loc                  relexpri or (preg)
  2535.  
  2536.          Address of field to be tested.
  2537.  
  2538.  
  2539.      len
  2540.  
  2541.          Length of field.
  2542.  
  2543.  
  2544.      FILL=char            cexpr8
  2545.  
  2546.          The character to be tested for.  Default is 0.
  2547.  
  2548.  
  2549.      N=count              unsigned integer or SETA symbol
  2550.  
  2551.          Number of instructions to be generated.
  2552.  
  2553.      ZERO=NULL
  2554.  
  2555.          Specifies that no test is to be performed if len is zero.
  2556.          The condition code will be set to zero in that case.
  2557.  
  2558.  
  2559.  
  2560.  NOTE:
  2561.  
  2562.      If FILL is not specified, OC instructions  are  generated  to
  2563.      test  the  field  for  zeros.   If  FILL  is  specified,  CLC
  2564.      instructions are generated, even if FILL=0 is specified.
  2565. 1                           - 54 -
  2566.  
  2567.  
  2568.                      MTR - Translate a field
  2569. +                    _______________________
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  MTR translates a field using a specified translate table.
  2575.  
  2576.  
  2577.  
  2578.  <symbol> MTR loc,table,len<,N=count><,ZERO=NULL>
  2579.  
  2580.  
  2581.  
  2582.      loc                  relexpri or (preg)
  2583.  
  2584.          Location of field to be translated.
  2585.  
  2586.  
  2587.      table                relexpri or (preg)
  2588.  
  2589.          Location of translate table.
  2590.  
  2591.  
  2592.      len
  2593.  
  2594.          Length of field.
  2595.  
  2596.  
  2597.      N=count              unsigned integer or SETA symbol
  2598.  
  2599.          Number of TR instructions to be generated.
  2600.  
  2601.      ZERO=NULL
  2602.  
  2603.          Specifies that no instructions are to be generated if len
  2604.          is zero.
  2605. 1                           - 55 -
  2606.  
  2607.  
  2608.                 MTRT - Translate and test a field
  2609. +               _________________________________
  2610.  
  2611.  
  2612.  
  2613.  
  2614.  MTRT performs a translate-and-test on a field.
  2615.  
  2616.  
  2617.  
  2618.  <symbol> MTRT loc,table,len<,N=count><,ZERO=NULL>
  2619.  
  2620.  
  2621.  
  2622.      loc                  relexpri or (preg)
  2623.  
  2624.          Location of field.
  2625.  
  2626.  
  2627.      table                relexpri or (preg)
  2628.  
  2629.          Location of translate-and-test table.
  2630.  
  2631.  
  2632.      len
  2633.  
  2634.          Length of field.
  2635.  
  2636.  
  2637.      N=count              unsigned integer or SETA symbol
  2638.  
  2639.          Number of instructions to be generated.
  2640.  
  2641.      ZERO=NULL
  2642.  
  2643.          Specifies that no translate and test is to  be  performed
  2644.          if  len  is  zero.   The condition code is set to zero in
  2645.          that case.
  2646. 1                           - 56 -
  2647.  
  2648.                        MZC - Clear a field
  2649. +                      ___________________
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  The MZC macro will clear a field to all X'00's.
  2655.  
  2656.  
  2657.  
  2658.  <symbol> MZC   loc,len<,N=count><,ZERO=NULL>
  2659.  
  2660.  
  2661.  
  2662.      loc                 relexpri or (preg)
  2663.  
  2664.          The address of the field to be zeroed.
  2665.  
  2666.  
  2667.      len
  2668.  
  2669.          The length of the field to be zeroed.
  2670.  
  2671.  
  2672.      N=count              unsigned integer or SETA symbol.
  2673.  
  2674.          The number of instructions to be generated.
  2675.  
  2676.      ZERO=NULL
  2677.  
  2678.          Specifies that no instructions are to be generated if len
  2679.          is zero.
  2680. 1                           - 57 -
  2681.  
  2682.                         DF - Define flags
  2683. +                       _________________
  2684.  
  2685.  
  2686.  DF is used to define one or more flag bits and optionally  assign
  2687.  initial values.
  2688.  
  2689.  <symbol> DF flag-name,...<INIT=(flag-name,...)>
  2690.  
  2691.  
  2692.      flag-name            symbol
  2693.  
  2694.         The name of the flag to be defined.  Any number  of  flags
  2695.         may be specified.  If more than 8 are specified, more than
  2696.         1 byte will be reserved.
  2697.  
  2698.      INIT=(flag-name,...) list of symbols
  2699.  
  2700.         Specifies flags which are to be initially 1 (on).
  2701. 1                           - 58 -
  2702.  
  2703.                           SF - Set flags
  2704. +                         ______________
  2705.  
  2706.  
  2707.  SF is used to turn on one or more flags defined with DF.
  2708.  
  2709.  <symbol> SF flag-name,...
  2710.  
  2711.  
  2712.      flag-name            symbol
  2713.  
  2714.         The name of a flag to be turned on (set to 1).   Up  to  8
  2715.         flags may be specified; all must reside in the same byte.
  2716. 1                           - 59 -
  2717.  
  2718.                          TF - Test flags
  2719. +                        _______________
  2720.  
  2721.  
  2722.  TF is used to test one or more flags defined with DF.
  2723.  
  2724.  <symbol> TF flag-name,...
  2725.  
  2726.  
  2727.      flag-name            symbol
  2728.  
  2729.         The name of a flag to be tested.  Up to  8  flags  may  be
  2730.         specified; all must reside in the same byte.
  2731.  
  2732.  
  2733.  RETURNS:
  2734.  
  2735.      CC =  Z  all tested flags off
  2736.            O  all tested flags on
  2737.            M  some on, some off
  2738. 1                           - 60 -
  2739.  
  2740.                          ZF - Zero flags
  2741. +                        _______________
  2742.  
  2743.  
  2744.  ZF is used to turn off one or more flags defined with DF.
  2745.  
  2746.  <symbol> ZF flag-name,...
  2747.  
  2748.  
  2749.      flag-name            symbol
  2750.  
  2751.         The name of a flag to be cleared.  Up to 8  flags  may  be
  2752.         specified; all must reside in the same byte.
  2753. 1                           - 61 -
  2754.  
  2755.           OSCALL - Pass control to an OS-type subroutine
  2756. +         ______________________________________________
  2757.  
  2758.  
  2759.  The OSCALL macro will pass  control  to  a  specified  subroutine
  2760.  using OS calling conventions.
  2761.  
  2762.  <symbol> OSCALL routine<,A><,R1=parm><,R0=parm>
  2763.                  <,R15=parm>
  2764.  
  2765.  
  2766.      routine              relexpra or vsymbol or (preg)
  2767.  
  2768.         The address of the subroutine to be called.
  2769.  
  2770.      A
  2771.  
  2772.         The address  specified  in  the  routine  parameter  is  a
  2773.         relexpra.
  2774.  
  2775.      R1=parm             addrla
  2776.  
  2777.         A parameter to be passed in register 1.
  2778.  
  2779.      R0=parm             addrla
  2780.  
  2781.         A parameter to be passed in register 0.
  2782.  
  2783.      R15=parm             addrla
  2784.  
  2785.         A parameter to be passed in register 15.
  2786.  
  2787.  
  2788.  NOTE:
  2789.  
  2790.     Register 15 is loaded with  the  entry  point  address  unless
  2791.     R15=parm is specified
  2792. 1                           - 62 -
  2793.  
  2794.                  OSENTER - Generate OS entry code
  2795. +                ________________________________
  2796.  
  2797.  
  2798.  The OSENTER macro will generate proper OS entry linkage code.
  2799.  
  2800.  <symbol> OSENTER <(reg1,reg2),...><,ENTRY=NO>
  2801.                   <,BASE=NO><,SAVE=area><,PACK=YES>
  2802.                   <,FORWARD=YES><,ID=identification>
  2803.  
  2804.  
  2805.      reg1,reg2            regs
  2806.  
  2807.         Registers  to  be  saved  in  STM  form.   Any  number  of
  2808.         parenthesized pairs may be specified.  If reg2 is the same
  2809.         as reg1, then reg2 and the parentheses may be omitted.
  2810.  
  2811.      ENTRY=NO
  2812.  
  2813.         Requests that an ENTRY point not be generated.
  2814.  
  2815.      BASE=NO
  2816.  
  2817.         Requests that a base register not be established.
  2818.  
  2819.      SAVE=area            relexpri
  2820.  
  2821.         The address of the users register save area.
  2822.  
  2823.      PACK=YES
  2824.  
  2825.         Registers are to be stored packed at 12  bytes  after  the
  2826.         start of the save area.
  2827.  
  2828.      FORWARD=YES
  2829.  
  2830.         Specifies that the forward linking of save areas is to  be
  2831.         performed.  Normally only backward linking is done.
  2832.  
  2833.      ID=identification    symbol or string or *
  2834.  
  2835.         Specifies an identifying character string to be  assembled
  2836.         4 bytes after the entry point.  * indicates that the entry
  2837.         name  (or  the CSECT name if there is no entry name) is to
  2838.         be used.
  2839.  
  2840.  
  2841.  NOTES:
  2842.  
  2843.     1.  The base register is BASER (see OSSETUP).
  2844.  
  2845.     2.  If SAVE=area is not specified, then no new save area  will
  2846.         be established.
  2847.  
  2848.     3.  The generated code does not depend on  register  15  being
  2849.         loaded    with    the    entry    point   address   unless
  2850.         ID=identification is specified.
  2851. 1                           - 63 -
  2852.  
  2853.                  OSEXIT - Generate OS return code
  2854. +                ________________________________
  2855.  
  2856.  
  2857.  The OSEXIT macro will generate proper OS exit linkage code.
  2858.  
  2859.  <symbol> OSEXIT <(reg1,reg2)...>,<,SAVE=area><,LTR=reg>
  2860.                  <,PACK=YES><,RC=value><,FLAG=YES>
  2861.  
  2862.  
  2863.      reg1,reg2            registers
  2864.  
  2865.         Registers to be restored in  LM  format.   Any  number  of
  2866.         parenthesized  pairs  may  be specified.  When reg2 is the
  2867.         same as reg1, reg2 and the parentheses may be omitted.
  2868.  
  2869.      SAVE=area            relexpri
  2870.  
  2871.         The address of the program's register save area.
  2872.  
  2873.      LTR=reg              reg
  2874.  
  2875.         Requests that an LTR  reg,reg  be  performed  to  set  the
  2876.         condition code upon return.
  2877.  
  2878.      PACK=YES
  2879.  
  2880.         Must  be  specified  if  PACK=YES   was   coded   on   the
  2881.         corresponding OSENTER macro.
  2882.  
  2883.      RC=value             valuela
  2884.  
  2885.         Specifies a return code to be loaded into register 15.
  2886.  
  2887.      FLAG=YES
  2888.  
  2889.         Specifies that X'FF' is to be placed into  the  high-order
  2890.         byte  of  word  4 of the save area after the registers are
  2891.         restored.
  2892.  
  2893.  
  2894.  NOTE:
  2895.  
  2896.      If  SAVE=area  is  not  specified,  then  the  registers  are
  2897.      restored from the area pointed to by register 13.  Note  that
  2898.      SAVE=0(SAVER) and SAVE=0(13) are perfectly acceptable.
  2899. 1                           - 64 -
  2900.  
  2901.              OSSETUP - Set up OS linkage environment
  2902. +            _______________________________________
  2903.  
  2904.  
  2905.  The OSSETUP macro, used once at the start of the  program  (after
  2906.  macro definitions, but before any code or EQUs), defines register
  2907.  names and optionally defines certain OS control blocks.
  2908.  
  2909.  symbol OSSETUP <REGS=option><,DCB=YES>
  2910.                 <,R15=name><,R14=name><,R13=name><,BASER=name>
  2911.                 <,R1=name><,R0=name>
  2912.  
  2913.  
  2914.      symbol                1-8 characters (required)
  2915.  
  2916.          CSECT name for the module.
  2917.  
  2918.      REGS=option           PLI or NO
  2919.  
  2920.          PLI is used to request PL/I compatible register
  2921.          definitions.  NO specifies that register definitions
  2922.          should not be included.
  2923.  
  2924.      DCB=YES
  2925.  
  2926.          Define OS DCB DSECT.
  2927.  
  2928.      R15=name               symbol
  2929.  
  2930.         Name to be used by OSENTER, OSEXIT and OSCALL to refer  to
  2931.         register 15.  Default is RCR.
  2932.  
  2933.      R14=name               symbol
  2934.  
  2935.         Name to be used by OSENTER, OSEXIT and OSCALL to refer  to
  2936.         register 14.  Default is RTNR.
  2937.  
  2938.      R13=name               symbol
  2939.  
  2940.         Name to be used by OSENTER, OSEXIT and OSCALL to refer  to
  2941.         register 13.  Default is SAVER.
  2942.  
  2943.      BASER=name             symbol
  2944.  
  2945.         Register to be loaded  by  OSENTER  as  a  base  register.
  2946.         Default is BASER.
  2947.  
  2948.      R1=name
  2949.  
  2950.         Name to be used by OSENTER, OSEXIT and OSCALL to refer  to
  2951.         register 1.  Default is VR1.
  2952.  
  2953.      R0=name
  2954.  
  2955.         Name to be used by OSENTER, OSEXIT and OSCALL to refer  to
  2956.         register 0.  Default is VR0.
  2957. 1                           - 65 -
  2958.  
  2959.  
  2960.  
  2961.  NOTE:
  2962.  
  2963.      Register definitions are as follows:
  2964.  
  2965.                                 Default         PLI
  2966.      Register   Absolute name   Symbolic name   Symbolic name
  2967.  
  2968.         0          R0               VR0           VR0
  2969.         1          R1               VR1           VR1
  2970.         2          R2               XRA, LOWR     XRA,HIGHR
  2971.         3          R3               XRB           XRB
  2972.         4          R4               XRC           XRC
  2973.         5          R5               XRD           XRD
  2974.         6          R6               XRE           XRE
  2975.         7          R7               XRF           XRF
  2976.         8          R8               XRG           XRG
  2977.         9          R9               XRH           XRH
  2978.        10          R10              XRI           XRI
  2979.        11          R11              XRJ           BASER,HIGHR
  2980.        12          R12              BASER, HIGHR  GCBR
  2981.        13          R13              SAVER         SAVER
  2982.        14          R14              RTNR          RTNR
  2983.        15          R15              RCR           RCR
  2984.  
  2985.      LOWR and HIGHR are for  use  with  OSENTER  and  OSEXIT  when
  2986.      specifying registers to be saved and restored.
  2987. 1                           - 66 -
  2988.  
  2989.                 OPENP - Check for successful open
  2990. +               _________________________________
  2991.  
  2992.  
  2993.  The OPENP macro will check DCBOFLGS to see if the DCB was  opened
  2994.  successfully.
  2995.  
  2996.  <symbol> OPENP dcb-addr
  2997.  
  2998.  
  2999.      dcb-addr             relexpri
  3000.  
  3001.          The address of the DCB to be checked.
  3002.  
  3003.  
  3004.  RETURNS:
  3005.  
  3006.      If the DCB was opened successfully, the condition  code  will
  3007.      be set to a non-zero value.
  3008.  
  3009.  
  3010.  NOTE:
  3011.  
  3012.      The DCBD macro must be included in the assembly.
  3013. 1                           - 67 -
  3014.  
  3015.          CBDELINK - Remove control block from linked list
  3016. +        ________________________________________________
  3017.  
  3018.  
  3019.  CBDELINK is used to remove a control block from a linked list  of
  3020.  similar control blocks.
  3021.  
  3022.  <symbol> CBDELINK prev-reg,del-reg,work-reg,HEAD=loc
  3023.                    <,TAIL=loc>,NEXT=dsect-loc
  3024.                    <,BACK=dsect-loc>
  3025.                    <,CB=dsect-name><,ZOT=YES>
  3026.  
  3027.  
  3028.      prev-reg             preg
  3029.  
  3030.         Register must contain a pointer to the control block which
  3031.         immediately  preceeds  the  one  to  be  removed.   Should
  3032.         contain zero if removing from the beginning of the list.
  3033.  
  3034.      del-reg              preg
  3035.  
  3036.         Register must contain a pointer to the control block to be
  3037.         removed from the list.
  3038.  
  3039.      work-reg             preg
  3040.  
  3041.          A work register.
  3042.  
  3043.      HEAD=loc             relexpri
  3044.  
  3045.         Location of a word which contains a pointer to  the  first
  3046.         element  in  the  list.   Contains  zero  when the list is
  3047.         empty.
  3048.  
  3049.      TAIL=loc             relexpri
  3050.  
  3051.         Location of a word which contains a pointer  to  the  last
  3052.         element  in  the  list.   Contains  zero  when the list is
  3053.         empty.
  3054.  
  3055.      NEXT=dsect-loc       symbol
  3056.  
  3057.         Name of the word defined in a DSECT for the control  block
  3058.         which  points  to  the  next  control  block  in the list.
  3059.         Contains zero for the last element in the list.
  3060.  
  3061.      BACK=dsect-loc       symbol
  3062.  
  3063.         If present, indicates a doubly-linked  list  (forward  and
  3064.         backward  pointers).   Name of the word defined in a DSECT
  3065.         for the control  block  which  points  to  the  preceeding
  3066.         control  block  in  the list.  Contains zero for the first
  3067.         element in the list.
  3068. 1                           - 68 -
  3069.  
  3070.  
  3071.  
  3072.      CB=dsect-id          symbol
  3073.  
  3074.         The name of the DSECT for the control block.  Omit if  the
  3075.         control block is defined with EQUs instead of a DSECT.
  3076.  
  3077.      ZOT=YES
  3078.  
  3079.         Indicates that the NEXT and BACK  fields  in  the  control
  3080.         block being removed should be set to zero.
  3081. 1                           - 69 -
  3082.  
  3083.      CBDLINKH - Remove control block from head of linked list
  3084. +    ________________________________________________________
  3085.  
  3086.  
  3087.  CBDLINKH is used to remove the first control block from a  linked
  3088.  list of similar control blocks.
  3089.  
  3090.  <symbol> CBDLINKH del-reg,work-reg,HEAD=loc<,TAIL=loc>
  3091.                    NEXT=dsect-loc<,BACK=dsect-loc>
  3092.                    <,CB=dsect-name><,ZOT=YES>
  3093.  
  3094.  
  3095.      del-reg              preg
  3096.  
  3097.         Register must contain a pointer to the first control block
  3098.         in the linked list.
  3099.  
  3100.      work-reg             preg
  3101.  
  3102.          A work register.
  3103.  
  3104.      HEAD=loc             relexpri
  3105.  
  3106.         Location of a word which contains a pointer to  the  first
  3107.         element  in  the  list.   Contains  zero  when the list is
  3108.         empty.
  3109.  
  3110.      TAIL=loc             relexpri
  3111.  
  3112.         Location of a word which contains a pointer  to  the  last
  3113.         element  in  the  list.   Contains  zero  when the list is
  3114.         empty.
  3115.  
  3116.      NEXT=dsect-loc       symbol
  3117.  
  3118.         Name of the word defined in a DSECT for the control  block
  3119.         which  points  to  the  next  control  block  in the list.
  3120.         Contains zero for the last element in the list.
  3121.  
  3122.      BACK=dsect-loc       symbol
  3123.  
  3124.         If present, indicates a doubly-linked  list  (forward  and
  3125.         backward  pointers).   Name of the word defined in a DSECT
  3126.         for the control  block  which  points  to  the  preceeding
  3127.         control  block  in  the list.  Contains zero for the first
  3128.         element in the list.
  3129.  
  3130.      CB=dsect-id          symbol
  3131.  
  3132.         The name of the DSECT for the control block.  Omit if  the
  3133.         control block is defined with EQUs instead of a DSECT.
  3134.  
  3135.      ZOT=YES
  3136.  
  3137.         Indicates that the NEXT and BACK  fields  in  the  control
  3138.         block being removed should be set to zero.
  3139. 1                           - 70 -
  3140.  
  3141.     CBDLINKT - Remove control block from tail of a linked list
  3142. +   __________________________________________________________
  3143.  
  3144.  
  3145.  CBDLINKT is used to remove the last control block from  a  linked
  3146.  list of similar control blocks.
  3147.  
  3148.  <symbol> CBDLINKT prev-reg<,del-reg>,work-reg,head=loc
  3149.                    <,TAIL=loc>,NEXT=dsect-loc
  3150.                    <,BACK=dsect-loc><,CB=dsect-name>
  3151.                    <,ZOT=YES>
  3152.  
  3153.  
  3154.      prev-reg             preg
  3155.  
  3156.         Register must contain a pointer to the control block which
  3157.         immediately  preceeds  the  one  to  be  removed.   Should
  3158.         contain zero if removing from the beginning of the list.
  3159.  
  3160.      del-reg              preg
  3161.  
  3162.         Register must contain a pointer to the control block to be
  3163.         removed from  the  list.   Required  only  if  ZOT=YES  is
  3164.         specified.
  3165.  
  3166.      work-reg             preg
  3167.  
  3168.          A work register.
  3169.  
  3170.      HEAD=loc             relexpri
  3171.  
  3172.         Location of a word which contains a pointer to  the  first
  3173.         element  in  the  list.   Contains  zero  when the list is
  3174.         empty.
  3175.  
  3176.      TAIL=loc             relexpri
  3177.  
  3178.         Location of a word which contains a pointer  to  the  last
  3179.         element  in  the  list.   Contains  zero  when the list is
  3180.         empty.
  3181.  
  3182.      NEXT=dsect-loc       symbol
  3183.  
  3184.         Name of the word defined in a DSECT for the control  block
  3185.         which  points  to  the  next  control  block  in the list.
  3186.         Contains zero for the last element in the list.
  3187.  
  3188.      BACK=dsect-loc       symbol
  3189.  
  3190.         If present, indicates a doubly-linked  list  (forward  and
  3191.         backward  pointers).   Name of the word defined in a DSECT
  3192.         for the control  block  which  points  to  the  preceeding
  3193.         control  block  in  the list.  Contains zero for the first
  3194.         element in the list.
  3195. 1                           - 71 -
  3196.  
  3197.  
  3198.  
  3199.      CB=dsect-id          symbol
  3200.  
  3201.         The name of the DSECT for the control block.  Omit if  the
  3202.         control block is defined with EQUs instead of a DSECT.
  3203.  
  3204.      ZOT=YES
  3205.  
  3206.         Indicates that the NEXT and BACK  fields  in  the  control
  3207.         block being removed should be set to zero.
  3208. 1                           - 72 -
  3209.  
  3210.             CBLINK - Add control block to linked list
  3211. +           _________________________________________
  3212.  
  3213.  CBLINK is used to add a control block anywhere in a  linked  list
  3214.  of similar control blocks.
  3215.  
  3216.  <symbol> CBLINK after-reg,new-reg,work-reg,HEAD=loc
  3217.                  <,TAIL=loc>,NEXT=dsect-loc,
  3218.                  <,BACK=dsect-loc><,CB=dsect-id>
  3219.  
  3220.  
  3221.      after-reg            preg
  3222.  
  3223.         Register containing a pointer to the control  block  after
  3224.         which  the  new  control  block  is  to  be added.  Should
  3225.         contain zero if the new control block is to  be  first  in
  3226.         the list.
  3227.  
  3228.      new-reg              preg
  3229.  
  3230.         Register must contain a pointer to the control block to be
  3231.         added.
  3232.  
  3233.      work-reg             preg
  3234.  
  3235.          A work register.
  3236.  
  3237.      HEAD=loc             relexpri
  3238.  
  3239.         Location of a word which contains a pointer to  the  first
  3240.         element  in  the  list.   Contains  zero  when the list is
  3241.         empty.
  3242.  
  3243.      TAIL=loc             relexpri
  3244.  
  3245.         Location of a word which contains a pointer  to  the  last
  3246.         element  in  the  list.   Contains  zero  when the list is
  3247.         empty.
  3248.  
  3249.      NEXT=dsect-loc       symbol
  3250.  
  3251.         Name of the word defined in a DSECT for the control  block
  3252.         which  points  to  the  next  control  block  in the list.
  3253.         Contains zero for the last element in the list.
  3254.  
  3255.      BACK=dsect-loc       symbol
  3256.  
  3257.         If present, indicates a doubly-linked  list  (forward  and
  3258.         backward  pointers).   Name of the word defined in a DSECT
  3259.         for the control  block  which  points  to  the  preceeding
  3260.         control  block  in  the list.  Contains zero for the first
  3261.         element in the list.
  3262.  
  3263.      CB=dsect-id          symbol
  3264.  
  3265.         The name of the DSECT for the control block.  Omit if  the
  3266.         control block is defined with EQUs instead of a DSECT.
  3267. 1                           - 73 -
  3268.  
  3269.     CBLINKH - Add a control block at the head of a linked list
  3270. +   __________________________________________________________
  3271.  
  3272.  
  3273.  CBLINKH is used to add a control block at the start of  a  linked
  3274.  list of similar control blocks.
  3275.  
  3276.  <symbol> CBLINKH new-reg,work-reg,HEAD=loc<,TAIL=loc>,
  3277.                   NEXT=dsect-loc<,BACK=dsect-loc>
  3278.                   <,CB=dsect-id>
  3279.  
  3280.  
  3281.      new-reg              preg
  3282.  
  3283.         Register must contain a pointer to the control block to be
  3284.         added.
  3285.  
  3286.      work-reg             preg
  3287.  
  3288.          A work register.
  3289.  
  3290.      HEAD=loc             relexpri
  3291.  
  3292.         Location of a word which contains a pointer to  the  first
  3293.         element  in  the  list.   Contains  zero  when the list is
  3294.         empty.
  3295.  
  3296.      TAIL=loc             relexpri
  3297.  
  3298.         Location of a word which contains a pointer  to  the  last
  3299.         element  in  the  list.   Contains  zero  when the list is
  3300.         empty.
  3301.  
  3302.      NEXT=dsect-loc       symbol
  3303.  
  3304.         Name of the word defined in a DSECT for the control  block
  3305.         which  points to the next control block which in the list.
  3306.         Contains zero for the last element in the list.
  3307.  
  3308.      BACK=dsect-loc       symbol
  3309.  
  3310.         If present, indicates a doubly-linked  list  (forward  and
  3311.         backward  pointers).   Name of the word defined in a DSECT
  3312.         for the control  block  which  points  to  the  preceeding
  3313.         control  block  in  the list.  Contains zero for the first
  3314.         element in the list.
  3315.  
  3316.      CB=dsect-id          symbol
  3317.  
  3318.         The name of the DSECT for the control block.  Omit if  the
  3319.         control block is defined with EQUs instead of a DSECT.
  3320. 1                           - 74 -
  3321.  
  3322.      CBLINKT - Add control block at the tail of a linked list
  3323. +    ________________________________________________________
  3324.  
  3325.  
  3326.  CBLINKT is used to add a control block at the  end  of  a  linked
  3327.  list of similar control blocks.
  3328.  
  3329.  <symbol> CBLINKT new-reg,work-reg,HEAD=loc,TAIL=loc,
  3330.                   NEXT=dsect-loc<,BACK=dsect-loc>
  3331.                   <,CB=dsect-id>
  3332.  
  3333.  
  3334.      new-reg              preg
  3335.  
  3336.         Register must contain a pointer to the control block to be
  3337.         added.
  3338.  
  3339.      work-reg             preg
  3340.  
  3341.          A work register.
  3342.  
  3343.      HEAD=loc             relexpri
  3344.  
  3345.         Location of a word which contains a pointer to  the  first
  3346.         element  in  the  list.   Contains  zero  when the list is
  3347.         empty.
  3348.  
  3349.      TAIL=loc             relexpri
  3350.  
  3351.         Location of a word which contains a pointer  to  the  last
  3352.         element in the list Contains zero when the list is empty.
  3353.  
  3354.      NEXT=dsect-loc       symbol
  3355.  
  3356.         Name of the word defined in a DSECT for the control  block
  3357.         which  points  to  the  next  control  block  in the list.
  3358.         Contains zero for the last element in the list.
  3359.  
  3360.  
  3361.      BACK=dsect-loc       symbol
  3362.  
  3363.         If present, indicates a doubly-linked  list  (forward  and
  3364.         backward  pointers).   Name of the word defined in a DSECT
  3365.         for the control  block  which  points  to  the  preceeding
  3366.         control  block  in  the list.  Contains zero for the first
  3367.         element in the list.
  3368.  
  3369.      CB=dsect-id          symbol
  3370.  
  3371.         The name of the DSECT for the control block.  Omit if  the
  3372.         control block is defined with EQUs instead of a DSECT.
  3373. 1                           - 75 -
  3374.  
  3375.                        IX. ALP CODING HINTS
  3376.  
  3377.  
  3378.  1.  Use indentation to  indicate  the  nesting  level.   The  ALP
  3379.      listing  shows  the current nesting level to the left of each
  3380.      input line.  It is increased by BEGIN, <, CASE,  SELECT,  ASM
  3381.      CASE, ASM SELECT and MACRO and is reduced by END, >, ENDCASE,
  3382.      ENDSEL  and  MEND.   With  WYLBUR,  tabs can be set every few
  3383.      positions (say 3) and each line indented  by  the  number  of
  3384.      tabs equal to its nesting level.
  3385.  
  3386.  2.  Avoid using explicit branching or "GOTOs".  The  ALP  control
  3387.      structures show intent much more clearly.
  3388.  
  3389.  3.  Use the readability and environment macros  --  they make the
  3390.      intent of a program much clearer.
  3391.  
  3392.  4.  Use the assembler USING statement for "global" base registers
  3393.      and the ALP USE statement for "local" base registers.
  3394.  
  3395.  5.  Using symbolic register  names  makes  a  program  easier  to
  3396.      understand.   Name  registers  according  to  function.   The
  3397.      OSSETUP macro provides one possible set of names.
  3398.  
  3399.  6.  Never use two names for the same register in a single section
  3400.      of code.
  3401.  
  3402.  7.  Always use RGOTO instead of BR and GOTO instead of B (if  you
  3403.      must use explicit branching).
  3404. 1                           - 76 -
  3405.  
  3406.                        X.  SAMPLE PROGRAM
  3407.  
  3408.  
  3409.  The following problem is taken from an actual class for beginning
  3410.  assembly language programmers.
  3411.  
  3412.  Given:  50 full words in  core,  each  containing  a  fixed-point
  3413.          (binary)  value.   The instructor will give you this data
  3414.          (in the form of DC statements) and describe the necessary
  3415.          JCL.  The first constant will be labeled NUMBERS.
  3416.  
  3417.  Task:   You are to determine the number  of  positive  constants,
  3418.          the  number  of negative constants and the number of zero
  3419.          constants, as well as the sum of each  of  these.   Store
  3420.          the  five computed values into core and output them via a
  3421.          core dump.  JFDUMP will be described in class.  Computing
  3422.          the sums will not result in overflow.
  3423. 1                           - 77 -
  3424.  
  3425.  Assembly Language Solution:
  3426.  
  3427.  //  EXEC  ASMHCOMP
  3428.  //COMP.SYSIN  DD  *
  3429.  PROB1    START 0
  3430.           SAVE  (14,12),,*
  3431.           BALR  10,0
  3432.           USING *,10
  3433.           LA    12,SAVE
  3434.           ST    13,4(12)
  3435.           ST    12,8(13)
  3436.           LR    13,12
  3437.           LA    2,50                MAX TIMES THRU
  3438.           SR    3,3                 ZERO INDEX REG
  3439.           SR    4,4                 # OF POS VALUES
  3440.           SR    5,5                 # OF NEG VALUES
  3441.           SR    6,6                 # OF ZERO VALUES
  3442.  TOP      L     7,NUMBERS(3)        GET VALUE
  3443.           LTR   7,7                 SET CC
  3444.           BP    POS                 POSITIVE
  3445.           BM    NEG                 NEGAGIVE
  3446.           LA    6,1(,6)             BUMP ZERO CTR
  3447.  GOBACK   LA    3,4(,3)             BUMP POINTER
  3448.           BCT   2,TOP               KEEP GOING
  3449.           STM   4,6,NUMS            SAVE RESULTS
  3450.           JFDUMP START=PROB1,END=NUMS+12
  3451.           L     13,4(13)            GO BACK
  3452.           RETURN (14,12),RC=0
  3453.  POS      LA    4,1(,4)             BUMP COUNTER
  3454.           L     8,POSNUM            GET  # OF POS
  3455.           AR    8,7                 ADD TO IT
  3456.           ST    8,POSNUM            SAVE IT BACK
  3457.           B     GOBACK              KEEP GOING
  3458.  NEG      LA    5,1(,5)             BUMP COUNTER
  3459.           L     8,NEGNUM            GET NUMBER
  3460.           AR    8,7                 ADD TO IT
  3461.           ST    8,NEGNUM            RESTORE IT
  3462.           B     GOBACK              KEEP GOING
  3463.  SAVE     DC    18F'0'              SAVE AREA
  3464.  NUMBERS DC 2F'8,1,1,0,2,-2,0,3,-3,0,4,-4,0,5,-5,0,6,-6,0,7,-7,0,8,-8,0'
  3465.  POSNUM   DC    F'0'                POSITIVE VALUE
  3466.  NEGNUM   DC    F'0'                NEGATIVE VALUE
  3467.  NUMS     DS    3F                  COUNTERS
  3468.           END
  3469.  //  EXEC  ASMHLKGO
  3470.  //GO.SYSUDUMP DD SYSOUT=A
  3471. 1                           - 78 -
  3472.  
  3473.  ALP Solution (without macros):
  3474.  
  3475.  //  EXEC  ALPHCOMP
  3476.  //COMP.SYSIN  DD  *
  3477.  PROB1: START 0;
  3478.  SAVE (14,12),,*;
  3479.  BALR 10,0; USING *,10;
  3480.  LA 12,SAVE; ST 13,4(,12); ST 12,8(,13);
  3481.  LR 13,12;
  3482.  
  3483.  LI 2,50;  % NUMBER OF TIMES THRU
  3484.  SR 3,3;  % CLEAR INDEX REGISTER
  3485.  SR 4,4;  % NUMBER OF POS VALUES
  3486.  SR 5,5;  % NUMBER OF NEG VALUES
  3487.  SR 6,6;  % NUMBER OF ZERO VALUES
  3488.  DO BEGIN
  3489.     L 7,NUMBERS(3);  % GET VALUE
  3490.     IF <LTR 7,7; CC Z> THEN LA 6,1(,6)  % ZERO VALUE
  3491.     ELSE IF <CC P> THEN BEGIN  % POSITIVE VALUE
  3492.        LA 4,1(,4);  % BUMP COUNTER
  3493.        L 8,POSNUM; AR 8,7; ST 8,POSNUM;  % COMPUTE SUM
  3494.        END
  3495.     ELSE BEGIN  % NEGATIVE VALUE
  3496.        LA 5,1(,5);  % BUMP COUNTER
  3497.        L 8,NEGNUM; AR 8,7; ST 8,NEGNUM;  % COMPUTE SUM
  3498.        END;
  3499.     LA 3,4(,3);  % BUMP POINTER
  3500.     END FOR 2;
  3501.  
  3502.  STM 4,6,NUMS;  % SAVE RESULTS
  3503.  JFDUMP START=PROB1,END=NUMS+12;
  3504.  L 13,4(,13);
  3505.  RETURN (14,12),RC=0;
  3506.  
  3507.  SAVE: DC 18F'0';  % SAVE AREA
  3508.  NUMBERS: DC 2F'8,1,1,0,2,-2,0,3,-3,0,4,-4,0,5,-5,0,6,-6,'_
  3509.                '0,7,-7,0,8,-8,0';
  3510.  POSNUM: DC F'0';  % POSITIVE VALUE
  3511.  NEGNUM: DC F'0';  % NEGATIVE VALUE
  3512.  NUMS:   DS 3F;
  3513.  END;
  3514.  //  EXEC  ALPHLKGO
  3515.  //GO.SYSUDUMP  DD  SYSOUT=A
  3516. 1                           - 79 -
  3517.  
  3518.  ALP Solution (with macros):
  3519.  
  3520.  //  EXEC  ALPHCOMP
  3521.  //COMP.SYSIN  DD  *
  3522.  PROB: TITLE 'CLASS PROBLEM 1';
  3523.  PROB1: OSSETUP;
  3524.  SUBTITLE 'MAIN PROGRAM';
  3525.  OSENTER (RTNR,HIGHR),SAVE=SAVE,FORWARD=YES;
  3526.  
  3527.  LI XRA,50;  % NUMBER OF TIMES THRU
  3528.  ZR XRB;  % CLEAR INDEX REGISTER
  3529.  ZR XRC;  % NUMBER OF POS VALUES
  3530.  ZR XRD;  % NUMBER OF NEG VALUES
  3531.  ZR XRE;  % NUMBER OF ZERO VALUES
  3532.  DO BEGIN
  3533.     L XRG,NUMBERS(XRB);  % GET NUMBER
  3534.     IF <RZ XRG> THEN AI XRE,1  % ZERO VALUE
  3535.     ELSE IF <CC P> THEN BEGIN  % POSITIVE VALUE
  3536.        AI XRC,1;  % BUMP COUNTER
  3537.        L XRH,POSNUM; AR XRH,XRG; ST XRH,POSNUM;  % COMPUTE SUM
  3538.        END
  3539.     ELSE BEGIN  % NEGATIVE VALUE
  3540.        AI XRD,1;  % BUMP COUNTER
  3541.        L XRH,NEGNUM; AR XRH,XRG; ST XRH,NEGNUM;  % COMPUTE SUM
  3542.        END;
  3543.     AI XRB,4;  % BUMP POINTER
  3544.     END FOR XRA;
  3545.  
  3546.  STM XRC,XRE,NUMS;  % SAVE RESULTS
  3547.  JFDUMP START=PROB1,END=NUMS+12;
  3548.  OSEXIT (RTNR,HIGHR),RC=0,SAVE=SAVE;
  3549.  
  3550.  SUBTITLE 'CONSTANTS AND WORK AREA';
  3551.  SAVE: DC 18F'0';  % SAVE AREA
  3552.  NUMBERS: DC 2F'8,1,1,0,2,-2,0,3,-3,0,4,-4,0,5,-5,0,6,-6,'_
  3553.                '0,7,-7,0,8,-8,0';
  3554.  POSNUM: DC F'0';  % POSITIVE VALUE
  3555.  NEGNUM: DC F'0';  % NEGATIVE VALUE
  3556.  NUMS:   DS 3F;
  3557.  END;
  3558.  //  EXEC  ALPHLKGO
  3559.  //GO.SYSUDUMP  DD  SYSOUT=A
  3560. 1                           - 80 -
  3561.  
  3562.                        XI. USING ALP AT NIH
  3563.  
  3564.  
  3565.  . The following procedures  are  available  and  conform  to  NIH
  3566.    conventions:
  3567.  
  3568.       ALP Procedure             Corresponding Assembler Procedure
  3569. +     _____________             _________________________________
  3570.  
  3571.  
  3572.         ALPHCOMP                          ASMHCOMP
  3573.         ALPHOBJ                           ASMHOBJ
  3574.         ALPHCOMF                          ASMHCOMP
  3575.         ALPHOBJF                          ASMHOBJ
  3576.         ALPHPRE                           None
  3577.         ALPHLKGO                          ASMHLKGO
  3578.         ALPHLDGO                          ASMHLDGO
  3579.         ALPHLKSM                          ASMHLKSM
  3580.         ALPHLKMM                          ASMHLKMM
  3581.         ALPHCALL                          ASMHCALL
  3582.         ALPHLOOK                          ASMHLOOK
  3583.  
  3584.    All symbolic parameters are the same.
  3585.  
  3586.  . Normally,  ALPHCOMP  and  ALPHOBJ produce only the ALP listing.
  3587.    However, if ASMLIST='' is specified on the EXEC statement,  the
  3588.    assembler listing will be produced as well.
  3589.  
  3590.  . ALPHCOMF and ALPHOBJF differ from ALPHCOMP and ALPHOBJ in  that
  3591.    the assembler listing is placed on microfiche.  Some additional
  3592.    symbolic parameters are provided to facilitate this:
  3593.  
  3594.       MFID=name                   Required.    Specifies   a   1-8
  3595.                                   character name  to  be  used  to
  3596.                                   insure  uniqueness of the DSNAME
  3597.                                   on the microfilm  tape.   Should
  3598.                                   begin with registered initials.
  3599.  
  3600.       MFNAME='dsname'             Optional.  Specifies the name of
  3601.                                   a  data  set  containing  PTFORM
  3602.                                   control   records.    A  default
  3603.                                   suitable for  most  applications
  3604.                                   is included.
  3605.  
  3606.       MFSTOR=unit                 Optional.  Specifies  unit  name
  3607.                                   for  the   PTFORM  control  data
  3608.                                   set.  Default is MFSTOR=FILE.
  3609.  
  3610.       MFDISK=volume               Optional.  Specifies the  volume
  3611.                                   on  which  the   PTFORM  control
  3612.                                   data set resides.
  3613. 1                           - 81 -
  3614.  
  3615.  . The procedure ALPHPRE may be used to perform ALP  preprocessing
  3616.    without  assembling the result.  Normally, only the ALP listing
  3617.    is produced.  However, if ASMLIST=''  is   specified   on   the
  3618.    EXEC  statement  the  generated assembly code will be listed as
  3619.    well.
  3620.  
  3621.  . Problems or questions concerning ALP should be forwarded to the
  3622.    PAL Unit, Computer  Center,  DCRT,  Building  12A,  Room  1017,
  3623.    accompanied  by  a  PTR  (Programmer  Trouble  Report)  and all
  3624.    necessary computer runs.  This is currently the only method  of
  3625.    support for this product.
  3626. 1                           - 82 -
  3627.  
  3628.                        XII. REFERENCES
  3629.  
  3630.  
  3631.  1.  Fletcher, J.  G.  et al., "On The  Appropriate  Language
  3632.  For  System  Programming",  SIGPLAN Notices Vol.  7, No.  7,
  3633.  (July 1972),28-32.
  3634.  
  3635.  2.  Lang, C.  A., "Languages for Writing  System  Programs",
  3636.  in   "Software   Engineering   Techniques".    NATO  Science
  3637.  Committee 101-106, April 1970.
  3638.  
  3639.  3.  Lyle, L.  M., "A Hierarchy of High Order  Languages  for
  3640.  Systems  Programming",  SIGPLAN  Notices  Vol.   6,  No.  9,
  3641.  (October 1971), 73&77.
  3642.  
  3643.  4.  Du Bois, P.  J.  et al., "The LRLTRAN Language  As  Used
  3644.  in  the  FROST  and  FLOE  Time-Sharing  Operating Systems",
  3645.  SIGPLAN Notices Vol.  6, No.  9, (October 1971), 92-104.
  3646.  
  3647.  5.  Haines, E.  C., "AL:  A Structured  Assembly  Language",
  3648.  M72-81,  The  MITRE Corp., Bedford, Mass., April 1972.  Also
  3649.  SIGPLAN Notices Vol.  8,  No.   1,  (January  1973),  15-20.
  3650.  Also SIGPLAN Notices Vol.  8, No.  4, (April 1973), 16-21.
  3651.  
  3652.  6.  Dijkstra, E.  W., "GO TO Statement Considered  Harmful",
  3653.  "Communications of the ACM", Vol.  11, No.  3, (March 1968),
  3654.  147-148.
  3655. 1
  3656.                          COMMENT FORM
  3657.  
  3658.  Is the ALP User's Guide                       YES  NO
  3659.  
  3660.      Clear?                                    __   __
  3661.      Well Organized?                           __   __
  3662.      Complete?                                 __   __
  3663.      Accurate?                                 __   __
  3664.      Suitable for the beginner?                __   __
  3665.      Suitable for the advanced user?           __   __
  3666.  
  3667.  
  3668.  Comments:________________________________________________________
  3669.  
  3670.  _________________________________________________________________
  3671.  
  3672.  _________________________________________________________________
  3673.  
  3674.  _________________________________________________________________
  3675.  
  3676.  _________________________________________________________________
  3677.  
  3678.  _________________________________________________________________
  3679.  
  3680.  _________________________________________________________________
  3681.  
  3682.  _________________________________________________________________
  3683.  
  3684.  _________________________________________________________________
  3685.  
  3686.  _________________________________________________________________
  3687.  
  3688.  _________________________________________________________________
  3689.  
  3690.  _________________________________________________________________
  3691.  
  3692.  _________________________________________________________________
  3693.  
  3694.  _________________________________________________________________
  3695.  
  3696.  _________________________________________________________________
  3697.  
  3698.  _________________________________________________________________
  3699.  
  3700.  
  3701.  
  3702.  
  3703.  Please give page references where appropriate.   If  you  wish  a
  3704.  reply, include your name and mailing address.
  3705.  
  3706.  
  3707.                     Send to:  NIH
  3708.                               DCRT
  3709.                               Computer Center
  3710.                               Technical Information Office
  3711.                               Bldg. 12A, Rm. 1017
  3712.                               Bethesda, Maryland   20892
  3713.  ,SEPARATOR
  3714.