求助一程序
读入一个文本文件并以DEBUG中的D命令格式显示。要求:A、以DEBUG中的D命令格式显示一个文本文件。
B、文件名从键盘键入。
思路:A、打开相应文件,读内容至程序缓冲区。
B、按要求显示。
data segment source_buffer db 21,21 dup (?) handle dw ? con db 0 bf db 16 dup (?) ms1 db 'File ','$' ms2 db ' isn',27h,'t exist!','$' data ends code segment main proc far assume cs:code,ds:data start: push ds sub ax,ax push ax mov ax,data mov ds,ax mov dx,offset source_buffer mov ah,0ah int 21h lea si,source_buffer inc si mov cl,[si] mov ch,0 cmp cx,0 jz flag7 loop1: inc si loop loop1 inc si mov byte ptr [si],0 mov ax,3d00h mov dx,offset source_buffer inc dx inc dx int 21h jnb open_ok flag7: mov dl,13 mov ah,2 int 21h mov dl,10 int 21h mov dx,offset ms1 mov ah,9 int 21h lea si,source_buffer inc si mov cl,[si] mov ch,0 cmp cx,0 jz flag6 loop6: inc si loop loop6 inc si mov byte ptr [si],'$' mov dx,offset source_buffer inc dx inc dx int 21h flag6: mov dx,offset ms2 int 21h jmp exit open_ok: mov handle,ax flag1: cmp con,1 jz exit1 flag2: mov bx,handle mov ah,3fh mov cx,16 lea dx,bf int 21h cmp ax,16 jz flag3 cmp ax,0 jz exit1 push ax mov dl,13 mov ah,2 int 21h mov dl,10 int 21h pop ax mov cx,ax lea si,bf loop4: inc si loop loop4 mov cx,16 sub cx,ax loop5: mov byte ptr [si],0 inc si loop loop5 mov con,1 jmp flag8 flag3: mov dl,13 mov ah,2 int 21h mov dl,10 int 21h flag8: mov cx,16 lea si,bf loop2: mov al,[si] push cx mov cl,4 rol al,cl pop cx and al,0fh add al,30h cmp al,3ah jl printit1 add al,7h jmp printit1 exit1: jmp exit printit1: mov dl,al mov ah,2 int 21h mov al,[si] and al,0fh add al,30h cmp al,3ah jl printit2 add al,7h printit2: mov dl,al int 21h inc si mov dl,' ' int 21h cmp cx,9 jnz flag4 mov dl,'-' int 21h flag4: loop loop2 mov dl,' ' int 21h mov dl,' ' int 21h mov cx,16 lea si,bf loop3: mov dl,[si] cmp dl,0 jnz flag5 mov dl,'.' flag5: int 21h inc si loop loop3 jmp flag1 exit: ret main endp code ends end start