主题:[原创]编写一个类似type命令的程序
1)用键盘输入文件名,若输入的字符串为空,则程序运行结束;
2)若输入的文件名存在,则显示内容,否则,显示文件不存在的信息;
.model samll
.stack 256
.data
fname db 30,?,30 dup(?),0
fail db "no find",10,13,"$"
buff db 128 dup(?)
.code
.startup
again:
mov ah,0ah
lea dx,fname
int 21h
mov bl,fname+1
cmp bl,0
jz over
xor bh,bh
mov fname[bx+1],0
mov dx,offset fname+2
mov al,0h
mov ah,3dh
int 21h
jnc succ
lea dx,fail
mov ah,09h
int 21h
jmp again
succ:
mov bx,ax
read:
lea dx,buff
mov cx,128
mov ah,3fh
int 21h
cmp ax,0
jz close
jc close
push bx
mov dx,ofset buff
mov cx,ax
mov bx,1
mov ah,40h
int 21h
pop bx
jmp read
close:
mov ah,3eh
int 21h
jmp again
over:
.exit 0
end
(不可转载)
2)若输入的文件名存在,则显示内容,否则,显示文件不存在的信息;
.model samll
.stack 256
.data
fname db 30,?,30 dup(?),0
fail db "no find",10,13,"$"
buff db 128 dup(?)
.code
.startup
again:
mov ah,0ah
lea dx,fname
int 21h
mov bl,fname+1
cmp bl,0
jz over
xor bh,bh
mov fname[bx+1],0
mov dx,offset fname+2
mov al,0h
mov ah,3dh
int 21h
jnc succ
lea dx,fail
mov ah,09h
int 21h
jmp again
succ:
mov bx,ax
read:
lea dx,buff
mov cx,128
mov ah,3fh
int 21h
cmp ax,0
jz close
jc close
push bx
mov dx,ofset buff
mov cx,ax
mov bx,1
mov ah,40h
int 21h
pop bx
jmp read
close:
mov ah,3eh
int 21h
jmp again
over:
.exit 0
end
(不可转载)