home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR3 / FMTFIX62.ZIP / FMTFIX.ASM next >
Assembly Source File  |  1994-01-26  |  4KB  |  145 lines

  1.     page ,132
  2. ;fmtfix vers 1.0  wm thompson January 25, 1994
  3. ;
  4. ;avoids long delay when trying to format a blank disk under
  5. ;ms-dos 6.2.  this is due to doublespace's "automount" feature
  6. ;which tries to determine if the disk is doublespace formatted.
  7. ;in particular with machines having an AMI bios and running
  8. ;smartdrive, this causes a delay of over a minute before the disk
  9. ;starts formatting.  this program detects the first disk read with
  10. ;a "missing address mark" error (a blank) and fakes all subsequent
  11. ;reads within 1/2 second with an immediate failure, thereby avoiding
  12. ;the delay.
  13.  
  14. ;assemble like this:
  15. ; masm fmtfix;
  16. ; link fmtfix;
  17. ; exe2bin fmtfix fmtfix.com
  18.  
  19. ;interrupt vectors
  20. bioint    equ    13h            ;std bios disk call
  21. timint    equ    08h            ;timer tick interrupt
  22.  
  23. ;labels for interrupt jump table
  24. abs0    segment at 0
  25.     org    bioint*4
  26. biooff    label    word            ;disk interrupt
  27.     org    $+2
  28. bioseg    label    word
  29.     org    timint*4
  30. timoff    label    word            ;timer tick interrupt
  31.     org    $+2
  32. timseg    label    word
  33. abs0    ends                ;end of labels
  34.  
  35. ;and now, the actual program...
  36. code    segment                ;segment for pgm
  37.     assume cs:code,ds:abs0
  38.     org    100h
  39.  
  40. start:    jmp    setup            ;go install this tsr
  41.  
  42. ;tsr replacement dos function call for trap
  43. newdsk:    cmp    dl,1            ;drive a: or b:?
  44.     ja    nwdsk1            ;no, jmp to bios
  45.  
  46. nwc1:    cmp    ah,2            ;read sectors?
  47.     jne    nwdsk1            ;no, jmp to bios
  48.  
  49. nwc2:    and    byte ptr cs:lastc,-1    ;count down=0?
  50.     jnz    nwc4            ;no, restart count and fail
  51.  
  52. nwc3:    pushf                ;yes, pretend this is an interrupt
  53.     call    cs:dskbio        ;and do the read using bios
  54.     jnc    nwc6            ;exit saving flags if ok
  55.     cmp    ah,2            ;missing addr mark (blank disk)?
  56.     jne    nwc5            ;exit with error if not
  57.  
  58. nwc4:    mov    al,9            ;else, preset count
  59.     mov    cs:lastc,al
  60.     mov    al,0            ;no sctrs read, addr mark fail (ah=2)
  61. nwc5:    stc                ;carry set=fail
  62. nwc6:    retf    2            ;and return from int saving flags
  63.  
  64. ;jump to installed far address for dos call
  65. nwdsk1:    db    0eah            ;far jmp opcode
  66. dskbio    label    dword            ;for far call to bios disk funct.
  67. nwdsk2:    dw    0            ;code addr overwritten at install
  68.     dw    0            ;seg addr overwritten at install
  69.  
  70. ;timer tick interrupt add-on counts down until it reaches zero
  71. newtim:    or    byte ptr cs:lastc,0    ;timer counted down?
  72.     jz    gotim            ;yes, do nothing
  73.     dec    byte ptr cs:lastc    ;no, count down one tick
  74. gotim:    db    0eah            ;far jmp opcode
  75. timx    dw    0            ;addr written at install
  76.     dw    0            ;jmps to original timer code
  77.  
  78. ;storage
  79. lastc    db    0            ;save time count
  80. last_adr:                ;for term and stay resident
  81.  
  82. ;installation code used once at startup
  83.     assume ds:abs0
  84.  
  85. setup:    push    ds            ;set data segment
  86.     xor    ax,ax            ;for int vector table
  87.     mov    ds,ax
  88.     assume    ds:abs0
  89.  
  90.     mov    si,bioint*4        ;install old interrupt addr's
  91.     mov    ax,[si]    
  92.     cmp    ax,offset newdsk    ;already installed?
  93.     je    noins            ;yes, don't re-do
  94.  
  95.     lea    bx,nwdsk2        ;in our code
  96.     mov    cs:[bx],ax
  97.     mov    ax,[si+2]
  98.     mov    cs:[bx+2],ax
  99.  
  100.     mov    si,timint*4
  101.     lea    bx,timx
  102.     mov    ax,[si]
  103.     mov    cs:[bx],ax
  104.     mov    ax,[si+2]
  105.     mov    cs:[bx+2],ax
  106.  
  107.     pop    ds            ;restore data segment
  108.     assume ds:code
  109.  
  110.     lea    dx,newdsk        ;new disk bios interrupt vector offset
  111.     mov    ah,37            ;change vector function
  112.     mov    al,bioint
  113.     int    21h
  114.  
  115.     lea    dx,newtim        ;new timer interrupt vector offset
  116.     mov    ah,37            ;change vector function
  117.     mov    al,timint
  118.     int    21h
  119.  
  120.     lea    dx,msg            ;display signon message
  121.     mov    ah,9
  122.     int    21h
  123.  
  124.     lea    dx,last_adr        ;for memory alloc
  125.     int    27h            ;term and stay resident
  126.  
  127. noins:    pop    ds            ;no install
  128.     assume ds:code
  129.     lea    dx,msg2            ;display no install message
  130.     mov    ah,9
  131.     int    21h
  132.     int    20h            ;exit to dos
  133.  
  134. msg    db    "DOS 6.2 resident format fix utility v1.0"
  135.     db    0dh,0ah
  136.     db    "copyright (c) 1994 William M. Thompson"
  137.     db    0dh,0ah,"$"
  138.  
  139. msg2    db    "DOS 6.2 resident format fix utility already installed"
  140.     db    0dh,0ah,"$"
  141.  
  142. code    ends                ;end code segment
  143.     end    start            ;end of program
  144.  
  145.