home *** CD-ROM | disk | FTP | other *** search
/ Shareware Supreme Volume 6 #1 / swsii.zip / swsii / 167 / FILLDISK.ZIP / FILLDISK.ASM < prev    next >
Assembly Source File  |  1990-10-10  |  4KB  |  158 lines

  1.  
  2.  
  3. ;       FILLDISK.ASM                        DOS UTILITY  10/03/86 BTR
  4. ;    ------------
  5. ;    Purpose:  Calculate remaining free disk space on target drive
  6. ;                 and fill with  one file of specified constant data.
  7. ;
  8. ;       Syntax:   FILLDISK <targetdrive> <filename> <fillchar> 
  9. ;
  10. ;       Example:  FILLDISK A: ZEROS.ABS 00
  11. ;         or      FILLDISK B: BLANK.TXT 20H
  12.  
  13.  
  14. CSEG            Segment
  15.         Assume    CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG
  16.         Org    002Ch
  17. Environment    Label     Word        ; Segment of Environment
  18.         Org    0080h
  19. Parameter    Label    Byte        ; Parameter         
  20.         Org    0100h
  21. Entry:        Jmp    Begin        ; Entry Point
  22.  
  23.  
  24. ;    Data Declarations
  25. ;    -----------------
  26.  
  27. SyntaxMsg    db    "Syntax:  FILLDISK <targetdrive> <filename> <fillchar>"
  28.          db    13,10,10
  29.                 db    "Example: FILLDISK A: ZEROS.ABS 00",13,10
  30.          db    "  or     FILLDISK B: BLANK.TXT 20H$"
  31.  
  32. DosVersMsg    db    "Needs DOS 2.0 +$"
  33. ParmsMsg    db    "Incorrect Parms$"
  34. Delimiters    db    9,' ,;='
  35. SpaceMsg    db    "KBytes were written to disk under filename $"
  36. PrintMsg    db    "Want to print file allocation table? (Y/N): $"
  37.  
  38.  
  39. ;    Check DOS Version
  40. ;    -----------------
  41.  
  42. Begin:        Mov    AH, 30h            ; Check for DOS Version
  43.         Int    21h            ;   through DOS call
  44.         Cmp    AL, 2            ; See if it's 2.0 or above
  45.         Jae    DosVersOK        ; If so, continue
  46.  
  47.         Mov    DX, Offset DosVersMsg    ; Error message
  48. ErrorExit:    mov    AH, 9            ; Print String function call
  49.         Int    21h            ; Do it
  50.         Int    20h            ; And exit prematurely
  51.  
  52.  
  53. ;    Parse Command Line
  54. ;    ------------------
  55.  
  56. ScanParms:    Lodsb                ; SUBROUTINE: Get byte
  57.         Cmp    AL, 13            ; See if end of parameter
  58.         Je    ErrorExit        ; If so, exit
  59.          Mov    DI, Offset Delimiters    ; Check if delimiter
  60.      Mov    CX, 5                        ; There are 5 of them
  61.         Repne    Scasb            ; Scan the string
  62.         Ret                ; And return
  63.  
  64.  
  65. ;       Video Subroutines
  66. ;       -----------------
  67.  
  68. VideoMod:       Mov    AL,0            ; 0 Text Med  40x25 CGA
  69.                         ; 2 Text High 80x25 CGA
  70.  
  71.                 Mov     AH,0             ; Function Set Video Mode
  72.         Int    10h
  73.         Ret
  74.  
  75. ClearWdw:    Mov     CH,0            ; Row upper left
  76.         Mov    CL,0            ; Column upper left
  77.         Mov     DH,24            ; Row lower left
  78.         Mov    DL,80            ; Column upper right
  79.         Mov     BH,7            ; Blank line attribute
  80.         Mov     AL,0            ; Number of lines to scroll
  81.  
  82.         Mov    AH,6            ; Function Scroll Window Up
  83.         Int    10h
  84.         Ret
  85.  
  86. PosCursr:    Mov    AH,2            ; Function Position Cursor
  87.         Int    10h            ; (DH Row, DL Column)
  88.         Ret
  89.  
  90.  
  91. ;     Error Handling
  92. ;    --------------
  93.  
  94. DosVersOK:    Mov    DX, Offset SyntaxMsg     ; Possible error msg
  95.         Mov    SI, 1+Offset Parameter    ; Parameter string
  96.         Cld                ; Directions forward
  97.  
  98. BegSearch:    Call    ScanParms        ; Check byte in subroutine
  99.         Je    BegSearch        ; If delimeter, keep searching
  100.         Mov    BX, SI            ; Save pointer in BX
  101.         Dec    BX            ; BX points to file spec
  102.  
  103. EndSearch:    Call    ScanParms        ; Check byte in subroutine
  104.         Jne    EndSearch        ; If not delimeter, keep going
  105.  
  106.  
  107. ;    Separate Parms  <targetdrive> <filename> <fillcharacter>
  108. ;    --------------------------------------------------------
  109.  
  110.         Dec     SI              ; Points after Parm
  111.         Xchg    SI, BX            ; SI points to beg, BX to end
  112.         Mov    DI, Offset FullPath    ; Points to destination
  113.         Cmp    Byte Ptr [SI + 1], ':'    ; See if drive  spec included
  114.         Jnz    GetDrive        ; If not, must get the drive
  115.         Lodsw                ; Otherwise, grab drive spec
  116.         Add    AL, 0DFh        ; Capitalize letter
  117.         Sub    AL, 40h            ; get drive number (A=1) 
  118.         Jmp    Short SaveDrive        ; And skip next section
  119.         
  120. GetDrive:    Mov    AH, 19h            ; Get current drive
  121.         Int    21h            ;   through DOS
  122.         Add    AL, 'A'            ; Convert to letter
  123.         Mov    AH, ':'            ; Colon after drive letter
  124.  
  125. SaveDrive:    Stosw                ; Save drive spec and colon
  126.         Int    21h            ;   through DOS
  127.  
  128. .....
  129.  
  130. get name of disk fill file
  131.  
  132. get fill character in hex
  133.  
  134. .....
  135.         Mo÷    DX¼ Offse⌠ ParmsMsτ    ╗ Possiblσ erro≥ message
  136.         Jc    ErrorExit         ; Exit it error
  137.         Sub    AL, Al            ; Search for terminating zero
  138.         Cmp    [SI], AL        ; Check if Root Directory
  139.         Jz    RootDir            ; If so, don't use it
  140.         Mov    CX, 64            ; Number of byte to search
  141.         Repnz    Scasb            ; Do the search
  142.         Dec    DI            ; DI points to last zero
  143.         Mov    AL, '\'            ; Put a backslash in there
  144.         Stosb                ; So filespec can follow
  145. RootDir:    Pop    SI            ; Get back SI
  146. AllParmsOk:    Mov    CX, BX            ; End of file spec
  147.  
  148. .....
  149.  
  150. open file
  151.  
  152. write file
  153.  
  154. .....
  155.  
  156. CSEG        EndS                ; End of the segment
  157.         End    Entry            ; Denotes entry point
  158.