title Calculate File Size name ('GETSIZE') ; Return the size of a file bdos equ 5 entry get_filesize extrn extmsk ; Enter: de -> fcb (36 bytes), freshly opened or ; copied from search-first buffer ; extmsk contains extent mask for file's drive ; ; Exit: a,hl = 24-bit file size value in 128-byte records ; get_filesize: ld hl,12 ; point to EXtent byte add hl,de ld a,(extmsk) ; if not directory entry #0 cpl and (hl) jr nz,g_rd ; ..call bdos ld b,(hl) ; save logical extent # inc hl ; point to S2 inc hl ld a,(hl) ; or if overflow into S2 and 7fh ; (not directory entry #0) jr nz,g_rd ; ..call bdos inc hl ; or if Record Count ld a,(hl) cp 80h ; ..is full jr z,g_rd ; ..call bdos ; ; calculate filesize from fcb data ; ld l,a ; hl = rec. cnt. of last log. extent inc b ld de,80h ; + 80h = size of each prior log. extent ld h,d ; h = 0 jr g_dj g_lp: add hl,de g_dj: djnz g_lp xor a ; clear high bits ret ; ; call bdos to calculate filesize ; g_rd: push de ; save fcb ptr ld c,35 ; call bdos for filesize call bdos pop de ld hl,33 ; point to random record # add hl,de ld e,(hl) ; get it inc hl ld d,(hl) inc hl ld a,(hl) ; high bits to A ex de,hl ; low 16 bits in HL ret end