home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ZSYS
/
SIMTEL20
/
SYSLIB
/
SLIB2.LBR
/
SFSIZE.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
2KB
|
89 lines
;
; SYSLIB Module Name: SFSIZE
; Author: Richard Conn
; SYSLIB Version Number: 3.6
; Module Version Number: 1.1
public f$size
;
; BDOS FUNCTION
;
GETFSIZ EQU 35 ; GET FILE SIZE
;
; SYSLIB UTILITIES
;
EXT MOVEB,INITFCB,BDOS,SHFTRH
;
; MACROS
;
PUTRG MACRO
PUSH AF
PUSH BC
PUSH DE
ENDM
GETRG MACRO
POP DE
POP BC
POP AF
ENDM
;
; F$SIZE -- COMPUTE SIZE OF FILE WHOSE FIRST 12 FCB BYTES ARE PTED TO BY DE
; THIS ROUTINE ASSUMES THE FILE IS LESS THAN THE MAX SIZE
;
; ON INPUT, DE PTS TO FIRST 12 BYTES OF FCB (NO MORE IS NECESSARY)
; ON OUTPUT, HL CONTAINS FILE SIZE IN K
;
F$SIZE:
PUTRG
LD HL,FCB ; COPY THEIR 12 BYTES INTO LOCAL FCB
EX DE,HL
LD B,12 ; 12 BYTES
CALL MOVEB
LD DE,FCB ; PT TO FCB
CALL INITFCB ; INIT IT
LD C,GETFSIZ ; GET FILE SIZE USING BDOS FUNCTION
CALL BDOS
LD D,0 ; SET NO OVERFLOW
LD HL,(RANREC) ; GET RANDOM RECORD NUMBER
CALL SETOVER ; SET FLAG IF OVER THIS K
CALL SHFTRH ; /2
CALL SETOVER
CALL SHFTRH ; /4
CALL SETOVER
CALL SHFTRH ; /8 FOR K
LD A,D ; CHECK FOR OVERFLOW
OR A ; 0=OK
JP Z,FS1
INC HL ; ADD 1K SINCE OVERFLOW
FS1:
GETRG
RET
;
; SET D=1 IF OVERFLOW OF EVEN BOUNDARY
;
SETOVER:
LD A,L ; CHECK LSB
AND 1
RET Z
LD D,1 ; SET OVERFLOW INDICATOR
RET
;
; FCB BUFFER
;
FCB:
DS 32
DB 0 ; SEQ RECORD
RANREC:
DW 0 ; RANDOM RECORD NUMBER
OVFL:
DB 0 ; OVERFLOW BYTE
END