; 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