home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CLIPB52.ZIP / COLE.ZIP / DRIVES.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-17  |  4.4 KB  |  128 lines

  1. ; Drives.asm
  2.  
  3. ; Contains 2 functions:
  4.  
  5. ; Syntax   : DrvType( <N>)
  6. ; Purpose  : To determine the type of floppy disk drive.
  7. ; Parameter: <N> 0 = 1st diskette drive (A:), 1 = 2nd (B:), etc.
  8. ; Return   : <N> 0 = error or no such floppy drive
  9. ;                1 = 360 floppy drive
  10. ;                2 = 1.2 mb floppy
  11. ;                3 = 720k floppy
  12. ;                4 = 1.44mb floppy
  13.  
  14. ; Syntax   : DrvNum()
  15. ; Purpose  : To determine the number of floppy drives.
  16. ; Parameter: None.
  17. ; Return   : <N> Number of floppy drives.
  18. ;-----------------------------------------------------
  19.  
  20. EXTRN           __PARNI:far
  21. EXTRN           __RETNI:far
  22.  
  23. PUBLIC          DrvType, DrvNum
  24.  
  25. DGROUP          GROUP   DATASG          ; Combine my data segment with Clipper's.
  26.  
  27. DATASG          SEGMENT 'DATA'          ; Start of data segment.
  28.  
  29.        numdrvs  db 0                    ; number of floppy drives.
  30.  
  31. DATASG          ENDS                    ; End of data segment.
  32.  
  33.  
  34. ASM_TEXT        segment byte public 'CODE'
  35.                 ASSUME  cs:ASM_TEXT, DS:DGROUP
  36.  
  37.  
  38.  
  39. DrvType         PROC    FAR
  40.  
  41.                 push    bp
  42.                 mov     bp,sp
  43.                 push    es
  44.                 push    di
  45.  
  46.                 call    GetNumdrvs      ; Determine # of floppy drives.
  47.  
  48.                 mov     ax, 1           ; Which one do we want to check?
  49.                 push    ax
  50.                 call    __PARNI
  51.                 add     sp, 2
  52.  
  53.                 cmp     numdrvs, al     ; Was a valid drive requested?
  54.                 jb      NoCanDo         ; No. Jump to end.
  55.  
  56.                 mov     dl, al          ; Move selected drive # to DL
  57.                                         ;   in prep. for int 13h
  58. Retry:
  59.                 mov     ah, 08          ; Function: Get current drive params
  60.                 int     13h             ; Disk I/O services
  61.                 jnc     Done            ; Finished
  62.                 
  63.                 cmp     ah, 06h         ; Has diskette changed?
  64.                 jne     NoCanDo         ; No. Error condition.
  65.                 mov     ah, 0           ; Reset the disk
  66.                 int     13h
  67.                 jmp     Retry           ; Retry
  68.  
  69. NoCanDo:
  70.                 mov     bl, 0           ; Set return value to error condition.
  71. Done:
  72.                 xor     bh, bh          ; blank out the high byte
  73.                 push    bx              ; Return result to Clipper via Extend
  74.                 call    __RETNI
  75.                 add     sp, 2
  76.  
  77.                 pop     di
  78.                 pop     es
  79.                 pop     bp
  80.                 ret
  81.  
  82. DrvType         endp
  83.  
  84. DrvNum          proc    far
  85.                 push    bp
  86.                 mov     bp,sp
  87.                 push    es
  88.                 push    di
  89.  
  90.                 call    GetNumdrvs      ; Determine # of floppy drives.
  91.                 inc     numdrvs         ; Function GetNumdrvs returns 1 less
  92.                                         ;  than actual number of drives.
  93.                 mov     al, numdrvs     ; Return via Extend.
  94.                 xor     ah, ah
  95.                 push    ax
  96.                 call    __RETNI
  97.                 add     sp, 2
  98.  
  99.                 pop     di
  100.                 pop     es
  101.                 pop     bp
  102.                 ret
  103. DrvNum          endp
  104.  
  105. GetNumdrvs      proc    near
  106.                 mov     ax, 0040h       ; Necessary because immediate mode
  107.                                         ;   not legal with ES.
  108.                 mov     es, ax          ; Segment of equipment list
  109.                 mov     ax, ES:[0010h]  ; Move equipment list to AX
  110.                 mov     bx, ax          ; Store it for later.
  111.                 test    al, 1           ; Isolate bit 0 to determine if there are any floppies.
  112.                 jz      NoCanDo         ; No, finished.
  113.  
  114.                 and     bl, 192         ; Find # of floppy drives by
  115.                                         ;  stripping all bits except
  116.                                         ;  6 and 7.
  117.                 mov     cl, 6           ; Set number of bits to shift.
  118.                 shr     bl, cl          ; Shift right 6 bits so that bits
  119.                                         ; 6 & 7 are now in bits 0 & 1.
  120.                 mov     numdrvs, bl     ; Store # of drives (minus 1) in variable.
  121.  
  122.                 ret
  123. GetNumdrvs      endp
  124.  
  125. ASM_TEXT                ENDS
  126.                         END
  127.  
  128.