home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / FLOPPIES / CHKVOL12.ZIP / CHKVOLID.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-02-27  |  5.6 KB  |  209 lines

  1. ;----------------------------------------------------------------------
  2. ;  Check the volume label on a disk
  3. ;----------------------------------------------------------------------
  4. ; Released to public domain 12-89 by Wayne Mingee
  5. ;
  6. ; FORMAT:        chkvolid [d:] 'volid'
  7. ;
  8. ;                volid must be enclosed in ' or "
  9. ;                if no [d:] given use default drive
  10. ;                if no 'volid' given then display volume label
  11. ;
  12. ; RETURNS ERRORLEVEL
  13. ;          1 = wrong vol id
  14. ;          2 = disk has no volume label
  15. ;          3-239 = disk status
  16. ;          240-255 = disk type
  17. ;------------------------------------------------------------------------------
  18. cseg        segment para public 'code'
  19.             assume  cs:cseg, ds:cseg, es:cseg, ss:cseg
  20.  
  21. dosfunc    equ   21h
  22. terminate  equ   4ch
  23.  
  24.            org   5ch
  25. data0      db    ?
  26.  
  27.            org   80h
  28. cmdlen     db    ?
  29. cmdline    db    128 dup (?)
  30.  
  31.            org   100h
  32. begin:     jmp   start
  33.  
  34. filename   db    ??filename,' '
  35.            db    ??date
  36.            db    ' v1.1'
  37. sdr        db    'd:*.*',0
  38. cmdsave    db    64 dup (0)
  39. errcode    db    2
  40. dskstat    db    0
  41. ;----------------------------------------------------------------------
  42. Start      proc  near
  43. ;------------------------------------------------------------------------------
  44.            cld
  45. ; go see if drive available
  46.            call  chkdrv
  47. ; if no disk errors continue else return code
  48.            cmp   dskstat, 0
  49.            je    norm
  50.            cmp   dskstat, 240
  51.            ja    norm
  52.            mov   al, dskstat
  53.            jmp   quit
  54. ; see drive given
  55. norm:      lea   dx, sdr+2
  56.            mov   cl, cmdlen
  57.            xor   ch, ch
  58.            jcxz  gotdr
  59.            inc   cx
  60.            mov   al, ' '
  61.            lea   di, cmdline
  62.            repe  scas cmdline          ;skip the blanks
  63.            je    gotdr
  64.            cmp   byte ptr [di], ':'
  65.            jne   nodr                  ;no drive given
  66.            mov   ah, byte ptr [di-1]
  67.            mov   sdr, ah
  68.            lea   dx, sdr
  69. ; now look for volid
  70.            inc   di
  71.            dec   cx
  72.            repe  scas cmdline
  73.            je    gotdr
  74. nodr:      push  di
  75.            pop   si
  76.            dec   di
  77.            cmp   byte ptr[di], '"'     ;volid must be in ''or ""
  78.            je    usesg
  79.            cmp   byte ptr[di], "'"
  80.            jne   gotdr
  81. ; search for trailing ' "
  82. usesg:     mov   al, byte ptr [di]
  83.            add   di, cx
  84.            std
  85.            repne scasb
  86.            jne   gotdr
  87.            cld
  88.            lea   di, cmdsave
  89.            rep   movsb
  90.            mov   errcode, 1
  91.  
  92. gotdr:                                 ; get volume label
  93.            mov   ax, 4e00h
  94.            mov   cx, 8
  95.            int   DosFunc
  96.            jc    error
  97. ;                                      ; get DTA address
  98.            mov   ax, 2f00h
  99.            int   DosFunc
  100.            assume es:nothing
  101.            jc    error
  102. ; setup for compare
  103.            push  bx
  104.            pop   di
  105.            add   di, 1eh
  106.            cmp   errcode, 2
  107.            je    displayid
  108.            lea   si, cmdsave
  109.            mov   cx, 13
  110. ; when we find a period bump past it since cmnd line won't have one
  111. ; DOS will compress spaces before '.' so bump up 8 in cmd line
  112. compn:     cmp   byte ptr [di], '.'
  113.            jne   cont
  114.            lea   si, cmdsave+8
  115.            jmp   incdi
  116. ; capitalize and compare
  117. cont:      lodsb
  118.            cmp   al, 'a'
  119.            jl    docomp
  120.            cmp   al, 'z'
  121.            jg    docomp
  122.            and   al, 5fh
  123. docomp:    cmp   al, byte ptr [di]
  124.            jne   error
  125.            cmp   al, 0                 ;end of line - all good
  126.            je    stop
  127. incdi:     inc   di
  128.            loop  compn
  129.  
  130. stop:      mov   errcode, 0
  131.  
  132. error:     mov   al, errcode
  133. quit:      mov   ah, Terminate
  134.            int   DosFunc
  135.            assume es:@curseg
  136.  
  137. ; no cmd line volid display volume label
  138. displayid: mov   cx, 12
  139. displaylp: mov   ah, 6
  140.            mov   dl, byte ptr [di]
  141.            cmp   dl, '.'
  142.            jne   send
  143.            mov   dl, ' '
  144.            cmp   cx, 4
  145.            jg    skip
  146.            inc   di
  147.            jne   displaylp
  148. send:      cmp   dl, 0
  149.            je    tstd
  150.            inc   di
  151. skip:      int   DosFunc
  152.            loop  displaylp
  153. tstd:      mov   al, dskstat
  154.            jmp   quit
  155.  
  156. start      endp
  157. ; see if drive ready and disk formated
  158. chkdrv     proc  near
  159.            mov   dl, data0
  160.            xor   dh, dh
  161.            dec   dl
  162.            jns   jmp1
  163.            mov   ah, 19h
  164.            int   dosfunc
  165.            mov   dl, al
  166. jmp1:
  167.            push  dx
  168.            int   11h
  169.            test  al, 01h
  170.            jz    jmp3
  171.            mov   cl, 6
  172.            shr   al, cl
  173.            and   al, 03h
  174.            jnz   jmp1a
  175.            mov   al, 01h
  176. jmp1a:     cmp   al, dl
  177.            jb    jmp3
  178. ; FD's only
  179. testfd:
  180.            mov   ah, 04h
  181.            mov   al, 01h
  182.            mov   ch, 00h
  183.            mov   cl, 01h
  184.            int   13h        ;verify disk sectors
  185.            jnb   jmp3
  186.            add   ah, 2
  187.            cmp   dskstat, 0
  188.            mov   dskstat, ah
  189.            je    testfd
  190.            mov   ah, 00h
  191.            int   13h        ;reset disk system
  192.            pop   dx
  193.            jmp   jmp2
  194. jmp3:                                  ;HD's and ok FD's get type
  195.            pop   dx
  196.            inc   dl
  197.            mov   ah, 1ch
  198.            xor   dh, dh
  199.            push  ds
  200.            int   dosfunc
  201.            mov   al, byte ptr [bx]
  202.            pop   ds
  203.            mov   dskstat, al
  204. jmp2:      ret
  205. chkdrv     endp
  206.  
  207. cseg       ends
  208.            end     begin
  209.