/
/ ftell.
/

	.globl	ftell

/
/ ftell(fp);
/ FILE *fp;
/
/ Return the location of the seek pointer
/ of a file.
/ As a long.
/

ftell:	jsr	r0,__csav	/Linkage

	mov	12(r5),r4	/Get file pointer
	mov	V_RBLK(r4),r0	/Assume input file
	mov	V_RBLK+2(r4),r1
	mov	V_RBYT(r4),r2
	bit	$VF_OUT,(r4)	/Correct?
	beq	0f		/Yes
	mov	V_EFBK(r4),r0	/No, get correct loc
	mov	V_EFBK+2(r4),r1
	mov	V_FFBY(r4),r2

0:	bit	$VF_FIL,(r4)	/Is this just the disc
	beq	0f		/Yes
	sub	$1,r1		/Convert VBN to origin 0
	sbc	r0

0:	mov	$9.,r3		/Blocks to bytes
0:	asl	r1
	rol	r0
	dec	r3
	bne	0b

	add	r2,r1		/Add in the bytes
	adc	r0
	jmp	__cret		/Done
