home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / SYSUTL / TSRWRK32.ZIP / DEVICES.DOC < prev    next >
Encoding:
Text File  |  1989-06-01  |  13.5 KB  |  263 lines

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