home *** CD-ROM | disk | FTP | other *** search
/ TopWare Tools / TOOLS.iso / tools / top1190 / devices.doc < prev    next >
Encoding:
Text File  |  1989-05-31  |  15.2 KB  |  265 lines

  1.  
  2.  
  3.        The DeviceS program, besides having a more gaudy display, takes a
  4.        different approach to finding and presenting the Device Chain.  A
  5.        typical approach is to find the NUL device as the first device in
  6.        the chain and present the devices in the order of the chain until
  7.        the device at the end of the chain.  The resulting addresses make
  8.        it appear that the NUL device is off in a segment of its own and
  9.        that devices added by Config.Sys are loaded ahead of the standard
  10.        DOS devices.  We wanted the devices in the order that they occupy
  11.        memory.  The DOS Devices should start with CON, end with NUL and
  12.        be followed by any Config.Sys loaded devices in the order loaded
  13.        rather than the order of the chain.
  14.  
  15.        Certain remarks seemed appropriate even when only translating the
  16.        Device Attribute word.  The decision as to what remarks would be
  17.        useful and meaningful consumed hours of planning time and may not
  18.        be over yet.  In case you choose to comment, the criteria were:
  19.  
  20.                      No remark should restate the obvious.
  21.                      Any remark should help a normal user.
  22.                                 Here is my screen as an example:
  23.  
  24.        Tue  May 30, 1989 14:20 d:\work> devices
  25.  
  26.          Address Strat Inter Attr Type Device  Name         Remarks
  27.         0070 014E 03CD 03D8  8013 Character    CON      Replaced Device
  28.         0070 0160 03CD 03DE  8000 Character    AUX
  29.         0070 0172 03CD 03F2  8000 Character    PRN
  30.         0070 0184 03CD 0410  8008 Character    CLOCK$   System Date/Time
  31.         0070 0196 03CD 0416  0840 Block Drives  A - F   Mappable Drives
  32.         0070 01A8 03CD 03F2  8000 Character    LPT1
  33.         0070 01BA 03CD 03DE  8000 Character    COM1
  34.         0070 01CC 03CD 03FC  8000 Character    LPT2
  35.         0070 01DE 03CD 0406  8000 Character    LPT3
  36.         0070 01F0 03CD 03E8  8000 Character    COM2
  37.         0070 2D08 14C6 14CC  8004 Character    NUL
  38.         0A27 0000 0036 0041  8000 Character    EMMXXXX0 Expanded Mem Mgr
  39.         0C8D 0000 277B 2786  8013 Character    CON
  40.         0C8D 001C 277B 2786  8000 Character    FCON
  41.         14FA 0000 0012 0021  2800 Block Drive   G
  42.         1529 0000 0017 0022  4000 Block Drive   H
  43.         1579 0000 0017 0022  4000 Block Drive   I
  44.         15C9 0000 0030 003B  C000 Character    4DOSSTAK
  45.  
  46.        To those who would argue that "System Date/Time" for CLOCK$ and
  47.        "Expanded Mem Mgr" violate the first rule we offer two thoughts
  48.        that show that the decisions are not easy.  The Clock Device is
  49.        NOT guaranteed to have a name as obvious as "CLOCK$".  A device
  50.        that replaces it could have ANY name.  "EMMXXXX0" certainly does
  51.        identify the Expanded Memory Manager device to most of us but we
  52.        let rule 2 overcome the doubts caused by rule 1.
  53.  
  54.        Much of what could be said about Disk Drives was accomplished by
  55.        identifying the Drive Letter(s).  The User already knows which of
  56.        these drives take removable media and what capacities and whether
  57.        any of them are RAM drives.  If my system was part of a network,
  58.        then "NetWork" would appear as the "Name".  Additional remarks to
  59.        the network line await your input.  If your system uses HI-MEM by
  60.        Microsoft as an Extended Memory Manager, it will be identified.
  61.        Also, those character devices which report "busy" when accessed
  62.        through IOCTL will show "Busy Rpt" giving you many remarks.
  63.  
  64.                              DeviceS.DOC - Page 1
  65.  
  66.  
  67.  
  68.        Examining the DeviceS.ASM code will answer most questions about
  69.        what has been included and how it has been accomplished.  If you
  70.        are interested in programming be sure to see the DevSort code.
  71.  
  72.        The TurboPower Device.EXE program was patterned after Dev.EXE by
  73.        Chris J. Dunford.  Looking at the first 10 DeviceS.ASM code lines
  74.        you will see a pattern variation at the outset.  We look for the
  75.        CON device first in order to scan the appropriate segment for the
  76.        NUL device.  In the DevFind PROCedure, the header for NUL fills
  77.        level 1 of the DevS data array.  The data for all devices is then
  78.        stored at subsequent levels until the end of the chain.  With 32
  79.        levels (counting the 0 level which will be used when sorting) and
  80.        the large stack for overflow, there should be no catastrophes.
  81.        Anyone with 32 or more devices please let us know, however!
  82.  
  83.        While data from the device header is being stored, the attribute
  84.        word is also interpreted for remarks.  You'll see most of that
  85.        from the DoName: label to the end of the DevLine PROCedure.  The
  86.        possible Block devices include NetWorks as well as disk drives.
  87.        In the case of disk drives, the number of Units is stored for
  88.        future interpretation as drive letters.
  89.  
  90.        Upon return to the Main PROCedure, the program ends with an error
  91.        message and ErrorLevel if NO devices were entered into the array.
  92.        Otherwise the Heading Line is displayed.  The ShowMsg PROCedure
  93.        is the one that interprets Units into drive letters and so we'll
  94.        save it for review last.
  95.  
  96.        Novice programmers were invited to examine and use the DevSort
  97.        PROCedure earlier.  The algorithm can be coded in any language.
  98.        The "Sinking Bubble Sort" was developed for teaching because a
  99.        "bubble sort" can be explained with only two hands whereas the
  100.        more efficient algorithms require sophisticated demonstration
  101.        aids that often overwhelm student programmers.  The "Sinking
  102.        Bubble Sort" is only a little harder to explain and is much more
  103.        efficient.  The "bubble sort" must process the array as many
  104.        times (minus 1) as there are members in the array.  The "Sinking"
  105.        technique raises "Bubble Sort" efficiency so that no perceptible
  106.        time is taken with as few as 32 members.
  107.  
  108.        Imagine that the array to be sorted is an apartment house which
  109.        assigns each floor according to the value of the furniture.  The
  110.        furniture is initially moved to the next available level starting
  111.        with the ground floor.  No intermediate floors are left vacant.
  112.        The furniture on each floor is tagged with a value.  The basement
  113.        floor is reserved for temporary storage and the floors above the
  114.        top floor that is used are sealed off with an infinite furniture
  115.        value tag.  The movers aren't very smart but they can compare two
  116.        values and they sure can move furniture!
  117.  
  118.        In the "Sinking Bubble Sort", the movers know two limits.  They
  119.        know that the first floor is level 1 and they know the number of
  120.        the top level.  In fact, their freight elevator won't go past the
  121.        highest level occupied with furniture.  They know that if they
  122.        get all the furniture in value order from the Ground level to the
  123.        Top floor, their work will be done.
  124.  
  125.        There are 61 lines in the DevSort PROCedure.  In the first five,
  126.        the movers advance from their Basement and when they find that
  127.        the next floor to examine is ABOVE the Top floor of furniture,
  128.        they go to the 59th line of DevSort from which they end their day
  129.        by returning to the Basement.
  130.  
  131.                              DeviceS.DOC - Page 2
  132.  
  133.  
  134.        Checking the middle lines of code, you will see labels for "sink,
  135.        down and done".  They mark the test for, end of and start of
  136.        "sinking" points.  See how the movers get to the DSsink: label.
  137.        While working from the Ground to Top floor, the movers check the
  138.        furniture value tags.  If the value of the tag which they read on
  139.        the floor that they are working is less than the one which they
  140.        find on the floor above, they can advance without any moving to
  141.        the floor above UNLESS that floor is sealed off.  If all of the
  142.        furniture was initially stored in order of value from the ground
  143.        to top floors, their day's work would consist only of checking
  144.        tags and NO moving.
  145.  
  146.        Now let's get real.  DeviceS has two possibilities.  If your
  147.        system has no devices installed by Config.Sys, then NUL will
  148.        chain to CON and, each in turn and in order, will chain to your
  149.        last DOS device.  (That device, by the way, will be the highest
  150.        COM device which your DOS version supports.  My screen example
  151.        shows COM2 for the DOS 3.2 version.  Your DOS 3.3 version might
  152.        show COM4.)
  153.  
  154.        In this first possibility, all devices are in order except for
  155.        the NUL device.  As the movers examine the NUL furniture and CON
  156.        furniture tags, they realize that the NUL furniture must move to
  157.        the second floor in place of the CON furniture.  To accomplish
  158.        this, they first move the CON furniture to the Basement (as done
  159.        by DevSort lines 13 - 19) and after moving the NUL furniture to
  160.        the old CON floor (20 -24), they move the CON furniture from the
  161.        basement to floor #1 (lines 25 - 29).  Noting that they are on
  162.        the Ground floor, they see that there is NO sinking to do and
  163.        therefore advance to floor #2.
  164.  
  165.        Floor #2 contains the NUL furniture which has a higher value than
  166.        the AUX furniture on level 3.  They take the AUX furniture to the
  167.        basement, move the NUL furniture to floor #3 and then bring the
  168.        AUX furniture to floor #2 just vacated by moving NUL to floor #3.
  169.        Now on floor #2, they compare the AUX furniture to CON and since
  170.        CON is lower priced, they recover their place (still on floor 2 -
  171.        at DSdone:) and advance to Floor #3.
  172.  
  173.        Guess what?  Guess what?  Guess what?  etc...  The NUL furniture,
  174.        being higher priced, replaces all the other devices furniture
  175.        until it is on the top floor.  Sinking down each time finds that
  176.        each device below NUL is already in proper order...  This simple
  177.        situation is unusual.  I doubt that it applies to your DeviceS.
  178.        If Config.Sys has loaded any devices, they will chain from NUL
  179.        and the FIRST Config.Sys device loaded will chain to the DOS CON
  180.        device.  In other words, NUL will be out of order at the top as
  181.        in the simple case, but it will be followed by the LAST device in
  182.        memory and ALL others out of order until reaching CON.
  183.  
  184.        When the movers go to work on this mess they will find NUL to be
  185.        properly located below the LAST device in memory.  After that,
  186.        the floor #2 (last device) will begin to move upward in floors.
  187.        As it moves up, the devices loaded after NUL will move down until
  188.        the first floors contain the NUL furniture followed by all of the
  189.        Config.Sys loaded devices' furniture in memory order.  The next
  190.        floor, at that point will contain the CON device furniture.  Not
  191.        only will it be replaced by the LAST device furniture, but, the
  192.        sink routine will really begin to operate at full power.  Once
  193.        the CON device furniture is moved below the last device furniture
  194.        the DSdown: comparison will find that it is also lower than each
  195.        of the other devices in turn until it has reached Ground level.
  196.  
  197.                              DeviceS.DOC - Page 3
  198.  
  199.  
  200.        This sequence of sinking will repeat until the last COM device is
  201.        sunk below the NUL device and above all other DOS devices.
  202.  
  203.        When the "Sinking Bubble Sort" goes into the sink mode, it does
  204.        exactly the same thing that it does in the conventional rising
  205.        mode except that it does it top down instead of bottom up.  The
  206.        sink mode moves furniture from the current position down as far
  207.        as the Ground floor, if necessary to insure that furniture values
  208.        are in ascending order.  In the conventional "bubble sort" there
  209.        is repetition of the bottom to top exchange until the ordering of
  210.        furniture is completed.  The need to go back and start from that
  211.        Ground floor position is eliminated by "sinking" any out-of-order
  212.        value when it is first encountered.
  213.  
  214.        Sinking has two conditions that will stop the movers exchange of
  215.        furniture from a lower out-of-order position through the basement
  216.        to the current "sink" position in exchange for the furniture at
  217.        that position.  The primary condition is that the furniture
  218.        at the two levels is already in order.  The absolute stopper is
  219.        that the lower level is the basement.  Whenever data is moved in
  220.        computer memory, it is only a copy that is moved.  The original
  221.        remains until over-written by the exchange.  When completed, the
  222.        sort routine will have left a copy of the last moved furniture in
  223.        the basement.  If you run DeviceS.EXE in a debugger, a set of NUL
  224.        device furniture will be found to remain in the basement as well
  225.        as at the proper level when the sort is complete.
  226.  
  227.        Two little auxiliary routines, "SI2BX" and the 3 "AX2ASCh" parts
  228.        provide means to copy either characters or ASCII representations
  229.        of numbers into the DevS array.  These routines are ubiquitous in
  230.        assembly language programs.  The AX2ASCh trio are nearly the same
  231.        as used by Chris J. Dunford in his Dev.EXE program.  Nobody has a
  232.        copyright on such common routines and you are free to use both or
  233.        either in any program that will benefit from them.
  234.  
  235.        ShowMsg Proc is quite specialized.  The last part of it from the
  236.        label SMnext: to ShowMsg EndP simply makes a double call to BIOS
  237.        routines to display each character by "teletype" in the same way
  238.        that TYPE at the DOS prompt does except that it initializes the
  239.        space that will be used by each character to the attribute that
  240.        is appropriate for where it is in a line of text.  The NOT Found
  241.        device header error message and heading line will be underlined
  242.        for mono video or black and white on color but the data lines are
  243.        displayed in white on blue for the first 48 characters and white
  244.        on red for the last 17.
  245.  
  246.        The special part of ShowMsg occurs only for lines NOT starting
  247.        with a space.  These record lines MAY contain the data for block
  248.        disk drive devices.  If this is the case, then the Units number
  249.        is converted to a drive letter.  SMproc: decides if this is to be
  250.        done.  SMmore: begins by looking for the next drive letter in the
  251.        "Kind" string.  The first drive device will start with "A:" and
  252.        the letters will increment depending on the number of Units.  In
  253.        my screen example, the first Disk Device is a Zenith driver that
  254.        controls two floppies and four hard disk partitions.  Even if you
  255.        had only 1 floppy drive and 1 hard disk partition, it would still
  256.        reserve letters "A:" and "B:" for floppies and "C: - F:" for your
  257.        hard drive partitions.  So Units = 6 becomes (count 'em) drives
  258.        "A - F".  Updating the 2nd word of FlgS to 6 readies the string
  259.        so that "G" is the next drive, etc.
  260.  
  261.                              DeviceS.DOC - Page 4
  262.  
  263.                                             by Tom Gilbert's Heart&Mind
  264.  
  265.