; Вариант 19
; Еникеев И.Р.  2084/1
.286
.model tiny
.data
org 100h
start:  

  mov dx, offset path

  mov di, offset pass
  mov cx, 10
  mov al, ' '
  repnz scasb
  jnz $+3
  inc cx
  sub cx, 10
  neg cx

  call bps
bps:
  pop bp
  sub bp, offset bps
;---------------------
  push ds
  push dx
  ; Test, if currently opening file is in database
  mov di, dx
  call SeekZ
  push di

  std
  mov al, '\'
  repnz scasb
  cld
  jnz $+3
  inc di
  inc di

  pop cx
  sub cx, di

  push cx
  push di

  mov dx, 12

  push cs
  pop es
  lea di, [bp+files]

searchloop:
  pop si
  pop cx
  push cx
  push si
  push di

  mov al, es:[di]
  jz not_found

  repz cmpsb
  jz found

  pop di
  add di, dx
  jmp searchloop

found:
  pop di
  pop si
  pop cx
  jmp outta

not_found:
    

outta:
        mov ah, 4ch
        int 21h

SeekZ proc near
  mov al, 0
  mov cx, 0ffffh
  repnz scasb
  neg cx
  dec cx
  dec di
  ret
endp

path db 0
files db 0
pass db '1234567890   '

end start
