home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 162_01 / readme.doc < prev    next >
Text File  |  1985-08-21  |  17KB  |  463 lines

  1.  
  2.  
  3.                 P R E F A C E  
  4.  
  5.  
  6.     Release of software like Mchip80 to the public domain is at least a
  7.    small boost to supportive commercial products that are discussed in the
  8.    documentation. Here is a list to acknowledge the vendors and the
  9.    products, plus some of the shortened names that might appear in the text.
  10.  
  11.     Vendor: The Software Toolworks    ['Toolworks']
  12.     Products:    C/80 compiler, C/80 Mathpak  ['Mathpak']
  13.    
  14.     Vendor: Microsoft
  15.     Products:    Macro80, m80.abs[.com], l80.abs[.com]
  16.    
  17.     Vendor: Heath/Zenith Computers    ['Heathkit']
  18.     Products:    H89 computer, HDOS system software
  19.    
  20.     Vendor: Advanced Micro Devices
  21.     Product:    AM9511 math processor chip  ['device']
  22.    
  23.     Vendor: Digital Research
  24.     Product:    CP/M system software
  25.    
  26.     Vendor: Zilog
  27.     Product:    Z80 microprocessor
  28.  
  29.     The C/80 user/programmer who chooses to use the Mchip80 software
  30.    package will in some cases need to make no changes to his pre-existing
  31.    programs that run with Toolworks C/80 Mathpak. There is no way to tell
  32.    the C/80 compiler that it is working with a substitute for its' Mathpak
  33.    cousin, and the C/80 compiler doesn't need to be told that dlibrary.rel
  34.    is substituting for about 90 percent of flibrary.rel. This degree of
  35.    compatibility is achieved at the assembly language level by having
  36.    Mchip80 use the same global labels as C/80 Mathpak, while performing
  37.    similarly defined tasks using very different methods.
  38.  
  39.     Considering the limited scope for naming labels in software packages
  40.    doing floating point and long arithmetic, assembly language labels such
  41.    as 'F.add' and 'L.div' must be accepted as generic, and not subject to
  42.    copyright, like single notes in a piece of music, or single words in a
  43.    novel. Beyond common usage of generic labels, no part of Mathpak is
  44.    reproduced. In some situations where Toolworks code is first and best,
  45.    where the AM9511 is not involved, Z80 or no Z80, there is no attempt at
  46.    replacement. The L80 linking loader is always commanded to search
  47.    flibrary, immediately after it's search of dlibrary, and the needed gem
  48.    of code in a Toolworks module will be included in the executable program.
  49.  
  50.     Observations such as "the C/80 compiler doesn't need to be told that
  51.    ...     ", occurring in this document, are not reviews of any product nor
  52.    updates to their documentation. These are opinions based on experiments
  53.    by one individual, who endorses all named products, the configurations in
  54.    which they are marketed, and the documentation that is part of those
  55.    products.
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.                 P A R T   O N E
  73.  
  74.         Creating and Running an Executable Version of 'Demo1.c'
  75.  
  76.                  Your Inventory
  77.  
  78.     For hardware you need an AM9511 math processor chip installed in a
  79.    Heathkit H89 computer or equivalent. The Z80 microprocessor is essential.
  80.  
  81.     You need this software, named Mchip80, which requires that you also
  82.    have the following set of software development tools, in versions that
  83.    run with either the CP/M or HDOS operating systems.
  84.  
  85.     C/80 compiler and C/80 Mathpak, which are two separate
  86.     packages from the Software Toolworks.
  87.     Macro80 assembler package from Microsoft.
  88.    
  89.                  Preparations.
  90.  
  91.     If you need more detailed instructions for any of the following
  92.    operations, consult the documentation that comes with the related
  93.    product. Configure the C/80 compiler to accept floats and longs, and also
  94.    to generate Macro80 output. You must use the augmented utility, cconfigf,
  95.    from the Mathpak distribution disk for the float/long fix.
  96.  
  97.     Get the file 'fprintf.c' from the C/80 Mathpak disk, compile and
  98.    assemble to create 'fprintf.rel'. Including the float version of printf
  99.    in this exercise will prove the compatibility of the function ftoa() as
  100.    supplied with Mchip80.
  101.  
  102.     Read your hardware documentation and make a note of the two I/O
  103.    ports used for your AM9511 chip. Convert the port numbers to decimal, or
  104.    consult your C/80 documentation on hex or octal constants.
  105.  
  106.     Load your editor program and view the file 'demo1.c' from your back
  107.    up copy of the Mchip80 disk. Locate the line that reads
  108.  
  109.     "portd = 188; portc = 189; /* must be YOUR hardware ports */ ".
  110.  
  111.     If your hardware uses port 188 (decimal) for AM9511 data access, and
  112.    189 for commands and status, delete this line from your program.
  113.    Otherwise change the line to reflect your data and command ports, and the
  114.    host program will write your numbers over preset values in a library
  115.    module, before the AM9511 is used. Remember to use this convenient port
  116.    setting procedure in all your future C/80 programs using Mchip80 and the
  117.    AM9511, or at least until you simplify the source code and remake
  118.    dlibrary.
  119.  
  120.                 Compile/Assemble
  121.  
  122.     Use C/80 to compile your modified version of 'demo1.c', then use m80
  123.    from the Microsoft package to assemble 'demo1.mac' and create
  124.    'demo1.rel'.
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.                    The Link Operation
  136.  
  137.     Copy the following files to drive A: [or SY0:]
  138.  
  139.         L80.abs[.com]    (Microsoft)
  140.         Demo1.rel    (as created above)
  141.         Fprintf.rel    (as created above)
  142.         Dlibrary.rel    (Mchip80 software)
  143.         Flibrary.rel    (Toolworks Mathpak disk)
  144.         Clibrary.rel    (Toolworks C/80 disk)
  145.  
  146.     Enter the following command line to run the linker program:
  147.  
  148.     L80 demo1,fprintf,dlibrary/s,flibrary/s,clibrary/s,demo1/n/e
  149.    
  150.    to create the executable version of demo1. A comment at this point is
  151.    that if you omit dlibrary/s from the above command line, you have
  152.    standard usage of the Toolworks flibrary. The resultant program will run,
  153.    but the AM9511 will not get involved.
  154.  
  155.                    Execution
  156.  
  157.     Run the newly created program by entering 'demo1'. There will be no
  158.    prompt, so enter a floating point number such as '34.56'. The number you
  159.    entered will be echoed 15 times, in five lines and three columns, in a
  160.    variety of formats and precisions. Next enter a number in exponential
  161.    format, such as '23.45e-2'. The same pattern will appear on the console.
  162.    You have just checked out your AM9511 chip, it's hardware interface, the
  163.    Mchip80 versions of ftoa() and atof(), and most of the modules from
  164.    dlibrary.
  165.  
  166.  
  167.                 P A R T   T W O
  168.  
  169.                  Usage and Background.
  170.  
  171.  
  172.     If you feel that you are now ready to run a C/80 program that you
  173.    have used successfully with Mathpak, hold the action and read some more
  174.    before you proceed. Look at your C/80 source file where the global float
  175.    variables are declared. Are any of them initialized? For example:
  176.  
  177.     float    fnum = 5.32e-6;
  178.  
  179.     Then your program has to be changed before it will run properly with
  180.    Mchip80. The good news is that this is the only C/80 feature that is
  181.    cancelled by use of Mchip80, as far as is known. Do not initialize floats
  182.    when using Mchip80. Find the best way to change your program. Why is
  183.    initialization of floats de-implemented? Read on.
  184.  
  185.                   Which Float Format?
  186.  
  187.     Unfortunately there are two good float formats to discuss, while the
  188.    simple approach of Mchip80 requires that one be used, and the other not
  189.    only discarded, but also quarantined to prevent any errors or confusion.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.    The float formats of Toolworks Mathpak and the AM9511 math chip play in
  202.    ballparks of equal dimensions,
  203.  
  204.     Both formats occupy 32 bits of memory, and
  205.     Both yield six significant decimal digits.
  206.  
  207.     Internally, the formats have a one bit alignment discrepancy, which
  208.    produces the following differences in numeric range:
  209.  
  210.                  Decimal Float values
  211.           MAX. (pos. or neg.)       MIN. (pos. or neg.)
  212.    AM9511 format          9.2e18             2.7e-20
  213.    Toolworks format           10e38              10e-38
  214.  
  215.     The C/80 compiler knows only the Mathpak float format, which
  216.    apparently it never uses, except to initialize float variables. In
  217.    runtime situations involving floats or longs, a C/80 program will copy
  218.    the four bytes per variable to CPU registers or the stack, and then call
  219.    a Mathpak routine. When a Mchip80 routine replaces a Mathpak routine, it
  220.    starts by finding the four byte variables in either CPU registers or the
  221.    stack. When it returns a variable, it copies four bytes from the device
  222.    to CPU registers and exits, just like a Mathpak exit routine. The host
  223.    program then usually moves the four bytes to RAM, not caring which float
  224.    format was used on them.
  225.  
  226.     The 'atof()' function that is supplied with the Mchip80 software
  227.    converts alpha-numeric strings, such as '4.5678e3', to 32 bit binary
  228.    float variables in the AM9511 device format. When four byte float
  229.    variables are passed to Mchip80 routines, they must either be a product
  230.    of this 'atof()' function, or of type conversion from int or long, since
  231.    those type conversions are done by the AM9511. When you write a program,
  232.    you control the creation of each float variable, and it must not be from
  233.    initialization by the C/80 compiler.
  234.  
  235.     There is no such quarantine requirement with long variables. You can
  236.    allow the C/80 compiler to initialize them.
  237.  
  238.          Individual Styles and Applications Start Here.
  239.  
  240.     Mchip80 provides 'dlibrary.rel', which is ready to use in many
  241.    applications, but Mchip80 does not exploit all the AM9511 potential.
  242.    Mchip80 is an unfinished package, with development stopped at several
  243.    points where individual preferences can start budding. Here are two
  244.    situations where the AM9511 is not exploited in Mchip80:
  245.  
  246.     16 bit int arithmetic, including the modulo operation.
  247.     C/80 does a fine job.
  248.    
  249.     Comprehensive error processing. Your options are
  250.     wide open, and there is something in 'dlibrary.rel'
  251.     that could be useful and convenient.
  252.  
  253.     The program 'demo2.c' shows a simple way for a program written in
  254.    C/80 to detect the AM9511's warning when an out of range input was
  255.    attempted before its last operation. This should lead you to reading of
  256.    the source code file 'COMP32.MAC', where for the convenience of C/80
  257.    programmers, the status byte returned by the AM9511 can be expanded into
  258.    a group of 14 global integers, which can be treated as flags since they
  259.    will always have values of either zero or one.
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.                   P A R T    T H R E E
  270.  
  271.           The List: Functions, Modules, Source Files.
  272.  
  273.  
  274.     The source code of all modules in dlibrary is on the distribution
  275.    disk of Mchip80. The remainder of this documentation is a list of those
  276.    source files, with sub-lists of the features in each source file.
  277.  
  278.     The features fall into two groups, and for each file documented
  279.    there are two sub-list headings. The first heading is "Compiler-call
  280.    subroutines", and any features listed here may only be called from C/80
  281.    compiler assembly coded output. These subroutines could be described as
  282.    invisible to the C/80 programmer.
  283.  
  284.     The second sub-list heading is "Visible functions for C/80". The
  285.    programmer uses these as regular C functions, and many of them conform to
  286.    the C/80 Mathpak documentation, while some exist to provide access to
  287.    features of the AM9511 math processor.
  288.  
  289.    FILE: DEQ.MAC (name means "Device Equates")
  290.        Compiler-call subroutines:
  291.        None
  292.        Visible functions for C/80
  293.        None
  294.        Remarks:
  295.        INCLUDED in all *.MAC files, and in some of the *.C files.
  296.  
  297.    FILE: ftoa.c (name means "Float to ASCII")
  298.        Compiler-call subroutines:
  299.        None
  300.        Visible functions for C/80
  301.        Ftoa() performs as described in the Toolworks Mathpak
  302.        documentation, except that the number of digits after the decimal
  303.        place is 20 or less, because the AM9511 float format is used.
  304.  
  305.    FILE: atof.c (name means "ASCII to Float")
  306.        Compiler-call subroutines:
  307.        None
  308.        Visible functions for C/80
  309.        Atof() performs as described in the Toolworks Mathpak
  310.        documentation, except that an exponent greater than 18 (less than
  311.        -20) will cause an unspecified error because the AM9511 float
  312.        format is used.
  313.  
  314.    FILE: fmdx.c (name means "Float, multiply/divide by 'X'")
  315.        Compiler-call subroutines:
  316.        None
  317.        Visible functions for C/80
  318.        Fdten(fexp) and fmten(fexp) return the value of fexp ("float
  319.        expression") divided by ten, or multiplied by ten. Both are used
  320.        by previous functions in this library.
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.    FILE: logpow.c (name means "Logs, Powers and Misc.")
  335.        Compiler-call subroutines:
  336.        None
  337.        Visible functions for C/80
  338.        Sqrt(),exp(),pow(),pow10(),ln(),log() and fabs() perform as
  339.        described in the Toolworks Mathpak documentation. The extra
  340.        function invrt(fexp) returns the float value of one(1) divided by
  341.        the float argument 'fexp'.
  342.  
  343.    FILE: ftrig.c (name means "Float, trigonometric")
  344.        Compiler-call subroutines:
  345.        None
  346.        Visible functions for C/80
  347.        Sin(), cos() and atan() perform as described in the Toolworks
  348.        Mathpak documentation. Three more functions, tan(), asin() and
  349.        acos() implement other commands in the AM9511 set, and return
  350.        tangent, arc sine and arc cosine. The AM9511 can be commanded to
  351.        place the float value of pi in its top of stack location, and the
  352.        functions fdpi(f) and fmpi(f) divide or multiply their float
  353.        arguments by pi.
  354.  
  355.    FILE: XLONG.MAC (name means "A single LONG operation(!!)")
  356.        Compiler-call subroutines:
  357.        Label "L.mod" is the entry point to the subroutine that returns
  358.        the long modulo result to the C/80 generated assembly program.
  359.        Visible functions for C/80
  360.        None
  361.        Remarks:
  362.        The AM9511 does not have a single command for long modulo, and
  363.        this routine gives it a string of commands to execute. Avoid this
  364.        slow operation and preferably arrange for modulo operations to
  365.        involve int types only.
  366.  
  367.    FILE: CONV32.MAC (name means "Conversions of longs and floats.")
  368.        Compiler-call subroutines:
  369.        Convert float variables to long type, and vice versa. C/80 will
  370.        sometimes need the variables in the stack, other times in
  371.        registers. The four operative labels are F..L, L..F, Bf.Bl and
  372.        Bl.Bf .
  373.        Visible functions for C/80
  374.        None
  375.        Remarks:
  376.        Each of these need only a single command to the AM9511.
  377.  
  378.    FILE: COMP32.MAC (name means "Comparisons for float and long types")
  379.        Compiler-call subroutines:
  380.        Float compare ("cf.??" labels) and long compare ("cl.??" labels),
  381.        as tabulated:
  382.         greater than/equals to        cf.ge        cl.ge
  383.         less than            cf.lt        cl.lt
  384.         equals                cf.eq        cl.eq
  385.         not equal to            cf.ne        cl.ne
  386.         greater than            cf.gt        cl.gt
  387.         less than/equals to        cf.le        cl.le
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.        Visible functions for C/80
  400.        Xpand1(), - with no arguments, updates the fourteen global
  401.        integers declared at the beginning of the source file, providing
  402.        all diagnostic clues as to the wholesomeness of the last result
  403.        given by the AM9511. All of these clues are from one byte of
  404.        status returned by the AM9511. See the program demo2.c for a
  405.        simple application.
  406.        Remarks:
  407.        Expect slow comparisons of floats and longs, and arrange for int
  408.        comparisons when possible.
  409.  
  410.    FILE: EDCODE.MAC (name means "Essential Device CODE.")
  411.        Compiler-call subroutines:
  412.        The AM9511 performs primary float and long arithmetic quickly
  413.        from single commands, after the variable data has been loaded.
  414.        Assembly and macro code at the following labels couple the AM9511
  415.        chip to C/80 calls as simply and conveniently as possible.
  416.             F.neg        L.neg
  417.             F.add        L.add
  418.             F.sub        L.sub
  419.             F.mul        L.mul
  420.             F.div        L.div
  421.        The AM9511 makes it simple and convenient to convert int type to
  422.        float, and vice versa, and the following C/80 labels are
  423.        honoured:
  424.             I..F        Hi.Bf
  425.             F..I        Bf.Hi
  426.        The AM9511 does not convert char, int or unsigned types to long
  427.        type (nor equivalent reverse functions), so the global labels
  428.        "C..L", "U..L" and "I..L" are in EDCODE, but only to intercept
  429.        the action and quickly pass it to a Toolworks flibrary module:
  430.        Visible functions for C/80
  431.        None
  432.        Remarks:
  433.        Conversions of longs back to int, char or unsigned are performed
  434.        entirely in a Toolworks library module.
  435.        Some code segments in EDCODE are used by earlier modules in
  436.        dlibrary, therefore library module EDCODE must be linked into the
  437.        last position in dlibrary.
  438.  
  439.     It is recommended that locations of modules in dlibrary be kept
  440.    within their original groups, below, and that the groups be kept in the
  441.    following order.
  442.  
  443.    Group One: atof.c, ftoa.c, and always last within this group, fmdx.c
  444.    Group Two: logpow.c, ftrig.c
  445.    Group Three: XLONG.MAC, CONV32.MAC, COMP32.MAC
  446.    Last Location in dlibrary: EDCODE.MAC
  447. 
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.