home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
beehive
/
utilitys
/
beertc.arc
/
TIME.MAC
< prev
Wrap
Text File
|
1990-07-21
|
2KB
|
167 lines
;02.05.87, age
TITLE 'Show MicroBee RTC values'
.Z80
ASEG
page 80 ;() sets compressed print, 8 lines/inch
org 100h
.phase 100h
addr_port equ 04h ;register selection port
data_out equ 06h ;data output port to rtc
data_in equ 07h ;data input port to read data from rtc
bdos equ 005h
coninf equ 001h
cnoutf equ 002h
printf equ 009h
bell equ 007h
tab equ 009h
lf equ 00ah
cr equ 00dh
clr equ 01ah
; registers
hour equ 4
min equ 2
sec equ 0
day equ 7
month equ 8
year equ 9
;macros
rdport macro
out (addr_port),a
in a,(data_in)
endm
; hide the cursor and clear screen
start: ld b,00fh
ld a,000h
ld hl,0fa00h
hide: ld (hl),a
inc hl
djnz hide
ld a,clr
call con
; signon
ld de,signon
ld c,printf
call bdos
; show the time incrementing
ld a,lf
call con
ld a,lf
call con
;read the data from the rtc
read_rtc:
ld de,space
ld c,printf
call bdos
ld a,hour
rdport ;get value for hours
call split ;convert to msb and lsb in H, L
ld (hours),hl
ld a,min
rdport
call split
ld (mins),hl
ld a,sec
rdport
call split
ld (secs),hl
ld a,day
rdport
call split
ld (days),hl
ld a,month
rdport
call split
ld (months),hl
ld a,year
rdport
call split
ld (years),hl
pr_time:
ld hl,hours
ld b,15h
pr1: ld a,(hl)
call con
inc hl
djnz pr1
; wait for next 1 second
loop: ld a,00ch ; status register
rdport
and 010h ; update bit
jp nz,read_rtc
ld c,06h ; swallow key
ld e,0ffh
call bdos
or a
jp nz,cpm
jr loop
; return to CP/M
cpm: jp 0 ; warm boot
;subroutines
;subroutine to take the packed BCD number in A and split it into a tens and
;a units digit in L and H.
split: push af
and 0f0h ;mask out units
ld l,a ;L contains tens
pop af
sub l
add a,'0' ;convert to ascii
ld h,a ;get units into H
srl l ;divide by 16 to get true 0-9 value
srl l
srl l
srl l
ld a,l
add a,'0' ;convert to ascii
ld l,a
ret
;console print subroutine
con: push af
push bc
push hl
ld e,a
ld c,cnoutf
call bdos
pop hl
pop bc
pop af
ret
;messages
signon: db clr,lf,lf,lf,tab,'MicroBee Real Time Clock'
db ' (press any key to abort)','$'
space: db cr,' ','$'
;data storage
hours: db '00:'
mins: db '00:'
secs: db '00 '
days: db '00/'
months: db '00/19'
years: db '00'
temp: ds 1
end