home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / system / numfixed.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  1.2 KB  |  47 lines

  1. ;unsigned short  number_fixed();
  2.  
  3.     EXTRN  _memory_model:byte
  4.  
  5. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  6.     ASSUME CS:_TEXT
  7.     PUBLIC _number_fixed
  8. _number_fixed proc near
  9.     push di            ;
  10.     push si            ;
  11.     push ds            ;DS changed by interrupt
  12.     int  11h        ;make BIOS equipment chk
  13.     sub  si,si        ;counts floppy drives
  14.     test ax,1        ;any drives at all?
  15.     jz   L2            ;jump ahead if not
  16.     and  ax,11000000B    ;clear all bits but 6-7
  17.     mov  cl,6        ;ready for shift
  18.     shr  ax,cl        ;bits to bottom of AX
  19.     inc  ax            ;count from 1, not 0
  20.     cmp  ax,2        ;at least two floppies?
  21.     jae  L1            ;jump if so
  22.     mov  ax,2        ;else skip over vacant specifier
  23. L1:    mov  si,ax        ;copy in SI
  24. L2:    sub  di,di        ;DI counts hard drives
  25. L3:    inc  si            ;drive number
  26.     mov  dx,si        ;place in DL for function
  27.     mov  ah,1ch        ;disk type function
  28.     int  21h        ;get the type
  29.     mov  al,[bx]        ;move type code to AL
  30.     sub  cl,cl        ;clear CL
  31.     mov  [bx],cl        ;remedy apparent DOS bug
  32.     cmp  al,0f8h        ;a fixed disk?
  33.     jne  L4            ;jump ahead if not
  34.     inc  di            ;else inc drive count
  35.     jmp  L3            ;check for another
  36. L4:    mov  ax,di        ;set return value
  37.     pop  ds            ;restore registers
  38.     pop  si            ;
  39.     pop  di
  40.     cmp  _memory_model,0    ;quit
  41.     jle  Quit        ;
  42.     db   0CBh        ;RET far
  43. Quit:    ret            ;RET near
  44. _number_fixed endp
  45. _TEXT    ENDS
  46.     END
  47.