home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / chasm2.zip / LABEL.ASM < prev    next >
Assembly Source File  |  1985-04-03  |  7KB  |  178 lines

  1. ;===========================================================
  2. ; PROGRAM LABEL  Version 1.10 (1983)
  3. ;
  4. ;        by David Whitman
  5. ;
  6. ; Adds or replaces DOS 2.0 volume labels on already
  7. ; formatted disks.  Will overwrite an existing label.
  8. ; The syntax is:
  9. ;
  10. ;   LABEL [d:]
  11. ;
  12. ; If no drive is specified, the default drive is assumed.
  13. ;
  14. ; LABEL will prompt for the text desired as a volume label.
  15. ; A maximum of 11 characters are allowed.
  16. ;
  17. ; Requires DOS 2.0, will abort under earlier versions.
  18. ; The program will also abort if the specfied disk is
  19. ; formatted with 8 sectors/track.
  20. ;
  21. ; This source file is written for the
  22. ; syntax of the CHASM assembler.
  23. ;============================================================
  24. ; HELP!
  25. ; The author was unable to find a way to safely
  26. ; erase existing volume labels.  The following
  27. ; methods were tried:
  28. ;
  29. ;        Technique                      Result
  30. ;  Delete with DOS call 0AH    Trashed file allocation table
  31. ;  Rename to begin with E5H    High bit turned off, label begins with 'E'
  32. ;  Rename to all blanks        Rename failed - no change in label
  33. ;
  34. ; It would be nice to have this capability.  Any suggestions?
  35. ;=============================================================
  36. ;
  37. ;===============
  38. ; Equates
  39. ;===============
  40. ;
  41. @getver   equ  30H      ;Get DOS version number
  42. @getfsp   equ  36H      ;Get disk free space
  43. @create   equ  16H      ;Create file
  44. @bufinp   equ  0AH      ;Buffered keyboard input
  45. @prnstr   equ  09H      ;Print string
  46. @close    equ  10H      ;close file
  47. @rename   equ  17H      ;rename file
  48. ;
  49. cr        equ  0DH      ;carriage return
  50. lf        equ  0AH      ;line feed
  51. beep      equ  07H      ;bell (makes a beep sound when printed)
  52.  
  53. drvnbr    equ  [5CH]    ;drive number for first parameter
  54.  
  55. ;=============
  56. ; Print title
  57. ;=============
  58.        mov     drvok, al            ;save validity of drive
  59.        mov     dx, offset(title)    ;title message
  60.        mov     ah, @prnstr          ;print
  61.        int     21H                  ;with dos call
  62.  
  63.        cmpb    drvok, 0FFH          ;was the drive valid?
  64.        jne     doschk               ;yes, continue
  65.        mov     dx, offset(baddrv)   ;no, bitch
  66.        mov     ah, @prnstr          ;print message
  67.        int     21H                  ;with dos call
  68.        jmps    exit                 ;and exit
  69.  
  70. doschk mov     ah, @getver          ;what dos are we under?
  71.        int     21H
  72.        cmp     al, 00H              ;earlier than 2.0?
  73.        jne     setdrv               ;no
  74.        mov     dx, offset(baddos)   ;yes: bitch
  75.        mov     ah, @prnstr          ;print message
  76.        int     21H                  ;with dos call
  77.        jmps    exit                 ;and exit
  78.  
  79. setdrv mov     dl, drvnbr           ;get drive number
  80.        mov     drvnbr1, dl          ;and put it in both
  81.        mov     drvnbr2, dl          ;extended FCBs
  82.  
  83. ;=============================================================
  84. ;we can tell what format the disk is in by examining the total
  85. ;number of clusters available.  The following numbers apply:
  86. ;
  87. ;  162H = 2 sides, 9 tracks    15FH = 1 side, 9 tracks
  88. ;  13BH = 2 sides, 8 tracks    139H = 1 side, 8 tracks
  89. ;=============================================================
  90.                                     ;dl already has drive number
  91. chkdsk mov     ah, @getfsp          ;get disk info
  92.        int     21H                  ;with dos call
  93.        cmp     dx, 13BH             ;how many clusters?
  94.        jg      input                ;more than 8 sectors, ok
  95.        mov     dx, offset(baddsk)   ;8 sectors? bitch
  96.        mov     ah, @prnstr          ;print message
  97.        int     21H                  ;with dos call
  98.        jmps    exit                 ;and quit
  99.  
  100. ;=========================================
  101. ; Prompt for and input the new label text.
  102. ;=========================================
  103. input  mov     dx, offset(prompt)   ;point to prompt message
  104.        mov     ah, @prnstr          ;print prompt
  105.        int     21H                  ;with dos call
  106.        mov     dx, offset(buffer)   ;point to buffer
  107.        mov     ah, @bufinp          ;call for buffered input
  108.        int     21H                  ;with dos call
  109.  
  110. ;=========================
  111. ; Create the volume label.
  112. ;=========================
  113. write  mov     si, offset(buftxt)   ;input buffer
  114.        mov     di, offset(newname)  ;rename field
  115.        sub     cx,cx                ;zero cx
  116.        mov     cl, numchr           ;number of input chars
  117.        rep                          ;move'em into FCB rename field
  118.        movsb
  119.        mov     dx, offset(xfcb2)    ;try to rename
  120.        mov     ah, @rename          ;with dos call
  121.        int     21H
  122.        cmp     al, 00H              ;was rename sucess?
  123.        je      exit                 ;yes, exit
  124.  
  125.        mov     si, offset(buftxt)   ;otherwise create new label
  126.        mov     di, offset(name1)    ;move text into fcb
  127.        sub     cx, cx               ;as above
  128.        mov     cl, numchr
  129.        rep
  130.        movsb
  131.        mov     dx, offset(xfcb)     ;and create label
  132.        mov     ah, @create          ;with dos call
  133.        int     21H
  134.  
  135. exit   mov     dx, offset(crlf)     ;start new line
  136.        mov     ah, @prnstr
  137.        int     21H
  138.        int     20H                  ;and get out of here
  139.  
  140. ;=======================
  141. ; Input buffer
  142. ;=======================
  143. buffer db      0CH        ;can hold 12 chars (including a CR)
  144. numchr db      00H        ;number of characters inputted
  145. buftxt ds      12, ' '    ;initial text is twelve spaces
  146.  
  147. drvok  db      00H        ;holds entry al value - drive validity
  148.  
  149. ;=======================
  150. ;File control blocks
  151. ;=======================
  152. xfcb    db 0FFH, 0,0,0,0,0
  153. attrib  db 08H                   ;volume label attribute
  154. drvnbr1 db 00H                   ;drive number
  155. name1   db '        '            ;name
  156.         db '   '                 ;extension
  157.         ds 25                    ;rest of fcb
  158.  
  159. xfcb2   db 0FFH, 0,0,0,0,0
  160. attrib2 db 08H                   ;volume label attribute
  161. drvnbr2 db 00H                   ;drive number
  162.         db '????????'            ;name
  163.         db '???'                 ;extension
  164.         ds 5                     ;first 5 'reserved' bytes
  165. newname db '        '            ;rename field
  166.         db '   '                 ;new extension
  167.         ds 9                     ;rest of fcb
  168.  
  169. ;==========
  170. ;Messages
  171. ;==========
  172. title  db  cr,lf 'LABEL Version 1.1 - 1983 by D. Whitman' cr,lf '$'
  173. prompt db  'Volume label (11 characters maximum): $'
  174. baddrv db  beep,cr,lf 'Invalid drive specification!' cr, lf, '$'
  175. baddos db  beep,cr,lf 'This utility only works under DOS 2.0!' cr, lf, '$'
  176. baddsk db  beep,cr,lf 'Volume labels not allowed on 8 track disks!' cr, lf, '$'
  177. crlf   db  cr, lf, '$'
  178.