home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
dbaseii
/
dbclock.lbr
/
DBCLOCK.ZZ0
/
DBCLOCK.Z80
Wrap
Text File
|
1987-05-23
|
2KB
|
102 lines
; ******************************************
; * *
; * READ DATESTAMPER FOR DBASE II *
; * May 14, 1987, Bruce Morgen *
; * *
; ******************************************
; This code has been tested with dBaseII Version 2.41 ONLY!
; It is based on TM-DS10.Z80 by Jim Lill and KP4CLOCK.Z80
; by Ulrich Steinberg. Note that no self-modifying code is
; employed to read the DateStamper "clock" - this is of no
; particular consequence on today's Z80-compatible CPUs but
; is a good habit to get into for pipelined chips like the
; upcoming Z280.
DBFREE EQU 0A400H ; First free memory above dBase
BDOS EQU 5 ; DOS call vector
CPMVER EQU 12 ; Get CP/M version function #
DSCLUE EQU 'D' ; Returned by DateStamper
ORG DBFREE
; Entry "vector"
JR DATE
JR WDAY ; Dummy for day-of-week
JR TIME
DATE:
CALL READRTC ; Read real time clock
RET NZ
LD A,(MONTH)
CALL STORE ; Store month in memory variable
INC HL
LD (HL),'/'
LD A,(DAY)
CALL STORE ; Store day in memory variable
INC HL
LD (HL),'/'
LD A,(YEAR)
JR STORE ; Return to dBase via STORE
TIME: CALL READRTC
RET NZ
LD A,(HOUR)
CALL STORE
INC HL
LD (HL),':'
LD A,(MINUTE)
JR STORE ; Return to dBase via STORE
; Read The DateStamper's "real time clock"
READRTC:
PUSH HL ; Save pointer
LD E,DSCLUE
LD C,CPMVER
CALL BDOS
CP 22H ; MUST be Version 2.2
RET NZ
LD A,H
CP DSCLUE
RET NZ
LD HL,RETURN ; Avoids self-modifying code:
PUSH HL ; DS's RET will get back there
PUSH DE ; Our 1st RET will get to DS
LD HL,COUNTERS ; Point to our data space
RET ; "CALL"ing The DateStamper
RETURN: POP HL ; Recover pointer to dBaseII
WDAY: RET ; Doubles as dummy routine
; Store ASCII in dBaseII's memory variables
STORE: LD B,A ; Stash BCD in B
RRCA ; Exchange nybbles
RRCA
RRCA
RRCA
AND 0FH ; Mask
ADD A,'0' ; ASCII
INC HL ; Bump pointer
LD (HL),A ; Store
LD A,B ; Get other nybble
AND 0FH ; Mask
ADD A,'0' ; ASCII
INC HL ; Bump pointer
LD (HL),A ; Store
RET
; BCD counter storage
COUNTERS:
YEAR: DS 1
MONTH: DS 1
DAY: DS 1
HOUR: DS 1
MINUTE: DS 1
SECOND: DS 1
END DBFREE