|
发表于 2013-1-17 17:28:10
|
显示全部楼层
- ;功能是读指定文件内容显示在屏幕上,不知道为什么,只读一个字节就报错了谁帮我看看??
- ;Μiss^依然
- data segment
- string db "file open is wrong$"
- string1 db "reading is error$"
- filename db '1.txt',0
- buffer db 200 dup (?)
- data ends
- ;============================================
- ;============================================
- code segment
- assume cs:code,ds:data
- start:
- mov ax,data
- mov ds,ax
- clc
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- ; 打开文件 ;
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- mov dx,offset filename
- mov ax,3d00h
- int 21h
- jnc open_ok
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- ; 不成功提示后退出 ;
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- mov dx,offset string
- call tishi
- jmp over
- open_ok proc
- mov bx,ax ;为啥给BX?
- push ax
- push bx
- return0:call du
- jc du_error
- cmp al,1ah
- je close
- call xianshi
- pop bx
- pop ax
- ; jmp return0
- ; ret
- open_ok endp
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- ; 关闭文件返回 ;
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- close proc
- mov ax,3e00h
- int 21h
- over: mov ax,4c00h
- int 21h
- close endp
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- ; 读出错后提示后返回 ;
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- du_error proc
- push dx
- push ax
- mov dx,offset string1
- call tishi
- pop ax
- pop dx
- jmp over
- du_error endp
- tishi proc
- PUSH AX
- mov ax,0900h
- int 21h
- pop ax
- ret
- tishi endp
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- ; 读文件过程 ;
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>
- du proc
- push cx
- push dx
- push ax
- mov cx,0ffffh
- mov dx,offset buffer
- mov ah,3fh
- int 21h
- jc return
- cmp ax,cx
- mov al,1ah
- jb s
- mov al,offset buffer
- s: clc
- return: pop ax
- pop dx
- pop cx
- ret
- du endp
- xianshi proc
- push si
- push dx
- push ax
- mov si,offset buffer
- xor dx,dx
- s1: mov dl,[si]
- inc si
- or dl,dl
- jz return2
- mov ax,0200h
- int 21h
- jmp s1
- return2:pop ax
- pop dx
- pop si
- ret
- xianshi endp
- code ends
- end start
复制代码 {:2_28:}没认真分析,有些地方看的不是很明白!
兄台雷好!!MOV CX,1取一个字节被我改成为四F了,原因是XIANSHIf过程这有INC SI等指令,估计兄台原思路也是只读一次然后逐个显示,不然此处没必要循环~你说是吧
然后就是缓冲区加大了点点~~其它没什么了!!写的非常好~继续加油哈
|
|