;*************************** AMUS Program Label ******************************
; Filename: FILANA.M68 Date: 10/4/91
; Category: UTIL Hash Code: 300-064-167-550 Version:
; Initials: ULTR/AM Name: DAVID PALLMANN
; Company: UTLRASOFT Telephone #: 5163484848
; Related Files:
; Min. Op. Sys.: Expertise Level:
; Special:
; Description: File analysis utility--file size in bytes, number of 7-bit
; characters, number of 8-bit characters, number of line feeds & form feeds
;
;*****************************************************************************
;****************************************************************************
;* *
;* FILANA *
;* File Analysis Program *
;* *
;****************************************************************************
;[100] 03 October 1991 14:29 Edited by David Pallmann
; Created.
;version number
VMAJOR =1
VMINOR =0
VSUB =0
VEDIT =100.
VWHO =0
;universals
SEARCH SYS
SEARCH SYSSYM
SEARCH TRM
;ASCII character definitions
$LF =12
$FF =14
$CR =15
;variables
.OFINI
.OFDEF CHARS, 4 ; total character count
.OFDEF CHAR7S, 4 ; 7-bit character count
.OFDEF CHAR8S, 4 ; 8-bit character count
.OFDEF LINES, 4 ; line count
.OFDEF PAGES, 4 ; page count
.OFDEF FILE, D.DDB ; file DDB
.OFSIZ MEMSIZ
;***********
;* START *
;***********
;initialization
START: PHDR -1,0,PH$REE!PH$REU ; program header
GETIMP MEMSIZ,A5 ; allocate local memory for variables
;************
;* CMDLIN *
;************
;command line processing
CMDLIN: BYP ; bypass spaces/tabs
LIN ; end of line?
JEQ USAGE ; yes - explain command usage
FSPEC FILE(A5),LIT ;
INIT FILE(A5) ;
;**********
;* OPEN *
;**********
OPEN: OPENI FILE(A5) ;
;************
;* BYPASS *
;************
;bypass header if an AlphaWRITE document
BYPASS: CMPW FILE+D.EXT(A5),#[WRT] ;
BNE GET ;
MOV #510.,D0 ;
10$: FILINB FILE(A5) ;
SOB D0,10$ ;
ADD #510.,CHARS(A5) ;
;*********
;* GET *
;*********
;get byte and process
GET: CTRLC CLOSE ; ^C check
FILINB FILE(A5) ; get byte
TST FILE+D.SIZ(A5) ; end of file?
BEQ CLOSE ; yes
INC CHARS(A5) ; increment character count
CALL SCAN.LINES ; update line feed count
CALL SCAN.PAGES ; update page count
CMPB D7,#127. ; 7-bit or 8-bit?
BLOS 20$ ; 7-bit
INC CHAR8S(A5) ; increment 8-bit character count
BR GET ; loop
20$: INC CHAR7S(A5) ; increment 7-bit character count
BR GET ; loop
;***********
;* CLOSE *
;***********
;close file, report on file contents, and exit
CLOSE: CLOSE FILE(A5) ; close file
CTRLC ABORT ; ^C check
L1: TYPESP File size is ;
MOV CHARS(A5),D1 ;
DCVT 0,OT$TRM!OT$TSP ;
TYPE byte ;
CMP D1,#1 ;
BEQ 10$ ;
TYPE s ;
10$: TYPE < (> ;
MOV CHAR7S(A5),D1 ;
DCVT 0,OT$TRM!OT$TSP ;
TYPE 7-bit character ;
CMP D1,#1 ;
BEQ 20$ ;
TYPE s ;
20$: TYPE <, > ;
MOV CHAR8S(A5),D1 ;
DCVT 0,OT$TRM!OT$TSP ;
TYPE 8-bit character ;
CMP D1,#1 ;
BEQ 30$ ;
TYPE s ;
30$: TYPECR ) ;
L2: TYPESP File contains ;
MOV LINES(A5),D1 ;
DCVT 0,OT$TRM!OT$TSP ;
MOVW FILE+D.EXT(A5),D7 ;
CMPW D7,#[WRT] ;
BEQ 20$ ;
CMPW D7,#[T ] ;
BEQ 20$ ;
TYPE line feed ;
CMP D1,#1 ;
BEQ 90$ ;
TYPE s ;
BR 90$ ;
10$: TYPE line ;
CMP D1,#1 ;
BEQ 90$ ;
TYPE s ;
BR 90$ ;
20$: TYPE carriage return ;
CMP D1,#1 ;
BEQ 90$ ;
TYPE s ;
BR 90$ ;
90$: TYPE <, > ;
MOV PAGES(A5),D1 ;
DCVT 0,OT$TRM!OT$TSP ;
TYPE form feed ;
CMP D1,#1 ;
BEQ 99$ ;
TYPE s ;
99$: CRLF ;
L3: CRLF ;
EXIT ;
ABORT: TYPECR ?Aborted ;
CRLF ;
EXIT ;
;***********
;* USAGE *
;***********
;explain command usage
USAGE: TYPECR Usage: .FILANA filespec
CRLF ;
EXIT ;
;****************
;* SCAN.LINES *
;****************
;Function: Update line count
;
;Inputs: D1 - character
SCAN.LINES:
MOVW FILE+D.EXT(A5),D7 ;
CMPW D7,#[WRT] ;
BEQ SL.WRT ;
CMPW D7,#[T ] ;
BEQ SL.SV ;
SL.OTH: CMPB D1,#$LF ; line feed?
BNE 10$ ; no
INC LINES(A5) ; increment line count
10$: RTN ;
SL.WRT: TSTB D1 ;
BNE 10$ ;
INC LINES(A5) ;
10$: RTN ;
SL.SV: CMPB D1,#$CR ;
BNE 10$ ;
INC LINES(A5) ;
10$: RTN ;
;****************
;* SCAN.PAGES *
;****************
;Function: Update page count
;
;Inputs: D1 - character
SCAN.PAGES:
CMPW FILE+D.EXT(A5),#[WRT] ;
BEQ SP.WRT ;
CMPB D1,#$FF ; form feed?
BNE 10$ ; no
INC PAGES(A5) ;
10$: RTN ;
SP.WRT: CMPB D1,#^H096 ; 2.1x page break?
BLO 10$ ; no
CMPB D1,#^H098 ; 2.1x page break?
BHI 10$ ; no
INC PAGES(A5) ;
10$: RTN ;
END