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
/
ZCPR33
/
A-R
/
JULIAN.LBR
/
JUL2BIN.ZZ0
/
JUL2BIN.Z80
Wrap
Text File
|
2000-06-30
|
1KB
|
67 lines
; routine jul2bin
; author: Bridger Mitchell & Howard Goldstein
; date: 4/16/1988
; Julian to binary date routine.
;
;>> hl = days since 77/12/31 (Julian date)
;<< b = month (1=jan...)
; c = year (78...)
; l = day (1...31)
; a = day (copy of l)
;
entry jul2bin
extrn dpermo
cseg
; convert hl = days to yr,mo,da
;
jul2bin:
PUSH DE
ld c,78 ;set yr = 78
yrlp: ld b,1 ;set mo = 1
ld de,dpermo ;point at table
molp: ld a,(de) ;get # days in mo
push de
ld e,a
ld d,0
or a
sbc hl,de ;subtract days in mo
jr c,j2bin9 ;done if <= 0
jr z,j2bin9
ld a,b ;if mo == Feb
cp 2
jr nz,j2bin3
ld a,c ;..and yr%4 == 0
and 00000011b
jr nz,j2bin3
dec hl ;have feb. of leap year
ld a,h ;if days left was 1 (Mar 1)
or l
jr nz,j2bin3
ld l,29 ;..it's Feb. 29th
jr j2bin8
j2bin3:
pop de ;mo tbl
inc de ;point at next month
inc b ;mo++
ld a,b
cp 13
jr c,molp ;do next month
inc c ;yr++
jr yrlp ;do next year
;
; done --
j2bin9: add hl,de ;add back subtracted size of next month
j2bin8 pop de ;clear stack
ld a,l ; # days in cur. month
POP DE
ret
;
;
end