CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Table of contents 1- 43 Macros 1- 53 Program_sections 2- 62 Local_data 3- 115 $$BUF - output buffer area 3- 120 $PDATA - pure data area 4- 152 $IDATA - impure data area 5- 167 STATE - TPARS state table 6- 213 CLOCK - Main line code 7- 264 Subroutines 7- 265 * TIMSET - set the system time from Grant-307 clock 8- 308 * CLKSET - set Grant-307 clock from system time 9- 368 * TODAY - routine to caculate day of week index 10- 417 * GETCMD - get and parse command line 10- 439 * REJECT - TPARS action routine 11- 447 TRAP - TRAP action routines 11- 448 * NOCLCK - SST nonexistent memory 11- 462 * POWERF - AST power fail 12- 482 * CHECK - AST compare system / Grant-307 clock time 13- 573 * DAYLIT - subroutine to check daylight savings time CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 1 1 .TITLE CLOCK 2 .IDENT /001.00/ 3 .rem ' 4 ! CLOCK is a task to set the system time from a Computer Products, 5 ! Grant Technology Devision model 307 time of day clock (TDC), or 6 ! to reset the TDC from the system time. 7 ! 8 ! Author: 9 ! William L. Kyle 10 ! E.I. duPont de Nemoures & Co. 11 ! Engineering Department 12 ! P.O. Box 6090 13 ! Newark, DE 19714-6090 14 ! 15 !========================================================================! 16 ! Copyright (C) 1987 ! 17 ! E.I. duPont de Nemoures & Co. ! 18 ! All rights reserved. ! 19 ! This software is furnished through the DECUS Library and may ! 20 ! NOT be sold. It may be copied only with the inclusion of ! 21 ! this copyright notice. ! 22 ! ! 23 ! DuPont assumes no responsibility for the use or reliability ! 24 ! of this software. ! 25 !========================================================================! 26 ! 27 ! Link command file 28 ! 29 ! CLOCK/PR/FP,CLOCK/MA/-SP=CLOCK,ERRMSG 30 ! / 31 ! UNITS=1 32 ! PRI=150 33 ! TASK=...CLK 34 ! // 35 ! 36 ' 37 .ENABL LC 38 .NLIST BEX 39 .NLIST CND 40 41 .LIBRARY /SYS$LIBRARY:PDPSML/ 42 43 .SBTTL Macros 44 45 .MCALL $$SML 46 .MCALL DIR$, GMCR$, ALUN$, GTIM$, STIM$ 47 .MCALL SPRA$S, SVTK$S, ASTX$S, SPND$S, MRKT$S 48 .MCALL EXST$S, QIOW$S 49 .MCALL ISTAT$, STATE$, TRAN$ 50 51 000000 $$SML ; structured macros 52 53 .SBTTL Program_sections 54 55 000000 .PSECT $CODE, I, RO, CON, REL, LCL 56 000000 .PSECT $PDATA, D, RO, CON, REL, LCL 57 000000 .PSECT $IDATA, D, RW, CON, REL, LCL CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 1-1 Program_sections 58 000000 .PSECT $$BUF, D, RW, OVR, REL, GBL 59 60 000000 .PSECT $CODE CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 2 Local_data 62 .SBTTL Local_data 63 ; 64 ; Define floating accumulators 65 ; 66 000000 F0 = %0 67 000001 F1 = %1 68 000002 F2 = %2 69 000003 F3 = %3 70 000004 F4 = %4 71 000005 F5 = %5 72 73 000001 TILUN = 1 ; logical unit number for TI: 74 000001 WRITFL = 1 ; event flag for I/O writes 75 000002 MARKFL = 2 ; event flag for mark time 76 000005 MARKTM = 5. ; number of minutes to wait on mark time 77 000001 FL.SYS = 1 ; flag to set system time from clock 78 000002 FL.CLK = 2 ; flag to set clock from system time 79 000004 FL.MON = 4 ; flag to monitor system time and clock 80 000010 FL.HLP = 10 ; flag to type help message 81 000020 FL.DST = 20 ; flag for auto daylight savings time 82 ; 83 ; Grant-307 register assignments 84 ; 85 170400 CLKBAS = 170400 ; Factory configuration of clock calender 86 ; address. CLKBAS should be changed if base 87 ; of Grant-307 is altered from the original 88 ; factory configuration. 89 000000 SECOND = 0 ; Seconds 90 000002 MINUTE = 2 ; Minutes 91 000004 HOUR = 4 ; Hours 92 000006 DOW = 6 ; Day of the week 93 000007 DAY = 7 ; Day of the month 94 000010 MONTH = 10 ; Month 95 000011 YEAR = 11 ; Year 96 000012 REGA = 12 ; Status register A 97 000013 REGB = 13 ; Status register B 98 000014 REGC = 14 ; Status register C 99 000015 REGD = 15 ; Status register D 100 ; 101 ; Register bits 102 ; 103 000200 UIP.A = 200 ; Update in progress 104 000020 DV0.A = 20 ; Clock divider (sets the clock frequency) 105 000040 DV1.A = 40 ; Clock divider (sets the clock frequency) 106 000100 DV2.A = 100 ; Clock divider (sets the clock frequency) 107 000200 SET.B = 200 ; Set the clock 108 000004 DM.B = 4 ; Set data in binary format 109 000002 MODE.B = 2 ; Set clock to 24 hour mode 110 000001 DSE.B = 1 ; Set the clock to do daylight savings time 111 000200 VRT.D = 200 ; Valid RAM and time bit tests for low 112 ; battery or power failure. CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 3 Local_data 114 .SAVE 115 .SBTTL $$BUF - output buffer area 116 000000 .PSECT $$BUF 117 118 000000 BUFFER: .BLKB 256. ; extend the buffer for output 119 .EVEN 120 .SBTTL $PDATA - pure data area 121 000000 .PSECT $PDATA 122 .NLIST BEX 123 000000 015 045 062 ERR1: .ASCII <15>&%2R -- Grant-307 clock not in system.& 124 000046 045 116 045 .ASCIZ &%N%10SBase address = %P& 125 000076 015 045 062 ERR2: .ASCIZ <15>&%2R -- Syntax error. "See HELP for correct systax."& 126 000163 015 045 062 ERR3: .ASCII <15>/%2R -- Unable to set the system time./ 127 000231 045 116 045 .ASCIZ /%N%10SDSW error %D./ 128 000255 015 045 062 ERR4: .ASCIZ <15>&%2R -- Grant-307 clock power fail. Reset the clock time.& 129 000347 015 045 062 ERR5: .ASCII <15>/%2R -- Unable to get the system time./ 130 000415 045 116 045 .ASCIZ /%N%10SDSW error %D./ 131 000441 015 045 062 ERR6: .ASCII <15>&%2R -- Grant-307 clock time and SYSTEM& 132 000510 045 116 045 .ASCIZ /%N%10Stime differ by more than one minute./ 133 000563 012 012 015 HLPMSG: .ASCII <12><12><15>/ CLOCK is a program used for the Grant-307 time of day clock./ 134 000663 012 012 015 .ASCII <12><12><15>/ CLOCK has three functions:/ 135 000721 012 015 040 .ASCII <12><15>/ * Set the system time from the Grant-307 clock./ 136 001007 012 015 040 .ASCII <12><15>/ * Set the Grant-307 clock from the system time./ 137 001075 012 015 040 .ASCII <12><15>/ * Monitor the system time verses the Grant-307 clock time./ 138 001176 012 012 015 .ASCII <12><12><15><11><11>/COMMAND SYNTAX/ 139 001221 012 015 040 .ASCII <12><15>& $ CLOCK SET SYSTEM_TIME ! sets system time.& 140 001301 012 015 040 .ASCII <12><15>& $ CLOCK SET CLOCK ! sets clock.& 141 001345 012 015 040 .ASCII <12><15>& $ CLOCK SET CLOCK/AUTO_DAYLIGHT_SAVINGS_TIME& 142 001425 012 015 040 .ASCII <12><15>& ! sets clock and enables auto daylight savings time.& 143 001517 012 015 040 .ASCII <12><15>& $ CLOCK MONITOR ! monitor the system time& 144 001575 012 015 040 .ASCII <12><15>& ! verses the Grant-307 clock time.& 145 001645 012 015 040 .ASCII <12><15>& $ CLOCK MONITOR/AUTO_DAYLIGHT_SAVINGS_TIME& 146 001723 012 015 040 .ASCII <12><15>& ! monitor the time and enables auto daylight savings time.&<12> 147 002024 012 015 040 .ASCII <12><15>& $ CLOCK HELP ! type this help text.&<12> 148 001312 HLPSZ = .-HLPMSG 149 .EVEN 150 .LIST BEX CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 4 $IDATA - impure data area 152 .SBTTL $IDATA - impure data area 153 000000 .PSECT $IDATA 154 155 000000 001334' SSTTBL: .WORD NOCLCK ; address for trap to 4 156 000002 WRITST: .BLKW 2 ; write I/O status 157 000006 ARGLST: .BLKW 7. ; output status area for errmsg 158 000024 FLAGS: .BLKW 1 ; flag area for command parsing 159 000026 LSTCLK: .BLKW 2 ; storage for last clock time 160 000032 ALUNTI: ALUN$ TILUN,TI,0 ; assign lun DPB for TI 161 000042 GMCR: GMCR$ ; get command line DPB 162 000164 GETTIM: GTIM$ TIMBUF ; get time DPB 163 000170 SETTIM: STIM$ TIMBUF ; set time DPB 164 000176 TIMBUF: .BLKW 8. ; Buffer for get and set time 165 000216 WEEKDY: .BLKW 1 ; Day of week CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 5 STATE - TPARS state table 167 .SBTTL STATE - TPARS state table 168 169 ; To be used with blank suppress option 170 000001 $RONLY = 1 ; make psects read only 171 172 000220 ISTAT$ CLOSTB,CLOKTB 173 174 000000 STATE$ CLOKEY 175 000000 TRAN$ $RAD50 176 177 000000 STATE$ 178 000000 TRAN$ '/,ACTION 179 000000 TRAN$ $LAMDA 180 181 000000 STATE$ ACTION 182 000000 TRAN$ $EOS,$EXIT,REJECT 183 000000 TRAN$ "SET",DEM 184 000000 TRAN$ "MONITOR",DST,,FL.MON,FLAGS 185 000000 TRAN$ "HELP",DONE,,FL.HLP,FLAGS 186 187 000000 STATE$ DEM 188 000000 TRAN$ '/,WHICH 189 000000 TRAN$ ':,WHICH 190 000000 TRAN$ '=,WHICH 191 000000 TRAN$ $LAMDA 192 193 000000 STATE$ WHICH 194 000000 TRAN$ "SYSTEM_TIME",DONE,,FL.SYS,FLAGS 195 000000 TRAN$ "CLOCK",DST,,FL.CLK,FLAGS 196 197 000000 STATE$ DST 198 000000 TRAN$ $EOS,$EXIT 199 000000 TRAN$ '/ 200 201 000000 STATE$ 202 000000 TRAN$ $EOS,$EXIT,REJECT 203 000000 TRAN$ "AUTO_DAYLIGHT_SAVINGS_TIME",DONE,,FL.DST,FLAGS 204 205 000000 STATE$ DONE 206 000000 TRAN$ $EOS,$EXIT 207 000000 TRAN$ $LAMDA,$EXIT,REJECT 208 209 000000 STATE$ 210 211 000000 .RESTORE CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 6 CLOCK - Main line code 213 .SBTTL CLOCK - Main line code 214 215 000000 CLOCK:: 216 000000 DIR$ #ALUNTI ;assign lun for TI: 217 000006 SVTK$S #SSTTBL,#1 ;specify address for nxm 218 000024 012705 170400 MOV #CLKBAS,R5 ;get base address of clock 219 000030 005000 CLR R0 ;set up flag word 220 000032 105715 TSTB (R5) ;check to see if clock present 221 000034 105765 000015 TSTB REGD(R5) ;check to see if clock present 222 000040 IF R0,EQ ;IF clock present 223 000044 010067 000000' MOV R0,SSTTBL ;clear out trap address 224 000050 SVTK$S #SSTTBL,#1 ;clear out SST table 225 000066 004767 001170 CALL GETCMD ;get the command 226 000072 IF ,CC ;IF got one, OK 227 000074 IF #FL.SYS,SET,FLAGS ;IF set system time 228 000104 004767 000266 CALL TIMSET ;set the time 229 000110 ENDI ;ENDI 230 000110 IF #FL.CLK,SET,FLAGS ;IF set the clock 231 000120 004767 000464 CALL CLKSET ;set the clock 232 000124 ENDI ;ENDI 233 000124 IF #FL.MON,SET,FLAGS ;IF monitor system time vs clock 234 000134 SPRA$S #POWERF ;specify power fail AST address 235 000146 MRKT$S #MARKFL,#1,#2,#CHECK 236 ;start to check the time 237 000174 SPND$S ;suspend forever, exit if resumed 238 000202 012700 000001 MOV #EX$SUC,R0 ;success 239 000206 ENDI ;ENDI 240 000206 IF #FL.HLP,SET,FLAGS ;IF help 241 000216 QIOW$S #IO.WLB,#TILUN,#WRITFL,,#WRITST,,<#HLPMSG,#HLPSZ,#40> 242 ;type out help text 243 000272 012700 000001 MOV #EX$SUC,R0 ;success 244 000276 ENDI ;ENDI 245 000276 ELSE ;ELSE no command, just exit 246 000300 012701 000076' MOV #ERR2,R1 ;get error address 247 000304 012702 000006' MOV #ARGLST,R2 ;get address of argument list 248 000310 005012 CLR (R2) ;assume no arguments 249 000312 012703 000001 MOV #TILUN,R3 ;lun to output error message 250 000316 004767 000000G CALL ERRMSG ;output error 251 000322 012700 000000 MOV #EX$WAR,R0 ;warning 252 000326 ENDI ;ENDI 253 000326 ELSE ;ELSE no clock present 254 000330 012701 000000' MOV #ERR1,R1 ;get error address 255 000334 012702 000006' MOV #ARGLST,R2 ;get address of argument list 256 000340 012712 000001 MOV #1,(R2) ;assume one argument 257 000344 012762 170400 000002 MOV #CLKBAS,2(R2) ;put clock address on argument list 258 000352 012703 000001 MOV #TILUN,R3 ;lun to output error message 259 000356 004767 000000G CALL ERRMSG ;output error 260 000362 012700 000002 MOV #EX$ERR,R0 ;error 261 000366 ENDI ;ENDI 262 000366 EXST$S R0 ;exit CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 7 Subroutines 264 .SBTTL Subroutines 265 .SBTTL * TIMSET - set the system time from Grant-307 clock 266 ; 267 ; TIMSET - set the system time from Grant-307 clock 268 ; 269 ; INPUT: 270 ; R5 = base address of Grant-307 clock 271 ; OUTPUT: 272 ; R0 = exit status 273 ; 274 000376 TIMSET: 275 000376 IFB #VRT.D,SET,REGD(R5) ;IF the clock is ok 276 000406 012767 177777 000212' MOV #-1,S.TICT+TIMBUF ;use default clock ticks 277 000414 012767 177777 000214' MOV #-1,S.TICP+TIMBUF ;use default ticks per second 278 000422 UNTILB #UIP.A,CLEAR,REGA(R5) ;UNTIL clock is readable 279 000434 ENDU ;ENDU 280 000436 116567 000000 000210' MOVB SECOND(R5),S.TISC+TIMBUF ;read the seconds 281 000444 116567 000002 000206' MOVB MINUTE(R5),S.TIMI+TIMBUF ;read the minutes 282 000452 116567 000004 000204' MOVB HOUR(R5),S.TIHR+TIMBUF ;read the hours 283 000460 116567 000007 000202' MOVB DAY(R5),S.TIDA+TIMBUF ;read the day 284 000466 116567 000010 000200' MOVB MONTH(R5),S.TIMO+TIMBUF ;read the month 285 000474 116567 000011 000176' MOVB YEAR(R5),S.TIYR+TIMBUF ;read the year 286 000502 DIR$ #SETTIM ;set the system time 287 000510 IF ,CC ;IF no error 288 000512 012700 000001 MOV #EX$SUC,R0 ;success 289 000516 ELSE ;ELSE error 290 000520 012701 000163' MOV #ERR3,R1 ;get error address 291 000524 012702 000006' MOV #ARGLST,R2 ;get address of argument list 292 000530 012712 000001 MOV #1,(R2) ;assume one argument 293 000534 016762 000000G 000002 MOV $DSW,2(R2) ;put DSW on argument list 294 000542 012703 000001 MOV #TILUN,R3 ;lun to output error message 295 000546 004767 000000G CALL ERRMSG ;output error 296 000552 012700 000002 MOV #EX$ERR,R0 ;error 297 000556 ENDI ;ENDI 298 000556 ELSE ;ELSE clock had power fail 299 000560 012701 000255' MOV #ERR4,R1 ;get error address 300 000564 012702 000006' MOV #ARGLST,R2 ;get address of argument list 301 000570 005012 CLR (R2) ;assume no arguments 302 000572 012703 000001 MOV #TILUN,R3 ;lun to output error message 303 000576 004767 000000G CALL ERRMSG ;output error 304 000602 012700 000002 MOV #EX$ERR,R0 ;error 305 000606 ENDI ;ENDI 306 000606 000207 RETURN CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 8 * CLKSET - set Grant-307 clock from system time 308 .SBTTL * CLKSET - set Grant-307 clock from system time 309 ; 310 ; CLKSET - set Grant-307 clock from system time 311 ; 312 ; INPUT: 313 ; R5 = base address of Grant-307 clock 314 ; OUTPUT: 315 ; R0 = exit status 316 ; 317 000610 CLKSET: 318 000610 DIR$ #GETTIM ;get the time from system 319 000616 IF ,CC ;IF no error 320 000620 116500 000015 MOVB REGD(R5),R0 ;make sure the valid time bit is reset 321 000624 152765 000200 000013 BISB #SET.B,REGB(R5) ;make sure the clock can be set 322 000632 010446 MOV R4,-(SP) ;save R4 323 000634 010604 MOV SP,R4 ;set flag true for while loop 324 000636 WHILE R4 ;WHILE clock not set 325 000642 116765 000176' 000011 MOVB G.TIYR+TIMBUF,YEAR(R5) ;set the year 326 000650 116765 000200' 000010 MOVB G.TIMO+TIMBUF,MONTH(R5) ;set the month 327 000656 116765 000202' 000007 MOVB G.TIDA+TIMBUF,DAY(R5) ;set the day 328 000664 004767 000222 CALL TODAY ;get day of week 329 000670 DIR$ #GETTIM ;get the time from system 330 000676 IF ,CC ;IF no error 331 000700 IFB G.TIDA+TIMBUF,EQ,DAY(R5) ;IF still same day 332 000710 116765 000210' 000000 MOVB G.TISC+TIMBUF,SECOND(R5) ;set the seconds 333 000716 116765 000206' 000002 MOVB G.TIMI+TIMBUF,MINUTE(R5) ;set the minutes 334 000724 116765 000204' 000004 MOVB G.TIHR+TIMBUF,HOUR(R5) ;set the hours 335 000732 116765 000216' 000006 MOVB WEEKDY,DOW(R5) ;set the day of the week 336 000740 112765 000040 000012 MOVB #DV1.A,REGA(R5) ;set the clock frequency 337 000746 IF #FL.DST,SET,FLAGS ;IF auto daylight savings time 338 000756 112765 000007 000013 MOVB #DM.B!MODE.B!DSE.B,REGB(R5) ;start the clock 339 000764 ELSE ;ELSE 340 000766 112765 000006 000013 MOVB #DM.B!MODE.B,REGB(R5) ;start the clock 341 000774 ENDI ;ENDI 342 000774 012700 000001 MOV #EX$SUC,R0 ;success 343 001000 005004 CLR R4 ;flag clock set 344 001002 ENDI ;ENDI 345 001002 ELSE ;ELSE error 346 001004 012701 000347' MOV #ERR5,R1 ;get error address 347 001010 012702 000006' MOV #ARGLST,R2 ;get address of argument list 348 001014 012712 000001 MOV #1,(R2) ;assume one argument 349 001020 016762 000000G 000002 MOV $DSW,2(R2) ;put DSW on argument list 350 001026 012703 000001 MOV #TILUN,R3 ;lun to output error message 351 001032 004767 000000G CALL ERRMSG ;output error 352 001036 012700 000002 MOV #EX$ERR,R0 ;error 353 001042 005004 CLR R4 ;flag exit while loop 354 001044 ENDI ;ENDI 355 001044 ENDW ;ENDW 356 001046 012604 MOV (SP)+,R4 ;restore R4 357 001050 ELSE ;ELSE error 358 001052 012701 000347' MOV #ERR5,R1 ;get error address 359 001056 012702 000006' MOV #ARGLST,R2 ;get address of argument list 360 001062 012712 000001 MOV #1,(R2) ;assume one argument 361 001066 016762 000000G 000002 MOV $DSW,2(R2) ;put DSW on argument list 362 001074 012703 000001 MOV #TILUN,R3 ;lun to output error message 363 001100 004767 000000G CALL ERRMSG ;output error 364 001104 012700 000002 MOV #EX$ERR,R0 ;error CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 8-1 * CLKSET - set Grant-307 clock from system time 365 001110 ENDI ;ENDI 366 001110 000207 RETURN CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 9 * TODAY - routine to caculate day of week index 368 .SBTTL * TODAY - routine to caculate day of week index 369 ; 370 ; TODAY - routine to caculate day of week index 371 ; 372 ; This routine is a slight modification of the routine from the 373 ; RSX-11M V3.2 indirect command processor manual. All credit 374 ; belongs to the orginal author. I had no desire to try to figure 375 ; out this code any more than required to get it to work. 376 ; 377 ; OUTPUT: 378 ; WEEKDY = day of week index (Sunday = 1) 379 ; 380 001112 TODAY: 381 001112 004767 000000G CALL $SAVAL ;save all registers and return as co-routine 382 001116 012701 000012 MOV #10.,R1 383 001122 066701 000200' ADD G.TIMO+TIMBUF,R1 ;T1 in R1 384 001126 010102 MOV R1,R2 ;T1 in R2 385 001130 005000 CLR R0 ;get set for divide 386 001132 071027 000015 DIV #13.,R0 ;T2 in R0 387 001136 010001 MOV R0,R1 ;T2 in R1 388 001140 070127 000014 MUL #12.,R1 ;T2*12. in R1 389 001144 005401 NEG R1 390 001146 060201 ADD R2,R1 ;T1-(T2*12.) in R1 391 001150 070127 000015 MUL #13.,R1 ;13.*(T1-(T2*12.)) in R1 392 001154 005301 DEC R1 ;(13.*(T1-(T2*12.)))-1 in R1 393 001156 005000 CLR R0 ;get set for divide 394 001160 071027 000005 DIV #5.,R0 ;((13.*(T1-(T2*12.)))-1)/5. in R0 395 001164 012701 000115 MOV #77.,R1 396 001170 060001 ADD R0,R1 ;(((13.*(T1-(T2*12.)))-1)/5.)+77. in R1 397 001172 066701 000202' ADD G.TIDA+TIMBUF,R1 ;T3 in R1 398 001176 016703 000176' MOV G.TIYR+TIMBUF,R3 ;T4 in R3 399 001202 IF G.TIMO+TIMBUF,LT,#3. ;IF JAN. or FEB. 400 001212 005303 DEC R3 ;T4 = T4-1 401 001214 ENDI ;ENDI 402 001214 070327 000005 MUL #5.,R3 ;5.*T4 in R3 403 001220 005002 CLR R2 ;get set for divide 404 001222 071227 000004 DIV #4.,R2 ;T7 in R2 405 001226 060201 ADD R2,R1 ;T3+T7 in R1 406 001230 005201 INC R1 ;T8 in R1 407 001232 010102 MOV R1,R2 ;T8 in R2 408 001234 005000 CLR R0 ;get set up for divide 409 001236 071027 000007 DIV #7.,R0 ;T8/7. in R0 410 001242 010001 MOV R0,R1 ;T8/7. in R1 411 001244 070127 000007 MUL #7.,R1 ;(T8/7.)*7. in R1 412 001250 005202 INC R2 ;T8+1 in R2 413 001252 160102 SUB R1,R2 ;day index (Sunday = 1) 414 001254 010267 000216' MOV R2,WEEKDY ;save day index 415 001260 000207 RETURN CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 10 * GETCMD - get and parse command line 417 .SBTTL * GETCMD - get and parse command line 418 ; 419 ; GETCMD - get and parse command line 420 ; 421 ; OUTPUT: 422 ; CS = syntax error 423 ; CC = good command, flag bits set to indicate command 424 ; 425 ; R5 saved 426 ; 427 001262 GETCMD: 428 001262 010546 MOV R5,-(SP) ;save R5 429 001264 DIR$ #GMCR ;get command line 430 001272 016703 000000G MOV $DSW,R3 ;get length of command line 431 001276 012704 000044' MOV #GMCR+G.MCRB,R4 ;get address of command 432 001302 012705 000000' MOV #CLOKEY,R5 ;address of state to start with 433 001306 012702 000000' MOV #CLOKTB,R2 ;point to key word table 434 001312 012701 001400 MOV #3*400,R1 ;set up options word 435 001316 004767 000000G CALL .TPARS ;parse it here and now 436 001322 012605 MOV (SP)+,R5 ;restore R5 437 001324 000207 RETURN 438 439 .SBTTL * REJECT - TPARS action routine 440 ; 441 ; REJECT - TPARS action routine 442 ; 443 001326 REJECT: ;reject transition 444 001326 062716 000002 ADD #2,(SP) ;point to reject return 445 001332 000207 RETURN CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 11 TRAP - TRAP action routines 447 .SBTTL TRAP - TRAP action routines 448 .SBTTL * NOCLCK - SST nonexistent memory 449 ; 450 ; NOCLCK - SST nonexistent memory 451 ; 452 ; Call by nonexistent memory SST if Grant-307 clock not in I/O page 453 ; 454 ; OUTPUT: 455 ; R0 /= 0 456 ; 457 001334 NOCLCK: 458 001334 066706 000006' ADD 6,SP ;clean up stack 459 001340 010600 MOV SP,R0 ;flag trap to 4 460 001342 000006 RTT ;return from trap 461 462 .SBTTL * POWERF - AST power fail 463 ; 464 ; POWERF - AST power fail 465 ; 466 ; Call by power fail recovery AST to reset system time 467 ; 468 001344 POWERF: 469 001344 010046 MOV R0,-(SP) ;save R0 470 001346 010146 MOV R1,-(SP) ;save R1 471 001350 010246 MOV R2,-(SP) ;save R2 472 001352 010346 MOV R3,-(SP) ;save R3 473 001354 010546 MOV R5,-(SP) ;save R5 474 001356 004767 177014 CALL TIMSET ;set the time 475 001362 012605 MOV (SP)+,R5 ;restore R5 476 001364 012603 MOV (SP)+,R3 ;restore R3 477 001366 012602 MOV (SP)+,R2 ;restore R2 478 001370 012601 MOV (SP)+,R1 ;restore R1 479 001372 012600 MOV (SP)+,R0 ;restore R0 480 001374 ASTX$S ;exit the ast routine CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 12 * CHECK - AST compare system / Grant-307 clock time 482 .SBTTL * CHECK - AST compare system / Grant-307 clock time 483 ; 484 ; CHECK - AST compare system / Grant-307 clock time 485 ; 486 ; Call by AST routine from mark time 487 ; 488 001402 CHECK: 489 001402 005726 TST (SP)+ ;clean stack 490 001404 010046 MOV R0,-(SP) ;save R0 491 001406 010146 MOV R1,-(SP) ;save R1 492 001410 010246 MOV R2,-(SP) ;save R2 493 001412 010346 MOV R3,-(SP) ;save R3 494 001414 010446 MOV R4,-(SP) ;save R4 495 001416 010546 MOV R5,-(SP) ;save R5 496 001420 170002 SETI ;set regular integer mode 497 001422 170001 SETF ;set regular floating mode 498 001424 012705 170400 MOV #CLKBAS,R5 ;get base address of clock 499 001430 005004 CLR R4 ;set error flag false 500 001432 DIR$ #GETTIM ;get system time 501 001440 IF ,CC ;IF no error 502 001442 UNTILB #UIP.A,CLEAR,REGA(R5) ;UNTIL clock is readable 503 001454 ENDU ;ENDU 504 001456 IFB G.TIYR+TIMBUF,EQ,YEAR(R5) ;IF year is the same 505 001466 IFB G.TIMO+TIMBUF,EQ,MONTH(R5) ;IF month is the same 506 ;; 507 ;; Get time from Grant-307 and convert to seconds from start of month 508 ;; 509 001476 116501 000007 MOVB DAY(R5),R1 ;get the day 510 001502 177001 LDCIF R1,F0 ;convert hour to floating 511 001504 171027 041300 MULF #24.,F0 ;convert to hours 512 001510 116501 000004 MOVB HOUR(R5),R1 ;get the hour 513 001514 177101 LDCIF R1,F1 ;convert to floating 514 001516 172001 ADDF F1,F0 ;add into hours 515 001520 171027 041560 MULF #60.,F0 ;convert to minutes 516 001524 116501 000002 MOVB MINUTE(R5),R1 ;get the minutes 517 001530 177101 LDCIF R1,F1 ;convert to floating 518 001532 172001 ADDF F1,F0 ;add into time 519 001534 171027 041560 MULF #60.,F0 ;convert to seconds 520 001540 116501 000000 MOVB SECOND(R5),R1 ;get the seconds 521 001544 177101 LDCIF R1,F1 ;convert to floating 522 001546 172001 ADDF F1,F0 ;add into total 523 001550 174003 STF F0,F3 ;save current clock time 524 ;; 525 ;; Now convert system time to seconds from start of month 526 ;; 527 001552 177267 000202' LDCIF G.TIDA+TIMBUF,F2 ;get the days 528 001556 171227 041300 MULF #24.,F2 ;make the days into hours 529 001562 177167 000204' LDCIF G.TIHR+TIMBUF,F1 ;get the hours in floating format 530 001566 172201 ADDF F1,F2 ;add into total 531 001570 171227 041560 MULF #60.,F2 ;make into minutes 532 001574 177167 000206' LDCIF G.TIMI+TIMBUF,F1 ;get the minutes in floating format 533 001600 172201 ADDF F1,F2 ;add into total 534 001602 171227 041560 MULF #60.,F2 ;now make it seconds 535 001606 177167 000210' LDCIF G.TISC+TIMBUF,F1 ;get the seconds in floating format 536 001612 172201 ADDF F1,F2 ;and add into total 537 001614 173200 SUBF F0,F2 ;subtract clock time from system time 538 001616 170602 ABSF F2 ;get the absolute value CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 12-1 * CHECK - AST compare system / Grant-307 clock time 539 001620 175601 STCFI F2,R1 ;convert to integer in R1 540 001622 IF #FL.DST,SET,FLAGS ;IF auto daylight savings time 541 001632 004767 000126 CALL DAYLIT ;go check daylight savings time 542 001636 ENDI ;ENDI 543 001636 IF #60.,LT,R1 ;IF time difference greater than 60 sec. 544 001644 010604 MOV SP,R4 ;flag error 545 001646 ENDI ;ENDI 546 001646 ELSE ;ELSE error 547 001650 010604 MOV SP,R4 ;flag error 548 001652 ENDI ;ENDI 549 001652 ELSE ;ELSE error 550 001654 010604 MOV SP,R4 ;flag error 551 001656 ENDI ;ENDI 552 001656 IF R4 ;IF error 553 001662 012701 000441' MOV #ERR6,R1 ;get error address 554 001666 012702 000006' MOV #ARGLST,R2 ;get address of argument list 555 001672 005012 CLR (R2) ;assume no arguments 556 001674 012703 000001 MOV #TILUN,R3 ;lun to output error message 557 001700 004767 000000G CALL ERRMSG ;output error 558 001704 ENDI ;ENDI 559 001704 ENDI ;ENDI 560 001704 170012 SETL ;set long integer mode 561 001706 175767 000026' STCFL F3,LSTCLK ;update last clock time 562 001712 170002 SETI ;set regular integer mode 563 001714 012605 MOV (SP)+,R5 ;restore R5 564 001716 012604 MOV (SP)+,R4 ;restore R4 565 001720 012603 MOV (SP)+,R3 ;restore R3 566 001722 012602 MOV (SP)+,R2 ;restore R2 567 001724 012601 MOV (SP)+,R1 ;restore R1 568 001726 012600 MOV (SP)+,R0 ;restore R0 569 001730 MRKT$S #MARKFL,#MARKTM,#3,#CHECK 570 ;check the time every MARKTM minutes 571 001756 ASTX$S ;exit ast routine CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 13 * DAYLIT - subroutine to check daylight savings time 573 .SBTTL * DAYLIT - subroutine to check daylight savings time 574 ; 575 ; DAYLIT - subroutine to check daylight savings time 576 ; 577 ; INPUT: 578 ; R1 = current time difference in seconds 579 ; F3 = current time in seconds from start of month 580 ; OUTPUT: 581 ; R1 = current time difference in seconds if not daylight 582 ; savings time change 583 ; R1 = 0 if daylight savings time change 584 ; Correct routine called to reset system time or 585 ; clock time. 586 ; 587 001764 DAYLIT: 588 001764 016702 000026' MOV LSTCLK,R2 ;get first word of last clock time 589 001770 056702 000030' BIS LSTCLK+2,R2 ;or in second word 590 001774 IF R2,NE ;IF not first check 591 002000 IF #60.*59.,LT,R1 ;IF more than 59 minutes difference 592 002006 IF #60.*61.,GT,R1 ;IF less than 61 minutes, assume time change 593 002014 170012 SETL ;set long integer mode 594 002016 177267 000026' LDCLF LSTCLK,F2 ;get last clock time in floating format 595 002022 170002 SETI ;set regular integer mode 596 002024 173203 SUBF F3,F2 ;subtract current time from last time 597 002026 170602 ABSF F2 ;get the absolute value 598 002030 175602 STCFI F2,R2 ;convert to integer in R2 599 002032 IF #<60.*MARKTM>+90.,LT,R2 ;IF change in Grant-307 clock 600 002040 004767 176332 CALL TIMSET ;set system time 601 002044 ELSE ;ELSE 602 002046 004767 176536 CALL CLKSET ;set clock 603 002052 ENDI ;ENDI 604 002052 005001 CLR R1 ;do not print time error 605 002054 ENDI ;ENDI 606 002054 ENDI ;ENDI 607 002054 ENDI ;ENDI 608 002054 000207 RETURN 609 610 000000' .END CLOCK CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 13-1 Symbol table ACTION 000010R 006 FL.MON= 000004 SET.B = 000200 $LEV = 000012 $1U2 001456R 002 ALUNTI 000032R 004 FL.SYS= 000001 SSTTBL 000000R 004 $NARG = 000003 $1V1 000434R 002 ARGLST 000006R 004 F0 =%000000 S.TIBA= 000002 $NO = 000006 $1V2 001454R 002 A.LULU= 000002 F1 =%000001 S.TIBO= 000004 $NUMBR= 000302 $1W1 000636R 002 A.LUNA= 000004 F2 =%000002 S.TICP= 000016 $RAD50= 000316 $2E1 000300R 002 A.LUNU= 000006 F3 =%000003 S.TICT= 000014 $RONLY= 000001 $2E2 000520R 002 BUFFER 000000R 005 F4 =%000004 S.TIDA= 000004 $SAVAL= ****** GX $2E3 001004R 002 CHECK 001402R 002 F5 =%000005 S.TIHR= 000006 $STRNG= 000304 $2E4 001654R 002 CLKBAS= 170400 GETCMD 001262R 002 S.TIMI= 000010 $SUBXP= 000310 $2E5 001704R 002 CLKSET 000610R 002 GETTIM 000164R 004 S.TIMO= 000002 $ULEV = 000000 $2E6 002054R 002 CLOCK 000000RG 002 GMCR 000042R 004 S.TISC= 000012 $U1 = 000002 $2I1 000326R 002 CLOKEY 000000R 006 G.MCRB= 000002 S.TIYR= 000000 $WLEV = 000000 $2I2 000556R 002 CLOKTB 000000RG 007 G.TIBA= 000002 TILUN = 000001 $W1 = 000001 $2I3 001044R 002 CLOSTB 000000RG 006 G.TICP= 000016 TIMBUF 000176R 004 $$CLEV= 000000 $2I4 001656R 002 DAY = 000007 G.TICT= 000014 TIMSET 000376R 002 $$SYM = 000001 $2I5 001704R 002 DAYLIT 001764R 002 G.TIDA= 000004 TODAY 001112R 002 $$$ARG= 000004 $2I6 002054R 002 DEM 000042R 006 G.TIHR= 000006 UIP.A = 000200 $$$FLG= 177777 $3E1 000110R 002 DM.B = 000004 G.TIMI= 000010 VRT.D = 000200 $$$KEY= 000005 $3E2 000124R 002 DONE 000124R 006 G.TIMO= 000002 WEEKDY 000216R 004 $$$OST= 000005 $3E3 000206R 002 DOW = 000006 G.TISC= 000012 WHICH 000060R 006 $$$STA= 000000 $3E4 000276R 002 DSE.B = 000001 G.TIYR= 000000 WRITFL= 000001 $$$TMP= 000043R 010 $3E5 001002R 002 DST 000100R 006 HLPMSG 000563R 003 WRITST 000002R 004 $$$T1 = 000002 $3E6 001650R 002 DV0.A = 000020 HLPSZ = 001312 YEAR = 000011 $$$T2 = 000036R 004 $3E7 002054R 002 DV1.A = 000040 HOUR = 000004 $ALPHA= 000322 $1D1 001046R 002 $3I1 000110R 002 DV2.A = 000100 IO.WLB= ****** GX $ANY = 000320 $1E1 000330R 002 $3I2 000124R 002 ERRMSG= ****** GX LSTCLK 000026R 004 $BLANK= 000306 $1E2 000560R 002 $3I3 000206R 002 ERR1 000000R 003 MARKFL= 000002 $CLEV = 000000 $1E3 001052R 002 $3I4 000276R 002 ERR2 000076R 003 MARKTM= 000005 $DIGIT= 000324 $1E4 001214R 002 $3I5 001002R 002 ERR3 000163R 003 MINUTE= 000002 $DNUMB= 000314 $1E5 001704R 002 $3I6 001652R 002 ERR4 000255R 003 MODE.B= 000002 $DSW = ****** GX $1E6 002054R 002 $3I7 002054R 002 ERR5 000347R 003 MONTH = 000010 $EOS = 000312 $1I1 000366R 002 $4E1 000766R 002 ERR6 000441R 003 NOCLCK 001334R 002 $EXIT = 000000 $1I2 000606R 002 $4E2 001636R 002 EX$ERR= 000002 POWERF 001344R 002 $FLEV = 000000 $1I3 001110R 002 $4E3 001646R 002 EX$SEV= 000004 REGA = 000012 $ILEV = 000000 $1I4 001214R 002 $4E4 002046R 002 EX$SUC= 000001 REGB = 000013 $I1 = 000006 $1I5 001704R 002 $4I1 000774R 002 EX$WAR= 000000 REGC = 000014 $I2 = 000006 $1I6 002054R 002 $4I2 001636R 002 FLAGS 000024R 004 REGD = 000015 $I3 = 000007 $1R1 000424R 002 $4I3 001646R 002 FL.CLK= 000002 REJECT 001326R 002 $I4 = 000004 $1R2 001444R 002 $4I4 002052R 002 FL.DST= 000020 SECOND= 000000 $LAMDA= 000300 $1U1 000436R 002 .TPARS= ****** GX FL.HLP= 000010 SETTIM 000170R 004 . ABS. 000000 000 (RW,I,GBL,ABS,OVR) 000000 001 (RW,I,LCL,REL,CON) $CODE 002056 002 (RO,I,LCL,REL,CON) $PDATA 002076 003 (RO,D,LCL,REL,CON) $IDATA 000220 004 (RW,D,LCL,REL,CON) $$BUF 000400 005 (RW,D,GBL,REL,OVR) $STATE 000136 006 (RO,D,LCL,REL,CON) $KTAB 000014 007 (RO,D,LCL,REL,CON) $KSTR 000076 010 (RO,D,LCL,REL,CON) Errors detected: 0 *** Assembler statistics Work file reads: 0 Work file writes: 0 CLOCK MACRO Y05.04 Tuesday 20-Jan-87 22:46 Page 13-2 Symbol table Size of work file: 14496 Words ( 57 Pages) Size of core pool: 15578 Words ( 59 Pages) Operating system: RSX-11M/PLUS Elapsed time: 00:00:54.27 CLOCK,CLOCK/-SP=CLOCK