home *** CD-ROM | disk | FTP | other *** search
- PAGE 55,96
- COMMENT |
-
- Functions readfil and writfil allow read/write
- to/from memory buffers whose segment address is
- passed to the procedures. The purpose is to
- eliminate the limitations of MS Pascal which does not
- allow to declare an object larger than some 58K.
-
- Pascal declarations:
-
- function
- readfil(var fnam:lstring;count:word;bufads:adsmem):
- word;extern;
-
- function
- writfil(var fnam:lstring;count:word;bufads:adsmem):
- word;extern; |
-
- TITLE FILIO.ASM Version 1.00
-
- fio segment 'code'
- assume cs:fio,ds:fio,es:fio
- public readfil,writfil
- readfil proc far
- push bp
- mov bp,sp
- mov bx,[bp+12] ;fname address
- mov si,[bx] ;fname length
- and si,0ffh ;mask upper 8 bits
- inc si ;loc just after fname
- mov byte ptr[bx+si],0 ;create ASCIIZ string
- mov dx,bx ;call needs it
- inc dx ;skip fname length
- mov ah,3dh ;get file handle
- mov al,0 ;access code read
- int 21h
- jc rerr_ex ;cannot open file
- mov bx,ax ;file handle
- mov cx,[bp+10] ;byte count
- mov ax,[bp+8] ;buffer segment
- mov dx,[bp+6] ;buffer offset
- push ds
- mov ds,ax
- mov ah,3fh
- int 21h ;read CX bytes
- pop ds
- jc rerr_ex ;error occured
- rexit: pop bp
- mov bx,[bp+12] ;fname address
- mov si,[bx] ;fname length
- and si,0ffh ;mask upper 8 bits
- inc si ;loc just after fname
- mov byte ptr[bx+si],0 ;create ASCIIZ string
- mov dx,bx ;call needs it
- ret 8 ;discard four parameter words
- rerr_ex:
- mov ax,0ffffh ;error rcode
- jmp rexit
- readfil endp
-
- writfil proc far
- push bp
- mov bp,sp
- mov bx,[bp+12] ;fname address
- mov si,[bx] ;fname length
- and si,0ffh ;mask upper 8 bits
- inc si ;loc just after fname
- mov byte ptr[bx+si],0 ;create ASCIIZ string
- mov dx,bx ;call needs it
- inc dx ;skip fname length
- xor cx,cx
- mov ah,3ch
- int 21h ;create file
- jc werr_ex ;error occured
- mov bx,ax ;file handle
- mov cx,[bp+10] ;byte count
- mov ax,[bp+8] ;buffer segment
- mov dx,[bp+6] ;buffer offset
- push ds ;preserve data segment
- push bx ;preserve handle
- mov ds,ax ;buffer data segment
- mov ah,40h
- int 21h ;write CX bytes
- pop bx ;restore handle
- pop ds ;restore data segment
- jc werr_ex ;write did not succeed
- mov ah,3eh ;close file code
- int 21h
- jc werr_ex ;error occured
- wexit:
- pop bp
- ret 8 ;discard four parameter words
- werr_ex:
- mov ax,0ffffh ;error rcode
- jmp wexit
- writfil endp
-
- fio ends
- end
-