home *** CD-ROM | disk | FTP | other *** search
- title FIXT&D.ASM
-
- vers equ 0
- rev equ 2
-
- ; vers 0.2
- ; Bridger Mitchell, 7/18/89
- ; vers 0.1
- ; Al Hawley, 10 Apr 89
- ; Ladera Z-Node, (213) 670-9465
-
- ; Quick & dirty pgm to recalculate, verify,
- ; and if incorrect and store the checksum bytes in a !!!TIME&.DAT file.
- ;
- ;======================================================
-
- ;External references:
-
- ;for versions of SYSLIB that are limited to 6 char symbols
- ;and if your assembler emits >6 char symbols
- ; note strange bug in SLR assembler:
- ; a ".request " line cannot contain a comment!
- ; for SLR format:
- .request syslibs
- ; for MS format:
- ; .request syslib
-
- ; ext r$read,r$writ,f$open,f$clos,print,padc
-
- ;for SYSLIB versions which use 7 char symbols,use:
- ext r$read,r$write,f$open,f$close,print,padc
- ;
- ;and change the calls to these routines accordingly
-
- ;======================================================
- ;data definitions
-
- dfcb equ 5ch
- tbuf equ 80h
- bdos equ 0005h
- cr equ 0dh
- lf equ 0ah
- ;======================================================
- ;start of pgm code. Symbols are public only for use
- ;by a symbolic debugger like DSD or ZSID or Z8E
-
- start:: ld (stack),sp
- ld sp,stack
- call signon
- ld a,(dfcb+1) ; check for help or drive:
- cp '/'
- jp z,help
- ld a,(dfcb)
- or a
- jr z,go ; ..default drive
- ld (tdfcb),a ; set explicit drive
- ;
- go:: ld e,0FFh ; save user #
- call user
- ld (origusr),a
- ld e,0 ; set user #0
- call user
- xor a ; initialize
- ld (count),a
- ld de,tdfcb ;open the file
- call f$open ;de is assumed preserved in all routines
- ld hl,tdfcb+9
- res 7,(hl) ; set file r/w
- ld c,30
- call xbdos
- ld a,(rc) ;size of the !!!TIME&.DAT file
- ld b,a ;..in B for stepping through the file
- ld c,0 ; initialize counter
- ;
- ;for recs 0-(B-1), adjust the checsum for each record
- rrloop::
- push bc
- call r$read ;read a record to tbuf
- jr nz,finish
- call docsum ;calculate & store 127 byte cksum
- jr z,ok
- ld hl,(rrecno) ;bump the random record number
- call r$write ;restore the record to the file
- pop bc
- push bc
- ld a,c ; get sector #
- call sayfixed
- ok:: ld hl,(rrecno) ;bump the random record number
- inc hl
- ld (rrecno),hl
-
- pop bc
- inc c ; bump counter
- djnz rrloop
-
- finish::
- call f$close ;close the file
- ld hl,tdfcb+9
- set 7,(hl) ; set r/o
- ld c,30
- call xbdos
- ld a,(count)
- or a,a
- call z,saynone
- ld a,(origusr) ; restore user #
- ld e,a
- call user
- ;
- exit:: ld sp,(stack)
- ret ;return to CCP quietly.
-
- ;======================================================
- signon::
- call print
- db cr,lf,'FIXT&D v. '
- vbyte: db vers+'0','.',rev+'0'
- db ' - verify/correct the checksums in !!!TIME&.DAT file.',0
- ret
-
- sayfixed::
- push af
- call print
- db cr,lf,'fixed T&D record #',0
- pop af
- call padc
- ld hl,count
- inc (hl)
- ret
-
- saynone::
- call print
- db cr,lf,'No changes required.',0
- ret
-
- help::
- call print
- db cr,lf,' usage: FIXT&D [d:]'
- db cr,lf,' to verify and correct checksums on drive [d:]',0
- jp exit
-
- ;routine to calculate checksum for one record (128 bytes)
- ; return Z if ok, else update, return NZ
-
- docsum:: ;cksum first 127 bytes, store in 128th byte
- ld hl,tbuf ;where the record exists
- ld b,127
- xor a ;initial val for cksum
- csloop::
- add (hl) ;accumulate the checksum
- inc hl ;bump the pointer
- djnz csloop
- cp a,(hl) ; if matches stored value
- ret z ; ..return ok
- ld (hl),a ; else update the checksum byte
- ret
-
- user:: ld c,32
- xbdos:: push de
- call bdos
- pop de
- ret
-
- ;======================================================
- ; DATA AREA
-
- tdfcb:: ds 1,0 ;uses default user
- db '!!!TIME&DAT' ;11 character file name&typ
- ds 3 ;ext,user,data module number
- rc:: ds 1
- ds 16,0 ;allocation map
- ds 1 ;current record
- rrecno::ds 3,0
-
- count:: ds 1
-
- origusr::ds 1
-
- ;======================================================
-
- stktop:: ds 50
- stack:: ds 2
-
- end
- nt
- db cr,lf,' usage: FIXT&D [d:]