home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug049.arc
/
TOD.MAC
< prev
next >
Wrap
Text File
|
1979-12-31
|
5KB
|
191 lines
;assemble with macro 80.
aseg
org 100h
.z80
bios equ 5 ;bios
;show time function for microbee with RTC kit
;
;register contents range
;
;0 seconds 0-60
;1 alarm seconds 0-60
;2 minutes 0-60
;3 alarm minutes 0-60
;4 hours 0-23
;5 alarm hours 0-23
;6 day of week 1-7
;7 day of month 1-30,31,29,28
;8 month 1-12
;9 year 0-99
;
;all outputs are in bcd
JP START
DATA: DB 1EH,1BH,'Y Time Of Day.COM D.BREEZE 18/12/85 ',01AH
;bit of a wank if file is 'typed'
;===================================================================
;main line of program for where all other routines are called
start: ld a,0ah ;point to clock register 0A
out (4),a ;set clock ale
in a,(7) ;read register
bit 7,a ;if bit 7 =1 then update in progress
jr nz,start ;wait for end of update
ld c,04 ;point to hours register
call input ;get hours
call numbers ;print hours
ld a,':' ;print ':'
call output ;/
ld c,02 ;point to minutes reg
call input ;get minutes
call numbers ;print minutes
ld a,':' ;print ':'
call output ;/
ld c,00 ;point to seconds reg
call input ;get seconds
call numbers ;print seconds
ld a,' ' ;print ' '
call output ;/
ld c,06 ;point to day of week
call input ;get day of week
ld hl,day ;point to day: table
call calcstr ;print day
ld A,' ' ;print ' '
call output ;/
ld c,07 ;point to date reg
call input ;get date
call numbers ;print date
ld a,' ' ;print ' '
call output ;/
ld c,08 ;point to month reg
call input ;get date
ld hl,month ;point hl to month: table
call calcstr ;print month
ld hl,year ;point to ' 19'
call outstr ;print it
ld c,09 ;point to year reg
call input ;get year
call numbers ;print year
ld hl,crlf ;print a crlf
call outstr
jp 0 ;exit
;===================================================================
;enters with b='tens' c='units' hl points to start of table
;required
calcstr:ld a,c ;put units in a
bit 0,b ;test for greater than ten (months only)
jr z,lessten ;if more than ten then
add a,0ah ;add ten to count
lessten:ld b,a ;ld b with binary of count
dec b ;dec it by 1
xor a ;clear a
repeat: add a,0ah ;table entry length 10 chars
djnz repeat ;repeat until a=table offset
print: ld d,0 ;clear d
ld e,a ;put offset in e
add hl,de ;find address off table entry
call outstr ;send to con:
ret
;===================================================================
;enters with hl pointing to start of string to be sent
outstr: push de
push bc
ex de,hl ;point de to string
ld c,9 ;bios fuction 'print string'
call bios ;go and do it
pop bc
pop de
ret
;===================================================================
;enters with b='tens' c='units'
numbers:ld hl,digits ;point to '0'
ld D,0 ;clear d
ld e,b ;put 'tens' in e
add hl,de ;point to first digit
ld a,(hl) ;get the char
call output ;output it
ld hl,digits ;point to '0'
ld e,c ;put 'tens' in e
add hl,de ;point to second digit
ld a,(hl) ;get the char
call output ;output it
ret
;===================================================================
;enters with char in a
output: push bc
push de
ld c,02h ;bios function
ld e,a ;char in e to con:
call bios ;do that
pop de
pop bc
ret
;===================================================================
;enters with c containing address of clock register to read
;and sets up bc to contain the bcd result
;b contains the upper nibble
;c contains the lower nibble
input: ld a,c ;put register num in a
out (4),a ;set register address in ale of clock
in a,(7) ;read desired register
push af ;save it on stack
and 0f0h ;scrub lower nibble
rra ;shift upper nibble down to lower nibble
rra ; /
rra ; /
rra ;/
ld b,a ;store in b
pop af ;restore a from stack
and 0fh ;scrub upper nibble
ld c,a ;store in c
ret
;===================================================================
;asci tables
digits: db '0123456789'
day: db 'Sunday$000'
db 'Monday$000'
db 'Tuesday$00'
db 'Wednesday$'
db 'Thursday$0'
db 'Friday$000'
db 'Saturday$0'
month: db 'January$00'
db 'February$0'
db 'March$0000'
db 'April$0000'
db 'May$000000'
db 'June$00000'
db 'July$00000'
db 'August$000'
db 'September$'
db 'October$00'
db 'November$0'
db 'December$0'
year: db ' 19$'
crlf: db 0dh,0ah,'$'
end