home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / 22rsx / rxmd.ark.2 / RXMD08.MAC < prev    next >
Encoding:
Text File  |  1985-12-07  |  2.1 KB  |  92 lines

  1. ;
  2. ; Shows available space on disk/area (A) (in range 'A'..'P').
  3. ; Print the free space remaining for the received file
  4. ; a,f,b,c,d,e,h,l
  5. kshow:    sui    'A';        make numeric (0,1,2,etc.)
  6.     push    psw
  7.     call    dskset;        find the proper allocation vector
  8.     mvi    c,curdpb
  9.     call    bdos;        Get ^DPB in hl
  10.     inx    h
  11.     inx    h
  12.     mov    a,m;        Get block shift
  13.     sta    blkshf
  14.     inx    h;        Bump to block mask
  15.     mov    a,m
  16.     inx    h
  17.     inx    h
  18.     mov    e,m;        Get max block #
  19.     inx    h
  20.     mov    d,m
  21.     xchg
  22.     shld    blkmax;        Save it
  23. ;    "    "
  24. ; Calculate # of K free on selected drive now
  25.     pop    psw;        get drive back
  26.     mov    b,a;        save
  27.     mvi    a,cpmver;    Get CP/M version number
  28.     call    dos
  29.     cpi    30h;        3.0?
  30.     jc    free20;        Use old method if not
  31.     mov    e,b;        Use new Compute Free Space BDOS call
  32.     mvi    a,getfre
  33.     call    dos
  34.     mvi    c,3;        Answer is a 24-bit integer
  35. fre3l1:    lxi    h,tbuf+2;    in 1st 3 bytes of DMA adr
  36.     mvi    b,3;        Convert it from sectors to K
  37.     ora    a;        By dividing by 8
  38. fre3l2:    mov    a,m
  39.     rar
  40.     mov    m,a
  41.     dcx    h
  42.     dcr    b
  43.     jnz    fre3l2;        Loop for 3 bytes
  44.     dcr    c
  45.     jnz    fre3l1;        Shift 3 times
  46.     lhld    tbuf;        Now get result in K
  47.     jmp    savfre;        Go store it
  48. ;
  49. ; Find free space available
  50. free20:    mvi    c,galloc;    Get address of allocation vector
  51.     call    bdos
  52.     xchg
  53.     lhld    blkmax;        Get its length
  54.     inx    h
  55.     lxi    b,0;        Init block count to 0
  56.     dcx    d
  57.     push    d
  58. free2a:    pop    d
  59.     inx    d
  60.     push    d;        Save alloc address
  61.     ldax    d
  62.     mov    d,a
  63.     mvi    e,8;        Set to process 8 blocks
  64. free2b:    mov    a,d;        Restore bits
  65.     dcr    e;        Count down 8 bits
  66.     jm    free2a
  67.     ral;            Test bit
  68.     jc    free2c;        block in use
  69.     inx    b
  70. free2c:    mov    d,a;        Save bits
  71.     dcx    h;        Count down blocks
  72.     mov    a,l
  73.     ora    h
  74.     jnz    free2b;        more blocks
  75.     pop    d;        Clear stack of allocation vector ptr.
  76.     mov    l,c;        Copy block to HL
  77.     mov    h,b
  78.     lda    blkshf;        Get block shift factor
  79.     sui    3;        Convert from sectors to K
  80.     jz    savfre;        Skip shifts if 1K blocks...
  81. free2d:    dad    h;        Multiply blocks by K/BLK
  82.     dcr    a
  83.     jnz    free2d
  84. ;    "    "
  85. ; Print the amount of free space remaining on the selected drive
  86. savfre:    call    decout
  87.     call    ilprt
  88.  db    'k free space is available',0
  89.     ret
  90. ;
  91. ; -------------------------------
  92. (f