实验12 磁盘文件操作程序
一.实验目的
1.掌握利用FCB进行磁盘文件读写的方法;
2.掌握利用HANDLE进行磁盘文件读写的方法;
3.INT 21H的0FH、10H、14H、15H、16H、1AH号功能调用; 4.INT 21H的3CH、3DH、3FH、40H号功能调用。
二.实验内容
1.编写文本文件内容显示程序; 2.编写磁盘文件拷贝程序。
三.实验要求
1.复习INT 21H 0FH、10H、14H、15H、16H、1AH、3CH、3DH、3FH、40H号功能调用
2.阅读有关磁盘文件的FCB、HANDLE的内容。
四.实验环境
PC微机
DOS操作系统或 Windows 操作系统
MASM.EXE,LINK.EXE,DEBUG.COM或宏汇编集成环境
五.实验步骤
1.将文本文件内容显示程序输入,建立源程序文件且存盘;
2.输入,汇编,连接此程序,用DEBUG将目的程序带参数调入,用D命令观看并记录PSP中的FCB内容。
3.将磁盘文件拷贝程序输入,建立源程序文件且存盘; 4.汇编、连接、运行此程序,观察按不同键所产生的效果。
六.实验报告要求
1.对照参考程序,画出程序流程图; 2.实验中产生的问题及体会; 3.实验记录。
七.思考题
按COPY AAA BBB 格式要求改写此程序,取消人机对话,源文件和目的文件名由命令行输入。
参考程序清单:
1.文本文件内容显示程序:
stack segment stack
db 100h dup(?)
stack ends data segment fcb db 36 dup(0) count db 0 char db 0 dta db 0 errmsg db 'file access error' data ends code segment main proc far
assume cs:code,ss:stack
start: push ds
sub ax,ax push ax mov ax,data mov es,ax assume es:data mov si,5ch
mov di,offset fcb mov cx,12 cld rep movsb mov ds,ax assume ds:data mov dx,offset dta mov ah,1ah int 21h
mov dx,offset fcb mov ah,0fh int 21h cmp al,0 jnz error
mov word ptr fcb+0ch,0 mov word ptr fcb+0eh,1 mov fcb+20h,0
again: lea dx,fcb
mov ah,14h int 21h cmp al,0
tab:
eof:
error:
display disp1:
display dispchar
jnz error mov al,dta cmp al,1ah jz eof cmp al,9 jz tab
call dispchar inc char cmp dta,0ah jnz again mov char,0 inc count cmp count,24 jnz again mov ah,0 int 16h mov count,0 jmp again mov al,' ' call dispchar inc char test char,7 jz again jmp tab lea dx,fcb mov ah,10h int 21h ret lea bx,errmsg call display
ret proc mov cx,30 mov al,[bx] call dispchar inc bx loop disp1 mov al,0dh call dispchar mov al,0ah call dispchar
ret endp proc
push bx mov bx,0 mov ah,14 int 10h pop bx ret
dispchar endp main endp code ends
end start
2、磁盘文件拷贝程序(参考):
stack segment stack
db 100h dup(9)
stack ends ; data segment sfile db 64
db ? db 64 dup(' ')
dfile db 64
db ? db 64 dup(' ')
ask1 db 0ah,0dh,'please input source'
db 'file name:','$'
ask2 db 0ah,0dh,'please input destnation'
db 'file name:','$'
note db 0ah,0dh,'please insert diskettes'
db 'and strike any when ready ','$'
er1 db 0ah,0dh,'create error $' er2 db 0ah,0dh,'open error$' er3 db 0ah,0dh,'read error$' er4 db 0ah,0dh,'write error$' er5 db 0ah,0dh,'close source file error' er6 db 0ah,0dh,'close dest file error' bufr dw ? data ends code segment
assume cs:code,ds:data,ss:stack
start proc far
push ds sub ax,ax push ax mov ax,data mov ds,ax
相关推荐: