home *** CD-ROM | disk | FTP | other *** search
- ; SIZEOF.ASM -- returns size in bytes of specified file
- ; returns 0 if file not found or error opening file
- ; SYNTAX: i = sizeof(<filename.ext>)
- ; EXAMPLE: i = sizeof(sizeof.asm)
- ; returns: i = 1794
- ;
- ; by Gary Gruber
- ; Data Base Designs
- ; 71-533 Tangier Rd.
- ; Rancho Mirage, Ca. 92270
- ; 619-568-4338
- ;
- public sizeof
- extrn _parc:far
- extrn _retnl:far
- extrn _retni:far
- ;
- _PROG segment byte public '_PROG'
- sizeof proc far
- assume cs:_PROG,ds:_PROG,es:_PROG
- push bp ;normal clipper set up
- mov bp,sp
- push ds
- push es
- cld
- get_file:
- mov ax,1 ;get file name
- push ax
- call _parc
- add sp,2
- mov ds,ax ;DS points to segment address of parameter
- mov dx,bx ;put file name here
- open_file:
- mov ah,3dh ;DOS open file function
- xor al,al
- int 21h
- jc error ; file not found?
- get_size:
- mov bx,ax ;put the file name here
- xor dx,dx
- xor cx,cx
- mov ah,42h ;move pointer function
- mov al,2 ;go to end of file
- int 21h
- jnc return
- error:
- xor ax,ax ; return 0 bytes
- xor dx,dx
- return:
- push ax
- mov ah,3eh
- int 21h
- pop ax
- pop es
- pop ds
- pop bp
- cmp dx,0 ;Is file larger than 64K?
- jnz return_long
- return_int:
- push ax
- call _retni
- add sp,2
- jmp exit
- return_long:
- mov bx,dx
- xchg ax,bx
- push ax
- push bx
- call _retnl
- add sp,4
- exit:
- ret
- sizeof endp
- _PROG ends
- end
-
-