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
/
CPM
/
PROGRAMS
/
CLOCKK
/
LB-TSTP1.LBR
/
TMSTP-LB.ZZ0
/
TMSTP-LB.Z80
Wrap
Text File
|
2000-06-30
|
11KB
|
450 lines
Title Time stamp VERS:- 01.01 DATE:- 01/07/88 TIME:- 18:54:34
;************************************************************
;*
;* File Tracking Program
;* by Eric Forbes
;* c/o Mississauga, Ont. Canada RCP/M System
;* (416) 826-5394
;*
;************************************************************
;Copyright (c) 1982, E. Forbes; permission granted to use,
;copy and distribute for non-commercial purposes.
;
;
;QUICK VIEW: Increment version and insert date and time each
; time a file is assembled / edited. See top line
; of this listing.
;
;To use the 'DATE:- ' and 'TIME:- ' functions, this program
;expects to find three consecutive bytes at MONTH and HOUR,
;in BCD format. E.G. to print the date 07/31/82, the bytes
;07H 31H 82H should be available at MONTH, MONTH+1 and MONTH+2.
;
;If you do not have a clock ignore the 'month' and 'hour'
;equates. They are both read only and will only be read if
;'DATE:- ' or 'TIME:- ' is found in the 1st record of the file
;
;See TIMESTMP.DOC for further deatails
;
;
page
;********************************************************************
;
; DAYDATE code:
;
; Gets date and time from BIOS software real-time clock,
; converts to BCD and places it in a 6-byte string
; in format mmddyyhhmmss at location 'month'.
;
; This version is customized for the AMPRO Little Board Z-80
; by Larry Sonderling
;
;********************************************************************
;
daydate: call getbios ; get BIOS jump tables into local storage
call j2md ; convert Julian date to month/day
;
ld a,(tmonth) ; convert each value to BCD
call binbcd ; and store in output string
ld (month),a ; for TIMESTMP to use.
;
ld a,(tday)
call binbcd
ld (month+1),a
;
ld a,(year)
call binbcd
ld (month+2),a
;
ld a,(bhour)
call binbcd
ld (month+3),a
;
ld a,(bmin)
call binbcd
ld (month+4),a
;
ld a,(bsec)
call binbcd
ld (month+5),a
;
jp timestmp ; jump to main code
;
;
month ds 6 ; output string for TIMESTMP main code
;
;********************************************************************
;
; Error exits for uninstalled clock or wrong BIOS version.
;
;********************************************************************
;
; Time of day TOD jmp was not in bios
;
NOCLK: CALL PRINT0
DEFB 'Clock not installed',CR,LF,0
JP 0
;
; wrong BIOS version
;
BADVER: CALL PRINT0
DEFB 'Requires Bios 3.6 or higher.',CR,LF,0
JP 0
;
;********************************************************************;
;
GETBIOS:LD DE,WBOOT ; build bios entry table
LD HL,(1) ; get bios start
LD BC,51 ; bytes to move
LDIR
CALL GETTBL ; get address of next jmp tbl
CP 36 ; must be bios ver 3.6 or higher
JR C,BADVER ; give message and exit
LD DE,NXTTBL ; 'hl' has bios nxttbl address
LD BC,15 ;
LDIR ; move the table
LD HL,0 ; make sure that clock is enabled
CALL TOD ; get clock base address
LD A,L ; see if address of tick was returned
OR H
JR Z,NOCLK ; exit if clock not enabled
;
; 'HL' has address of clock
;
LD DE,BSEC ; move time and date to work area
LD BC,6
LDIR
RET
;
;****************************************************************
; convert julian to month/day
;****************************************************************
;
J2MD: LD DE,MTHS ; int month pointer
LD HL,(JDAY) ; julian day in 'hl'
INC HL ; adjust for ordinal 0
XOR A
LD B,A ; init high byte of sub with 0
INC A
LD (TMONTH),A ; init month to 1
J2MD1: LD A,(DE)
OR A ; clear carry
LD C,A
LD A,L ; may be day
SBC HL,BC
JR C,J2MD2
JR Z,J2MD2
LD A,(TMONTH)
INC A ; update month
LD (TMONTH),A
INC DE
JR J2MD1
J2MD2: LD (TDAY),A ; set day
RET
;
;***************************************************************
; convert binary to BCD
; in: a - binary value
; out: a - BCD equivalent
;***************************************************************
;
BINBCD: LD C,0 ; init count for MSD
LD B,10 ; divisor
BIN1: SUB B ; divide by 10
JR C,BINEXT ; finished if underflow
INC C ; else incr MSD and
JR BIN1 ; loop back for another one
BINEXT: ADD A,B ; A = ones digit C = tens digit
AND 0FH ; zero high nibble
SLA C ; shift MSD to high nibble
SLA C
SLA C
SLA C
OR C ; insert MSD
RET ; done
;
; Print a null-terminated string on the console
;
print0: pop hl ; get address of string
ld a,(hl) ; load the character
and a ; test for null
jr z,prnend ; quit if null
push hl ; else save the pointer
ld c,a ; and print to console
call conout
pop hl ; restore pointer
inc hl ; bump to next address
jr print0+1 ; go back again
prnend: push hl ; at end HL is return address
ret
;
;**************************************************************************
;
; Table of lengths of months
;
MTHS: DEFB 31,29,31,30,31,30,31,31,30,31,30,31
;
; bios entry table
;
WBOOT: DEFS 3 ; Warm start
CONST: DEFS 3 ; Console status
CONIN: DEFS 3 ; Console character in
CONOUT: DEFS 3 ; Console character out
LIST: DEFS 3 ; List character out
PUNCH: DEFS 3 ; Punch character out
READER: DEFS 3 ; Reader character in
HOME: DEFS 3 ; Seek to home position
SELDSK: DEFS 3 ; Select disk
SETTRK: DEFS 3 ; Set track number
SETSEC: DEFS 3 ; Set sector number
SETDMA: DEFS 3 ; Set DMA address
READ: DEFS 3 ; Read disk
WRITE: DEFS 3 ; Write disk
LISTST: DEFS 3 ; Return list status
SECTRAN:DEFS 3 ; Sector translate
GETTBL: DEFS 3 ; Point to more jumps, returns bioss
; version in 'a'.
;
; Extended BIOS jump table - AMPRO LB specific
;
NXTTBL:
SWAP: DEFS 3 ; jmp swap
HD$INF: DEFS 3 ; get hd table info
PHTBAC: DEFS 3 ; get/set phytab acces
PAGET: DEFS 3 ; get phytab entry address
TOD: DEFS 3 ; get base address of clock tick
BSEC: DEFS 1 ; binary seconds
BMIN: DEFS 1 ; binary minutes
BHOUR: DEFS 1 ; binary hours
JDAY: DEFS 2 ; Julian day
YEAR: DEFS 1 ; binary year
TMONTH: DEFS 1 ; binary month
TDAY: DEFS 1 ; binary day
TYEAR: DEFS 1 ; not used
;
;********************************************************************
;********************************************************************
page
;********************************************************************
; some equates
;********************************************************************
;
false equ 0
true equ not false
hour equ month+3 ; hour byte in bios
base equ 0 ; standard CP/M
recsiz equ 128 ; record length
bell equ 7
bdos equ base+5
tail equ base+80h ; command line
endasm equ base+100h ; org if stand alone
fcb equ base+5ch ; use default fcb
cr equ 0dh ; carriage return
lf equ 0ah ; line feed
;
;********************************************************************
;
; BC = Count of characters in command line tail.
; DE = File control block.
; HL = Command line tail.
;
;********************************************************************
; Main TIMESTMP code begins here
;********************************************************************
;
timestmp:
ld de,crlf
ld c,9 ;new line
call bdos
ld a,(base+6dh) ;get option ' ' or 'M'
ld (major),a ;save it
ld bc,3
ld de,fcb+9 ;set up to
ld hl,ext ;make default ext 'Z80'
ld a,(de)
cp ' ' ;jump if ext not ' '
jr nz,start3
ldir ;ext = 'Z80'
;
start3: ld de,fcb ;open input file
ld c,15
call bdos
ld de,nofile ;report if can't open and
inc a ;exit to CP/M
jp z,error
ld de,buff
ld c,26 ;setdma
call bdos
;
ld de,fcb
ld c,20 ;read record 1
call bdos
;
ld de,verstx
call find ;update version
ld de,novers
call nz,print
call z,versn
;
ld de,datetx
call find ;update date
ld de,nodate
call nz,print
call z,date
;
ld de,timetx
call find ;update time
ld de,notime
call nz,print
call z,time
;
;write record back into file and exit to assembler or CP/M
;The file is not closed, 'cos that would reduce it to a
;single record.
;
xor a
ld (fcb+32),a ;zero the record count
ld de,fcb
ld c,21
call bdos
ld de,donmsg
error: call print ;print error message and exit.
;also normal exit
ret ;back to CP/M
;
print: push af
ld c,9
call bdos
ld hl,fcb+1
ld de,prtnam
ld bc,11
ldir
ld de,prtfil
ld c,9
call bdos ;print file name
pop af
ret
;
;Increment the version number
;
versn: inc hl ;hl --> units of major change
ld a,(major) ;is a major change requested
cp 'M'
call z,twoinc ;inc major change number
jr z,zeromn ;zero minor change number
cp 'N' ;do not change version if
ret z ;'n' option given
inc hl
inc hl
inc hl ;hl --> units of vers no.
;
twoinc: push af ;increment a 2 digit field
push hl
ld b,2
ld a,'9'+1 ;hl --> units position
two1: inc (hl)
cp (hl)
jr nz,twox ;exit if not > 9 ascii
ld (hl),'0' ;else zero the units
dec hl ;and inc the tens
djnz two1
twox: pop hl
pop af
ret
;
zeromn: inc hl ;zero minor version
inc hl
ld (hl),'0' ;used when major changes
inc hl
ld (hl),'0'
ret
;
date: ld de,month ;insert m/d/y
ld b,2
date1: call unpack
ld (hl),'/'
inc hl
djnz date1
call unpack
ret
;
time: ld de,hour
ld b,2
time1: call unpack ;insert h:m:s
ld (hl),':'
inc hl
djnz time1
call unpack
ret
;
;find the first character of string in de (V, D or T)
;
find: ld hl,buff ;de = compare string
ld bc,recsiz ;limit search to 1 rec
trynxt: ld a,(de) ;get 1st char to find
cpir
ret po ;ret nz set = not found
;
;see if the rest of the string compares equal. Retry til we
;get to the end of the buffer
;
push bc
push de
ld b,6 ;compare next 6 chars
find2: inc de
ld a,(de)
cp (hl)
jr nz,tryagn ;try for another string
inc hl
djnz find2 ;keep comparing til b = 0
pop de
pop bc
ret ;ret with z set
;
tryagn: pop de ;Found the 1st character, but
pop bc ;there was a bad compare in
jr trynxt ;the next 6 characters.
;
unpack: ld a,(de) ;unpack the BCD time & date
inc de ;and put the ASCII characters
push af ;in the buffer.
rrca
rrca
rrca ;move high nibble to low
rrca
call unpak1
pop af ;do the low nibble
unpak1: and 0fh
add a,'0' ;make it an ASCII number
ld (hl),a
inc hl
ret
;
donmsg: db '++ Date stamped$'
nofile: db '++ No source$'
novers: db '++ No '
verstx: db 'VERS:- '
db 'in$'
nodate: db '++ No '
datetx: db 'DATE:- '
db 'in$'
notime: db '++ No '
timetx: db 'TIME:- '
db 'in$'
crlf: db cr,lf,'$'
major: db 0
ext: db 'Z80'
buff: ds recsiz
prtfil: db ' File:- '
prtnam: db ' ',cr,lf,lf,'$'
end