home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / icon / dos / bin / ipd181.doc < prev    next >
Text File  |  1992-01-31  |  21KB  |  727 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                  Version 8.5 of Icon for MS-DOS
  8.  
  9.                         Ralph E. Griswold
  10.     Department of Computer Science, The University of Arizona
  11.  
  12.  
  13.  
  14. 1.__Introduction
  15.  
  16.    Version 8.5 of Icon for MS-DOS should run on any computer run-
  17. ning MS-DOS 3.0 or higher.  Math co-processors are supported and
  18. used if present; otherwise software emulation is used.  Approxi-
  19. mate 500K of free RAM is needed to run Icon satisfactorily.  Two
  20. versions of Icon's executor system are provided. One supports
  21. arithmetic on integers of unlimited magnitude and the other does
  22. not. The latter is considerably smaller than the former and can
  23. be used if you do not have enough RAM for the former.
  24.  
  25.    Version 8.5 of Icon for MS-DOS is distributed on 5.25" or 3.5"
  26. diskettes, which include executable binary files, a few test pro-
  27. grams, and documentation in machine-readable form. Printed docu-
  28. mentation is included with diskettes distributed by the Icon Pro-
  29. ject at The University of Arizona.
  30.  
  31.    This implementation of Icon is in the public domain and may be
  32. copied and used without restriction.  The Icon Project makes no
  33. warranties of any kind as to the correctness of this material or
  34. its suitability for any application.  The responsibility for the
  35. use of Icon lies entirely with the user.
  36.  
  37.  
  38. 2.__Documentation
  39.  
  40.    The basic reference for Version 8 of Icon is the second edi-
  41. tion of the book The Icon Programming Language [1].  This book is
  42. available from the Icon Project at The University of Arizona. It
  43. also can be ordered through any bookstore that handles special
  44. orders.
  45.  
  46.    The new features of Version 8.5 of Icon are in an accompanying
  47. technical report [2].
  48.  
  49.  
  50. 3.__Installing_MS-DOS_Icon
  51.  
  52.    Two executable binary files are needed to run Icon:
  53.  
  54.         icont.exe   translator
  55.         iconx.exe   executor
  56.  
  57. These files should be located at a place on your PATH specifica-
  58. tion.  As mentioned in Section 1, there are two forms of iconx:
  59. one without large-integer arithmetic and one with it.  The former
  60. is named iconx.exe as distributed, while the latter is named
  61.  
  62.  
  63.  
  64. IPD181                        - 1 -              January 31, 1992
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. iconxl.exe.
  74.  
  75.    The distribution is contained in several files in LHarc (lzh)
  76. format. A copy of lharc.exe is included for dearchiving. The dis-
  77. tribution files are:
  78.  
  79.         docs.lzh     documents
  80.         icon.lzh     executable binary files
  81.         lharc.exe    dearchiving utility
  82.         readme       installation overview and recent notes
  83.         samples.lzh  Icon programs and data
  84.  
  85.  
  86.    To install the .exe files, set your current directory to the
  87. desired place, place the appropriate distribution diskette in
  88. drive A, and dearchive the files there using lharc.exe.  For
  89. example, to dearchive the executable binary files, the following
  90. will do:
  91.  
  92.         a:lharc a:icon.lzh
  93.  
  94. The same technique can be used for extracting the remaining
  95. files.
  96.  
  97.    Pick the executor that fits your needs, place it at a location
  98. on your path, and rename it to iconx.exe if necessary. For exam-
  99. ple, if you want the executor that supports large-integer arith-
  100. metic, the following will do:
  101.  
  102.         rename iconxl.exe iconx.exe
  103.  
  104.  
  105.  
  106. 4.__Running_MS-DOS_Icon_-_Basic_Information
  107.  
  108.    Files containing Icon programs must have the extension .icn.
  109. Such files should be plain text files (without line numbers or
  110. other extraneous information).  The icont  translator produces an
  111. ``icode'' file that can be executed by iconx.  For example, an
  112. Icon program in the file prog.icn is translated by
  113.  
  114.         icont prog.icn
  115.  
  116. The result is an icode file with the name prog.icx.  This file
  117. can be run by
  118.  
  119.         iconx prog.icx
  120.  
  121. If your executor is named differently, simply use that name. For
  122. example, if your executor is named iconxl.exe, use
  123.  
  124.         iconxl prog.icx
  125.  
  126. Alternatively, icont can be instructed to execute the icode file
  127.  
  128.  
  129.  
  130. IPD181                        - 2 -              January 31, 1992
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. after translation by appending a -x to the command line, as in
  140.  
  141.         icont prog.icn -x
  142.  
  143. This only works if your executor is named iconx.exe, since the -x
  144. option looks for this name.  In the sections that follow, it is
  145. assumed that the executor is named iconx.exe.
  146.  
  147.    If icont is run with the -x option, the file prog.icx is left
  148. and can be run subsequently using an explicitly named executor as
  149. described above.
  150.  
  151.    The extensions .icn and .icx are optional. For example, it is
  152. sufficient to use
  153.  
  154.         icont prog
  155.  
  156. and
  157.  
  158.         iconx prog
  159.  
  160.  
  161.    iconx will find an icode file if it is in the current direc-
  162. tory or at place given on your PATH specification.
  163.  
  164.  
  165. 5.__Testing_the_Installation
  166.  
  167.    There are a few programs on the distribution diskette that can
  168. be used for testing the installation and getting a feel for run-
  169. ning Icon:
  170.  
  171.      hello.icn   This program prints the Icon version number,
  172.                  time, and date. Run this test as
  173.  
  174.                          icont hello
  175.                          iconx hello
  176.  
  177.                  Note that this can be done in one step with
  178.  
  179.                          icont hello -x
  180.  
  181.  
  182.      cross.icn   This program prints all the ways that two words
  183.                  intersect in a common character. The file
  184.                  cross.dat contains typical data. Run this test
  185.                  as
  186.  
  187.                          icont cross -x <cross.dat
  188.  
  189.  
  190.      meander.icn This program prints the ``meandering strings''
  191.                  that contain all subsequences of a specified
  192.                  length from a given set of characters. Run this
  193.  
  194.  
  195.  
  196. IPD181                        - 3 -              January 31, 1992
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.                  test as
  206.  
  207.                          icont meander -x <meander.dat
  208.  
  209.  
  210.      roman.icn   This program converts Arabic numerals to Roman
  211.                  numerals. Run this test as
  212.  
  213.                          icont roman -x
  214.  
  215.                  and provide some Arabic numbers from your con-
  216.                  sole.
  217.  
  218. If these tests work, your installation is probably correct and
  219. you should have a running version of Icon.
  220.  
  221.  
  222. 6.__More_on_Running_Icon
  223.  
  224.    For simple applications, the instructions for running Icon
  225. given in Section 4 may be adequate. The icont translator supports
  226. a variety of options that may be useful in special situations.
  227. There also are several aspects of execution that can be con-
  228. trolled with environment variables.  These are listed here. If
  229. you are new to Icon, you may wish to skip this section on the
  230. first reading but come back to it if you find the need for more
  231. control over the translation and execution of Icon programs.
  232.  
  233. 6.1__Arguments
  234.  
  235.    Arguments can be passed to the Icon program by appending them
  236. to the command line.  Such arguments are passed to the main pro-
  237. cedure as a list of strings.  For example,
  238.  
  239.         iconx prog text.dat log.dat
  240.  
  241. runs the icode file prog.icx, passing its main procedure a list
  242. of two strings, "text.dat" and "log.dat".  The program also can
  243. be translated and run with these arguments with a single command
  244. line by putting the arguments after the -x:
  245.  
  246.         icont prog -x text.dat log.dat
  247.  
  248. These arguments might be the names of files that prog.icn reads
  249. from and writes to. For example, the main procedure might begin
  250. as follows:
  251.  
  252.         procedure main(a)
  253.            in := open(a[1]) | stop("cannot open input file")
  254.            out := open(a[2],"w") | stop("cannot open output file")
  255.                        .
  256.                        .
  257.                        .
  258.  
  259.  
  260.  
  261.  
  262. IPD181                        - 4 -              January 31, 1992
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. See also the information about the processing of command-line
  272. arguments given in Section 6.4.
  273.  
  274. 6.2__The_Translator
  275.  
  276.    The icont translator can accept several Icon source files at
  277. one time.  When several files are given, they are translated and
  278. combined into a single icode file whose name is derived from the
  279. name of the first file.  For example,
  280.  
  281.         icont prog1 prog2
  282.  
  283. translates the files prog1.icn and prog2.icn and produces one
  284. icode file, prog1.icx.
  285.  
  286.    A name other than the default one for the icode file produced
  287. by MiconfR can be specified by using the -o option, followed by
  288. the desired name. For example,
  289.  
  290.         icont -o probe.icx prog
  291.  
  292. produces the icode file named probe.icx rather than prog.icx.
  293.  
  294.    If the -c option is given to icont, the translator stops
  295. before producing an icode file and intermediate ``ucode'' files
  296. with the extensions .u1 and .u2 are left for future use (normally
  297. they are deleted).  For example,
  298.  
  299.         icont -c prog1
  300.  
  301. leaves prog1.u1 and prog1.u2, instead of producing prog1.icx.
  302. These ucode files can be used in a subsequent icont command by
  303. using the .u1 name. This saves translation time when the program
  304. is used again.  For example,
  305.  
  306.         icont prog2 prog1.u1
  307.  
  308. translates prog2.icn and combines the result with the ucode files
  309. from a previous translation of prog1.icn. Note that only the .u1
  310. name is given. The extension can be abbreviated to .u, as in
  311.  
  312.         icont prog2 prog1.u
  313.  
  314. Ucode files also can be added to a program using the link
  315. declaration.
  316.  
  317.    Icon source programs may be read from standard input.  The
  318. argument - signifies the use of standard input as a source file.
  319. In this case, the ucode files are named stdin.u1 and stdin.u2 and
  320. the icode file is named stdin.icx.
  321.  
  322.    The informative messages from the translator can be suppressed
  323. by using the -s option.  Normally, both informative messages and
  324. error messages are sent to standard error output.
  325.  
  326.  
  327.  
  328. IPD181                        - 5 -              January 31, 1992
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.    The -t option causes &trace to have an initial value of -1
  338. when the icode file is executed.  Normally, &trace has an initial
  339. value of 0.
  340.  
  341.    The option -u causes warning messages to be issued for unde-
  342. clared identifiers in the program.
  343.  
  344.    Icon has several tables related to the translation of pro-
  345. grams.  These tables are large enough for most programs, but
  346. translation is terminated with an error message, indicating the
  347. offending table, if there is not enough room.  If this happens,
  348. larger table sizes can be specified by using the -S option. This
  349. option has the form -S[cfgilnrstCFL]n, where the letter following
  350. the S specifies the table and n is the number of storage units to
  351. allocate for it.
  352.  
  353.      c  constant table          100
  354.      f  field table             100
  355.      g  global symbol table     200
  356.      i  identifier table        500
  357.      l  local symbol table      100
  358.      n  line number table      1000
  359.      r  record table            100
  360.      s  string space          20000
  361.      t  tree space            15000
  362.      C  code buffer           15000
  363.      F  file names               10
  364.      L  labels                  500
  365.  
  366. The units depend on the table involved, but the default values
  367. can be used as guides for appropriate settings of -S options
  368. without knowing the units.  For example,
  369.  
  370.         icont -Sc200 -Sg600 prog
  371.  
  372. translates prog.icn with twice the constant table space and three
  373. times the global symbol table space that ordinarily would be pro-
  374. vided.
  375.  
  376. 6.3__Environment_Variables
  377.  
  378.    When an icode file is executed, several environment variables
  379. are examined to determine execution parameters.  The values
  380. assigned to these variables should be numbers.
  381.  
  382.    Environment variables are particularly useful in adjusting
  383. Icon's storage requirements.  Particular care should be taken
  384. when changing default values: unreasonable values may cause Icon
  385. to malfunction.
  386.  
  387.    The following environment variables can be set to adjust
  388. Icon's execution parameters. Their default values are listed in
  389. parentheses after the environment variable name:
  390.  
  391.  
  392.  
  393.  
  394. IPD181                        - 6 -              January 31, 1992
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.         TRACE (undefined).  This variable initializes the value
  404.      of &trace.  If this variable has a value, it overrides the
  405.      translation-time -t option.
  406.  
  407.         NOERRBUF (undefined).  If this variable is set, &errout
  408.      is not buffered.
  409.  
  410.         STRSIZE (65000). This variable determines the size, in
  411.      bytes, of the region in which strings are stored.  If addi-
  412.      tional string regions are needed, they may be smaller.
  413.  
  414.         BLKSIZE (65000).  This variable determines the size, in
  415.      bytes, of the region in which Icon allocates lists, tables,
  416.      and other objects.  If additional block regions are needed,
  417.      they may be smaller.
  418.  
  419.         COEXPSIZE (2000). This variable determines the size, in
  420.      32-bit words, of each co-expression block.
  421.  
  422.         MSTKSIZE (10000). This variable determines the size, in
  423.      words, of the main interpreter stack.
  424.  
  425.         QLSIZE (5000). This variable determines the size, in
  426.      bytes, of the region used by the garbage collector for
  427.      pointers to strings.
  428.  
  429.    The maximum region size that can be specified is 65000.
  430.  
  431. 6.4__Details_of_Command-Line_Processing
  432.  
  433.    The processing of command-line arguments normally is important
  434. only in running iconx. Some details follow:
  435.  
  436.      +  An argument containing white space must be enclosed in
  437.         double quotes.  For example, "abc def" is a valid argu-
  438.         ment. The quotes are deleted in the string passed to
  439.         iconx.
  440.  
  441.      +  If a quoted argument contains a double quote, the embed-
  442.         ded quote must be preceded by a backslash. For example,
  443.         "abc de\"f" is a valid argument. The outer quotes and the
  444.         backslash are deleted in the string passed to iconx.
  445.  
  446.      +  If a non-quoted argument contains a double quote, the
  447.         embedded quote can be preceded by a backslash or not. For
  448.         example, abc\"d and abc"d are equivalent arguments.
  449.  
  450.      +  To pass a lone double quote as an argument, precede it
  451.         with a backslash.
  452.  
  453.      +  Wild-card characters are not expanded.
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460. IPD181                        - 7 -              January 31, 1992
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.      +  Quote-balancing errors are not checked.  The start-up
  470.         routine scans the residual command line from left to
  471.         right.
  472.  
  473.  
  474. 7.__Features_of_MS-DOS_Icon
  475.  
  476.    MS-DOS Icon supports all the features of Version 8.5 of Icon,
  477. with the following exceptions and additions:
  478.  
  479.      +  Pipes are not supported. A file cannot be opened with the
  480.         "p" option.
  481.  
  482.      +  For files opened in the translate mode, the position pro-
  483.         duced by seek() may not reflect the actual byte position
  484.         because of the translation of carriage-return/line-feed
  485.         sequences to line-feed characters.
  486.  
  487.      +  Path specifications can be entered using either a / or a
  488.         \. Examples are:
  489.  
  490.                 A:\ICON\TEST.ICN
  491.                 A:/ICON/TEST.ICN
  492.  
  493.  
  494.      +  The following MS-DOS device names can be used as file
  495.         names:
  496.  
  497.                 console        CON
  498.                 printer        PRN LST LPT LPT1
  499.                 auxiliary port AUX COM RDR PUN
  500.                 null           NUL NULL
  501.  
  502.         For example,
  503.  
  504.                 prompt := open("CON", "w")
  505.  
  506.         causes strings written to prompt to be displayed on the
  507.         console.  Use of a null file name means no file is
  508.         created.
  509.  
  510.      +  MS-DOS Icon also has some functions in addition to the
  511.         standard repertoire.  These are described in the next
  512.         section.
  513.  
  514.  
  515. 8.__MS-DOS_Functions
  516.  
  517.    Disclaimer: The following functions provide a gateway to
  518. facilities provided by MS-DOS and ROM BIOS. These functions
  519. should be used with care, since Icon maintains strict control
  520. over its environment (although it uses standard MS-DOS interfaces
  521. and does not bypass MS-DOS or ROM BIOS in any way).  The descrip-
  522. tions that follow are low-level descriptions. They assume
  523.  
  524.  
  525.  
  526. IPD181                        - 8 -              January 31, 1992
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535. knowledge of the Intel 8086 (8088, 80x86) architecture.
  536.  
  537. Int86(L) generates a hardware interrupt. The input is a list of
  538. integer values: [interrupt number, ax, bx, cx, dx, si, di, es,
  539. ds].  It returns a list of the form [flags, ax, bx, cx, dx, si,
  540. di, es, ds].
  541.  
  542.    Great care must be taken in using this function. Some things
  543. to watch out for are:
  544.  
  545.      +  Interrupt functions that alter the stack registers (SS or
  546.         SP) or alter the MS-DOS memory chain (that is, allocate
  547.         or deallocate memory in the MS-DOS memory region). When
  548.         Icon expands memory, it expects the next allocation to be
  549.         contiguous with the region it currently owns.
  550.  
  551.      +  Interrupt functions that operate on files opened by
  552.         Icon's open(s) function - that is, closing, seeking,
  553.         reading, or writing.
  554.  
  555.      +  The values of ES and DS may not be valid on return.
  556.  
  557.  
  558. InPort(i) returns an integer from hardware port i.
  559.  
  560. OutPort(i1,i2) writes value i2 to hardware port i1.
  561.  
  562. GetSpace(i) allocates a static block of storage outside of Icon's
  563. direct control (that is, it is not be affected by garbage collec-
  564. tion).  This function simply calls the malloc() allocation rou-
  565. tine and returns the address of the resulting block as a long
  566. integer.
  567.  
  568. FreeSpace(A) frees a static block of storage, where A is a value
  569. returned by GetSpace(i).  No check is make to verify that the
  570. block was allocated by GetSpace(i). The results are unpredictable
  571. if it was not.  Arithmetic should not be performed directly on a
  572. value returned by GetSpace(i).
  573.  
  574. Peek(A,i) builds a string pointing to the address specified by A
  575. with a length of i, where A is either an integer that specifies a
  576. linear address value or a list of the form [segment, offset] and
  577. i is a length (default 1).
  578.  
  579.    This is the only way of `seeing' the contents of a block of
  580. storage allocated by GetSpace(i). Consider the following example:
  581.  
  582.         block := Peek(addr := GetSpace(100),100)
  583.  
  584. The value of block is a string of length 100 and addr is the
  585. linear address of the block.
  586.  
  587. Peek(A,i) does not move data into Icon's memory region.  Instead,
  588.  
  589.  
  590.  
  591.  
  592. IPD181                        - 9 -              January 31, 1992
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601. it builds a string qualifier that points to the data.
  602.  
  603. Poke(A,s) copies a string s to location A, where A is an address
  604. specified in the same way as for Peek(A,s) and s is a string to
  605. be copied to that storage location. The string is copied directly
  606. into storage, byte by byte. No conversion is performed.  This is
  607. the only way of assigning data to a block of storage allocated by
  608. GetSpace(i).
  609.  
  610.  
  611. 9.__Known_Bugs
  612.  
  613.    A list of known bugs in Icon itself is given in [2].
  614.  
  615.    MS-DOS memory management also can cause problems.  Some pro-
  616. grams that require a lot of memory may hang when run by the -x
  617. option to icont.  This can be avoided by using iconx in a
  618. separate step.  Also, if there is not enough free RAM, the sys-
  619. tem() function may fail silently or hang.
  620.  
  621.  
  622. 10.__Reporting_Problems
  623.  
  624.    Problems with Icon should be noted on a trouble report form
  625. (included with the distribution) and sent to
  626.  
  627.         Icon Project
  628.         Department of Computer Science
  629.         Gould-Simpson Building
  630.         The University of Arizona
  631.         Tucson, AZ   85721
  632.         U.S.A.
  633.         (602) 621-8448 (voice)
  634.         (602) 621-4246 (fax)
  635.         icon-project@cs.arizona.edu     (Internet)
  636.         ... {uunet, allegra, noao}!arizona!icon-project     (uucp)
  637.  
  638.  
  639.  
  640. 11.__Registering_Copies_of_Icon
  641.  
  642.    If you received your copy of Icon directly from the Icon Pro-
  643. ject, it has been registered in your name and you will automati-
  644. cally receive the Icon Newsletter.  This newsletter contains
  645. information about new implementations, updates, programming tech-
  646. niques, and information of general interest about Icon.
  647.  
  648.    If you received your copy of Icon from another source, please
  649. fill out the registration form that is included in the distribu-
  650. tion and send it to the Icon Project at the address listed above.
  651. This will assure that you receive the Icon Newsletter and infor-
  652. mation about updates.
  653.  
  654.  
  655.  
  656.  
  657.  
  658. IPD181                       - 10 -              January 31, 1992
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667. Acknowledgements
  668.  
  669.    The design and implementation of the Icon programming language
  670. was supported, in part, by grants from the National Science Foun-
  671. dation.
  672.  
  673.    Clint Jeffery, Gregg Townsend, and Ken Walker collaborated
  674. with the author in the development of Version 8.5.
  675.  
  676. References
  677.  
  678.  
  679. 1.   R. E. Griswold and M. T. Griswold, The Icon Programming
  680.      Language, Prentice-Hall, Inc., Englewood Cliffs, NJ, second
  681.      edition, 1990.
  682.  
  683. 2.   R. E. Griswold, C. L. Jeffery, G. M. Townsend and K. Walker,
  684.      Version 8.5 of the Icon Programming Language, The Univ. of
  685.      Arizona Icon Project Document IPD174, 1992.
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  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. IPD181                       - 11 -              January 31, 1992
  725.  
  726.  
  727.