;---------------------------------------------------------------- ; This is a module for the PL/I-80 subroutine library ; ; This module must return the date and time to PL/I in the ; same format as the inbuilt function does. ; ; Date returns a character 6 string yymmdd ; Time returns a character 12 string hhmmsstttttt ; ; Written by Richard Holmes 08-12-84 ; Last update Richard Holmes 08-12-84 ;---------------------------------------------------------------- ; name 'smdate' public gdate,gtime,string maclib z80 ; bdos equ 05 start: call gtime call gdate jmp start ;-------------- ; Get date only ;-------------- ; gdate: call fetch lhld @date ; date since 1 Jan 78 lxi b,365 ; count years xra a ; year counter year$loop: dsbc b ; -1 years jc got$year inr a daa dsbc b ; -2 years jc got$year inr a daa inx b ; leap year = 366 days dsbc b ; -3 years jc got$year inr a daa dcx b dsbc b ; -4 years jc got$year inr a daa jmp year$loop ; got$year: dad b ; correct adi 78h ; add year 1978 ora a daa sta year leap$loop: ; check for leap year sui 4 jc not$leap jnz leap$loop mvi a,29 jmp set$feb ; not$leap: mvi a,28 set$feb: sta feb ; set february lxi d,jan xra a mov b,a month$loop: jc month$end push psw ; save count ldax d mov c,a ; days to BC pop psw inr a ; count month daa dsbc b inx d ; next month jnz month$loop month$end: dad b ; correct sta month ; set month mov a,l ; get day cpi 10h jc not20 adi 6 cpi 20h jc not20 adi 6 not20: ora a daa sta day ; Return this as yymmdd lxi h,string ; -> destination lda year ; load parameter call bcd$asc lda month call bcd$asc lda day call bcd$asc ; Now load back for PL/I mvi b,6 ; 6 characters send$back: lxi h,string ; -> start of string mov e,b mvi d,00 ; load an indexer dad d dcx h xchg ; DE -> last string entry mov c,b ; Save counter pop h ; PL/I return address sb1: ldax d push psw ; put onto stack inx sp dcx d ; get next character djnz sb1 mov a,c ; Flag number of characters returned pchl ; Return via HL ; ; Get the time only ; gtime: call fetch push psw ; Seconds field lxi h,string lda @date + 2 ; hh field call bcd$asc lda @date + 3 call bcd$asc pop psw call bcd$asc mvi b,12 jmp send$back ; Send all string ; bcd$asc: push psw ani 0f0h ; high BCD rrc rrc rrc rrc adi '0' ; make ascii mov m,a inx h pop psw ani 0fh adi '0' mov m,a inx h ret ; fetch: lxi h,string mvi m,' ' mov e,l mov d,h inx d lxi b,11 ldir ; blank fill string mvi c,105 ; Read time bdos function lxi d,@date call bdos ret ; dseg string ds 12 ; make a sting up in this @date db 00,00,00,00 ; Date and time field year ds 1 ; 1 byte 2 digit bcd month ds 1 ; 1 byte 2 digit bcd day ds 1 ; 1 byte 2 digit bcd dweek ds 1 ; 1 byte 1 digit bcd ** low nibble only *** ; This table reminds us that :- ; 30 days have September, April June and November ; and February is stuffed up every 4 years. montbl: db 0 jan: db 31 ; January feb: db 28 ; February (28 or 29 days) db 31 ; March db 30 ; April db 31 ; May db 30 ; June db 31 ; July db 31 ; August db 30 ; September db 31 ; October db 30 ; November db 31 ; December end