程序如下,是书上的一个例子,使用文件代号法实现文件拷贝。
但是我实现不了文件拷贝,只出现了提示输入源文件名,后面就死掉了。


data segment 
sfile db    64
    db    ?
    db 64 dup(20h)
dfile     db    64
    db    ?
    db    64 dup(20h)
ask1     db     0ah,0dh,'please input source file name :$'
ask2    db    0ah,0dh,'please input dest file name:$'
note    db     0ah,0dh,'please insert diskettes and strike any key'
    db    'when ready$'
er1     db    'create error$'
er2     db    'open error$'
er3    db    'read error$'
er4    db    'write error$'
er5    db      'close source file error'
er6    db    'close dest file error'
bufr     dw    ?
data ends
stack segment    para stack 'btack'
    db     50 dup('$')
stack    ends
code     segment
    assume cs:code,ds:data,es:data,ss:stack
start     proc    far
    push    ds
    sub    ax,ax
    push     ax
    mov    ax,data
    mov     dx,ax
    mov     es,ax
    lea    dx,ask1
    call     disply
    mov     dx,offset sfile
    call    input
    mov     cl,sfile+1
    xor    ch,ch
    mov     si,cx
    mov    [si+sfile+2],0
    lea    dx,ask2
    call    disply
    lea    dx,dfile
    call     input
    mov     cl,dfile+1
    xor    ch,ch
    mov     si,cx
    mov     [si+dfile+2],0
    lea     dx,note
    call    disply
    mov    ah,7
    int     21h
    call     copy
    ret
start     endp

disply    proc
    mov    ah,9
    int 21h
    ret
disply     endp
input    proc
    mov    ah,0ah
    int 21h
    ret
input     endp
copy    proc    near
    mov ah,3ch
    lea     dx,dfile+2
    mov    cx,0020h
    int 21h
    lea    dx,er1
    mov    bx,ax
    jc    err
    mov     bufr,ax
    mov    ah,3dh
    mov al,0
    lea     dx,sfile+2
    int     21h
    lea    dx,er2
    mov     bx,ax
    jc    err
rw:     mov cx,0010h
    mov    ah,3fh
    lea    dx,sfile+2
    int     21h
    lea    dx,er3
    jc    err
    or     ax,ax
    je    exit
    mov    ah,40h
    lea    dx,sfile+2
    xchg    bufr,bx
    int    21h
    lea    dx,er4
    jc     err
    xchg    bufr,bx
    jmp    rw
exit:    mov    ah,3eh
    int     21h
    lea    dx,er5
    jc    err
    xchg    bufr,bx
    mov    ah,3eh
    int    21h
    lea    dx,er6
    jc     err
    ret
err:    mov    ah,3eh
    int 21h
    xchg    bufr,bx
    mov    ah,3eh
    int 21h
    call     disply    
    ret
copy    endp
code ends
    end     start