.MCALL .MODULE .MODULE SETCLK,VERSION=10,COMMENT= ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ; ; Author: D.B. Fingerhut ; ;18-Oct-1990 JFW V08 - Add support for TOY clock on 11/9x ; ;22-Oct-1990 JFW V09 - Set day of week in TOY clock on 11/9x ; ;6-Oct-1998 DC V10 - change CMPB's in date handling to CMP's ; properly set TOY date ; .SBTTL Constants .GLOBL CALL$F,IWEEKD ;SYSLIB routines ; The following are for the PRO TOY clock CKSEC = 173000 ;TOY seconds CKMIN = 173004 ;TOY minutes CKMAL = 173006 ;TOY minutes alarm CKHOU = 173010 ;TOY hours CKHAL = 173012 ;TOY hours alarm CKDAY = 173014 ;TOY day of week CKDAT = 173016 ;TOY day of month CKMON = 173020 ;TOY month CKYEA = 173022 ;TOY year CKCSR1 = 173026 ;TOY CSR1 ;SET/RESET CK1DST = 1 ;Enable DST/Disable DST CK124 = 2 ;24 hour clock mode/12 hour clock mode CK1DM = 4 ;Binary format/BCD format CK1SET = 200 ;Inhibit/allow interrupts CKCSR2 = 173030 ;TOY CSR2 CKCSR3 = 173032 ;TOY CSR3 ; The following are for the 11/9x TOY clock AddSR = 177526 ; KDJ-11E Additional Status Register (11/93-94 only) TOYCom = 400 ; R/W bit for Time-Of-Year clock communication .SBTTL Pure area MONTHS: .ASCIZ /JAN/ .ASCIZ /FEB/ .ASCIZ /MAR/ .ASCIZ /APR/ .ASCIZ /MAY/ .ASCIZ /JUN/ .ASCIZ /JUL/ .ASCIZ /AUG/ .ASCIZ /SEP/ .ASCIZ /OCT/ .ASCIZ /NOV/ .ASCIZ /DEC/ .WORD 0 MONLEN: .WORD 0-1 ;JANUARY .WORD 31.-1 ;FEBRUARY .WORD 59.-1 ;MARCH .WORD 90.-1 ;APRIL .WORD 120.-1 ;MAY .WORD 151.-1 ;JUNE .WORD 181.-1 ;JULY .WORD 212.-1 ;AUGUST .WORD 243.-1 ;SEPTEMBER .WORD 273.-1 ;OCTOBER .WORD 304.-1 ;NOVEMBER .WORD 334.-1 ;DECEMBER TOYPAT: .WORD 35305,56243,35305,56243 ; 64-bit "match" pattern .WORD 0 ;End of table marker PWEEKD: ;Parameter list for IWEEKD .WORD 3 ;three parameters .WORD TOYMON .WORD TOYDAT .WORD TOYYEA MSGDM: .ASCII /Data Mode: /<200> MSGBC: .ASCIZ /BCD/ MSGBI: .ASCIZ /BINARY/ MSGHM: .ASCII \24/12 Hour Mode: \<200> MSG12: .ASCIZ /12 Hour/ MSG24: .ASCIZ /24 Hour/ MSGDS: .ASCII /Daylight Savings Clock: /<200> MSGND: .ASCIZ /Disabled/ MSGYD: .ASCIZ /Enabled/ .SBTTL Impure Area .EVEN TIMBLK: .BLKW 2 ;Area for monitor time DATBLK: .BLKW 3 ;Date/time information block TOYSEC: .WORD 0 ;Time of year seconds TOYMIN: .WORD 0 ;Time of year minutes TOYHOU: .WORD 0 ;Time of year hours TOYDAY: .WORD 0 ;Time of year day of week TOYDAT: .WORD 0 ;Time of year day of month TOYMON: .WORD 0 ;Time of year month TOYYEA: .WORD 0 ;Time of year year OLDASR: .BLKW 1 ;Old Added Status Register contents .SBTTL C12H24 - Convert 12 hour to 24 hour ;+ ; C12H24 - Convert a time from 12 hour to 24 hour ; If BCD is on, the number is converted to binary, converted to ; 24 hour mode, then back to BCD. ; ; Input: R0 -> Number to convert ; Output: R0 -> Converted number ; ;- C12H24:: BIT #CK1DM,@#CKCSR1 ;Is BCD on? BNE 5$ ;Branch if not BIS #FL.12H,FLAGWD ;Preserve the 12Hour bit CALL BCDBIN ;Convert to binary 5$: BITB #200,@R0 ;Is it PM? BEQ 10$ ;Branch if not BICB #200,@R0 ;Clear out the PM sign ADD #12.,@R0 ;Make it 13 through 24 CMP #24.,@R0 ;Is it noon? BNE 11$ ;Branch if not MOV #12.,@R0 ;Noon is 12 in 24hour mode BR 11$ ;Continue 10$: CMP #12.,@R0 ;Is it midnight? BNE 11$ ;Branch if not CLR @R1 ;Midnight is 0 in 24hour mode 11$: BIT #CK1DM,@#CKCSR1 ;Is this BCD mode? BNE 12$ ;Branch if not CALL BINBCD ;Convert to BCD 12$: RETURN .SBTTL C24H12 - Convert 24hour to 12hour mode ;+ ; C24H12 - Convert a time from 24 hour to 12 hour mode ; ; Input: R0 -> Number to convert ; Output: R0 -> Converted number ; ;- C24H12:: BIT #CK1DM,@#CKCSR1 ;Is BCD on? BNE 5$ ;Branch if not BIS #FL.12H,FLAGWD ;Preserve the 12Hour bit CALL BCDBIN ;Convert to binary 5$: CMP #12.,@R0 ;Is it morning? BHI 10$ ;Branch if so BISB #200,@R0 ;Indicate PM SUB #12.,@R0 ;Make it 0 through 11 BNE 11$ ;Branch if not noon MOV #12.,@R0 ;Noon is 12 in 12hour mode BISB #200,@R0 ;Indicate PM BR 11$ ;Continue 10$: TST @R0 ;Is it midnight? BNE 11$ ;Branch if not MOV #12.,@R0 ;Midnight is 12 in 12hour mode 11$: BIT #CK1DM,@#CKCSR1 ;Is this BCD mode? BNE 12$ ;Branch if not CALL BINBCD ;Convert to BCD 12$: RETURN .SBTTL BCDBIN - Convert from BCD to BIN ;+ ; BCDBIN - Convert from BCD to BIN ; If bit 7 is set it will be ignored during the conversion, ; and reset after the conversion. ; Some BCD numbers can have bit 7 set, example, 83. If FL.12H is ; set in FLAGWD, this check for bit 7 will be skipped. ; Input: R0 -> number to be converted ; Output: R0 -> converted number ; Registers changed: R2,R5 ;- BCDBIN:: MOV R0,-(SP) ;Save address to put number MOV @R0,R0 ;R0 = number to convert CLR R5 BIT #FL.12H,FLAGWD ;Do we want 12hour check? BEQ 10$ ;Branch if not BIT #200,R0 ;Is bit 7 set? BEQ 10$ ;Branch if not BIC #200,R0 ;Clear bit 7 INC R5 ;Indicate set 10$: MOV R0,R2 ASR R2 ASR R2 ASR R2 BIC #1,R2 MOV R2,-(SP) ASL R2 ADD (SP)+,R2 SUB R2,R0 TST R5 ;Was it set? BEQ 20$ ;Branch if not BIS #200,R0 ;Set the 12hour bit 20$: MOV R0,R2 ;Save result MOV (SP)+,R0 ;Restore address to put number MOV R2,(R0) ;Save the number RETURN .SBTTL BINBCD - Convert from BIN to BCD ;+ ; BINBCD - Convert from BIN to BCD ; ; Input: R0 -> number to be converted ; If bit 7 is set it will be ignored during the conversion, ; and reset after the conversion. ; Output: R0 -> converted number ; Registers changed: R1 ;- BINBCD:: MOV R0,-(SP) ;Save address for result MOV @R0,R0 ;R0 = number to convert CLR R5 ;bit 7 not set BIT #200,R0 ;Was it set? BEQ 10$ ;Branch if not INC R5 ;Indicate bit 7 set 10$: MOV R0,R1 ;R1 = number to convert CLR R0 ;Clear for divide DIV #10.,R0 ;R1/10. R0= quotient, R1=rem MOV R1,-(SP) ;Save remainder MUL #16.,R0 ;R1 = 16*R0 ADD (SP)+,R1 ;R1 = BCD MOV R1,R0 ;Set up result TST R5 ;Was bit 7 set? BEQ 20$ ;Branch if not BIS #200,R0 ;Set the bit 20$: MOV R0,R1 ;R1 = converted number MOV (SP)+,R0 ;Restore address to put number MOV R1,(R0) ;Save the number RETURN .SBTTL DAY - Calculate the day of the week ;+ ; DAY - Calculate the day of the week given the date ; ; Input: TOYDAT, TOYMON, TOYYEA are set ; Output: TOYDAY is set ; ;- DAY:: CMP #100.,TOYYEA ;It is "beyond year 1999"? BGT 69$ ;yes SUB #100.,TOYYEA ;else "wrap around" for 2 digit years CMP #72.,TOYYEA ;Is it "beyond year 2072"? BGT 69$ ;If so, display truncation warning .ERR #ERRARE,#TRU,RETURN=YES,LEVEL=W 69$: MOV #IWEEKD,R0 ;SYSLIB day of the week routine MOV #PWEEKD,R5 ;Parameter list for same CALL CALL$F ;call it MOV R0,TOYDAY ;save results RETURN .SBTTL DIV50 - Double precision division for TIME ;+ ; DIV50,DIV60 - Division for TIME handling ; ; Input: ; R4,R5 = integer to divide by 50. or 60. ; Output: ; R0 = remainder ; Registers modified: R4,R5,R3 ;- .ENABL LSB DIV50:: MOV #50.,R3 ;Divide by 60 BR 10$ DIV60:: MOV #60.,R3 ;Divide by 60 10$: CLR R0 ;Init remainder MOV #32.,-(SP) ;Shift count (16. for s.p.) 20$: ASL R5 ;Shift and subtract ROL R4 ;(not needed for s.p.) ROL R0 CMP R0,R3 ;Sub out divisor ? BLO 30$ ;No SUB R3,R0 INC R5 ;Add in low bit 30$: DEC @SP ;Repeat count BNE 20$ TST (SP)+ ;Pop shift count RETURN .DSABL LSB .SBTTL DMULT - Double word multiply ;+ ; DMULT ; Multiplies two unsigned integers yielding an unsigned ; double-precision integer. ; ; CALL ; R0 = multiplier ; R1,R2 = multiplicand (lo,hi order) ; ; RETURNS ; R0 = 0 ; R1,R2 = product (low,hi order) ; ;- DMULT:: CLR -(SP) ;Clear product CLR -(SP) 10$: BIT #1,R0 ;Low-order bit on? BEQ 20$ ;Nope, don't do the add ADD R1,2(SP) ;Add low order ADC (SP) ;Add carry ADD R2,(SP) ;And high-order 20$: ROL R1 ;Shift multiplicand left ROL R2 ASR R0 ;While shifting multiplier right BNE 10$ MOV (SP)+,R2 ;Return high order in R2 MOV (SP)+,R1 ; and low order in R1 RTS PC .SBTTL GETDAT - Get the monitor date ;+ ; GETDAT - Get the monitor date ; ; Input: none ; Output: TIMDAT: day of month ; TIMMON: month number ; TIMYEA: year (last 2 digits of actual year) ; ;- GETDAT:: CALL $SAVAL ;Save all registers .DATE ;Get the date in R0 MOV R0,R5 ;AAMMMMDDDDDYYYYY;R5 = date BEQ 30$ ;Branch if no date ASL R5 ;AMMMMDDDDDYYYYY0;Isolate day in R5 ASL R5 ;MMMMDDDDDYYYYY00 ASL R5 ;MMMDDDDDYYYYY000 SWAB R5 ;YYYYY000MMMDDDDD BIC #^C<37>,R5 ;00000000000DDDDD;R5 = day MOV R5,TOYDAT ;Save the day of month MOV R0,R2 ;AAMMMMDDDDDYYYYY;R2 = Date ASR R2 ;?AAMMMMDDDDDYYYY;Isolate the month in R2 SWAB R2 ;DDDDYYYY?AAMMMMD MOV R2,R3 ;R3 = month BIC #^C<140>,R2 ;000000000AA00000;save Age bits ASR R3 ;000000000000MMMM;Make it real month BIC #^C<37>,R3 ;000000000000MMMM;R2 = month MOV R3,TOYMON ;Save the month BIC #^C<37>,R0 ;00000000000YYYYY;R0 = year BIS R2,R0 ;000000000AAYYYYY;R0 = age + year ADD #72.,R0 ;Make it real year MOV R0,TOYYEA ;Save the year 30$: RETURN .SBTTL GETTIM - Get the monitor time ;+ ; GETTIM - Get and save the monitor time ; ; Input: none ; Output: TIMSEC: seconds ; TIMMIN: minutes ; TIMHOU: hours (24 hour clock) ;- GETTIM:: CALL $SAVAL ;Save all registers .GTIM #IOAREA,#TIMBLK ;Get the time in TIMBLK and TIMBLK+2 MOV TIMBLK,R4 ;R4, R5 = time MOV TIMBLK+2,R5 ; in ticks past midnight MOV @#$SYPTR,R0 ;R0 -> RMON TST $CNFG1(R0) ;KW11L Clock present? BPL 70$ ;No - no time present BIT #CLK50$,$CNFG1(R0) ;50 or 60 cycle? BNE 50$ ;Branch if 50 CALL DIV60 ;60 cycles. Discard ticks BR 60$ ;Continue 50$: CALL DIV50 ;50 cycles. Discard ticks 60$: CALL DIV60 ;Discard seconds MOV R0,TOYSEC ;Save seconds CALL DIV60 ;R0 = minutes MOV R0,TOYMIN ;Save minutes CALL DIV60 ;R0 = hours MOV R0,TOYHOU ;Save hours 70$: RETURN .SBTTL PTTOYD - Put TOY Date (PRO version) ;+ ; PUTTOYD - Set the PC Time Of Year Date ; ; Input: TOYDAY,TOYDAT,TOYMON,TOYYEA are set ; Output: Registers changed: ; ;- PTTOYD:: CALL DAY BIT #CK1DM,@#CKCSR1 ;Are we in BCD mode? BNE 10$ ;Branch if not MOV #TOYDAT,R0 ;R0 -> Toy area 5$: CALL BINBCD ;Convert to BCD TST (R0)+ ;Point to next one CMP #TOYYEA,R0 ;finished? BHIS 5$ ;Branch if not 10$: BIS #CK1SET,@#CKCSR1 ;Inhibit clock interrupts MOV TOYDAY,@#CKDAY ;Set the day of week MOV TOYDAT,@#CKDAT ;Set the day of month MOV TOYMON,@#CKMON ;Set the month MOV TOYYEA,@#CKYEA ;Set the year BIC #CK1SET,@#CKCSR1 ;Allow clock to interrupt RETURN .SBTTL PT9XD - Put TOY Date (11/9x version) ;+ ; PUT9XD - Set the PC Time Of Year Date ; ; Input: TOYDAT,TOYMON,TOYYEA are set ; Output: Registers changed: ; ;- PT9XD:: CALL DAY ;Get day of week DEC TOYDAY ;back one for European view of week ; (Mon--Sun) BNE 10$ ;ok MOV #7,TOYDAY ;else fix up for Sunday 10$: CALL SETTOY ;Set up TOY chip to get date ;010 CALL GET9X4 ;skip 4 time bytes MOV #TOYDAY,R0 ;get day of week in binary CALL BIN9X ;convert and send to TOY MOV #TOYDAT,R0 ;get day of month in binary CALL BIN9X ;convert and send to TOY MOV #TOYMON,R0 ;get month number in binary CALL BIN9X ;convert and send to TOY MOV #TOYYEA,R0 ;get year number in binary BIN9X: ;convert from binary, send to TOY ;R0 -> binary, @R0 converted to BCD CALL BINBCD ;convert to BCD MOV @R0,R0 ;load day of month CALLR PUT9X ;write into TOY .SBTTL PTTOYT - Put TOY Time (PRO version) ;+ ; PTTOYT - Set the PC Time Of Year Date ; ; Input: TOYSEC, TOYMIN, TOYHOU are set ; Output: Registers changed: ; ;- PTTOYT:: BIT #CK1DM,@#CKCSR1 ;Are we in BCD mode? BNE 10$ ;Branch if not MOV #TOYSEC,R0 ;R0 -> Toy area 5$: CALL BINBCD ;Convert to BCD TST (R0)+ ;Point to next one CMP #TOYHOU,R0 ;finished? BHIS 5$ ;Branch if not 10$: BIT #CK124,@#CKCSR1 ;Are we in 12 hour mode? BNE 20$ ;Branch if not MOV #TOYHOU,R0 ;R0 -> 24hour mode hours CALL C24H12 ;Convert it to 12hour mode 20$: BIS #CK1SET,@#CKCSR1 ;Inhibit clock interrupts MOV TOYSEC,@#CKSEC ;Set the seconds MOV TOYMIN,@#CKMIN ;Set the minutes MOV TOYHOU,@#CKHOU ;Set the hours BIC #CK1SET,@#CKCSR1 ;Allow clock to interrupt RETURN .SBTTL PT9XT - Put TOY Time (11/9x version) ;+ ; PT9XT - Set the PC Time Of Year Date ; ; Input: TOYSEC, TOYMIN, TOYHOU are set ; Output: Registers changed: ; ;- PT9XT:: CALL SETTOY ;Prepare the TOY clock for access CLR R0 ;Pass 0 as fractional seconds CALL PUT9X ;Send a byte to TOY MOV #TOYSEC,R0 ;Get seconds in binary CALL BIN9X ;send seconds MOV #TOYMIN,R0 ;Get minutes in binary CALL BIN9X ;send minutes MOV #TOYHOU,R0 ;Get hours in binary CALL BIN9X ;send hours GET9X4: ; skip date part and finish CALL @PC ; Get and ignore four bytes CALL @PC ; ... CALLR GET9X ; ... .SBTTL Subroutine to set up the Time-Of-Year clock for read or write ; The DS1215 is accessed serially through the TOYCom bit (the low bit of the ; high byte) in the "Additional Status Register" (AddSR). Before data can be ; read from or written to the chip, it must be sent a 64-bit enable pattern; ; this subroutine sends the enable pattern to the chip. ; ; Reading from the chip is not a problem since the other bits in the AddSR ; can be ignored, but writes should not disturb any of the other bits since ; some of them control the KDJ11-E board configuration. This problem is re- ; solved by first reading and saving the register bits and then reloading all ; of the other bits each time a bit is sent to the chip. ; ; Since sending the enable pattern to the chip must be preceeded with a read ; from the chip, the read is also used to get the other bits that must be re- ; loaded into the AddSR with each write. Then the 4 16-bit pattern words are ; send to the chip with 64 writes. ; ; On subroutine exit: the chip is ready to have its 8 bytes of time and date ; information either read or written, R0 contains the address of the high byte ; of AddSR and R2 contains the shifted contents of the high byte of AddSR (for ; writing data to the chip). R2, R3, R4 and R5 have all been modified. SETTOY:: MOV #ADDSR+1,R0 ;Get address of Add'l Status Reg, MOV #TOYPAT,R1 ; point to the match pattern. MOVB @R0,R2 ;Get (READ) contents of high byte, ASR R2 ; shift it right to vacate bit 0 MOV R2,OLDASR ;save for the PUT9X routine 10$: MOV (R1)+,R3 ;Get next match pattern word BEQ 30$ ; Zero = end of table MOV #16.,R4 ;Load count of bits 20$: MOV R2,R5 ;Copy shifted old value to work reg, ASR R3 ; shift low match bit into Carry, ROL R5 ; shift it back into data byte and MOVB R5,(R0) ; WRITE match bit to Status Reg. SOB R4,20$ ;Loop until all bits done in this word BR 10$ ;Word done, go try next one 30$: RETURN GET9X: MOV #8.,R0 ;Load count of bits per byte 50$: MOVB @#ADDSR+1,R1 ;Read from high byte SOB R0,50$ ;Loop RETURN PUT9X: MOV #8.,R4 ;Load count of bits per word 50$: MOV OLDASR,R5 ;Get old ASR value (shifted by 1) ASR R0 ; shift low bit into Carry ROL R5 ; and shift Carry into write value MOVB R5,@#ADDSR+1 ; and write to TOY SOB R4,50$ ;Loop to fill 16-bit word with data RETURN .SBTTL PUTDAT - Set the monitor date ;+ ; PUTDAT - Set the monitor date ; ; Input: TIMDAT,TIMMON,TIMYEA are set ; Output: The monitor date is set ; Registers changed: R1,R2,R0 ;- PUTDAT:: MOV TOYMON,R2 ;R2 = month SWAB R2 ;Move month to high byte ASL R2 ;Move it to bit 10 ASL R2 MOV TOYDAT,R0 ;R0 = day of month SWAB R0 ;Move it to high byte ASR R0 ASR R0 ASR R0 ;Move it to bit 5 BIS R0,R2 ;R2 = month and day MOV TOYYEA,R0 ;R0 = year SUB #72.,R0 ;R0 = year - 72 MOV R0,-(SP) ;Save Age bits BIC #^c37,R0 ;Clear all but year bits BIS R0,R2 ;R2 = Day, Mon, Year ASL @SP ;00000000AAYYYYY0 SWAB @SP ;AAYYYYY000000000 BIC #^c140000,@SP ;Clear all but Age bits BIS (SP)+,R2 ;R2 = Day, Mon, Year, Age MOV R2,DATBLK ;Move the date word in MOV #-1,DATBLK+2 ;Don't change time .SDTTM #IOAREA,#DATBLK ;Set the monitor date RETURN .SBTTL PUTTIM - Set the monitor time ;+ ; PUTTIM - Set the monitor time ; ; Input: TOYSEC, TOYMIN, TOYHOU are set ; Output: The monitor time is set ; Registers changed: R1,R2,R0,R3 ;- PUTTIM:: CALL $SAVAL ;Save all regs 30$: MOV #60.,R0 ;TIME=HOUR*60 MOV TOYHOU,R1 CLR R2 CALL DMULT MOV #60.,R0 ; TIME=*60 ADD TOYMIN,R1 ADC R2 CALL DMULT MOV #60.,R0 ; TIME=*60 ADD TOYSEC,R1 ADC R2 CALL DMULT MOV R2,DATBLK+2 ;SET HIGH- MOV R1,DATBLK+4 ; AND LOW-ORDER TIME MOV #-1,DATBLK ;Don't set DATE .SDTTM #IOAREA,#DATBLK ;Set the monitor date RETURN .SBTTL BCD - Handle BCD and NOBCD ;+ ; BCD - Convert contents of TOY clock to BCD ; ; Input: none ; Output: none ; ; Registers changed: R0,R0,R2 ; ;- BCD:: TSTB PRFX ;NOBCD? BNE 50$ ;Branch if so BIT #CK1DM,@#CKCSR1 ;Is BCD mode on already? BEQ 90$ ;Branch if so BIS #,@#CKCSR1 ;Stop the clock BIC #CK1DM,@#CKCSR1 ;Indicate BCD on MOV #CKSEC,R0 ;R0 -> start of TOY data 10$: CALL BINBCD ;Convert it TST (R0)+ ;Point to next one CMP #CKYEA,R0 ;Finished? BHIS 10$ ;Branch if not BIC #,@#CKCSR1 ;Restart the clock BR 90$ ;All done 50$: BIT #CK1DM,@#CKCSR1 ;Is BCD mode already off? BNE 90$ ;Branch if so BIS #,@#CKCSR1 ;Stop the clock BIS #CK1DM,@#CKCSR1 ;Indicate BCD off MOV #CKSEC,R0 ;R0 -> start of TOY data 20$: CMP #CKYEA,R0 ;Is this YEAR? BNE 21$ ;Branch if not BIC #FL.12H,FLAGWD ;12 HOUR mode not possible 21$: CALL BCDBIN ;Convert it BIS #FL.12H,FLAGWD ;Do 12 hour mode check TST (R0)+ ;Point to next one CMP #CKYEA,R0 ;Finished? BHIS 20$ ;Branch if not BIC #,@#CKCSR1 ;Restart the clock 90$: RETURN .SBTTL DATE - Handle the DATE command ;+ ; DATE - Set the time of year clock ; ; Input: ; R4 -> Second character following "DATE" in command buffer ; ; Output: ; R4 updated beyond values and comma. ; ;- DATFLG =100000 ;flag bits to test for setting ;010 YEAFLG =40000 ; a field twice ;010 MONFLG =20000 ; ;010 DATE:: CLR TOYDAY ;Use this for flag bits ;010 CALL GETDAT ;Get the monitor date 10$: BIT #FL.PRM,FLAGWD ;Any parameters? BEQ 60$ ;Branch if not CALL GETBIN ;Get a binary parameter in R0 BCS 50$ ;Branch if it's a month TST R0 ;Is it positive? BPL 30$ ;Branch if so ;+ ;ERROR 20$: .ERR #ERRARE,#IVV,RETURN=NO,LEVEL=F,ASCII=#PBUF ; <-F-Invalid value> ;- 30$: CMP #32.,R0 ;Is it a day? ;010 BLOS 40$ ;Branch if not BIT #DATFLG,TOYDAY ;Did we already set the day? ;010 BNE 20$ ;If so, operator error ;010 MOV R0,TOYDAT ;Save the day of month BIS #DATFLG,TOYDAY ;MArk that we set the day ;010 BR 10$ ;Get next parameter 40$: CMP #2099.+1,R0 ;is it a year? BLOS 20$ ;no, much too big CMP #1972.,R0 ;is it a 4 digit year? BHI 41$ ;no SUB #1900.,R0 ;"normalize" BR 42$ 41$: CMP #99.+1,R0 ;Is it a year? ;010 BLOS 20$ ;Branch if not CMP #72.-1,R0 ;Is it a year? ;010 BHIS 20$ ;Branch if not 42$: BIT #YEAFLG,TOYDAY ;Did we already set the year? ;010 BNE 20$ ;If so, operator error ;010 MOV R0,TOYYEA ;Save the year BIS #YEAFLG,TOYDAY ;Mark that we set it ;010 BR 10$ ;Get next parameter 50$: MOV #MONTHS,R2 ;R2 -> table of months MOV #PBUF,R0 ;R0 -> user supplied month CALL TBSRC ;Search for the month BCS 20$ ;Branch if not found ASR R1 ;Convert to month number INC R1 ;Correct for base 0 BIT #MONFLG,TOYDAY ;Did we already set the month? ;010 BNE 20$ ;If so, operator error ;010 MOV R1,TOYMON ;Save the month BIS #MONFLG,TOYDAY ;Mark that we've set the month ;010 BR 10$ ;Get next parameter 60$: TST TOYDAT ;Is there a day of month? BEQ 65$ ;Branch if not TST TOYMON ;Is there a month? BEQ 65$ ;Branch if not TST TOYYEA ;Is there a year? BNE 66$ ;Branch if os ;+ ;ERROR 65$: .ERR #ERRARE,#DNS,RETURN=NO,LEVEL=FATAL ; <-F-Monitor date not set> ;- 66$: CALL PUTDAT ;Set the monitor date TST IS9X ;Is this on an 11/9x? BNE 75$ ;Yes BIT #PR.11,TERMWD ;Is this on an 11? BNE 70$ ;Branch if so CALL PTTOYD ;Set TOY date 70$: RETURN 75$: CALLR PT9XD ;Set 11/9x TOY date .SBTTL DST - Handle DST command ;+ ; DST - Enable/Disable Daylight Savings Time ;- DST:: BIS #,@#CKCSR1 ;Inhibit clock interrupts BIC #,@#CKCSR1 ;RESET DST TSTB PRFX ;Was there a NO prefix? BNE 10$ ;Branch if so BIS #,@#CKCSR1 ;SET DST 10$: BIC #,@#CKCSR1 ;Enable clock interrupts RETURN .SBTTL HOUR12 - Handle 12HOUR command ;+ ; HOUR12 - RESET the TOY 24/12 hour mode ; ; Input: none ; Output: none ; Registers changed: R1 ;- HOUR12:: BIT #CK124,@#CKCSR1 ;Is it already reset? BEQ 90$ ;Branch if so BIS #CK1SET,@#CKCSR1 ;Disable clock interrupts MOV #CKHOU,R0 ;R0 -> HOURS CALL C24H12 ;Convert to 12HOUR mode MOV #CKHAL,R0 ;R0 -> Hours alarm CALL C24H12 ;Convert to 12HOUR mode BIC #CK124,@#CKCSR1 ;Indicate 12 hour clock BIC #CK1SET,@#CKCSR1 ;Enable clock interrupts 90$: RETURN .SBTTL HOUR24 - Handle 24HOUR command ;+ ; HOUR24 - Set the TOY 24/12 hour mode ; ; Input: none ; Output: none ; Registers changed: R1 ;- HOUR24:: BIT #CK124,@#CKCSR1 ;Is it already set? BNE 90$ ;Branch if so BIS #CK1SET,@#CKCSR1 ;Inhibit clock interrupts MOV #CKHOU,R0 ;R0 -> hours CALL C12H24 ;Convert to 24hour mode MOV #CKHAL,R0 ;R0 -> hours alarm CALL C12H24 ;Convert to 24hour mode BIS #CK124,@#CKCSR1 ;Indicate 24 hour clock BIC #CK1SET,@#CKCSR1 ;Enable clock interrupts 90$: RETURN .SBTTL TIME - Handle TIME command ;+ ; TIME - Set the monitor and TOY Time ; ; Input: R4 -> Second character following "TIME" in command buffer ; ; Output: R4 updated beyond values and comma ; ;- TIME:: CALL GETTIM ;Get the monitor time BIT #FL.PRM,FLAGWD ;Any parameters? BEQ 90$ ;Branch if not CALL GETBIN ;Get the hours BCC 20$ ;Branch if no error ;+ ;ERROR 5$: .ERR #ERRARE,#IVV,RETURN=NO,LEVEL=FATAL,ASCII=#PBUF ; <-F-Invalid value > ;- 20$: CMP #24.,R0 ;Too high? BLOS 5$ ;Branch if so MOV R0,TOYHOU ;Save the hours BMI 5$ ;Branch if negative BIT #FL.PRM,FLAGWD ;Any more parameters? BEQ 80$ ;Branch if not CALL GETBIN ;Get the minutes BCS 5$ ;Branch on error CMP #59.,R0 ;Too high? BLO 5$ ;Branch if so MOV R0,TOYMIN ;Save the minutes BMI 5$ ;Branch if negative BIT #FL.PRM,FLAGWD ;Any more parameters? BEQ 80$ ;Branch if not CALL GETBIN ;Get the seconds BCS 5$ ;Branch on error CMP #59.,R0 ;Too high? BLO 5$ ;Branch if so MOV R0,TOYSEC ;Save the seconds BMI 5$ ;Branch if negative 80$: CALL PUTTIM ;Set the monitor time 90$: TST IS9X ;is this on an 11/9x? BNE 98$ ;Yes BIT #PR.11,TERMWD ;Is this on an 11? BNE 99$ ;Branch if so CALL PTTOYT ;Set the TOY time 99$: RETURN 98$: CALLR PT9XT ;Set the 11/9x TOY time .SBTTL SHWCLK - Handle CLOCK SHOW ;+ ; SHWCLK - Handle the CLOCK SHOW command ; ; Input: none ; Output: none ;- SHWCLK:: .PRINT #MSGDM ;Data Mode: BIT #CK1DM,@#CKCSR1 ;Is it on? BNE 31$ ;Branch if binary .PRINT #MSGBC ;Print BCD BR 32$ 31$: .PRINT #MSGBI ;Print Binary 32$: .PRINT #MSGHM ;Hour mode: BIT #CK124,@#CKCSR1 ;Is it on? BNE 33$ ;Branch if 24 hour .PRINT #MSG12 ;Print 12hour BR 34$ 33$: .PRINT #MSG24 ;Print 24hour 34$: .PRINT #MSGDS ;Daylight Savings: BIT #CK1DST,@#CKCSR1 ;Is it on? BNE 35$ ;Branch if on .PRINT #MSGND ;No DST BR 36$ 35$: .PRINT #MSGYD ;yes DST 36$: RETURN .END