home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / zsys / simtel20 / z3lib / zlib2.lbr / Z3ROOT.Z80 < prev    next >
Encoding:
Text File  |  1986-02-07  |  1.0 KB  |  52 lines

  1. ;
  2. ; Z3LIB Module Name:  Z3ROOT
  3. ; Author:  Richard Conn
  4. ; Z3LIB  Version Number:  1.3
  5. ; Module Version Number:  1.1
  6. ;
  7.     public    root
  8.  
  9.     ext    envptr,retud
  10.  
  11. ;
  12. ;    ROOT returns the DU of the root directory in BC.  No other registers
  13. ; are affected.
  14. ;
  15. root:
  16.     push    de        ;save DE
  17.     push    hl        ;save HL
  18.     ld    hl,(envptr)    ;pt to environment
  19.     ld    de,9        ;pt to path entry
  20.     add    hl,de
  21.     ld    e,(hl)        ;get path address in DE
  22.     inc    hl
  23.     ld    d,(hl)
  24.     ex    de,hl        ;HL pts to path
  25.     call    retud        ;get current DU
  26.     ld    a,h        ;no path?
  27.     or    l
  28.     jp    z,rootx
  29. rootl:
  30.     ld    a,(hl)        ;get next path element
  31.     or    a        ;end of path?
  32.     jp    z,rootx        ;done if so
  33.     call    retud        ;get current DU
  34.     cp    '$'        ;current disk?
  35.     jp    z,root1
  36.     ld    b,a        ;get disk in B
  37.     dec    b        ;adjust for A=0
  38. root1:
  39.     inc    hl        ;pt to user
  40.     ld    a,(hl)        ;get user
  41.     inc    hl        ;pt to next path element
  42.     cp    '$'        ;current user?
  43.     jp    z,rootl        ;advance
  44.     ld    c,a        ;set user
  45.     jp    rootl        ;continue
  46. rootx:
  47.     pop    hl        ;restore HL
  48.     pop    de        ;restore DE
  49.     ret
  50.  
  51.     end
  52.