home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 11a / flop.zip / FLOP.ASM next >
Assembly Source File  |  1987-07-18  |  12KB  |  226 lines

  1. TITLE        FLOP        6-16-87        [6-16-87]
  2. ;
  3. ;  Author  Rick Housh
  4. ;
  5. ;For PC's and compatibles
  6. ;
  7. ;SPEED UP YOUR FLOPPIES  -  Start doing it now.
  8. ;
  9. ;For reference, see the column "C Notes", by Joseph Katz in SEXTANT
  10. ;magazine, May-June, 1987, pp. 46-53, and the article "Faster Disk
  11. ;Access for Heath/Zenith MS-DOS", by Pat Swayne, REMark magazine,
  12. ;August, 1986.  Both those articles deal with the concept of this
  13. ;simple utility.
  14. ;
  15. ;This program, while originally written for Heath/Zenith PC compatible
  16. ;computers, should work with any IBM PC compatible, with ANY version
  17. ;of MS-DOS, with assembly by ANY version of MASM.
  18. ;
  19. ;Reconfigures floppy drives to modify the head settle times and
  20. ;wait for motor start set in ROM.  These original times have proved
  21. ;to be overly conservative for the latest half-height drives with locking
  22. ;latches, in which the heads are always engaged.
  23. ;
  24. ;Based on an original idea by Pat Swayne, modified and translated by me
  25. ;into Turbo Pascal, rewritten by Joseph Katz in 'C', and here translated
  26. ;back into assembly language for MASM.
  27. ;
  28. ;All higher language overhead has been removed here, and the medium speed
  29. ;has been modified slightly, to allow some head settle time.  Experience
  30. ;and testing have indicated that, while reducing the head settle time to
  31. ;zero has increased transfer rates, it has also increased the number of
  32. ;retries caused by read or write errors.  If that does not prove to be
  33. ;a problem, use FLOP FAST, otherwise use FLOP MEDIUM.  Almost never should
  34. ;FLOP SLOW be required.
  35. ;
  36. ;How will you know if you have an excessive number of retries?  Beats me!
  37. ;My Shugarts do, my Teacs don't.
  38. ;
  39. ;This is NOT a TSR (memory resident) program.  It patches (on the fly)
  40. ;the memory locations in which DOS holds the DBP (disk base parameters).
  41. ;Therefore, it can be run at any time and will effectuate the changes
  42. ;immediately.
  43. ;
  44. ;Typically, switching from FLOP SLOW to FLOP FAST will result in an increase
  45. ;in the data transfer rate of about 30%, a worthwhile gain.
  46. ;
  47. ;Actually, to be completely "well-behaved" this program should get the
  48. ;segment and offset addresses of the disk parameters through function
  49. ;35 (hex) of DOS interrupt 21 (hex), which would supply the vector to
  50. ;them, then use function 25 (hex) to reset the vectors to entirely new
  51. ;locations.
  52. ;
  53. ;Nevertheless, in the interests of speed and size, direct memory
  54. ;access is used herein, based on the assumption that Bill Gates and
  55. ;"Big Blue" will not decide to grace us all with a change, and the
  56. ;values in the original locations are simply "patched" with new values.
  57. ;"And God bless us all," said Tiny Tim.
  58. ;
  59. ;In his column Dr. Katz expressed some anxiety that many Turbo Pascal
  60. ;programmers might be in better physical condition than he, implying
  61. ;some apprehension that he might be in danger of abuse for criticizing
  62. ;someone's choice of language.  I, for one, am just a simple country lawyer,
  63. ;as deskbound as any college professor such as Dr. Katz, and have no intention
  64. ;of disputing his claims that C can produce more compact programs.  On the
  65. ;contrary, I agree.  What I do not agree with is that one needs a C shell
  66. ;simply for the purpose of calling a few assembly language routines.
  67. ;
  68. ;To those of you who are interested, because I was taken somewhat to
  69. ;task by Dr. Katz for my Turbo Pascal program, which occupied about
  70. ;12,000 bytes, while his 'C' program only used about 6,000, this assembly
  71. ;program, which performs almost exactly the same function, uses only 472
  72. ;bytes, less than one standard MS-DOS disk sector.
  73. ;
  74. ;How can that be, you say?
  75. ;
  76. ;Well, it has nothing in it that it doesn't use, while compilers have
  77. ;a lot of unused baggage.  Yes, Turbo Pascal has more than C.
  78. ;
  79. ;You get what you pay for (with your coding time) and compilers carry
  80. ;overhead.  This is a very small program, and should be written in
  81. ;assembly language.  I have done it here just to show the contrast.
  82. ;
  83. ;It could even be written in <UGH> BASIC and compiled, in which case it
  84. ;would need about 32,000 bytes.  (Think of all the unused "PLAY" and
  85. ;"SCREEN" and "Who-Knows-What-Else" code which is carried along, unused).
  86. ;
  87. ;It is the "#include <stdio.h>" in Dr. Katz' C program which carries the
  88. ;C baggage.  The equivalent code is automatically included in Turbo Pascal
  89. ;and Basic.  Assembly includes nothing you don't write yourself.
  90. ;
  91. ;If you are interested, access Compuserve, Heath Users Group, (GO PCS 48)
  92. ;and download my Turbo Pascal program DSKSPD.ARC, in addition to this
  93. ;program, FLOP.ARC.  I could not find Dr. Katz' program SPIN.C (mentioned in
  94. ;his SEXTANT column) there.  I guess you'll have to buy that issue.
  95. ;
  96. ;The whole schmear (SP?) is a good lesson in why you should learn assembly
  97. ;language.
  98. ;
  99. ;                            Rick Housh
  100. ;                            Compuserve PIN 72466,212
  101. ;                            MUG (Mission, KS. User's Group)
  102. ;                            BBS (913) 362-9583
  103. ;
  104. ;  My thanks to Tom Gilbert, President, MUG, (Mission, Kansas Users' Group),
  105. ;  whose course in assembly language made this possible for me.
  106. ;
  107. ;       Next is assembly code for FLOP.COM
  108. ;
  109. ;First, the equates:
  110. ;
  111. LF              equ     0Ah                     ;Line feed
  112. CR              equ     0Dh                     ;Carriage return
  113. BELL            equ     07h                     ;ASCII bell character ^G
  114. CMD_LINE        equ     80h                     ;Command line length location
  115. PARM_CHAR       equ     82h                     ;1st significant char in cmd ln
  116. ALT_PARM_CHAR   equ     83h                     ;2nd    "         "    "  "   "
  117. HEAD_SETTLE     equ     0579h                   ;Disk base parameter memory
  118. MOTOR_START     equ     057Ah                   ;locations for head settle time
  119.                                                 ;and motor start wait time,
  120.                                                 ;respectively.  In seg 0000:
  121. SET_FLOPPIES        SEGMENT
  122.  
  123.       ASSUME DS:SET_FLOPPIES, SS:SET_FLOPPIES, CS:SET_FLOPPIES, ES:SET_FLOPPIES
  124.  
  125.         ORG        100h
  126. START:        jmp        INIT_GETPARMS
  127.  
  128. NOPARM_MSG         db      BELL,CR,'FLOP.COM by Rick Housh '
  129.                    db      CR,LF,'Optimizes floppy disk access times.'
  130.                    db      CR,LF,'You must enter a valid parameter.'
  131.                    db      CR,LF
  132.                    db      'Proper syntax is FLOP/Speed or FLOP Speed'
  133.                    db      ' where "Speed" is FAST,'
  134.                    db      CR,LF,'MEDIUM, NORMAL, or SLOW,'
  135.                    db      ' e.g., FLOP FAST, FLOP/FAST, FLOP F, or FLOP/F.'
  136.                    db      CR,LF,'Normal and Slow are the same.'
  137.                    db      ' Current settings not changed.'
  138.                    db      CR,LF,'$'
  139.  
  140. ;The next two db's are here only to allow you to get the above message printed
  141. ;to the screen when you enter TYPE FLOP.COM at the DOS prompt.
  142. ;FIXIT knocks out the $ sign and CTRL_Z makes the DOS TYPE command think it
  143. ;sees the end of a text file.  You may remove them and save three bytes if
  144. ;you don't care about that.
  145.  
  146. FIXIT              db      CR,' '
  147. CTRL_Z             db      1Ah
  148.  
  149. ;But don't remove the next four db's.  They are necessary messages.
  150.  
  151. FLOP_SET_MSG       db      CR,LF,'Floppies set to $'
  152. FAST_MSG           db      'fast.',CR,LF,'$'
  153. MEDIUM_MSG         db      'medium.',CR,LF,'$'
  154. SLOW_MSG           db      'normal (slow).',CR,LF,'$'
  155.  
  156.  
  157. INIT_GETPARMS:
  158. ;
  159. ;  We're going to fudge quite a bit here, in the interest of saving space.
  160. ;  We should throw away leading spaces and other junk, but won't.
  161. ;  We'll allow just one extra character at beginning of param line.
  162. ;  The worst that will happen is a "no parameter" message.
  163. ;
  164.         mov     AH,[CS:CMD_LINE]                ;Get # of chars in param string
  165.         cmp     AH,02h                          ;Are there less than two?
  166.         jb      ERROR_EXIT                      ;Then not enough. Exit
  167.         mov     AL,[CS:PARM_CHAR]               ;Get second char in param line
  168.         cmp     AL,'/'                          ;Is it a slash?
  169.         jnz     NOT_SLASH                       ;No? Then read it.
  170.         mov     AL,[CS:ALT_PARM_CHAR]           ;Yes? Then read third.
  171. NOT_SLASH:
  172.         cmp     AL,'f'                          ;Is 1st char less than 'f'?
  173.                                                 ;e.g., upper case?
  174.         jb      CONTINUE                        ;Yes? Then use it.
  175.         sub     AL,20h                          ;Else make upper case.
  176. CONTINUE:
  177.         cmp     AL,'S'                          ;Is it 'Slow'
  178.         jz      DO_SLOW                         ;Yes?  Then make floppies slow
  179.         cmp     AL,'N'                          ;Is it 'Normal'?
  180.         jz      DO_SLOW                         ;Yes? Then same as Slow.
  181.         cmp     AL,'M'                          ;Is it 'Medium'?
  182.         jz      DO_MEDIUM                       ;Yes?  Then set floppies medium
  183.         cmp     AL,'F'                          ;Is it  'Fast'? (Last option)
  184.         jnz     ERROR_EXIT                      ;Yes?  Then just fall through
  185.                                                 ;else go to error exit.
  186. DO_FAST:                                        ;If going to fast floppies
  187.         mov     BH,00h                          ;Set head settle for 0 msec.
  188.         mov     BL,01h                          ;and motor start wait for 1/8,
  189.         mov     DX,OFFSET FAST_MSG              ;Get ready to print message
  190.         jmp     SET_SPEED                       ;and do it.
  191. DO_MEDIUM:                                      ;If going to medium
  192.         mov     BH,03h                          ;Head settle at 3 msec.
  193.         mov     BL,02h                          ;Mtr start wait at 1/4 sec.
  194.         mov     DX,OFFSET MEDIUM_MSG            ;Get ready to print message
  195.         jmp     SET_SPEED                       ;and do it.
  196. DO_SLOW:
  197.         mov     BH,0Dh                          ;Slow head settle is 13 msec!
  198.         mov     BL,08h                          ;and mtr start wait is 1 sec!
  199.         mov     DX,OFFSET SLOW_MSG              ;No other possibility here
  200.                                                 ;so just fall through.
  201. SET_SPEED:
  202.         push    DX                              ;Save floppy speed msg ptr
  203.         mov     AH,09h                          ;Set for print string function
  204.         mov     DX,OFFSET FLOP_SET_MSG          ;for "Floppies set to "
  205.         int     21h                             ;and call DOS
  206.         push    BP                              ;Save BP
  207.         mov     BP,SP                           ;Move SP to BP
  208.         push    ES                              ;Save Extra Segment
  209.         xor     AX,AX                           ;Set AX to zero
  210.         mov     ES,AX                           ;and set ES to Seg 0000:
  211.         mov     BYTE PTR ES:[HEAD_SETTLE],BH    ;Put value in BH in 0000:0579h
  212.         mov     BYTE PTR ES:[MOTOR_START],BL    ;and value in BL in 0000:057ah
  213.         pop     ES                              ;Restore ES
  214.         pop     BP                              ;and BP
  215.         pop     DX                              ;Get speed message ptr
  216.         jmp     FINIS
  217. ERROR_EXIT:
  218.         mov     DX,OFFSET NOPARM_MSG            ;Set ptr to info-error message
  219. FINIS:
  220.         mov     AH,09h                          ;and
  221.         int     21h                             ;print the message at DX,
  222.         int     20h                             ;then Quit.
  223.         SET_FLOPPIES        ENDS
  224. ;
  225. END        START
  226.