home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / M2V11-1.LHA / modula / docs / TURBO.DOC < prev   
Encoding:
Text File  |  1994-10-03  |  13.2 KB  |  351 lines

  1. ================================================================================
  2.  
  3.                             Turbo Modula-2 V1.1 (27/9/94)
  4.  
  5.     Turbo Modula-2 (c) Copyright 1994 by Amritpal Mann, All Rights Reserved
  6.  
  7.     Email: amrit@econet.demon.co.uk
  8.  
  9. ================================================================================
  10.  
  11.     This is a freely distributable Modula-2 development system.
  12.     The version of Modula supported is as described in Niklaus Wirth's book:
  13.     Programming in Modula-2, 4th edition (Springer-Verlag)
  14.  
  15.     Turbo Modula-2 consists of:
  16.  
  17.         A compiler(M2C), a link utility(M2L), an error lister(M2E),
  18.         and a program builder(M2B).
  19.         Interface modules for V40 of the AmigaOS & corresponding linker library,
  20.         ANSI C standard library definitions as well as those from PIM.
  21.  
  22.     The compiler reads source code in a single pass which means fast
  23.     compilation. Internally however it performs several passes over each
  24.     procedures statement sequence in order to generate fast and compact code.
  25.     Typically, generated code is 25% smaller & 75% faster than the
  26.     commercial Amiga Modula-2 compiler used for the initial bootstraps.
  27.  
  28.     Turbo does not have its own linker, instead it requires a 'C' compiler
  29.     front-end to link generated code.
  30.     The unregistered freeware version of Matt Dillon's excellent C system,
  31.     DICE, has been included and contains 2 necessary programs, DCC & DLINK,
  32.     as well as vital startup code(c.o) and support libraries(c.lib,auto.lib,x.o)
  33.     Note that Turbo does NOT produce 'C' as intermediate output, it just uses
  34.     DCC to link and add startup code the machine code it generates.
  35.  
  36.     You do not need to know how to use DICE in order to generate M2 executables,
  37.     M2L calls DCC for you , all you need do is extract DICE (see below).
  38.     The reason for using DICE instead of say BLINK, are that DICE has excellent
  39.     support for generating residentable programs, also the standard C library
  40.     supplied with DICE becomes automatically available and finally
  41.     (for those of us who have slow(er) amigas) DLINK runs fast!
  42.  
  43.     The unregistered freeware version of DICE may only be distributed complete &
  44.     unmodified.This also applies to Turbo Modula-2.
  45.  
  46.     The minimum required setup in order to use Turbo is 1MB of memory
  47.     and 1.2(V33) workbench & 1 disk drive. However I recommend
  48.     that you should have at least 1MB of available(free) memory and a hard disk.
  49.     M2B will not propagate ^C break detection to M2C & M2L unless you're
  50.     running under atleast V36 of dos.library.
  51.     To use M2B you really need a real-time clock or otherwise set the time at
  52.     bootup or instead use M2C & M2L directly.
  53.     If you dont have a RTC you can use a software hack: examples/src/IncTime.mod
  54.  
  55. Dice Extraction
  56. ===============
  57.  
  58.     The file dice/dice.lha contains the DICE system.In order to save your
  59.     hard disk space, the dice/M2EXTRACT script will extract the files that we
  60.     are interested in:
  61.  
  62.         >cd dice
  63.         >execute M2EXTRACT
  64.  
  65.     You can of course extract the entire archive if you prefer.
  66.     If you already have DICE installed on your system, and are therefore not
  67.     extracting it again, you should delete the appropriate lines in the
  68.     s/startup script.
  69.  
  70. Installation
  71. ============
  72.  
  73.     Add the following lines to your s:user-startup (startup-sequence under 1.3):
  74.  
  75.     >assign MODULA: <dir> ; <dir> = directory where you unarchived Turbo
  76.     >execute MODULA:s/startup
  77.  
  78. Directory Organisation
  79. ======================
  80.  
  81.     docs/
  82.  
  83.     M2OPTS      Default M2OPTS file (see below).
  84.  
  85.     examples/   Some example programs
  86.  
  87.     amiga/    20000 lines of definition modules for V40 of the AmigaOS,
  88.             these files were hand translated from Commodores header files.
  89.  
  90.     ansi-c/     Definition for the Ansi-C library that comes with DICE.
  91.  
  92.     sym/        Symbol files for above definition modules.
  93.  
  94.     obj/        Compiled object modules, mainly from the implementation modules
  95.                 for the definition modules in /amiga/. On startup these modules
  96.                 normally open the required amiga libraries (intuition etc).
  97.  
  98.     lib/        Modula-2 support code.
  99.  
  100.     m2lib    M2Lib.def
  101.  
  102.     bin/        Residentable executables for M2C, M2B, M2E & M2L.
  103.                 All these programs were developed completely from scracth by
  104.                 me, the initial M2C bootstrap was done using M2Amiga.
  105.                 These programs are only runable from the shell.
  106.  
  107.     dice/       DICE system. If you want to redistribute DICE then you must
  108.         include all the files in the dice.lha archive.
  109.  
  110.     s/        Contains startup script.
  111.  
  112. Filename extensions
  113. ===================
  114.  
  115.     *.err    Binary error file generated by M2C & M2B, used by M2E.
  116.     *.mod    Program/implementation module (ascii text).
  117.     *.def    Definition module (ascii text).
  118.     *.o      Standard Amiga object file, generated by M2C from a *.mod file.
  119.     *.sym    Symbol file generated by M2C from a *.def file.
  120.     *.lib    Linker Library. A concatenation of *.o files.
  121.     *.lnk    Linker object file list(ascii), written to the T: directory by M2L,
  122.              read by DCC.
  123.  
  124. Error Lister (M2E)
  125. ==================
  126.  
  127.     If M2B or M2C encounter errors while processing a source file, then a
  128.     binary error file will be generated.
  129.     Use M2E to view the errors encoded in this file.
  130.  
  131.     usage: m2e modulename
  132.  
  133. Program Builder (M2B)
  134. =====================
  135.  
  136.     M2B will take care of compilation and linking for you.It checks file
  137.     timestamps to see which files need to be (re)compiled/(re)linked.
  138.  
  139.     M2B is like MAKE, but instead of using a makefile it scans import lists.
  140.  
  141.     usage: m2b [-f][-v][-t] [compile/link options] filename [DCC options & args]
  142.  
  143.     -f: Force all time comparisons to fail(all modules will be (re)compiled).
  144.  
  145.     -v: Write out the name of each file as it is read.
  146.  
  147.     -t: Don't actually call M2C & M2L just print the commands that would have
  148.         been executed.
  149.  
  150.     example:
  151.  
  152.                                 /-------- -s passed to DCC
  153.       >m2b -v -p -b -q foo.mod -s
  154.                ^--^--^------------------ -p -b -q are compiler(M2C) options
  155.                                          -q is also an M2L option.
  156.  
  157.     Assuming that foo.o is older than foo.mod and foo.mod does not import
  158.     any other module then M2B will call M2C & M2L as
  159.  
  160.       m2c -p -b -q foo.mod
  161.       m2l -q foo.o -s  (but only if m2c did not fail)
  162.  
  163.     You may find the TOUCH program (in dice/bin/) useful when using M2B.
  164.  
  165. Compiler (M2C)
  166. ==============
  167.  
  168.     usage: m2c [-D][-C][-b][-p][-w][-q][-l] {-Mdir} filename/modulename
  169.  
  170.     -D: Use large data model (default is small data model).
  171.         If your program declares more than 64K of global variables then you must
  172.         enable this option for each constituent module (except library
  173.         modules that were compiled small data & -l), otherwise linking will
  174.         fail. By allocating large data structures on the heap you can easily
  175.         avoid the need to use this option.
  176.  
  177.         Using the small data & code models will make your program more compact.
  178.         Compiling all modules small data will also allow a program to be
  179.         made fully resident.
  180.  
  181.     -C: Use large code model.
  182.         If a module compiles to about 32000 bytes or more, then you may need to
  183.         enable this option (depending on whether linking fails).
  184.         If a module compiles to more than 32767 bytes then you definitely need
  185.         to enable this option.
  186.         The maximum code size using large code is 48K(per module).
  187.  
  188.     -b: Enable array bounds checking.
  189.  
  190.     -p: Enable pointer checking.
  191.         The compiler will insert code to check that all pointer & VAR parameter
  192.         accesses are within a specific range.At the moment the bounds are
  193.         fixed to 1K..16M.If you're Amiga has valid memory outside this range
  194.         (and you're program may access it) then you cannot use this option.
  195.         Programmers who do not have a MMU, may find this option very useful.
  196.         Pointer checking should only be used during program development.
  197.  
  198.         Depending on programming style (access procedures or open structures),
  199.         pointer checking may or may not massively increase the size of a program
  200.         It does not slow down a program by as much as you may expect.
  201.  
  202.     -w: Disable compiler warnings.
  203.  
  204.     -q: Shut the f*ck up.
  205.  
  206.     -l: (equivalent to the DICE option -S)
  207.         Name BSS(global variable space) section libbss instead of just 'bss'.
  208.         Use this option to compile re-usable modules that do not have much BSS.
  209.         This will enable you to use small code library modules with (large code)
  210.         program modules that declare a lot of BSS.This option avoids the need to
  211.         have two different versions (one small & one large) of said modules.
  212.  
  213.     -M: Add dir to the symbol file directory search path.
  214.         If a dir/sym/ subdirectory exists, it will be added instead.
  215.  
  216.     It is possible to set/clear some of these options inside a source text
  217.     by using comments, see extensions.doc.
  218.  
  219.     If a Modula-2 run-time error occurs (illegal case index, halt called,
  220.     array/pointer checking etc) the run time support code (in M2.lib) will
  221.     display a requester with the first 4 letters of the module name and (full)
  222.     line number of where the error occurred.
  223.  
  224.     ¥ou can use DICE DOBJ to view the machine code generated by the compiler.
  225.  
  226.   One pass compilation
  227.   --------------------
  228.  
  229.     The compiler operates in a single pass, this means that you must declare
  230.     variables & procedures before you use them.The compiler provides the FORWARD
  231.     keyword in order to allow early declarations for procedures that are
  232.     implemented later.
  233.  
  234.     PROCEDURE f( ) ; FORWARD ; (* implementation must be in the same scope *)
  235.  
  236.     PROCEDURE g( ) ;
  237.     BEGIN f( ) ;
  238.     END g ;
  239.  
  240.     PROCEDURE f( ) ; (* alternatively we could nest f( ) inside g( ) *)
  241.     BEGIN g( )
  242.     END f ;
  243.  
  244.     If a procedure is declared in a definition module then a forward declaration
  245.     in the corresponding implementation module is never required.
  246.  
  247.   Type sizes & extremal values
  248.   ----------------------------
  249.  
  250.             size (bytes)                range
  251.             ============                =====
  252.  
  253.     SHORTCARD   1                     0 .. 255
  254.     CARDINAL    2                    0  .. 65535
  255.  
  256.     SHORTINT    1                   -128 .. 127
  257.     INTEGER     2                 -32768 .. 32767
  258.     LONGINT     4                -(2^31) .. (2^31)-1
  259.  
  260.     SHORTREAL   4                   Motorola FFP
  261.     REAL        4               IEEE single precision
  262.     LONGREAL    8               IEEE double precision
  263.  
  264.     There is also a LONGCARD datatype which is declared as a
  265.     LONGINT[0..MAX(LONGINT)].
  266.  
  267.  
  268. Linker frontend (M2L)
  269. =====================
  270.  
  271.     M2L calls DCC (which in turn calls DLINK) to link the object modules
  272.     generated by the compiler into an executable file. M2L is itself normally
  273.     called by M2B (M2B->M2L->DCC->DLINK).
  274.  
  275.     Usage: m2l [-q] {-Mdir} module[.o] [DCC options & args]
  276.  
  277.     -q    : Quiet, don't print the path of each file as it is read.
  278.  
  279.     -Mdir : Add directory dir to the object file search path.
  280.             If a dir/obj/ subdirectory exists, it will be added instead.
  281.  
  282.     module: Program (root) module name.
  283.             This object module must be in a local directory
  284.  
  285.     Anything on the command line that follows the module name is passed to DCC.
  286.  
  287.     example: m2l -q foo -s -r
  288.                          ^--^-- passed to dcc.
  289.  
  290.     This will invoke DCC:
  291.  
  292.     dcc -LMODULA:lib @t:foo.lnk -s -r -ofoo
  293.  
  294.     Where t:foo.lnk (intermediate file generated by M2L) will contain:
  295.  
  296.     m2_main.o
  297.     foo.o
  298.     m2.lib
  299.  
  300.     m2_main.o m2.lib are normally in directory MODULA:lib
  301.  
  302.  
  303. M2OPTS
  304. ======
  305.  
  306.     An optional ascii text file named M2OPTS in the MODULA: directory can
  307.     specify M2C and M2L command line options.
  308.  
  309.     M2L filters M2OPTS looking for -q & -M's ignoring all other options.
  310.     Options in M2OPTS are scanned before command line options.
  311.  
  312.     An M2OPTS text in your source directory will override the one in MODULA: .
  313.  
  314. Debugging
  315. =========
  316.  
  317.     Ideally Turbo should include a source level debugger.
  318.     The DCC options '-s' dumps symbols into final executable so you can
  319.     atleast use a low level debugger (eg Devpac Monam), this does however
  320.     require knowledge of 68000 assembler.
  321.  
  322. Bug Reports
  323. ===========
  324.  
  325.     As the library modules are so large they are likely to contain a few
  326.     mistakes.The structure sizes and constant values have been automatically
  327.     verified with those in the commodore header files, however is not easily
  328.     possible to mechanically check the types of all parameters and fields.
  329.     Rare mistakes like *mi : Menu*  instead of  *mi : MenuItem* should be
  330.     detected during compilation: when youre program tries to instantiate the
  331.     parameter/field.
  332.  
  333.     The code called for DIV & MOD are the 68000 versions, which differ from
  334.     those defined in the Modula standard.The difference is only important
  335.     when dealing with negative numbers.
  336.  
  337.     The executables have not been tested under the enforcer program, so
  338.     may cause hits.I have used the pointer checking option (described above)
  339.     so I would be suprised if any occur??
  340.  
  341.     Please report any bugs/comments/suggestions/job offers,ive been unemployed
  342.     since graduating :-(, to amrit@econet.demon.co.uk.
  343.  
  344.     Snail Mail:
  345.  
  346.        Amrit Mann
  347.        1 Blossom Way,
  348.        West Drayton,
  349.        Middlesex,UB7-9HF,
  350.        England(UK).
  351.