home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / DISKA.ASM < prev    next >
Assembly Source File  |  1994-10-15  |  2KB  |  73 lines

  1.     page    66,132
  2. ;******************************** DISKA.ASM  *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. ;----------------------------------------------------------------------------
  13.     extrn    strlen3:far
  14.     extrn    to_upper:far
  15.     extrn    last_char:far
  16. comment 
  17. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  DISK   )
  18. DECODE_FILENAME - return pointers to major portions of file name
  19. ;
  20. ;  inputs: ds:bx = pointer to file name, use EXPAND_FILENAME to format first
  21. ;  
  22. ;  output: if no carry then,
  23. ;           ds:si = pointer to path
  24. ;           ds:di = pointer to filename
  25. ;              cx = path length
  26. ;              dx = filename length
  27. ;              ah = drive letter
  28. ;              al = drive number
  29. ;          if carry, then filename is bad.
  30. ;
  31. ; Note: The input string should be:  <drive letter>:/<path>/<filename>0
  32. ;* * * * * * * * * * * * * *
  33. 
  34.     PUBLIC    DECODE_FILENAME
  35. DECODE_FILENAME        PROC    FAR
  36.     mov    al,'\'
  37.     call    last_char        ;find start of filename
  38.     inc    ax
  39.     add    ax,bx
  40.     mov    di,ax            ;save ptr to filename
  41.     
  42.     sub    ax,bx            ;compute length of
  43.     sub    cx,ax            ;  filename portion
  44.     mov    dx,cx            ;    and put in DX
  45. ;
  46. ; registers:  ds:bx = input string  di=filename ptr  dx=filename length
  47. ;
  48.     cmp    byte ptr [bx+1],':'    ;check if drive in expected location
  49.     jne    df_error        ;  jmp if error
  50.     mov    si,bx            ;compute path
  51.     add    si,3            ;  offset
  52.     
  53.     call    strlen3            ;compute
  54.     sub    cx,dx            ;  length of
  55.     sub    cx,3            ;    path portion
  56.  
  57.     mov    al,byte ptr [bx]    ;get drive letter
  58.     mov    ah,0
  59.     call    to_upper
  60.     sub    al,'A'
  61.     mov    ah,byte ptr [bx]
  62.     clc
  63.     jmp    df_exit
  64. df_error:
  65.     stc
  66. df_exit:        
  67.     retf
  68. DECODE_FILENAME        ENDP
  69. ;                
  70.  
  71. LIBSEG    ENDS
  72.     end
  73.