unit DiskIO; interface type HFile = word; const OF_READ=01; OF_WRITE=02; OF_READWRITE=03; OF_CREATE=04; function OpenFile(lpFileName:pointer;uStyle:byte):HFile; procedure CloseHandle(TheFile:HFile); procedure ReadFile(TheFile:HFile;var Buffer;Size:integer); procedure WriteFile(TheFile:HFile;const Buffer;Size:integer); procedure RString(TheFile:HFile;var Para:string); procedure WString(TheFile:HFile;Para:string); implementation {******************** Open/Close ************************} function OpenFile(lpFileName:pointer;uStyle:byte):HFile; assembler; asm mov ah,3dh mov al,uStyle cmp al,OF_CREATE jne @OFi1 mov ah,3ch mov cx,00 @OFi1: dec al mov dx,word ptr lpFileName int 21h end; procedure CloseHandle(TheFile:HFile); assembler; asm mov ah,3eh mov bx,TheFile int 21h end; {***************** Read/Write Data **********************} procedure ReadFile(TheFile:HFile;var Buffer;Size:integer); assembler; asm mov ah,3fh mov bx,TheFile mov cx,Size mov dx,word ptr Buffer int 21h end; procedure WriteFile(TheFile:HFile;const Buffer;Size:integer); assembler; asm mov ah,40h mov bx,TheFile mov cx,Size mov dx,word ptr Buffer int 21h end; {**************** Read/Write Strings ********************} procedure RString(TheFile:HFile;var Para:string); assembler; asm push TheFile push word ptr Para+2 push word ptr Para push 01 call ReadFile push TheFile mov si,word ptr Para mov ah,00 mov al,[si] inc si push word ptr Para + 2 push si push ax call ReadFile end; procedure WString(TheFile:HFile;Para:string); assembler; asm push TheFile push word ptr Para + 2 mov si,word ptr Para push si mov ah,00 mov al,[si] inc ax push ax call WriteFile end; end.