home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / assemutl.zip / DSK.ASM < prev    next >
Assembly Source File  |  1985-05-11  |  1KB  |  50 lines

  1. PAGE 60,132 ;
  2. TITLE BASIC SUBROUTINE : DSK(A,B)
  3. ;------------------------------------------------------
  4. ;
  5. ; Returns the number of free sectors on a disk.
  6. ; Called form BASIC. Used with a PC-TALK patch.
  7. ;
  8. ;------------------------------------------------------
  9.  
  10. .RADIX 16
  11.     ;BASIC machine lang. subroutine: CALL DSK(A,B)
  12.     ;A=Drive to check- 0,1,2 or 3.    0=default drv, 1=A:, etc.
  13.     ;B=# of free sectors (returned).
  14.     ;Jack Wright  Nov 1983
  15. CSEG    SEGMENT PARA PUBLIC 'CODE'
  16.     ASSUME CS:CSEG
  17.     PUBLIC DSK
  18.     ;DS=ES=SS=default DEF SEG (BASIC's data segment)
  19.     ;All seg. regs. & SP must be saved & restored.
  20.     ;BIOS interrupts preserve all seg. regs. & BX,CX,DX.
  21.     ;DOS 2.0
  22.     ORG    100
  23. DSK    PROC    FAR
  24.     PUSH    BP
  25.     MOV    BP,SP
  26.     MOV    SI,[BP+08]    ;Addr. of arg. A->SI.
  27.     MOV    DX,[SI]     ;A->DX (A=drive # to check)
  28.     CLI            ;Disable maskable interrupts
  29.     MOV    AX,CS
  30.     MOV    SS,AX        ;Set up new stack for INT 21 s
  31.     MOV    SP,100
  32.     STI
  33.     MOV    AH,36        ;DL=drive to check
  34.     INT    21        ;Returns AX=# of sectors/alloc. unit,
  35.     MUL    BX        ;BX=# of avail. alloc. units
  36.                 ;after MUL, DX,AX=no. of avail. sectors
  37.     CLI
  38.     MOV    BX,ES        ;SS was saved in ES
  39.     MOV    SS,BX
  40.     MOV    SP,BP        ;SP was saved in BP
  41.     STI
  42.     ;Must restore SS (above) before checking [BP+06] (below):
  43.     MOV    DI,[BP+06]    ;Point DI to B
  44.     MOV    [DI],AX     ;Transfer AX to last arg. (B)
  45. EXIT:    POP    BP
  46.     RET    4
  47. DSK    ENDP
  48. CSEG    ENDS
  49.     END    DSK ;
  50.