.TITLE RDCLK Read time and date .NLIST BEX .ENABL LC ; ; Pdp11/dcn - read time and date ; ; External symbols ; .GLOBL HASH,RDDEC ;read routines ; ; Entry symbols ; .GLOBL RDCLK ;read system clock .GLOBL RDDAT ;read system date ; ; Module definitions ; .MACRO TABLE ARG ;generate month table ..N = 0 .IRP X, .WORD ..N ..N = ..N+X .ENDR .ENDM TABLE ; ; Procedure segment ; .PSECT $BOSI,RO,I ; ; Rdclk (clk) read clock in hh:mm:ss format ; Returns r0-r1 = milliseconds past midnight ; RDCLK: MOV R2,-(SP) ;save registers MOV R3,-(SP) CLR R0 ;get hours JSR PC,CLK71 MOV #60.,R0 ;get minutes JSR PC,CLK71 MOV #60.,R0 ;get seconds JSR PC,CLK71 MOV #1000.,R0 ;scale to milliseconds JSR PC,CLK70 MOV R2,R0 ;get result MOV R3,R1 MOV (SP)+,R3 ;restore registers MOV (SP)+,R2 RTS PC ; ; Subroutine to multiply partial product ; (called only by rdclk) ; R0 = multiplier, r2-r3 = multiplicand, returns r2-r3 = product (lsb) ; CLK70: MOV R4,-(SP) ;initialize CLR R1 MOV #33.,R4 1$: ASR R1 ;shift partial product right ROR R2 ROR R3 BCC 2$ ;branch if lsb = 0 ADD R0,R1 ;lsb ~= 0. add multiplier 2$: DEC R4 BNE 1$ MOV (SP)+,R4 RTS PC ; ; Subroutine to multiply partial product and get next field ; (called only by rdclk) ; R0 = multiplier, r2-r3 = multiplicand, returns r2-r3 = product (lsb) ; CLK71: JSR PC,CLK70 ;multiply partial product JSR PC,RDDEC ;get next field ADD R0,R3 ;add to product ADC R2 RTS PC ; ; Rddat (rdd) read calender date in dd-mmm-yy format ; Returns r0 = calender date (rt-11 format) ; RDDAT: MOV R1,-(SP) ;save registers MOV R2,-(SP) JSR PC,RDDEC ;get day BIC #^C37,R0 ;align ASH #5,R0 MOV R0,-(SP) JSR PC,HASH ;get month MOV R0,R2 CLR R0 MOV PC,R1 ;search table ADD #MONTBL-.,R1 1$: ADD #2000,R0 ;update month TST @R1 ;is this end of table BEQ 2$ ;branch if yes CMP R2,(R1)+ ;no. does it match BNE 1$ ;branch if no BIS R0,@SP 2$: JSR PC,RDDEC ;get year BEQ 4$ SUB #72.,R0 CMP R0,#99.-72. ;[JMBW] outside of range 1972.-1999.? BLOS 4$ ;[JMBW] no, fine SUB #1972.-72.,R0 ;[JMBW] assume 4-digit year 4$: BIS (SP)+,R0 ;assemble month, day, year BEQ 5$ JSR PC,RTDAT ;convert to system format 5$: MOV (SP)+,R2 ;restore registers MOV (SP)+,R1 RTS PC ; ; Subroutine to convert rt-11 date to system date (days past 1 Jan 1972) ; r0 = rt-11 date, returns r0 = system date ; RTDAT: MOV R0,R2 ;convert year ASH #-2,R0 BIC #^C7,R0 MUL #1461.,R0 ;(4*365+1) MOV PC,R3 ;assume standard year ADD #STDYER-2-.,R3 MOV R2,R0 BIC #^C3,R0 BNE 7$ ADD #LEPYER-STDYER,R3 ;assume leap year 7$: ASL R0 ADD PC,R0 ADD YEAR-.(R0),R1 MOV R2,R0 ;convert month ASH #-10.,R0 BIC #^C17,R0 ASL R0 ADD R3,R0 ADD @R0,R1 MOV R2,R0 ;convert day ASH #-5,R0 BIC #^C37,R0 DEC R0 ADD R1,R0 RTS PC ; ; Data segment ; .PSECT $BOSD,RO,D ; MONTBL: .RAD50 'JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC' ; ; xx0 xx1 xx2 xx3 YEAR: TABLE <366.,365.,365.,365.> ; jan feb mar apr may jun jul aug sep oct nov dec STDYER: TABLE <31.,28.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31.,999.> LEPYER: TABLE <31.,29.,31.,30.,31.,30.,31.,31.,30.,31.,30.,31.,999.> ; .END