home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 02a / pushpath.zip / POPPATH.ASM next >
Assembly Source File  |  1987-02-28  |  4KB  |  97 lines

  1. ;Pops the path that PUSHPATH.ASM left in e:\path.dat.
  2. ;D. Seidman, 2/28/87
  3. cseg      segment   para  public   'code'
  4. popp      proc      far
  5.           assume    cs:cseg, ds:cseg, es:cseg, ss:cseg
  6.           org       100H                ;for com file
  7. begin:    jmp       start
  8. file      db        'C:\PATH.DAT',0
  9. output    db        0
  10. order     db        'PATH='
  11. string    db        128 dup (0DH)
  12. start:    mov       sp, offset stk      ;move stack in
  13.           mov       ah,4ah              ;make room for command.com
  14.           mov       bx,400h             ;leave 16 k
  15.           int       21h
  16. ;open the path stack file
  17.           mov       ah, 3DH             ;function call, open file
  18.           mov       dx, offset file     ;address of fname
  19.           mov       al, 2               ;access code -- read write
  20.           int       21H                 ;open it
  21.           mov       bx,ax               ;save the file handle
  22.           jc        quit                ;carry flag set by error
  23. ;get file size
  24.           mov       ah, 42H             ;function call, seek
  25.           xor       dx,dx               ;zero offset on seek
  26.           xor       cx,cx               ;same
  27.           mov       al,2                ;method --EOF
  28.           int       21H                 ;move it.
  29.           cmp       ax,1                ;see if anything there
  30.           jl        quit                ;jump if no path found
  31.           push      ax                  ;save file size
  32.           xor       dx,dx
  33.           mov       al,0                ;pointer to beginning of file
  34.           mov       ah,42H
  35.           int       21H                 ;do it
  36.           pop       cx                  ;bytes to read
  37.           dec       cx                  ;don't read final CR
  38.           mov       dx,offset filebuf   ;read data to here
  39.           mov       ah,3FH              ;read entire file
  40.           int       21H
  41.           mov       ah,3EH              ;close the file
  42.           int       21H
  43.           mov       dx,offset file
  44.           mov       ah,41H              ;delete the file
  45.           int       21H
  46.           mov       al,13               ;look for a CR
  47.           mov       di, offset filebuf  ;starting point
  48.           add       di,cx               ;start at end of file read
  49.           std                           ;search backwards
  50. repne     scasb
  51.           cld
  52.           jcxz      pathit
  53.           inc       di
  54.           inc       di
  55.           inc       cx
  56.           inc       cx
  57. ;if no previous path, no need to write out the file
  58.           cmp       cx, 3
  59.           jl        pathit
  60.           push      cx
  61.           xor       cx,cx               ;set file attribute at zero
  62.           mov       ah,3CH
  63.           mov       dx,offset file
  64.           int       21H                 ;create the file
  65.           mov       bx,ax               ;save its handle
  66.           mov       ah,40H              ;write
  67.           pop       cx                  ;no of bytes to write
  68.           mov       dx,offset filebuf   ;starting place of write
  69.           int       21H
  70. ;now close the file. Handle should still be in bx
  71.           mov       ah, 3EH             ;function call, close
  72.           int       21H                 ;do it
  73. ;now change the path
  74. pathit:
  75.           xor       cx,cx
  76.           mov       cl, [di]
  77.           mov       output, cl
  78.           add       output, 5
  79.           dec       cx                  ;because not writing CR
  80.           mov       si,di
  81.           inc       si
  82.           mov       di,offset string
  83.           rep movsb
  84.           mov       dx, offset output
  85.           mov       si,dx
  86.           int       2eh
  87.  
  88. quit:     int       20H
  89. popp      endp
  90. stuff     db        200 dup (0)
  91. stk       db        0
  92. filebuf   db        0
  93.           cseg      ends
  94.           end       begin
  95.  
  96.  
  97.