home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MODULA2 / FM2CMP.ZIP / FMODULA2.DOC < prev    next >
Encoding:
Text File  |  1987-10-20  |  75.8 KB  |  2,773 lines

  1.  
  2.  
  3.                           Modula-2 Compiler Version 1.1
  4.  
  5.                     (C) Copyright 1987 Fitted Software Tools.
  6.                               All rights reserved.
  7.  
  8.  
  9.  
  10.                               Fitted Software Tools
  11.                                  P.O.Box 956129
  12.                                 Duluth, Ga 30136
  13.  
  14.      
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.                              DISCLAIMER OF WARRANTY
  26.  
  27.      THIS SOFTWARE AND MANUAL ARE PROVIDED "AS IS" AND WITHOUT WARRANTIES
  28.      AS TO PERFORMANCE OR MERCHANTABILITY.
  29.  
  30.      THIS SOFTWARE IS PROVIDED WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES
  31.      WHATSOEVER. BECAUSE OF THE DIVERSITY OF CONDITIONS AND HARDWARE UNDER
  32.      WHICH THIS SOFTWARE MAY BE USED, NO WARRANTY OF FITNESS FOR A
  33.      PARTICULAR PURPOSE IS OFFERED. THE USER IS ADVISED TO TEST THIS
  34.      SOFTWARE THOROUGHLY BEFORE RELYING ON IT. THE USER MUST ASSUME THE
  35.      ENTIRE RISK OF USING THIS SOFTWARE.
  36.  
  37.      
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.      IBM is a registered trademark of International Business Machines
  49.      Corporation.
  50.  
  51.      
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.      Introduction                                                         2
  68.      
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.                                     Chapter 1
  77.  
  78.                                   Introduction
  79.  
  80.  
  81.  
  82.      Thank you for your interest in our Modula-2 compiler. 
  83.  
  84.      This system features a Modula-2 compiler with an integrated editor and
  85.      "make" facility, a program linker, a makefile generator, and an
  86.      execution profiler. 
  87.  
  88.      The compiler generates code for the Intel 8086 "huge" or "large"
  89.      memory model: In the "huge" memory model, each module has its own data
  90.      and code segment, each of which can be up to 64k in size; In the
  91.      "large" memory model, all the modules' static data is combined into a
  92.      single data segment.  In either model, pointers are 4 bytes long and
  93.      all the leftover memory is available for the "heap". More restrictive
  94.      memory models are not currently supported. 
  95.  
  96.      All the library and runtime support source code is provided to our
  97.      registered users (see Shareware).
  98.  
  99.      We hope that our effort will prove itself worthy of your support. 
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.      Introduction                                                         3
  134.      
  135.  
  136.  
  137.  
  138.  
  139.  
  140.      1.1 Hardware requirements
  141.  
  142.  
  143.      This system will run on IBM PC, PC/AT, or compatible systems with at
  144.      least 512K of RAM, two double sided floppy disk drives and a
  145.      monochrome display adapter, color graphics adapter or equivalent. 
  146.  
  147.      For best performance, a hard disk and 640K of RAM are recommended. 
  148.  
  149.      
  150.  
  151.  
  152.  
  153.  
  154.      1.2 Software requirements
  155.  
  156.  
  157.      This system will run under DOS version 2.0 or later. 
  158.  
  159.      No other software is required to use this system, but you will need an
  160.      assembler if you intend to modify one of the runtime support modules:
  161.      M2Reals (floating point support), M2Longs (LONG arithmetic) or M2Procs
  162.      (coroutine handling). 
  163.  
  164.      
  165.  
  166.  
  167.  
  168.  
  169.      1.3 What is new in version 1.1
  170.  
  171.  
  172.      The compiler now allows the specification of module priorities in the
  173.      module header.  As an example on the use this new capability, we
  174.      include the source code of a simple multitasking communications
  175.      program running under a small kernel that supports interrupt
  176.      processes, signals and locks. 
  177.  
  178.      The compiler and linker now allow you to use a "large" memory model. 
  179.      In this memory model, all the modules share a common data segment for
  180.      static data; pointers are still 4 bytes long.  Using the large memory
  181.      model usually produces smaller (and faster, although you may not be
  182.      able to tell) executable files, as data references to external objects
  183.      do not cost anything extra. 
  184.  
  185.      The compiler has new command line options, so that you can directly
  186.      invoke the editor or the make process from the command line. 
  187.  
  188.      From the compiler menu you may now invoke the linker and the makefile
  189.      generator, although these are still freestanding programs. 
  190.  
  191.      The compiler now accepts EXPORT statements in definition modules, but
  192.      simply treats them as comments.  This capability was requested by some
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.      Introduction                                                         4
  200.      
  201.  
  202.      of our users. 
  203.  
  204.      The editor includes 3 new commands: delete line, delete to end of line
  205.      and delete word. 
  206.  
  207.      M2ED.CFG now has additional information in it: through EDCONFIG you
  208.      may now select the display attributes (colors) to be used by the
  209.      editor; you may also select different default values for tab spacing
  210.      and whether or not to expand tabs. 
  211.  
  212.      A new option was added to M2Link: /SWAP. When invoked, this option
  213.      directs the linker to swap the code segments of the program being
  214.      processed out to disk, thereby allowing you to link larger programs. 
  215.  
  216.      Many new library modules were added: Keyboard, display, DOS file and
  217.      directory handling, and even modules to handle windows and pop up and
  218.      pull down menus.  These libraries are provided just to help you get
  219.      started; We will leave the production of more elaborate libraries to
  220.      those vendors that specialize in such. 
  221.  
  222.      
  223.  
  224.  
  225.  
  226.  
  227.      1.4 As version 1.0 becomes history...
  228.  
  229.  
  230.      Before going on, we would like to thank all our registered users: your
  231.      encouragement made this new version possible.  We will strive to never
  232.      let you down. 
  233.  
  234.      We also appreciated the input received from those that evaluated the
  235.      product and were nice enough to let us in on their thoughts. 
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.      Software installation                                                5
  266.      
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.                                     Chapter 2
  275.  
  276.                               Software installation
  277.  
  278.  
  279.  
  280.      Before starting, please print the file READ.ME, which provides a
  281.      description of every file in the distribution disks. 
  282.  
  283.      
  284.  
  285.  
  286.  
  287.  
  288.      2.1 Theory
  289.  
  290.  
  291.      The library module TermIO (through which Terminal does its IO)
  292.      requires that the ANSI.SYS driver be installed. 
  293.  
  294.      The executable files (MC.EXE, M2LINK.EXE, ...) should, for ease of
  295.      operation, be placed in a drive/directory named in the DOS PATH
  296.      variable. 
  297.  
  298.      The editor configuration file M2ED.CFG must be accessible through the
  299.      DOS PATH variable. 
  300.  
  301.      Both the compiler and the linker will use the environment variable
  302.      M2LIB to locate required library modules (the format for the M2LIB
  303.      entry matches that of the DOS PATH).
  304.  
  305.      The environment variable M2MODEL may be set to 'HUGE' or 'LARGE',
  306.      after which you no longer have to tell the compiler what memory model
  307.      to compile for (unless you wish to override the environment
  308.      selection).  IF M2MODEL is not set, the compiler, by default (and for
  309.      compatibility with version 1.0), assumes that you want to compile for
  310.      the HUGE model. 
  311.  
  312.      The compiler and utilities in this package do not keep many files open
  313.      simultaneously.  If you set the FILES parameter in CONFIG.SYS to 10
  314.      you should not encounter any problems.  For performance
  315.      considerations, you should also allocate more than the default number
  316.      of buffers for DOS: If you are running on a PC class machine, try
  317.      allocating 20 buffers in your CONFIG.SYS. On an AT type machine, try
  318.      64 buffers. 
  319.  
  320.      Example CONFIG.SYS:
  321.  
  322.           DEVICE=ANSI.SYS
  323.           FILES=10
  324.           BUFFERS=20
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.      Software installation                                                6
  332.      
  333.  
  334.  
  335.      This compiler is a memory hog (you heard it here first!).  Therefore,
  336.      unless you have 640k of memory installed in your system, you should
  337.      have COMMAND.COM available for reload once you exit the compiler. 
  338.  
  339.      If you have 640k of memory, you will probably want to enable the
  340.      "COMMAND save" feature of the compiler, which will stop it from
  341.      clobbering the resident portion of COMMAND.COM. Just add the following
  342.      line to your AUTOEXEC.BAT file:
  343.  
  344.           SET CMDSIZE=NN
  345.  
  346.      where NN is the size of the resident portion of COMMAND.COM in K (18
  347.      for DOS 3.0).
  348.  
  349.      MC clobbers the top of the memory space available for use during
  350.      initialization.  Therefore, to find out the size of the resident
  351.      portion of COMMAND.COM try the following procedure: start by setting
  352.      CMDSIZE to the size of COMMAND.COM. If now you execute MC, exit it,
  353.      and press the F3 key, DOS will still remember your MC command. 
  354.      Decrement CMDSIZE and retry the MC test until the system forgets your
  355.      last command (COMMAND.COM had to be reloaded). 
  356.  
  357.      Because the compiler supports 2 different memory models, 2 different
  358.      sets of library object files (.M2O) are provided, one for each of the
  359.      memory models.  If you are going to be using both memory models, keep
  360.      each of these sets of files on a different directory, and change the
  361.      M2LIB path according to the model in use.  We use the following BAT
  362.      files to take care of this:
  363.  
  364.  
  365.      LARGE.BAT:
  366.           set M2MODEL=LARGE
  367.           set M2LIB=C:\M2\LIB;C:\M2\LIBL
  368.  
  369.      HUGE.BAT:
  370.           set M2MODEL=HUGE
  371.           set M2LIB=C:\M2\LIB;C:\M2\LIBH
  372.  
  373.      where \M2\LIB is the directory where all the DEF files reside,
  374.      \M2\LIBL contains the LARGE memory model M2O files,... 
  375.  
  376.      In the following discussion we will, for simplicity sake, assume that
  377.      you will be using only one of the memory models. 
  378.  
  379.      
  380.  
  381.  
  382.  
  383.  
  384.      2.2 Recommended setup for a system with 2 floppy drives
  385.  
  386.  
  387.      This whole system is too large to fit in a single 360k floppy. 
  388.      Therefore, it is recommended that you build a "compiler" floppy and a
  389.      "utilities" floppy (you may combine them both in a 720k or 1.2Mb
  390.      floppy). 
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.      Software installation                                                7
  398.      
  399.  
  400.  
  401.      On the compiler floppy, place the compiler (MC.EXE), all the library
  402.      definition modules (*.DEF), the file M2ED.CFG and DOS' COMMAND.COM.
  403.  
  404.      The utilities floppy will take the rest of the system: the linker
  405.      (M2LINK.EXE), other .EXE files, and the library and runtime support
  406.      object files (*.M2O and *.BIN).
  407.  
  408.      Assuming that you will use drive A for the compiler and utilities disk
  409.      and drive B as your work drive, add the following to your AUTOEXEC.BAT
  410.      file:
  411.  
  412.           SET PATH=A:
  413.           SET M2LIB=A:
  414.  
  415.      If you follow these suggestions, you may use all the system's
  416.      capabilities.  Just remember to swap the floppy in drive A before and
  417.      after invoking the linker from the compiler's menu. 
  418.  
  419.  
  420.  
  421.  
  422.      2.3 Recommended setup for a hard disk system
  423.  
  424.  
  425.      Place the executable files (*.EXE) and M2ED.CFG in a directory
  426.      currently in the DOS search path, or in a new directory (ex: \MODULA2)
  427.      to be added to the PATH list.  Example:
  428.  
  429.           SET PATH=C:\BIN;C:\MODULA2
  430.  
  431.      Make a directory for the library files (ex: \M2LIB) and copy all the
  432.      .DEF, .M2O and .BIN files to it.  To the AUTOEXEC.BAT file add the
  433.      line:
  434.  
  435.           SET M2LIB=C:\M2LIB
  436.  
  437.      You will probably want to create a directory for your own reusable
  438.      library modules.  This directory can be added to the M2LIB environment
  439.      variable.  Example:
  440.  
  441.           SET M2LIB=C:\M2LIB;C:\MYLIB
  442.  
  443.      You may keep your projects in their own, individual, directories. 
  444.  
  445.      
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.      A little tour through the system                                     8
  464.      
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.                                     Chapter 3
  473.  
  474.                         A little tour through the system
  475.  
  476.  
  477.  
  478.      After you finish the installation as described above, please copy the
  479.      files identified as the "system tour files" in the READ.ME file to
  480.      your work disk or directory. 
  481.  
  482.      Because we do not know your particular system configuration, in the
  483.      following examples we will assume the worst possible scenario. 
  484.      Therefore, some of the capabilities of this system will not be fully
  485.      exploited.  Specifically, we will not invoke the linker or run the
  486.      programs from the compiler menu, neither will we invoke a DOS shell to
  487.      run DBG2MAP.
  488.  
  489.      
  490.  
  491.  
  492.  
  493.  
  494.      3.1 The tour
  495.  
  496.  
  497.      First, we will look at the unnatural case of compiling, linking and
  498.      running a program that works the first time around.  Please execute
  499.      the following commands:
  500.  
  501.           MC SIEVE /C
  502.           M2LINK SIEVE /O
  503.  
  504.      Well, that's it!  Ready to run... 
  505.  
  506.           SIEVE
  507.  
  508.      Now for the more usual case:
  509.  
  510.           MC BADSIEVE
  511.  
  512.      From the compiler menu, select 'C' for compile. 
  513.  
  514.      Gee, that was quick!  Press RETURN to take a look at our errors... 
  515.  
  516.      The cursor is now positioned at the location of the first error. 
  517.      Using the keys Ctrl-E (find next error) and Ctrl-P (find previous
  518.      error) you may visit all the errors flagged by the compiler.  All the
  519.      while, the editor shows the error description on the top line of the
  520.      screen.  But, going back to the first error... 
  521.  
  522.      We really confused the compiler when we mistakenly typed in '.'
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.      A little tour through the system                                     9
  530.      
  531.  
  532.      instead of '..' in the range declaration.  Move the cursor back (left
  533.      arrow key) to where the '.' is, type in another '.', and that should
  534.      fix that!  As you will see as you type Ctrl-E, that single error
  535.      caused the compiler to dislike a few other things on that same line;
  536.      we will just ignore those errors and go on. 
  537.  
  538.      Go on to the next error location (line 22). This time, we should have
  539.      used a ']' but typed '}' instead.  The backspace key will delete the
  540.      offending character; now, type the ']' in its place. 
  541.  
  542.      And that is that.  Shall we try to compile the program again? 
  543.  
  544.      Press Alt-S to save the file, Alt-Q to leave the editor and, back at
  545.      the main menu, select 'C'.
  546.  
  547.      More errors?! 
  548.  
  549.           These errors should have been detected during pass2 of the
  550.           compiler; If not, you may try to fix these errors and recompile,
  551.           or you may opt for loading and compiling the new file
  552.           BADSIEV1.MOD, which contains the earlier fixes.
  553.  
  554.      Going back to the editor... 
  555.  
  556.      We find that we used the identifier 'cnt' which is undefined; we
  557.      really meant to use count.  So, moving the cursor around with the
  558.      cursor keys and/or deleting characters with the backspace or delete
  559.      key, please replace 'cnt' by 'count'.
  560.  
  561.      Searching for the next error... 
  562.  
  563.      The next error occured during the processing of the call to WriteCard.
  564.      What happened here is that WriteCard requires 2 parameters, the second
  565.      one being the size of the field to display.  So, to fix it, let's
  566.      insert a comma after 'count' and some number (for example 'count,4').
  567.  
  568.      Any more erors?  No, that is it... 
  569.  
  570.      We now save the file (Alt-S), quit the editor (Alt-Q) and recompile
  571.      (c).
  572.  
  573.      Now, the program should have compiled without errors.  If not, you may
  574.      recompile BADSIEV2.MOD instead. 
  575.  
  576.      We may now quit the compiler (q).
  577.  
  578.      By now, we have some program that has compiled clean (BADSIEVE,
  579.      BADSIEV1 or BADSIEV2). In what follows, we will assume all went well
  580.      and we have BADSIEVE.
  581.  
  582.      If you look at the directory, you will see the new object module
  583.      created as a result of the previous exercise (BADSIEVE.M2O). The
  584.      compiler always writes its output to a file with the extension 'M2O'.
  585.  
  586.      Let us link and test the program:
  587.  
  588.           M2LINK BADSIEVE /L
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.      A little tour through the system                                    10
  596.      
  597.  
  598.  
  599.      We use the /L option so that the line number information written out
  600.      by the compiler to the object file will be preserved by the linker. 
  601.      We will need this information later. 
  602.  
  603.           BADSIEVE
  604.  
  605.      A runtime error?  And it gives us a PC location.  Very informative, is
  606.      it not?  How in the world are we supposed to fix the program based on
  607.      that?  Do not dispair! 
  608.  
  609.      Looking at your directory, you will notice that the linker created 2
  610.      files: BADSIEVE.EXE and BADSIEVE.DBG.
  611.  
  612.      No, TYPEing BADSIEVE.DBG does not help, it just displays garbage.  But
  613.      we have a utility called DBG2MAP that will convert the information in
  614.      that file to a DOS LINK compatible MAP file.  Let's try it:
  615.  
  616.           DBG2MAP BADSIEVE
  617.  
  618.      Now, using your favorite editor (or the editor in MC: MC BADSIEVE.MAP
  619.      and then E), look at the contents of BADSIEVE.MAP. In the last few
  620.      lines of the file, we have the line number information for BADSIEVE.
  621.      If you look up the line whose address is closest (but lower) to the PC
  622.      in the error message, you get the number of the line where the error
  623.      occured (line 22).
  624.  
  625.      Let's see what happened... 
  626.  
  627.           MC BADSIEVE
  628.  
  629.      Pick 'E' to go into the editor and, either move the cursor down to the
  630.      line indicated by your research, or let the editor find it with Alt-G.
  631.  
  632.      So, what is the problem?  Well, we declared the 'flag' array to have a
  633.      maximum index of 8190, but 'j' got bigger than that (the FOR loop will
  634.      increment 'j' up to the value of 10000).
  635.  
  636.      You may fix the problem by deleting the '10000' and typing in its
  637.      place 'SIZE'.
  638.  
  639.      Recompile the program, link it, and run it.  Did it work?  Good.
  640.  
  641.      It is time for you to experiment on your own.  But, before you do much
  642.      more, you may want to check out the Editor chapter of the
  643.      documentation. 
  644.  
  645.      
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.      The Compiler                                                        11
  662.      
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.                                     Chapter 4
  671.  
  672.                                   The Compiler
  673.  
  674.  
  675.  
  676.      In Modula-2, identifiers may be used before they are declared, except
  677.      when they are used in another declaration (this restriction does not
  678.      apply to pointers).  This forces the compilation process to be done in
  679.      at least two passes.  To avoid imposing unnecessary restrictions and,
  680.      yet, provide reasonable performance, the two pass approach was
  681.      selected: During the first pass, syntax analysis and declaration
  682.      analysis are performed; The second pass performs the semantic analysis
  683.      and code generation. 
  684.  
  685.      The compiler has an integrated text editor.  Should errors be
  686.      encountered, the editor is invoked at the end of the current compiler
  687.      pass (sooner, if an error is found during the processing of an import
  688.      list or if 20 errors are identified). 
  689.  
  690.      The compiler also has a built in "make" processor.  A makefile must be
  691.      created before this process is invoked.  Although you can create a
  692.      makefile using the editor, we recommend that you use the utility
  693.      provided for that purpose: GENMAKE (this utility may be invoked from
  694.      the compiler menu -- G).
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.      The Compiler                                                        12
  728.      
  729.  
  730.  
  731.  
  732.  
  733.  
  734.      4.1 Running the compiler
  735.  
  736.  
  737.      Compiler invocation:
  738.  
  739.           MC [workModule] [/p mainModule] [/c] [/e] [/m]
  740.  
  741.      The '/p' option may be used to indicate the name of the main module of
  742.      the program that you are working on (the name should not have an
  743.      extension).  If this option is not used, but workModule is entered
  744.      without an extension, then the same name is also used for mainModule. 
  745.  
  746.      If you use of the '/c' command line option, the compiler starts
  747.      compiling "workModule" immediately and, if no errors are encountered,
  748.      will bring you right back to the DOS prompt.  This is useful when
  749.      running the compiler from a batch file:
  750.  
  751.           MC myprog /c
  752.  
  753.      The '/e' option will send you straight into the editor. 
  754.  
  755.      The '/m' option invokes the make processor, which will look for the
  756.      file mainModule.MAK for the dependencies list. 
  757.  
  758.      The compiler always sets the DOS errorlevel to 0 if the last compile
  759.      was successful (no errors); otherwise, the DOS errorlevel is set to 1.
  760.  
  761.      If the compiler is invoked without the '/c', '/e' or '/m' options, you
  762.      will get a screen that looks something like this:
  763.  
  764.  
  765.           Modula-2 compiler, Version 1.1
  766.           (C) Copyright 1987 Fitted Software Tools.
  767.           All rights reserved.
  768.  
  769.           Memory model in use: LARGE
  770.  
  771.           Heap in use:                   0K
  772.           Available Heap:              229K
  773.  
  774.           Program:     sieve
  775.  
  776.           Work module: sieve.MOD
  777.  
  778.           Program  New   Options  DOS   Quit
  779.           Compile  Edit  Genmake  Make  Link  eXecute >
  780.  
  781.  
  782.      The options at this point are:
  783.  
  784.      Program           Specify the name of the main program module. 
  785.  
  786.      New               Specify another "Work module". 
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.      The Compiler                                                        13
  794.      
  795.  
  796.  
  797.      Options           To select the memory model to use. 
  798.  
  799.      DOS               Invoke a new DOS shell.  At the DOS prompt, you
  800.                        should type EXIT to return to this system. 
  801.  
  802.      Quit              Return to DOS.
  803.  
  804.      Compile           Compile the "Work module". 
  805.  
  806.      Edit              Edit the "Work module". 
  807.  
  808.      Genmake           Invoke the GenMake program, passing as argument the
  809.                        name in Program.
  810.  
  811.      Make              Recompile all the necessary modules as per the rules
  812.                        of a makefile (The makefile is assumed to have the
  813.                        name in Program and the extension of .MAK). Note: If
  814.                        errors are encountered during the compilation of one
  815.                        of the modules, the make process is aborted.  After
  816.                        fixing the errors, select Make again. 
  817.  
  818.      Link              Invokes the linker (M2Link) passing along as
  819.                        arguments the name in Program and '/L'.
  820.  
  821.      eXecute           Program is executed. 
  822.  
  823.      
  824.  
  825.  
  826.  
  827.  
  828.      4.2 The compilation process
  829.  
  830.  
  831.      
  832.  
  833.  
  834.      4.2.0.1 The input file
  835.  
  836.      If the module to be compiled is already loaded into one of the editor
  837.      buffers, that source is compiled.  Otherwise, the compiler tries to
  838.      open the named file. 
  839.  
  840.      
  841.  
  842.  
  843.      4.2.0.2 The imported modules
  844.  
  845.      The compiler and the linker cooperate in assuring that all the modules
  846.      that refer to a particular definition module will have been compiled
  847.      against the same version of that definition module. 
  848.  
  849.      To this end, the compiler places in the 'module header' and 'module
  850.      import' records of the object file a "module key".  This module key is
  851.      the date of the DEF file used during the compilation of the
  852.      implementation module or during the processing of the IMPORT
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.      The Compiler                                                        14
  860.      
  861.  
  862.      statement. 
  863.  
  864.      Due to this, the compiler will not look in the editor buffers for the
  865.      DEF files needed to process an IMPORT list.  These are always read in
  866.      from the disk. 
  867.  
  868.      
  869.  
  870.  
  871.      4.2.0.3 The output file
  872.  
  873.      The output from the compilation of a main module or an implementation
  874.      module is a single output file, with the same name of the source file
  875.      but with the extension of 'M2O' (Modula-2 Object).
  876.  
  877.      The compilation of a definition module does not generate any new
  878.      output files.  If the compilation is successful (no errors), the
  879.      compiler simply 'touches' the source file, updating its modification
  880.      time. 
  881.  
  882.      
  883.  
  884.  
  885.      4.2.0.4 A warning
  886.  
  887.      Because of the fact that the compiler uses the date of the DEF file as
  888.      that module's key, you may not modify a DEF file unless you intend to
  889.      recompile all the modules that use it, nor can you copy the file in
  890.      such a way that its date is not preserved. 
  891.  
  892.      In particular, if you are going to be transferring your modules
  893.      between computers, you must use some procedure that will preserve all
  894.      the DEF files' dates. 
  895.  
  896.      
  897.  
  898.  
  899.  
  900.  
  901.      4.3 Compiler directives
  902.  
  903.  
  904.      Certain compiler code generation options may be set through directives
  905.      included in the program text.  These directives must appear
  906.      immediately at the beginning of a comment; multiple directives may be
  907.      entered in a single comment by separating them by commas.  Example
  908.  
  909.           (* $S-, $R+ *)
  910.  
  911.      A '+' sets the directive to TRUE, a '-' sets it to FALSE.
  912.  
  913.      The following compiler directives are defined:
  914.  
  915.      $A                Alignment. Default $A+. If enabled, all new variables
  916.                        declared are aligned on a word boundary.  Record
  917.                        fields are packed (not aligned) regardless of the
  918.                        setting of this option. 
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.      The Compiler                                                        15
  926.      
  927.  
  928.  
  929.      $S                Stack overflow checking.  Default $S+. If enabled,
  930.                        stack overflow checking is performed on entry to a
  931.                        procedure and when copying open arrays to a
  932.                        procedure's local stack frame. 
  933.  
  934.      $R                Range checking.  Default $R+. If enabled, before any
  935.                        assignment is made to a variable of a subrange type,
  936.                        the value to be assigned is tested against the limits
  937.                        of the subrange type. 
  938.  
  939.      $T                Array subscript checking.  Default $T+. If enabled,
  940.                        any time a subscript operation is performed on an
  941.                        array, the subscript value is checked to confirm that
  942.                        the operation would not generate an address outside
  943.                        the bounds of the array. 
  944.  
  945.      $L                Generate line number information.  Default $L-. If
  946.                        this option is enabled, the compiler will include a
  947.                        list of source code line numbers and their
  948.                        corresponding object code offsets in the output
  949.                        file.  This line number information is passed on to
  950.                        the .DBG file when the program is linked with the /L
  951.                        option. 
  952.  
  953.      
  954.  
  955.  
  956.  
  957.  
  958.      4.4 Runtime errors
  959.  
  960.  
  961.      When, during the execution of a program, a runtime error is detected,
  962.      the runtime error handler will terminate the program and write out a
  963.      message indicating the type of error encountered and its location (PC
  964.      address). 
  965.  
  966.      To find the location of the error in the source code, run DBG2MAP
  967.      against the .DBG file generated by M2LINK for this program.  Scanning
  968.      the .MAP file created, you should be able to always determine the
  969.      module and procedure where the error occured.  If the $L+ directive
  970.      was used when compiling the module in question and the /L option was
  971.      used when linking the program, the error location can be pinpointed to
  972.      the offending line by scanning the line number information at the end
  973.      of the .MAP file. 
  974.  
  975.      
  976.  
  977.  
  978.      4.4.1 Trapping runtime errors in your program
  979.  
  980.      The Library module System provides you with a means of intercepting
  981.      runtime errors.  The following are the currently defined runtime error
  982.      numbers that may be passed to your error handler routine:
  983.  
  984.           0   stack overflow ($S option)
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.      The Compiler                                                        16
  992.      
  993.  
  994.           1   range error ($R or $T option)
  995.           2   integer/cardinal overflow (divide by zero)
  996.           3   floating point error
  997.           4   function did not execute a RETURN
  998.           5   HALT was invoked
  999.  
  1000.  
  1001.  
  1002.  
  1003.      4.5 Compiler size limits
  1004.  
  1005.  
  1006.      The following are the code and data size limits imposed by this
  1007.      compiler:
  1008.  
  1009.        -  A string constant cannot exceed 80 characters.  This is also the
  1010.           limit set for the size of any identifier. 
  1011.  
  1012.        -  When using the HUGE memory model, each compilation module is
  1013.           assigned its own data segment, which can be up to 64k in size. 
  1014.           In the data segment, the compiler allocates the space for all the
  1015.           module's global variables and some of the module's constants. 
  1016.  
  1017.        -  When using the LARGE memory model, all the modules' data are
  1018.           combined, at link time, into a single data segment (64k
  1019.           maximum). 
  1020.  
  1021.        -  The maximum size of a data structure is 65532 bytes. 
  1022.  
  1023.        -  The maximum amount of space allocated for variables local to a
  1024.           procedure is 32000 bytes. 
  1025.  
  1026.        -  The compiler will also refuse to generate the code to pass, in a
  1027.           procedure call, by value, a parameter greater than 65000 bytes in
  1028.           size. 
  1029.  
  1030.      The following are the compiler's internal limits:
  1031.  
  1032.        -  The maximum number of different (namewise) identifiers that can
  1033.           be processed in a single compilation is 2000.
  1034.  
  1035.        -  The total number of characters in all the different (namewise)
  1036.           identifiers processed cannot exceed 12000 characters. 
  1037.  
  1038.        -  No single procedure can be translated into more than 10k of
  1039.           object code. 
  1040.  
  1041.        -  An array of 8k bytes is used to keep track of all the initialized
  1042.           data for a module.  This imposes a limit on the total amount of
  1043.           string, real and long constants used in the compilation module. 
  1044.  
  1045.  
  1046.  
  1047.  
  1048.      4.6 The language supported
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.      The Compiler                                                        17
  1058.      
  1059.  
  1060.      This release of the compiler will translate a program written in the
  1061.      Modula-2 language as defined by Niklaus Wirth in the 3rd edition of
  1062.      his book "Programming in Modula-2", with the exceptions noted bellow:
  1063.  
  1064.      
  1065.  
  1066.        -  Integer and Cardinal arithmetic overflow is not detected. 
  1067.  
  1068.        -  ASM is a reserved word in this implementation. 
  1069.  
  1070.        -  For those programmers that "grew up" in the Hex world, a way to
  1071.           define CHAR literals in Hex is provided: 20X corresponds to the
  1072.           "space" character in ASCII.
  1073.  
  1074.      
  1075.  
  1076.  
  1077.      4.6.1 LONGINT and LONGCARD
  1078.  
  1079.      This compiler implements the standard types LONGINT and LONGCARD.
  1080.  
  1081.      Operands of the type LONGINT or LONGCARD may appear in any expression,
  1082.      just like INTEGER or CARDINAL. But that is about it! 
  1083.  
  1084.      Subranges of these types are not supported. 
  1085.  
  1086.      No standard procedure (like INC, DEC) except the ones listed later in
  1087.      this document will accept operands of one of these types. 
  1088.  
  1089.      A variable of type LONGINT or LONGCARD cannot be used as the control
  1090.      variable in a FOR loop.  Neither can CASE labels be of a LONG type. 
  1091.  
  1092.      Constants of type LONGINT or LONGCARD can be coded in decimal only and
  1093.      are terminated by an 'L'. Example
  1094.  
  1095.           123L is a valid LONGCARD or LONGINT constant
  1096.  
  1097.           -348762L is a valid LONGINT constant
  1098.  
  1099.           565656 -89076 are CARDINAL and INTEGER constants out of range
  1100.  
  1101.  
  1102.      4.6.2 Additional standard procedures
  1103.  
  1104.  
  1105.      4.6.2.1 NEW and DISPOSE
  1106.  
  1107.      NEW and DISPOSE have been deleted from the language definition in the
  1108.      3rd edition of Wirth's book.  We implement them thus:
  1109.  
  1110.           NEW(p)
  1111.  
  1112.      Invokes the procedure ALLOCATE, which must conform to the type:
  1113.  
  1114.           PROCEDURE ( VAR ADDRESS, CARDINAL )
  1115.  
  1116.      passing along p and the size of the object p is defined as pointing
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.      The Compiler                                                        18
  1124.      
  1125.  
  1126.      to. 
  1127.  
  1128.           DISPOSE(p)
  1129.  
  1130.      Invokes the procedure DEALLOCATE, which must conform to the type:
  1131.  
  1132.           PROCEDURE ( VAR ADDRESS, CARDINAL )
  1133.  
  1134.      passing along p and the size of the object p is defined as pointing
  1135.      to. 
  1136.  
  1137.      The procedures ALLOCATE and DISPOSE must, therefore, be defined in the
  1138.      module using NEW and/or DISPOSE, or imported from some other module,
  1139.      like Storage.
  1140.  
  1141.      
  1142.  
  1143.  
  1144.      4.6.2.2 LONG and SHORT
  1145.  
  1146.           PROCEDURE LONG( INTEGER ) :LONGINT;
  1147.  
  1148.           PROCEDURE LONG( CARDINAL ) :LONGCARD;
  1149.  
  1150.           PROCEDURE SHORT( LONGINT ) :INTEGER;
  1151.  
  1152.           PROCEDURE SHORT( LONGCARD ) :CARDINAL;
  1153.  
  1154.      LONG takes an INTEGER (CARDINAL) and converts it into a LONGINT
  1155.      (LONGCARD).
  1156.  
  1157.      SHORT takes a LONGINT (LONGCARD) and converts it into an INTEGER
  1158.      (CARDINAL).
  1159.  
  1160.  
  1161.  
  1162.  
  1163.      4.7 Objects exported by the pseudo module SYSTEM
  1164.  
  1165.  
  1166.      4.7.0.1 TYPE BYTE
  1167.  
  1168.      Takes 1 byte of storage.  Only assignment is defined for this type. 
  1169.      If the formal parameter of a procedure is of type BYTE, the
  1170.      corresponding actual parameter may be of any type that takes 1 byte of
  1171.      storage. 
  1172.  
  1173.      If the formal parameter of a procedure is of type ARRAY OF BYTE, the
  1174.      corresponding actual parameter may be of any type. 
  1175.  
  1176.  
  1177.      4.7.0.2 TYPE WORD
  1178.  
  1179.      Takes 1 word (2 bytes) of storage.  Only assignment is defined for
  1180.      this type.  If the formal parameter of a procedure is of type WORD,
  1181.      the corresponding actual parameter may be of any type that takes 1
  1182.      word of storage. 
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.      The Compiler                                                        19
  1190.      
  1191.  
  1192.  
  1193.      If the formal parameter of a procedure is of type ARRAY OF WORD, the
  1194.      corresponding actual parameter may be of any type.  Care should be
  1195.      taken in this case, as the size of the parameter passed is rounded up
  1196.      to an even size. 
  1197.  
  1198.  
  1199.      4.7.0.3 TYPE ADDRESS
  1200.  
  1201.      The type ADDRESS is compatible with all pointer types.  ADDRESS itself
  1202.      is defined as a POINTER TO WORD. In this implementation, the type
  1203.      ADDRESS is not compatible with any arithmetic type.  This is due to
  1204.      the fact that the Intel 8086 series processors use segmented
  1205.      addresses.  It would not be hard to implement automatic conversions
  1206.      between LONGCARD and ADDRESS but it is felt that this would be
  1207.      contrary to the spirit of the language, whereby the compiler is not
  1208.      expected to perform any "magic" tricks.  Instead, two functions are
  1209.      provided for that purpose: FLAT and PTR.
  1210.  
  1211.  
  1212.      4.7.0.4 SEG and OFS
  1213.  
  1214.      These are field definitions for POINTER types.  If you import these
  1215.      you may access the segment or offset portions of a pointer variable
  1216.      using regular field selection syntax.  Example
  1217.  
  1218.           pointer.SEG :segment portion of pointer
  1219.  
  1220.  
  1221.      4.7.0.5 PROCEDURE ADR
  1222.  
  1223.      ADR( designator ) Returns the address of designator (type ADDRESS).
  1224.  
  1225.  
  1226.      4.7.0.6 PROCEDURE FLAT
  1227.  
  1228.      FLAT( ADDRESS ) returns a LONGCARD "flat" address. 
  1229.  
  1230.  
  1231.      4.7.0.7 PROCEDURE PTR
  1232.  
  1233.      PTR( LONGCARD ) returns an ADDRESS corresponding to the "flat" address
  1234.      represented by the LONGCARD.
  1235.  
  1236.  
  1237.      4.7.0.8 PROCEDURE SEGMENT
  1238.  
  1239.      SEGMENT( designator ) returns the segment portion of the address of
  1240.      'designator'. Example:
  1241.  
  1242.           DX := SEGMENT( buffer ); would assign to DX the segment value of
  1243.           ADR(buffer).
  1244.  
  1245.  
  1246.      4.7.0.9 PROCEDURE OFFSET
  1247.  
  1248.      OFFSET( designator ) returns the offset portion of the address of
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.      The Compiler                                                        20
  1256.      
  1257.  
  1258.      'designator'.
  1259.  
  1260.  
  1261.      4.7.0.10 PROCEDURE NEWPROCESS
  1262.  
  1263.      NEWPROCESS(p:PROC; a:ADDRESS; n:CARDINAL; VAR p1:ADDRESS)
  1264.  
  1265.      creates a new process whose entry point is p and workspace is at a for
  1266.      n bytes.  p1 is the new process pointer.  This process is not
  1267.      activated until a TRANSFER to p1 is done. 
  1268.  
  1269.      The starting priority of the new process is the current processor
  1270.      priority at the time NEWPROCESS is invoked (please refer to the
  1271.      section on Module Priorities).
  1272.  
  1273.  
  1274.      4.7.0.11 PROCEDURE TRANSFER
  1275.  
  1276.      TRANSFER( VAR p1, p2 :ADDRESS)
  1277.  
  1278.      suspends the current process, assigning it to p1 and resumes p2.  The
  1279.      current process' value is assigned to p1 only after p2 has been
  1280.      identified; it is, therefore, okay for p1 and p2 to be the same. 
  1281.  
  1282.      The process is resumed at the same priority level that it was running
  1283.      at, at the time of suspension. 
  1284.  
  1285.  
  1286.      4.7.0.12 PROCEDURE IOTRANSFER
  1287.  
  1288.      IOTRANSFER( VAR p1, p2 :ADDRESS; intVector :CARDINAL )
  1289.  
  1290.      issues a TRANSFER from p1 to p2 (just the way TRANSFER does it) after
  1291.      installing the current process for reactivation when an interrupt
  1292.      comes in through interrupt vector intVector. 
  1293.  
  1294.      When the interrupt occurs, the interrupt vector is reloaded with its
  1295.      previous value.  A TRANSFER is done to the I/O process (the one that
  1296.      issued the IOTRANSFER) such that p2 now contains the value of the
  1297.      process that was running when the interrupt occured. 
  1298.  
  1299.  
  1300.      4.7.0.13 ASSEMBLER
  1301.  
  1302.      An 8086 inline assembler is provided.  Once ASSEMBLER is imported from
  1303.      SYSTEM, you can enter inline assembler code by bracketing it with the
  1304.      keywords ASM and END.
  1305.  
  1306.      Assembler input is free form.  Comments are entered as in regular
  1307.      Modula-2. Example
  1308.  
  1309.           loop:   CMP  BYTE [SI], 0   (*end of string?*)
  1310.                   MOV  BYTE [DI], [SI]
  1311.                   INC  SI  INC DI     (*increment pointers*)
  1312.                   JMP  loop
  1313.  
  1314.      The assembler accepts all the 8086/8088 opcode mnemonics.  Address
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.      The Compiler                                                        21
  1322.      
  1323.  
  1324.      operands can be coded in just about any form acceptable to other
  1325.      assemblers, except that the only operator supported if '+'. Operand
  1326.      type overrides are: WORD, BYTE, FAR, NEAR and are not to be followed
  1327.      by the keyword POINTER or PTR. Example
  1328.  
  1329.           label:  MOV  AX, ES:[BX,DI+5]
  1330.                   MOV  AX, ES:5[DI+BX]
  1331.                   MOV  WORD [5], 1
  1332.                   CALL NEAR [DI]
  1333.                   TEST BYTE i+2, 1
  1334.  
  1335.      All the mnemonics and register names must be entered in upper case. 
  1336.      In case you need to use a Modula-2 name that conflicts with one of the
  1337.      assembler reserved symbols, you may precede it with a '@'. Example
  1338.  
  1339.           MOV @AX, AX
  1340.  
  1341.      would generate a move from register AX to variable AX.
  1342.  
  1343.      All modula-2 variables can generaly be accessed in assembler.  Record
  1344.      field names are not accessible from assembler.  The assembler will not
  1345.      automatically do anything for you.  For example: if you specify a VAR
  1346.      parameter as an operand to an instruction, you are naming the address
  1347.      of the pointer to the actual parameter.  Example
  1348.  
  1349.           PROCEDURE p( VAR done :BOOLEAN );
  1350.           ...
  1351.           ASM
  1352.                LES  DI, done
  1353.                MOV  BYTE ES:[DI], TRUE
  1354.           END;
  1355.  
  1356.      is the correct way of storing TRUE in done. 
  1357.  
  1358.      The following types of constants may be accessed in assembler:
  1359.      INTEGER, CARDINAL, BOOLEAN, CHAR and enumeration constants. 
  1360.  
  1361.      All labels declared inside an ASM section are local to that section of
  1362.      code.  But labels names cannot match some name known in the scope of
  1363.      the current procedure.  Labels can only be referenced in jump
  1364.      instructions. 
  1365.  
  1366.      All jumps are optimized by the compiler.  There is, therefore, no need
  1367.      (or capability) to specify the size of a jump.  In particular, the
  1368.      compiler will turn a conditional jump out of range into a reverse
  1369.      conditional jump over a far jump to the original destination. 
  1370.  
  1371.      Remember, this is a Modula-2 compiler, not an assembler!  The inline
  1372.      assembler capability is provided for use in exceptional situations
  1373.      only. 
  1374.  
  1375.      
  1376.  
  1377.  
  1378.  
  1379.  
  1380.      4.8 The generated object code
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.      The Compiler                                                        22
  1388.      
  1389.  
  1390.  
  1391.  
  1392.      
  1393.  
  1394.  
  1395.      4.8.1 Data type representation
  1396.  
  1397.      CHAR              1 byte
  1398.  
  1399.      INTEGER           2 bytes 2's complement
  1400.  
  1401.      CARDINAL          2 bytes
  1402.  
  1403.      LONGCARD          4 bytes
  1404.  
  1405.      LONGINT           4 bytes 2's complement
  1406.  
  1407.      BOOLEAN           1 byte (1=TRUE, 0=FALSE)
  1408.  
  1409.      REAL              4 bytes Intel 8087 format. 
  1410.  
  1411.      BITSET            1 word.  0 is low order bit, 15 is high order bit. 
  1412.  
  1413.      Enumerations      1 byte
  1414.  
  1415.      SETs              1 to 8 words (sets of up to 256 elements)
  1416.  
  1417.      POINTERs          4 bytes in Intel 8086/88 format
  1418.  
  1419.      PROCEDUREs        4 bytes POINTER to procedure entry point
  1420.  
  1421.      Addresses are represented in the default Intel 8086 format:
  1422.  
  1423.           1 word          byte offset
  1424.  
  1425.           1 word          segment
  1426.  
  1427.      Numeric values are likewise represented the way the Intel 8086
  1428.      processor family likes them: low order byte first, high order byte
  1429.      last. 
  1430.  
  1431.      
  1432.  
  1433.  
  1434.      4.8.2 The runtime memory map
  1435.  
  1436.      Currently, the compiler generates code using the "large" or "huge"
  1437.      memory model only. 
  1438.  
  1439.      In the "huge" memory model, each module has its own data and code
  1440.      segments. 
  1441.  
  1442.      In the "large" memory model, each module has its own code segment. 
  1443.      The entire program has one data segment. 
  1444.  
  1445.      The linker binds all the code segments first, and then all the data
  1446.      segments.  The stack is allocated above the data segments.  All the
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.      The Compiler                                                        23
  1454.      
  1455.  
  1456.      remainning memory is available for the heap. 
  1457.  
  1458.      When a program is loaded for execution, here is what the memory looks
  1459.      like:
  1460.  
  1461.  
  1462.           From low to high addresses:
  1463.  
  1464.           0         ----------------------------------------------
  1465.                     I  Interrupt vectors                         I
  1466.                     I  DOS                                       I
  1467.           PSP       I  Program segment prefix                    I
  1468.           PSP+100h  I  Program Code segments                     I
  1469.                     I  Program Data segment(s)                   I
  1470.           StackSeg  I  Stack                                     I
  1471.           HeapTop   I  Heap                                      I
  1472.                     I  ...                                       I
  1473.                     I  DOS Command (resident portion)            I
  1474.           MemTop    ----------------------------------------------
  1475.  
  1476.      Label names on the left are the ones exported by System.
  1477.  
  1478.      This system uses interrupt vector 192 (0C0H) at location 0000:0300.
  1479.      Interrupt 192 is issued by a program when a runtime error occurs, when
  1480.      HALT is invoked or when a coroutine other than the main one terminates
  1481.      via a return. 
  1482.  
  1483.      The first word (offset 0) in every code segment contains the data
  1484.      segment value for that particular module (for the program, in the case
  1485.      of the "large" memory model. 
  1486.  
  1487.  
  1488.      4.8.3 Procedure calling conventions
  1489.  
  1490.      Procedure parameters are pushed into the stack 1st argument first. 
  1491.      Control is then transferred to the procedure through a FAR call.  It
  1492.      is the called procedure's responsibility to remove its parameters from
  1493.      the stack before returning. 
  1494.  
  1495.      
  1496.  
  1497.  
  1498.      4.8.3.1 Parameter passing (all except open array parameters)
  1499.  
  1500.      If the formal parameter of a procedure is a value parameter, the
  1501.      actual parameter is copied into the stack. 
  1502.  
  1503.      If the formal parameter is a variable parameter (VAR), the address of
  1504.      the actual parameter is pushed into the stack (first the segment
  1505.      portion of the address and then the offset part). 
  1506.  
  1507.      
  1508.  
  1509.  
  1510.      4.8.3.2 Parameter passing (open array parameters)
  1511.  
  1512.      If the formal parameter is an open array, the address and HIGH value
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.      The Compiler                                                        24
  1520.      
  1521.  
  1522.      of the corresponding formal parameter are pushed into the stack (HIGH
  1523.      value first, and then the address, as above). 
  1524.  
  1525.      If the open array parameter is a value parameter, the value of the
  1526.      actual parameter is copied into the stack on procedure entry. 
  1527.  
  1528.      
  1529.  
  1530.  
  1531.      4.8.3.3 Returning values from a function procedure
  1532.  
  1533.      One byte results are returned in AL, two byte results are returned in
  1534.      AX, and four byte results are returned in DX:AX (DX has the high order
  1535.      part of the result). 
  1536.  
  1537.      
  1538.  
  1539.  
  1540.  
  1541.  
  1542.      4.9 Module priorities
  1543.  
  1544.  
  1545.      Eight module priority levels are supported in this implementation,
  1546.      from 0 (highest priority) to 7.
  1547.  
  1548.      Priorities are implemented by masking off, on the 8259 interrupt
  1549.      controller, all the interrupts at or below the current priority
  1550.      level. 
  1551.  
  1552.      Because the PC usually runs with several of the interrupt levels
  1553.      disabled, it is not easy to decide what the interrupt mask for the
  1554.      value for "no priority" should be for your particular application. 
  1555.      The implementation of NEWPROCESS, therefore, assumes that you have
  1556.      enabled all the interrupts that your program will be capable of
  1557.      processing before you create your processes.  The value in the
  1558.      interrupt mask register of the 8259 at the time of process creation
  1559.      will determine the initial priority level of this process, once it
  1560.      gets started.  Because of this, invoking NEWPROCESS from inside a
  1561.      priority module is usually not what you want to do! 
  1562.  
  1563.      Execution priorities are changed when entering/exitting procedures in
  1564.      modules that have a priority specification, and during the execution
  1565.      of some form of a TRANSFER.
  1566.  
  1567.      We highly recommend that you study the communications program
  1568.      provided, paying particular attention to the module Kernel, for an
  1569.      example of how to use priorities with this system. 
  1570.  
  1571.      NOTE: The compiler does not restrict the priority level specified (any
  1572.      number will do).  You must, therefore, exercise care in defining a
  1573.      module's priority level.  On the other hand, it is easy to add
  1574.      additional priority levels by simply modifying the runtime module
  1575.      M2Procs.
  1576.  
  1577.      
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.      The Compiler                                                        25
  1586.      
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.      4.10 Memory models
  1593.  
  1594.  
  1595.      In general, you may compile the same code under either the LARGE or
  1596.      the HUGE memory model. 
  1597.  
  1598.      The only factor to consider is when using inline assembler. 
  1599.  
  1600.      Under the HUGE memory model, the compiler generates code to reload DS
  1601.      after any invocation of an imported procedure or a VARiable
  1602.      procedure.  Under the LARGE memory model, this is not necessary as a
  1603.      single data segment is defined.  If you write some inline assembler
  1604.      code that modifies DS, please restore it, even if the next thing you
  1605.      do is a RETurn; this way, your routine will work regardless of whether
  1606.      you use the LARGE or the HUGE memory model. 
  1607.  
  1608.      Under the HUGE memory model, access to external variables is done
  1609.      through an indirect pointer, whereas in the LARGE memory model the
  1610.      external variable resides in the programs ONLY data segment and is,
  1611.      therefore directly accessible. 
  1612.  
  1613.      
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.      The Text Editor                                                     26
  1652.      
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.                                     Chapter 5
  1661.  
  1662.                                  The Text Editor
  1663.  
  1664.  
  1665.  
  1666.      The text editor included in this package has all the features that you
  1667.      have come to expect from a basic program editor: the ability to
  1668.      insert, delete, move, find and replace text; support for concurrent
  1669.      editing of multiple files (as many as will fit in memory) in separate
  1670.      windows (as many as will fit on the screen) with the ability to copy
  1671.      or move text from window to window. 
  1672.  
  1673.      Although you may load the same file in two different windows, the
  1674.      editor will not be aware of the fact and will treat the two copies as
  1675.      two different files. 
  1676.  
  1677.      The only preset limitation in the editor is that it cannot handle
  1678.      files bigger than 64k. This decision was justified by the fact that
  1679.      Modula-2 programs are supposed to be modular.  File load/save speed
  1680.      was the overriding factor here. 
  1681.  
  1682.      All the text editor keys are defined by the user through the use of
  1683.      the EDCONFIG program.  When the editor starts, it expects to find the
  1684.      file M2ED.CFG in the current PATH.
  1685.  
  1686.      M2ED.CFG will also tell the editor what display colors (attributes) to
  1687.      use for the Status line, for Normal text and for Marked text blocks. 
  1688.  
  1689.      Finally, M2ED.CFG also contains the default settings for the TAB size
  1690.      value, as well as whether or not the editor will expand the tabs
  1691.      inserted into the text spaces.  Note: Tabs present in a file will not
  1692.      be expanded to spaces by the editor. 
  1693.  
  1694.      To get you started, we provide a M2ED.CFG file with the following
  1695.      definitions:
  1696.  
  1697.           Cursor left                    : Left
  1698.           Cursor right                   : Right
  1699.           Cursor up                      : Up
  1700.           Cursor down                    : Down
  1701.           Previous word                  : ^Left
  1702.           Next word                      : ^Righ
  1703.           Page up                        : PgUp
  1704.           Page down                      : PgDn
  1705.           Cursor to beginning of line    : Home
  1706.           Cursor to end of line          : End
  1707.           Cursor to top of window        : ^Home
  1708.           Cursor to bottom of window     : ^End
  1709.           To beginning of file           : ^PgUp
  1710.           To end of file                 : ^PgDn
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.      The Text Editor                                                     27
  1718.      
  1719.  
  1720.           Current line to top of window  : AltT
  1721.           Toggle insert/overtype         : Ins
  1722.           Delete character under cursor  : Del
  1723.           Delete previous character      : ^H
  1724.           Delete Current Line            : ^Y
  1725.           Delete to EOL                  : AltY
  1726.           Delete Word                    : ^D
  1727.           New file                       : AltN
  1728.           Read file                      : AltR
  1729.           Write block                    : AltW
  1730.           Save file                      : AltS
  1731.           Open window                    : ^O
  1732.           Close Window                   : ^C
  1733.           Next window                    : F2
  1734.           Previous window                : aF2
  1735.           Split screen                   : ^S
  1736.           Mark beginning of block        : F7
  1737.           Mark end of block              : F8
  1738.           Goto beginning of block        : AltB
  1739.           Goto end of block              : AltE
  1740.           Clear block marks              : AltH
  1741.           Copy block                     : AltC
  1742.           Delete block                   : AltD
  1743.           Move block                     : AltM
  1744.           Search forward                 : F5
  1745.           Search backwards               : aF5
  1746.           Replace forward                : F6
  1747.           Replace backwards              : aF6
  1748.           Global replace                 : ^F6
  1749.           Repeat last search/replace     : F1
  1750.           Goto next error                : ^E
  1751.           Goto previous error            : ^P
  1752.           Goto line                      : AltG
  1753.           Set options                    : AltO
  1754.           Redraw the screen              : ^L
  1755.           Quit                           : AltQ
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.      The Linker                                                          28
  1784.      
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.                                     Chapter 6
  1793.  
  1794.                                    The Linker
  1795.  
  1796.  
  1797.  
  1798.      The linker is invoked by the command line
  1799.  
  1800.           M2LINK myprog [/s n] [/h n] [/o] [/p] [/l] [/swap [path]]
  1801.  
  1802.      where 'myprog' is the main module of the program you are creating. 
  1803.      The options are thus:
  1804.  
  1805.      /s n              n is the size of the stack to allocate (default is
  1806.                        4096).
  1807.  
  1808.      /h n              n is the amount of space to reserve for the heap (in
  1809.                        paragraphs).  The default is all the free memory. 
  1810.  
  1811.      /o                invokes the optimizer.  The optimizer prevents the
  1812.                        output, to the object file, of all the procedures
  1813.                        that are part of included modules but are not
  1814.                        referenced.  This will make your final EXE files
  1815.                        smaller. 
  1816.  
  1817.      /p                tells the linker to include the profiler
  1818.                        (M2Prof.M2O). For further information, see the
  1819.                        chapter on "Utilities".
  1820.  
  1821.      /l                tells the linker to process the line number
  1822.                        information in the .M2O files and include it in the
  1823.                        .DBG file.  This option is disabled if the optimizer
  1824.                        is invoked. 
  1825.  
  1826.      /k                tells the linker to ignore module keys, i.e.  to not
  1827.                        check for module version compatibility.  This option
  1828.                        should be used with extreme care. 
  1829.  
  1830.      /swap [path]      tells the linker to use a swap file.  Code segments
  1831.                        will be kept in this swap file instead of in main
  1832.                        memory during the link process.  This allows you to
  1833.                        link larger programs. 
  1834.  
  1835.      The linker creates two files: the .EXE file is your executable
  1836.      program, the .DBG file is a file containning symbol information for
  1837.      use by other utilities (see Map file generator, Profiler).
  1838.  
  1839.      If the /swap directive is used, a swap file is created.  You may
  1840.      select the path (drive:directory) where the swap file is to be
  1841.      created.  Example:
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.      The Linker                                                          29
  1850.      
  1851.  
  1852.           M2LINK myprog /swap D:
  1853.  
  1854.  
  1855.  
  1856.  
  1857.      6.1 Module keys
  1858.  
  1859.  
  1860.      The module header record and the import records written out by the
  1861.      compiler to the object file are stamped with the date of the .DEF file
  1862.      that was processed - this becomes the module key.  The linker will
  1863.      assure that these module keys in the module header of the imported
  1864.      module and in the import record match; If they do not match, both
  1865.      modules were not compiled using the same definition module. 
  1866.  
  1867.      Because of the use of module keys, it is imperative that the date of
  1868.      the distributed .DEF files not be modified unless you intend to
  1869.      recompile the implementation modules. 
  1870.  
  1871.      
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.      Other utilities                                                     30
  1916.      
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.                                     Chapter 7
  1925.  
  1926.                                  Other utilities
  1927.  
  1928.  
  1929.  
  1930.      
  1931.  
  1932.  
  1933.  
  1934.  
  1935.      7.1 Editor configurator
  1936.  
  1937.  
  1938.      This program lets you define the keystrokes to be used to invoke all
  1939.      the editor commands, the screen attributes (colors) to use, and the
  1940.      default editor options. 
  1941.  
  1942.      Invokation:
  1943.  
  1944.           EDCONFIG
  1945.  
  1946.      EdConfig presents you with a menu from which you may elect to modify
  1947.      the default editor options, the display attributes, or configure the
  1948.      editor commands. 
  1949.  
  1950.      If you are creating a new configuration file, you must configure the
  1951.      editor commands. 
  1952.  
  1953.      If you chose to configure the editor commands, you will be prompted
  1954.      for a log file (default M2ED.HLP), a text file in which all of your
  1955.      command choices will be saved.  You may print this file to create a
  1956.      quick reference card.  EDCONFIG will then prompt you for the key
  1957.      sequence to be used for each editor command.  For each command,
  1958.      EDCONFIG will also give you the option of defining an alternate key
  1959.      sequence. 
  1960.  
  1961.      When you select Quit, the program will prompt you for an output file,
  1962.      the default being 'M2ED.CFG'.
  1963.  
  1964.      
  1965.  
  1966.  
  1967.  
  1968.  
  1969.      7.2 Map file generator
  1970.  
  1971.  
  1972.      Invokation:
  1973.  
  1974.           DBG2MAP program_name
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.      Other utilities                                                     31
  1982.      
  1983.  
  1984.  
  1985.      Reads the .DBG file created by M2LINK and creates a DOS LINK
  1986.      compatible .MAP file. 
  1987.  
  1988.      
  1989.  
  1990.  
  1991.  
  1992.  
  1993.      7.3 Make and the Makefile generator
  1994.  
  1995.  
  1996.      These utilities eliminate the burden, on the user's part, of having to
  1997.      figure out which modules are affected and, therefore, need to be
  1998.      recompiled as a result of any changes to particular definition
  1999.      modules. 
  2000.  
  2001.      GENMAKE creates the .MAK file, the file with all the dependencies
  2002.      (this is the hard part) whereas MAKE (built into the compiler) will
  2003.      insure that these dependencies are observed when updating the object
  2004.      files. 
  2005.  
  2006.      GENMAKE Invokation:
  2007.  
  2008.           GENMAKE main_module_name
  2009.  
  2010.      generates the .MAK file containning all the module dependencies for
  2011.      the named program.  It does this by reading all the IMPORT statements
  2012.      in the main module and, recursively, generating the dependency lists
  2013.      for all those modules (but only the ones that can be found in the
  2014.      current directory!).  GENMAKE will indeed read all the .MOD and .DEF
  2015.      files involved. 
  2016.  
  2017.      MAKE invocation: see "Running the Compiler".
  2018.  
  2019.      MAKE will invoke the compiler as needed to assure that all the
  2020.      dependencies in the make file are observed.  MAKE is dumb in that it
  2021.      will just run through the makefile sequentially.  It was GENMAKE's
  2022.      responsibility to see that the dependencies are listed in a proper
  2023.      sequence.  Please keep this in mind if you should edit a makefile! 
  2024.  
  2025.      
  2026.  
  2027.  
  2028.  
  2029.  
  2030.      7.4 The execution profiler
  2031.  
  2032.  
  2033.      When you link your program with the /p option, the module M2Prof is
  2034.      included in the output generated. 
  2035.  
  2036.      When you execute the program, the profiler will ask you for the name
  2037.      of the .DBG file to use and give you an option of profiling your
  2038.      entire program (generating an execution profile by module), a
  2039.      particular module (generating an execution profile by procedure in
  2040.      that module) or a particular procedure (generating an execution
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.      Other utilities                                                     32
  2048.      
  2049.  
  2050.      profile by line in the procedure). 
  2051.  
  2052.      Upon program termination, the profiler outputs the list of all the
  2053.      modules/procedures/lines profiled, ranked by execution time, to a file
  2054.      of your choice. 
  2055.  
  2056.      This profiler is not that versatile, but it is useful nevertheless. 
  2057.      It proved instrumental in pinpointing some obvious areas for
  2058.      improvement in the compiler (Oh, we did not tell you, did we?  This
  2059.      compiler was written in the language it compiles -- Modula-2 -- and
  2060.      this system was used as our primary development tool since very early
  2061.      in the development process). 
  2062.  
  2063.      
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.      The Library Modules                                                 33
  2114.      
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.                                     Chapter 8
  2123.  
  2124.                                The Library Modules
  2125.  
  2126.  
  2127.  
  2128.      For complete information on what each library module provides, as well
  2129.      as its proper usage, please refer to the .DEF files. 
  2130.  
  2131.      In addition, the source code of all the library modules is available
  2132.      to all the registered users (see the order form in the back of this
  2133.      document for details). 
  2134.  
  2135.      
  2136.  
  2137.  
  2138.  
  2139.  
  2140.      8.1 Release 1.1 libraries
  2141.  
  2142.  
  2143.      In this release, several library modules were "extended". We have not
  2144.      created any source level incompatibility with the old library modules,
  2145.      that we are aware of.  But you will have to recompile all your
  2146.      programs, as they will not link with the new library modules. 
  2147.  
  2148.      Because of the implementation of module priorities, the new M2PROCS
  2149.      runtime support module has additional routines and different
  2150.      interfaces for the old ones. 
  2151.  
  2152.      
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.      Shareware                                                           34
  2180.      
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.                                     Chapter 9
  2189.  
  2190.                                     Shareware
  2191.  
  2192.  
  2193.  
  2194.      This software package is distributed as Shareware.
  2195.  
  2196.      Shareware distribution gives users a chance to try this software
  2197.      before buying it.  Besides, by using this distribution method, we
  2198.      eliminate the high cost of publishing and advertising (our users do it
  2199.      for us) and can, therefore, provide the same product for less. 
  2200.  
  2201.      If you try this program and continue to use it, you are expected to
  2202.      register it. 
  2203.  
  2204.      This software can be freely distributed, as long as no money is
  2205.      charged for it, all the files are included, unmodified, and with their
  2206.      modification dates preserved.  If you are going to place this software
  2207.      on a bulletin board (we thank you for it), please upload it in a
  2208.      library format (we suggest ARC) that will preserve this package's
  2209.      integrity. 
  2210.  
  2211.      This software cannot be distributed as a part of, or in conjunction
  2212.      with, another product. 
  2213.  
  2214.      This software cannot be used in a commercial environment without the
  2215.      payment of a $25 (as of this writing) license fee per copy. 
  2216.  
  2217.      Our success will depend not only on the quality of this software but
  2218.      on the willingness of every individual user to "support" its
  2219.      developers. 
  2220.  
  2221.      If you use this product, please send in the registration form in the
  2222.      back of this document, along with your registration fee.  For $35 (as
  2223.      of this writing) we will send you the latest version of this software
  2224.      and all the library and runtime support source code (what a
  2225.      bargain!).  This source code is made available to registered users
  2226.      only! 
  2227.  
  2228.      Whether or not you use this product, please give complete copies of
  2229.      this software to others (the more the better).  You are an integral
  2230.      part of our distribution channel! 
  2231.  
  2232.      
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.      License terms                                                       35
  2246.      
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.                                    Chapter 10
  2255.  
  2256.                                   License terms
  2257.  
  2258.  
  2259.  
  2260.      Before you register this product and become a licensed user, you are
  2261.      granted a limitted license to evaluate the product to determine
  2262.      whether or not it will fit your needs.  Use of this system for any
  2263.      other purpose, before registration and without our written consent, is
  2264.      expressly forbidden. 
  2265.  
  2266.      Registered users are given a non-exclusive license to use this
  2267.      software on any machine that they have access to, but not on more than
  2268.      one at a time (the "treat this software like a book" idea). 
  2269.  
  2270.      Registered users may modify the source code provided to suit their
  2271.      needs, but this source code (in original or modified form) may not be
  2272.      distributed without the prior written consent of Fitted Software
  2273.      Tools.
  2274.  
  2275.      Registered users may include compiled portions of the library and
  2276.      runtime support code in the programs by them developed, and use or
  2277.      distribute these programs without payment of any additional license
  2278.      fees to Fitted Software Tools.
  2279.  
  2280.      
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.      Support                                                             36
  2312.      
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.                                    Chapter 11
  2321.  
  2322.                                      Support
  2323.  
  2324.  
  2325.  
  2326.      Our basic philosophy is very simple: Without happy users, we do not
  2327.      have a business -- or, at least, we will not have one for long! 
  2328.  
  2329.      We will do everything in our power to assure that our users get the
  2330.      kind of support that they deserve and we can afford to provide. 
  2331.  
  2332.      Above all, we do not want to create false expectations on the part of
  2333.      our users, the reason for this chapter. 
  2334.  
  2335.      We will provide our registered users with support either by mail or
  2336.      through our newly installed BBS, at 404/497-0931. We much prefer that
  2337.      you use our BBS to contact us, if at all possible. 
  2338.  
  2339.      The advantages of using the BBS are: all users get immediate
  2340.      notification of bugs and fixes; It encourages users to participate in
  2341.      finding resolution to "how to" type questions. 
  2342.  
  2343.      We cannot, of course, promise to fix any bug that you may find within
  2344.      a certain period of time.  As a matter of fact, we do not even promise
  2345.      to fix any and all bugs that you may find, but we will try...  When a
  2346.      fix is not imminent, we will try to give you a workaround procedure,
  2347.      so that you may go on with your work. 
  2348.  
  2349.      As we fix bugs, we will make the new versions of the affected programs
  2350.      available for download from the BBS. Should this not be acceptable to
  2351.      you, you may elect to have the fixes mailed to you, for $5 to cover
  2352.      media and handling charges. 
  2353.  
  2354.      We will also make all new product updates available for download. 
  2355.  
  2356.      In those cases where a reported bug gets fixed only in a later release
  2357.      of the product, the first user reporting the bug has the option of
  2358.      getting that update by mail for the $5 that we charge to ship bug
  2359.      fixes. 
  2360.  
  2361.      Registered users have the option of getting software updates by mail
  2362.      instead of downloading them.  The current price of such updates is
  2363.      $12.
  2364.  
  2365.      
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.  
  2374.  
  2375.  
  2376.  
  2377.      Your input matters to us                                            37
  2378.      
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.                                    Chapter 12
  2387.  
  2388.                             Your input matters to us
  2389.  
  2390.  
  2391.  
  2392.      You can bet that this is serious!  We know, and you know, that there
  2393.      are many ways in which this system can be improved.  It is in our
  2394.      common interest that we agree on just how (what needs changing, what
  2395.      additional capabilities are needed) and when (let's take care of the
  2396.      more important stuff first!). 
  2397.  
  2398.      Maybe you like this software so much that you would hate to see us
  2399.      improve it in the wrong direction (ha, ha, ha)... 
  2400.  
  2401.      Maybe you find some weaknesses in this product that make it awkward to
  2402.      use. 
  2403.  
  2404.      Maybe even (God forbid!)  that one or more of those weaknesses make
  2405.      this software unusable for your purposes. 
  2406.  
  2407.      Whichever the case may be, we need to know about it, our future is at
  2408.      stake!!! 
  2409.  
  2410.      So, please!, fill out the survey form and send it in. 
  2411.  
  2412.      
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.                        Your comments would be appreciated
  2446.  
  2447.      
  2448.  
  2449.  
  2450.  
  2451.      How did you first learn about this product?
  2452.  
  2453.           ---------------------------------------------------------
  2454.  
  2455.      Where did you get this software from?
  2456.  
  2457.           ( ) us                   ( ) a bulletin board
  2458.           ( ) a friend                 phone # ___ ___ ____
  2459.           ( ) a computer club      ( ) a shareware software distributor
  2460.           ( ) other ________________________
  2461.  
  2462.      Systems you intend to use this software on
  2463.  
  2464.           ( ) PC (8088/8086)       ( ) AT (80286)      ( ) 80386
  2465.  
  2466.      Typical system's configuration
  2467.  
  2468.           ( ) hard disk
  2469.           ( ) 512k       ( ) 640k
  2470.           ( ) extended memory
  2471.           ( ) expanded memory (EMS, EEMS)
  2472.           ( ) EGA adapter
  2473.           ( ) VGA adapter
  2474.  
  2475.      What programming languages do you use regularly?
  2476.  
  2477.           ---------------------------------------------------------
  2478.  
  2479.      What do you like the most about this system?
  2480.  
  2481.           _____________________________________________________________
  2482.           _____________________________________________________________
  2483.           _____________________________________________________________
  2484.           _____________________________________________________________
  2485.           _____________________________________________________________
  2486.  
  2487.      What do you NOT like about this system?
  2488.  
  2489.           _____________________________________________________________
  2490.           _____________________________________________________________
  2491.           _____________________________________________________________
  2492.           _____________________________________________________________
  2493.           _____________________________________________________________
  2494.  
  2495.      Other comments / suggestions:
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.                                    BUG REPORT
  2512.  
  2513.      We would like to think that our software is bug free, but we have been
  2514.      around a while.  Someone once wrote that a bug free program is a
  2515.      program whose bugs have not been uncovered yet. 
  2516.  
  2517.      So, if you uncover one of those nasty critters, please provide us with
  2518.      the information below, and whatever else that may help us duplicate
  2519.      the problem. 
  2520.  
  2521.  
  2522.      Name_____________________________________________
  2523.  
  2524.      Company__________________________________________
  2525.  
  2526.      Address__________________________________________
  2527.  
  2528.      City, State, Zip_________________________________
  2529.  
  2530.      Telephone _____________
  2531.  
  2532.  
  2533.      Version of the software in use:  ___________________________
  2534.  
  2535.      Machine in use (make and model): ___________________________
  2536.  
  2537.      Memory / Disks / Display type:   ___________________________
  2538.  
  2539.      Operating system used:           ___________________________
  2540.  
  2541.      Other system information that may be pertinent (PATH settings,
  2542.      CONFIG.SYS contents,...) 
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.      Problem description:
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.                                    ORDER FORM
  2578.  
  2579.  
  2580.  
  2581.  
  2582.      Mail this form to:
  2583.  
  2584.           Fitted Software Tools
  2585.           P.O.Box 956129
  2586.           Duluth, Ga 30136
  2587.  
  2588.      to register your copy/copies of the Modula-2 compiler, register/order
  2589.      additional copies, and/or order updates. 
  2590.  
  2591.      We distribute the software and documentation on 360k floppies.  A
  2592.      printed version of the manual is not available yet. 
  2593.  
  2594.      The unauthorized distribution of the library and runtime support
  2595.      source code included in the distribution disks that you receive when
  2596.      you order a registered copy or update is specifically prohibited. 
  2597.      This source code is made available to registered users only. 
  2598.  
  2599.      If you are ordering multiple copies for your organization (or for you
  2600.      and your friends), we would suggest that you order 1 of the $35 ($39)
  2601.      packages and the rest as $25 ($29) registrations.  You may then
  2602.      distribute the number of copies that you ordered from the master that
  2603.      you receive. 
  2604.  
  2605.  
  2606.      Name_____________________________________________
  2607.  
  2608.      Company__________________________________________
  2609.  
  2610.      Address__________________________________________
  2611.  
  2612.      City, State, Zip_________________________________
  2613.  
  2614.  
  2615.      QTY
  2616.      ___   X   Registration @ $25.00 (*)                  _________
  2617.  
  2618.      ___   X   Registration & latest version @ $35.00 (*) _________
  2619.  
  2620.      ___   X   diskette updates @$12.00                   _________
  2621.  
  2622.                4% Sales tax (GA residents)                _________
  2623.  
  2624.      Total enclosed:                                      _________
  2625.  
  2626.  
  2627.      If ordering the latest version, please specify how long you are
  2628.      willing to wait for a new, imminent update ____________________
  2629.  
  2630.  
  2631.      (*) After March 1/1988 the prices are $29 and $39.
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.                            Table of Contents
  2647.  
  2648.  
  2649.      Chapter 1 Introduction                                           2
  2650.  
  2651.         1.1 Hardware requirements                                     3
  2652.         1.2 Software requirements                                     3
  2653.         1.3 What is new in version 1.1                                3
  2654.         1.4 As version 1.0 becomes history...                         4
  2655.  
  2656.      Chapter 2 Software installation                                  5
  2657.  
  2658.         2.1 Theory                                                    5
  2659.         2.2 Recommended setup for a system with 2 floppy drives
  2660.                                                                       6
  2661.         2.3 Recommended setup for a hard disk system                  7
  2662.  
  2663.      Chapter 3 A little tour through the system                       8
  2664.  
  2665.         3.1 The tour                                                  8
  2666.  
  2667.      Chapter 4 The Compiler                                           11
  2668.  
  2669.         4.1 Running the compiler                                      12
  2670.         4.2 The compilation process                                   13
  2671.  
  2672.               4.2.0.1 The input file                                  13
  2673.               4.2.0.2 The imported modules                            13
  2674.               4.2.0.3 The output file                                 14
  2675.               4.2.0.4 A warning                                       14
  2676.  
  2677.         4.3 Compiler directives                                       14
  2678.         4.4 Runtime errors                                            15
  2679.  
  2680.            4.4.1 Trapping runtime errors in your program              15
  2681.  
  2682.         4.5 Compiler size limits                                      16
  2683.         4.6 The language supported                                    16
  2684.  
  2685.            4.6.1 LONGINT and LONGCARD                                 17
  2686.            4.6.2 Additional standard procedures                       17
  2687.  
  2688.               4.6.2.1 NEW and DISPOSE                                 17
  2689.               4.6.2.2 LONG and SHORT                                  18
  2690.  
  2691.         4.7 Objects exported by the pseudo module SYSTEM              18
  2692.  
  2693.               4.7.0.1 TYPE BYTE                                       18
  2694.               4.7.0.2 TYPE WORD                                       18
  2695.               4.7.0.3 TYPE ADDRESS                                    19
  2696.               4.7.0.4 SEG and OFS                                     19
  2697.               4.7.0.5 PROCEDURE ADR                                   19
  2698.               4.7.0.6 PROCEDURE FLAT                                  19
  2699.               4.7.0.7 PROCEDURE PTR                                   19
  2700.               4.7.0.8 PROCEDURE SEGMENT                               19
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.               4.7.0.9 PROCEDURE OFFSET                                19
  2709.               4.7.0.10 PROCEDURE NEWPROCESS                           20
  2710.               4.7.0.11 PROCEDURE TRANSFER                             20
  2711.               4.7.0.12 PROCEDURE IOTRANSFER                           20
  2712.               4.7.0.13 ASSEMBLER                                      20
  2713.  
  2714.         4.8 The generated object code                                 21
  2715.  
  2716.            4.8.1 Data type representation                             22
  2717.            4.8.2 The runtime memory map                               22
  2718.            4.8.3 Procedure calling conventions                        23
  2719.  
  2720.               4.8.3.1 Parameter passing (all except open array
  2721.                     parameters)                                       23
  2722.               4.8.3.2 Parameter passing (open array parameters)
  2723.                                                                       23
  2724.               4.8.3.3 Returning values from a function procedure
  2725.                                                                       24
  2726.  
  2727.         4.9 Module priorities                                         24
  2728.         4.10 Memory models                                            25
  2729.  
  2730.      Chapter 5 The Text Editor                                        26
  2731.  
  2732.      Chapter 6 The Linker                                             28
  2733.  
  2734.         6.1 Module keys                                               29
  2735.  
  2736.      Chapter 7 Other utilities                                        30
  2737.  
  2738.         7.1 Editor configurator                                       30
  2739.         7.2 Map file generator                                        30
  2740.         7.3 Make and the Makefile generator                           31
  2741.         7.4 The execution profiler                                    31
  2742.  
  2743.      Chapter 8 The Library Modules                                    33
  2744.  
  2745.         8.1 Release 1.1 libraries                                     33
  2746.  
  2747.      Chapter 9 Shareware                                              34
  2748.  
  2749.      Chapter 10 License terms                                         35
  2750.  
  2751.      Chapter 11 Support                                               36
  2752.  
  2753.      Chapter 12 Your input matters to us                              37
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.  
  2773.