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

  1. title UP - move up 1 directory level
  2. page 60,132
  3.  
  4. ;++++++++++++++++++++++++++++++
  5. ; Abstract:
  6. ;    This routine will move the
  7. ; user up one directory level. It
  8. ; will yield an error message as
  9. ; to it's success. The dos errorlevel
  10. ; parameter is used for exit. It is
  11. ; set to:
  12. ; 0 - if the up was successful
  13. ; 1 - if the user was at the top of
  14. ;     the tree when up was executed.
  15. ; 2 - If there was an error in the
  16. ;     program.
  17. ;------------------------------
  18.  
  19. ; +++
  20. ; Author:
  21. ;    Jeffrey Spidle
  22. ;    Office of Continuing Education
  23. ;    Ames,Ia 50011
  24. ;    (515)294-6222
  25. ;
  26. ; Date:
  27. ;    11 JAN 84
  28. ;
  29. ; System:
  30. ;    IBM-PC executing PC-DOS 2.0 or
  31. ;             MS-DOS 2.0
  32. ; Release:
  33. ;    1.1
  34. ; ---
  35. ;*****************************************
  36. ; Instructions:
  37. ;   To assemble link and go:
  38. ;  Masm up;
  39. ;  Link up;
  40. ;  Exe2bin up.exe up.com
  41. ;  UP
  42. ;
  43. ; This program is placed in the public domain and
  44. ; is not intended for any type of commercial sale.
  45. ; Free use and copying of this program is allowed
  46. ; provided that no fee is charged for its distribution.
  47. ;******************************************
  48. cgroup group code_seg, data_seg
  49.     assume cs:cgroup,ds:cgroup
  50.  
  51. data_seg    segment     public
  52. hello        db    'Up ok.$'
  53. cant_go_up    db    'Can',39,'t go up.$'
  54. error        db    'Up Error.$'
  55. start_path    db    '\'
  56. path_name    db    64 dup (0)
  57. data_seg ends
  58.  
  59. code_seg segment
  60.     org 100h
  61. main    proc    near
  62.     mov    si,offset cgroup:path_name ;address of where to put the
  63.                     ; current path_name
  64.     mov    dl,0            ; default drive request
  65.     mov    ah,47H            ; get current path
  66.     int    21H            ; call dos to get it
  67.     jnc    ok1            ; call ok ?
  68.     jmp    oops            ; nope
  69. ok1:    mov    bx,offset cgroup:path_name ; get the begining of the
  70.                     ; path into bx
  71.     cmp    byte ptr [bx],0     ; if first char of path is a
  72.                     ; null then we must be at the
  73.                     ; top of the tree ==> we can't
  74.                     ; go up from here
  75.     je    cant            ; therefore put out a message
  76.     add    bx,64            ; get the end of the path area
  77. loop:    cmp    byte ptr [bx],92    ; is this a \ char
  78.     je    backslash        ; it is
  79.     mov    byte ptr [bx],0     ; no then null it
  80.     dec    bx            ; back up a char
  81.     cmp    bx,offset cgroup:path_name ; begining of string?
  82.     jne    loop            ; nope go back up
  83. backslash:                ; it is or found a \
  84.     mov    byte ptr [bx],0     ; get rid of the backslash
  85.     mov    dx,offset cgroup:start_path
  86.                     ; have dx point to the new
  87.                     ; pathname prefaced with a \
  88.     mov    ah,3bH            ; chdir call
  89.     int    21H            ; call dos to do it
  90.     jnc    ok2            ; call ok?
  91.     jmp    oops            ; nope
  92. ok2:    mov    dx,offset cgroup:hello
  93.     mov    ah,9
  94.     int    21H
  95.     mov    ax,4c00H        ; set errorcode 00
  96.     int    21H
  97.  
  98. oops:    mov    dx,offset cgroup:error
  99.     mov    ah,9
  100.     int    21H
  101.     mov    ax,4c02H        ; set errorcode 02
  102.     int    21H
  103.  
  104. cant:    mov    dx,offset cgroup:cant_go_up
  105.     mov    ah,9
  106.     int    21H
  107.     mov    ax,4c01H        ; set errorcode 01
  108.     int    21H
  109.  
  110. main    endp
  111. code_seg ends
  112.     end    main
  113.