HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Table of contents 2- 19 STARTUP 4- 1 Error conditions 5- 1 Convert ASCII time to hours/min/sec/tenths 6- 1 Convert ASCII date to month/day/year 6- 22 Convert hours/minutes/seconds/tenths to ticks 7- 1 Convert day/month/year to RT-11 date word 8- 1 Get character from serial port 9- 1 Convert 2 digits to binary; store at (R4) 9- 20 multiply by 10 9- 29 Double precision multiply [R0,R1] by R2 10- 1 Data HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 1 1 .enabl mcl 2 000000 .module HEATH,release=V01,version=00,comment=,audit=YES 3 ;+ 4 ;***************************************************************************** 5 ; 6 ; Author: John M. Crowell 01-Dec-87 7 ; Multiware, Inc. 8 ; 9 ; This program sets the RT-11 date and time from an ASCII string produced 10 ; by the Heathkit GC1000 WWV clock connected to a DL11-type serial port. 11 ; 12 ; The following locations can be patched to customize the program without 13 ; rebuilding it. 14 ; 15 ; 1000 contains the base CSR for the serial port (defaults to 176500) 16 ; 17 ; 1002 contains the interrupt vector for the serial port (defaults to 300) 18 ; 19 ; 1004 contains the number of clock ticks to wait before assuming that there 20 ; is nothing coming in the serial port, or that whatever is connected 21 ; is not sending a "time frame" terminated by a carriage return. 22 ; 23 ; 1006 contains a fine-tuning value. The ASCII output from the HEATH clock 24 ; is delayed by about 1 second, which is taken into account by this 25 ; program. The computation time to convert the ASCII string into RT-11 26 ; format date and time is processor dependent. A fudge factor can be 27 ; inserted at this location which will be added to the number of clock 28 ; ticks since midnight, to adjust for processing time. 29 ; 30 ; 1010 Error severity code for "fatal" errors. 31 ; e.g. No input - "clock is off-line" 32 ; Unable to protect interrupt vectors (another job has'em) 33 ; Framing error - unable to sync to clock input (no ) 34 ; 35 ; 1012 Error severity code for "non-fatal" errors. 36 ; e.g. Clock time is not set. 37 ; Clock data frame is undecipherable 38 ; 39 ; If the program is run from a command file, patching these locations 40 ; will affect the continuation of the command file, depending upon the 41 ; current level of SET ERROR. 42 ; 43 ; SET ERROR LEVEL 44 ; Value NONE WARNING ERROR FATAL SEVERE 45 ; 0-1 cont cont cont cont cont (success) 46 ; 2 cont abort cont cont cont (warning) 47 ; 4 cont abort abort cont cont (error) 48 ; 10 cont abort abort abort abort (fatal/severe) 49 ; 20 abort abort abort abort abort (unconditional) 50 ; 51 ; If the clock is "set" but not locked, the tenths-of-seconds digit on the 52 ; clock will be dim indicating that the clock time is not necessarily 53 ; accurate. In this case, a warning message will be printed, and a WARNING 54 ; level error will be generated. 55 ;- HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 2 1 .mcall .print 2 .dsabl gbl 3 .nlist bex 4 5 000015 cr = 15 6 000053 $usrrb = 53 ; user error byte 7 000002 warn$ = 2 8 000004 error$ = 4 9 000010 fatal$ = 10 10 000300 config = 300 ; offset in monitor to configuration word 11 000040 clk50$ = 40 ; 50Hz clock bit in configuration word 12 000001 fbmon$ = 1 13 14 000050 strsiz = 40. 15 16 .iif ndf icsr, icsr = 176500 17 .iif ndf vector, vector=300 18 19 .sbttl STARTUP 20 21 000000 .psect .code.,rw,i,lcl,rel,con 22 23 000000 176500 i$csr:: .word icsr ; CSR for DL-11 interface 24 000002 000300 $vect:: .word vector 25 000004 000264 $ticks::.word 3.*60. ; clock ticks to wait before quitting 26 000006 000000 $fudge::.word 0 27 000010 000010 $fatal::.word fatal$ 28 000012 000004 $error::.word error$ 29 30 000014 000240 heath:: nop ; for debugging 31 000016 016700 177756 mov i$csr,r0 ; verify and set up serial port 32 000022 005020 clr (r0)+ 33 000024 010067 000014' mov r0,i$dat 34 000030 005720 tst (r0)+ 35 000032 010067 000016' mov r0,o$csr 36 000036 005020 clr (r0)+ 37 000040 010067 000020' mov r0,o$dat 38 000044 016767 177734 000042' mov $ticks,$wait+2 ; set up .MRKT 39 000052 .gval #area,#config ; get our configuration 40 000072 012767 000006 000010' mov #6,tick ; assume 60 ticks/sec 41 000100 032700 000040 bit #clk50$,r0 ; 50Hz clock? 42 000104 001403 beq 5$ 43 000106 012767 000005 000010' mov #5,tick ; yes, make that 50 ticks/sec 44 000114 042700 177776 5$: bic #^cfbmon$,r0 45 000120 110067 000013' movb r0,fbflag ; = 0 if SJ 46 000124 001420 beq 9$ 47 000126 .protec #area,$vect ; grab our interrupt vector 48 000146 103017 bcc 10$ 49 000150 .print #$novec 50 000156 152737 000010 000053 bisb #fatal$,@#$usrrb 51 000164 .exit HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 3 STARTUP 1 000166 9$: .gtim #area,#$time0 ; if SJ, get base time 2 000206 016700 177570 10$: mov $vect,r0 ; initialize interrupt vector 3 000212 012720 001330' mov #$input,(r0)+ 4 000216 012710 000340 mov #340,(r0) 5 000222 012767 000106' 000104' mov #string,point ; initialize string pointer 6 000230 112767 177777 000012' movb #-1,iflag ; initialize input flag 7 000236 012700 000022' mov #$mrkt,r0 8 000242 104375 emt 375 ; start .MRKT request 9 000244 052777 000100 177526 bis #100,@i$csr ; enable input interrupts 10 000252 .spnd ; go to sleep 11 000260 105767 000013' 11$: tstb fbflag ; If SJ, check time passage 12 000264 001033 bne 14$ 13 000266 .gtim #area,#$time1 14 000306 166767 000042' 000052' sub $wait+2,$time1+2 15 000314 005667 000050' sbc $time1 16 000320 002757 blt 11$ 17 000322 166767 000040' 000050' sub $wait,$time1 18 000330 002753 blt 11$ 19 000332 026767 000050' 000044' cmp $time1,$time0 20 000340 003005 bgt 14$ 21 000342 001346 bne 11$ 22 000344 026767 000052' 000046' cmp $time1+2,$time0+2 23 000352 002742 blt 11$ 24 000354 012700 000032' 14$: mov #$cmkt,r0 ; If we get here, cancel the .MRKT 25 000360 104375 emt 375 26 000362 005077 177412 clr @i$csr ; kill interrupts 27 000366 116700 000012' movb iflag,r0 ; did anything happen while we were asleep? 28 000372 003004 bgt 15$ ; yes, at least there was input 29 000374 001414 beq framer ; yes, but we never got a 30 000376 005200 inc r0 31 000400 001405 beq timout ; no, the port is dead 32 000402 000411 br framer ; yes, but we overran our buffer 33 000404 020027 000002 15$: cmp r0,#2 ; we got a whole frame in time... 34 000410 002034 bge convrt ; go try to interpret it. 35 000412 000405 br framer ; we timed out before getting second HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 4 Error conditions 1 .sbttl Error conditions 2 .enabl lsb 3 4 000414 005077 177360 timout: clr @i$csr ; Too long to wait. Nothing coming in. 5 000420 012700 000156' mov #$offln,r0 6 000424 000402 br 5$ 7 8 000426 012700 000213' framer: mov #$frmer,r0 ; Framing error. Can't sync to input 9 000432 5$: .print 10 000434 156737 177350 000053 bisb $fatal,@#$usrrb 11 000442 000167 000640 jmp finish 12 13 000446 012700 000256' seterr: mov #notset,r0 ; Clock isn't set 14 000452 000402 br 10$ 15 000454 012700 000312' error: mov #stxerr,r0 ; Can't decipher input 16 000460 10$: .print 17 000462 .print #string 18 000470 156737 177316 000053 bisb $error,@#$usrrb 19 000476 000167 000604 jmp finish 20 21 .dsabl lsb HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 5 Convert ASCII time to hours/min/sec/tenths 1 .sbttl Convert ASCII time to hours/min/sec/tenths 2 3 000502 005067 000066' convrt::clr hours 4 000506 005067 000070' clr minute 5 000512 005067 000072' clr second 6 000516 005067 000074' clr tenths 7 000522 005067 000076' clr day 8 000526 005067 000100' clr month 9 000532 005067 000102' clr year 10 000536 012701 000106' mov #string,r1 11 000542 012704 000066' mov #hours,r4 12 000546 004767 000714 call twodig ; get hours 13 000552 103735 bcs seterr 14 000554 122127 000072 cmpb (r1)+,#': ; must have colon 15 000560 001335 bne error 16 000562 026727 000066' 000030 cmp hours,#24. 17 000570 103331 bhis error 18 000572 012704 000070' mov #minute,r4 19 000576 004767 000664 call twodig 20 000602 103721 bcs seterr 21 000604 122127 000072 cmpb (r1)+,#': 22 000610 001321 bne error 23 000612 026727 000070' 000074 cmp minute,#60. 24 000620 103315 bhis error 25 000622 012704 000072' mov #second,r4 26 000626 004767 000634 call twodig 27 000632 103001 bcc 30$ 28 000634 000704 br seterr 29 000636 122127 000056 30$: cmpb (r1)+,#'. 30 000642 001304 bne error 31 000644 026727 000072' 000074 cmp second,#60. 32 000652 103300 bhis error 33 000654 005067 000074' clr tenths 34 000660 112105 movb (r1)+,r5 35 000662 122705 000071 cmpb #'9,r5 36 000666 103007 bhis 35$ 37 000670 120527 000077 cmpb r5,#'? 38 000674 001267 bne error 39 000676 .print #$lock 40 000704 000405 br 40$ 41 000706 162705 000060 35$: sub #'0,r5 42 000712 002660 blt error 43 000714 010567 000074' mov r5,tenths 44 000720 112105 40$: movb (r1)+,r5 45 000722 001456 beq 70$ 46 000724 120527 000040 cmpb r5,#40 47 000730 001773 beq 40$ 48 000732 120527 000101 cmpb r5,#'A 49 000736 001406 beq 45$ 50 000740 120527 000120 cmpb r5,#'P 51 000744 001007 bne 50$ 52 000746 062767 000014 000066' add #12.,hours 53 000754 122127 000115 45$: cmpb (r1)+,#'M 54 000760 001235 bne error 55 000762 000756 br 40$ HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 6 Convert ASCII date to month/day/year 1 .sbttl Convert ASCII date to month/day/year 2 3 000764 005301 50$: dec r1 4 000766 012704 000100' mov #month,r4 5 000772 004767 000470 call twodig 6 000776 103626 55$: bcs error 7 001000 122127 000057 cmpb (r1)+,#'/ 8 001004 001223 bne error 9 001006 026727 000100' 000015 cmp month,#13. 10 001014 103217 bhis error 11 001016 012704 000076' mov #day,r4 12 001022 004767 000440 call twodig 13 001026 103612 bcs error 14 001030 026727 000076' 000040 cmp day,#32. 15 001036 103206 bhis error 16 001040 122127 000057 cmpb (r1)+,#'/ 17 001044 001203 bne error 18 001046 012704 000102' mov #year,r4 19 001052 004767 000410 call twodig 20 001056 103747 bcs 55$ 21 22 .sbttl Convert hours/minutes/seconds/tenths to ticks 23 24 001060 016705 000072' 70$: mov second,r5 ; convert HH:MM:SS.T to ticks 25 001064 005205 inc r5 ; HEATH output is delayed by ~1 sec. 26 001066 004767 000446 call mul10 27 001072 066705 000074' add tenths,r5 28 001076 016701 000066' mov hours,r1 29 001102 006301 asl r1 ; *60. 30 001104 006301 asl r1 31 001106 010146 mov r1,-(sp) 32 001110 006301 asl r1 33 001112 006301 asl r1 34 001114 006301 asl r1 35 001116 006301 asl r1 36 001120 162601 sub (sp)+,r1 37 001122 066701 000070' add minute,r1 38 001126 005000 clr r0 39 001130 012702 001130 mov #600.,r2 40 001134 004767 000414 call $$dmul 41 001140 060501 add r5,r1 42 001142 005500 adc r0 ; add delay for CPU time 43 001144 016702 000010' mov tick,r2 44 001150 004767 000400 call $$dmul 45 001154 066701 176626 add $fudge,r1 ; add delay for CPU time 46 001160 005500 adc r0 47 001162 010067 000062' mov r0,$$time 48 001166 010167 000064' mov r1,$$time+2 49 001172 .assume $$time eq $$date+2 HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 7 Convert day/month/year to RT-11 date word 1 .sbttl Convert day/month/year to RT-11 date word 2 3 001172 016700 000102' mov year,r0 ; construct date word 4 001176 162700 000110 sub #72.,r0 ; subtract base year 5 001202 002002 bge 75$ 6 001204 062700 000144 add #100.,r0 7 001210 010046 75$: mov r0,-(sp) 8 001212 042716 177740 bic #^c37,(sp) ; year in bits [4:0] 9 001216 042700 177637 bic #177637,r0 ; isolate two-bit "age" 10 001222 000300 swab r0 11 001224 006300 asl r0 ; put age in bits [15:14] 12 001226 050016 bis r0,(sp) 13 001230 016700 000076' mov day,r0 ; put day in bits [5:9] 14 001234 042700 177740 bic #^c37,r0 15 001240 006300 asl r0 16 001242 006300 asl r0 17 001244 006300 asl r0 18 001246 006300 asl r0 19 001250 006300 asl r0 20 001252 050016 bis r0,(sp) 21 001254 016700 000100' mov month,r0 ; month in bits [13:10] 22 001260 042700 177760 bic #^c17,r0 23 001264 000300 swab r0 24 001266 006300 asl r0 25 001270 006300 asl r0 26 001272 052600 bis (sp)+,r0 27 001274 010067 000060' mov r0,$$date ; done! 28 001300 012700 000054' mov #$sdttm,r0 29 001304 104375 emt 375 ; set date and time 30 001306 finish: .unprot #area,$vect ; release the vector 31 001326 .exit ; and go away happy. HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 8 Get character from serial port 1 .sbttl Get character from serial port 2 .enabl lsb 3 4 001330 $input::.inten 4 ; drop prioirty, and free up R4 and R5 5 001336 117704 000014' movb @i$dat,r4 ; get character 6 001342 042704 177600 bic #^c177,r4 ; strip to 7 bits 7 001346 105767 000012' tstb iflag ; have we seen a yet? 8 001352 003010 bgt 10$ ; yes, continue 9 001354 105067 000012' clrb iflag ; no, but we did get something! 10 001360 120427 000015 cmpb r4,#cr ; is this a ? 11 001364 001002 bne 5$ 12 001366 105267 000012' incb iflag ; yes, we can start looking for data 13 001372 000207 5$: return 14 15 001374 120427 000015 10$: cmpb r4,#cr ; end-of-frame? 16 001400 001413 beq 15$ 17 001402 110477 000104' movb r4,@point ; no, stash character in string 18 001406 005267 000104' inc point ; and bump pointer 19 001412 026727 000104' 000156' cmp point,#endlin ; out-of-room? 20 001420 103416 blo 20$ ; no, just exit 21 001422 112767 177775 000012' movb #-3,iflag ; yes, major bummer! 22 23 001430 105267 000012' 15$: incb iflag ; we've got all the data we can handle 24 001434 105077 000104' clrb @point ; terminate the string 25 001440 105077 176334 clrb @i$csr ; disable interrupts 26 001444 010046 qtime:: mov r0,-(sp) 27 001446 .rsum ; and restart the main program. 28 001454 012600 mov (sp)+,r0 29 001456 112767 177777 000013' 20$: movb #-1,fbflag 30 001464 000207 return 31 32 .dsabl lsb HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 9 Convert 2 digits to binary; store at (R4) 1 .sbttl Convert 2 digits to binary; store at (R4) 2 3 001466 112105 twodig: movb (r1)+,r5 4 001470 122705 000071 cmpb #'9,r5 5 001474 002417 blt 10$ ; oops, not a digit 6 001476 162705 000060 sub #'0,r5 7 001502 001404 beq 5$ ; ignore if zero 8 001504 002413 blt 10$ ; oops, not a digit 9 001506 004767 000026 call mul10 ; multiply first digit by 10. 10 001512 010514 mov r5,(r4) ; and store it 11 001514 112105 5$: movb (r1)+,r5 ; get second digit 12 001516 122705 000071 cmpb #'9,r5 13 001522 002404 blt 10$ ; gimme a break! 14 001524 162705 000060 sub #'0,r5 15 001530 060514 add r5,(r4) ; add "ones" digit 16 001532 005727 tst (pc)+ 17 001534 000261 10$: sec 18 001536 000207 return 19 20 .sbttl multiply by 10 21 22 001540 006305 mul10: asl r5 23 001542 010546 mov r5,-(sp) 24 001544 006305 asl r5 25 001546 006305 asl r5 ; 8X 26 001550 062605 add (sp)+,r5 ; +2X 27 001552 000207 return 28 29 .sbttl Double precision multiply [R0,R1] by R2 30 31 001554 010346 $$dmul::mov r3,-(sp) 32 001556 010246 mov r2,-(sp) 33 001560 010246 mov r2,-(sp) 34 001562 010002 mov r0,r2 35 001564 010103 mov r1,r3 36 001566 005000 clr r0 37 001570 005001 clr r1 38 001572 005716 1$: tst (sp) 39 001574 001410 beq 3$ 40 001576 006016 ror (sp) 41 001600 103003 bcc 2$ 42 001602 060301 add r3,r1 43 001604 005500 adc r0 44 001606 060200 add r2,r0 45 001610 006303 2$: asl r3 46 001612 006102 rol r2 47 001614 000766 br 1$ 48 001616 005726 3$: tst (sp)+ 49 001620 012602 mov (sp)+,r2 50 001622 012603 mov (sp)+,r3 51 001624 000207 return HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 10 Data 1 .sbttl Data 2 3 000000 .psect .data.,rw,d,lcl,rel,con 4 5 000000 area: .blkw 4 ; EMT parameter block 6 000010 000000 tick: .word 0 ; = 5 or 6 for 50Hz or 60 Hz 7 000012 000 iflag: .byte 0 ; data capture flag 8 000013 000 fbflag: .byte 0 ; FB/SJ flag 9 000014 176502 i$dat: .word icsr+2 ; address of input data buffer 10 000016 176504 o$csr: .word icsr+4 ; address of output CSR (not used yet) 11 000020 176506 o$dat: .word icsr+6 ; address of output data buffer (not used yet) 12 000022 000 022 $mrkt: .byte 0,22 ; mark time request to avoid hanging 13 000024 000040' .word $wait 14 000026 001444' .word qtime 15 000030 000002 .word 2 16 000032 000 023 $cmkt: .byte 0,23 ; cancel mark time request 17 000034 000000 000000 .word 0,0 18 000040 000000 000000 $wait: .word 0,0 19 000044 $time0: .blkw 2 ; starting time 20 000050 $time1: .blkw 2 ; endind time (used by SJ) 21 000054 000 040 $sdttm: .byte 0,40 ; .SDTTM parameter block 22 000056 000060' $$date 23 000060 000000 $$date: .word 0 ; date word goes here 24 000062 $$time: .blkw 2 ; time in ticks goes here 25 26 000066 000000 hours:: .word 0 ; time-of-day 27 000070 000000 minute::.word 0 28 000072 000000 second::.word 0 29 000074 000000 tenths::.word 0 30 000076 000000 day:: .word 0 ; date 31 000100 000000 month:: .word 0 32 000102 000000 year:: .word 0 33 34 000104 000000 point:: .word 0 ; pointer into ASCII string 35 000106 string::.blkb strsiz ; ASCII string from clock 36 000156 endlin: 37 000156 $offln: .nlcsi type=i,part=prefix 38 000165 106 055 103 .asciz /F-Clock is off-line./<7> 39 000213 $frmer: .nlcsi type=i,part=prefix 40 000222 106 055 103 .asciz /F-Clock data framing error/<7> 41 000256 notset: .nlcsi type=i,part=prefix 42 000265 105 055 103 .asciz /E-Clock is not set./<7> 43 000312 stxerr: .nlcsi type=i,part=prefix 44 000321 105 055 103 .asciz /E-Clock frame unintelligible/<7> 45 000357 $lock: .nlcsi type=i,part=prefix 46 000366 127 055 103 .asciz /W-Clock time is not definite/<7> 47 000424 $novec: .nlcsi type=i,part=prefix 48 000433 106 055 103 .asciz /F-Cannot protect interrupt vector/<7> 49 50 000014' .end heath HEATH - Set RT-11 date and time MACRO V05.05 Tuesday 26-Dec-89 16:43 Page 10-1 Symbol table AREA 000000R 003 HEATH 000014RG 002 SECOND 000072RG 003 $FATAL 000010RG 002 $VECT 000002RG 002 CLK50$= 000040 HOURS 000066RG 003 SETERR 000446R 002 $FRMER 000213R 003 $WAIT 000040R 003 CONFIG= 000300 ICSR = 176500 STRING 000106RG 003 $FUDGE 000006RG 002 $$DATE 000060R 003 CONVRT 000502RG 002 IFLAG 000012R 003 STRSIZ= 000050 $INPUT 001330RG 002 $$DMUL 001554RG 002 CR = 000015 I$CSR 000000RG 002 STXERR 000312R 003 $LOCK 000357R 003 $$TIME 000062R 003 DAY 000076RG 003 I$DAT 000014R 003 TENTHS 000074RG 003 $MRKT 000022R 003 .AUDIT 107117 G ENDLIN 000156R 003 MINUTE 000070RG 003 TICK 000010R 003 $NOVEC 000424R 003 .HEATH 000000 G ERROR 000454R 002 MONTH 000100RG 003 TIMOUT 000414R 002 $OFFLN 000156R 003 ...V1 = 000003 ERROR$= 000004 MUL10 001540R 002 TWODIG 001466R 002 $SDTTM 000054R 003 ...V2 = 000005 FATAL$= 000010 NOTSET 000256R 003 VECTOR= 000300 $TICKS 000004RG 002 ...V27= 031311 FBFLAG 000013R 003 O$CSR 000016R 003 WARN$ = 000002 $TIME0 000044R 003 ...V28= 001450 FBMON$= 000001 O$DAT 000020R 003 YEAR 000102RG 003 $TIME1 000050R 003 ...V5 = 000114 FINISH 001306R 002 POINT 000104RG 003 $CMKT 000032R 003 $USRRB= 000053 ...V6 = 001450 FRAMER 000426R 002 QTIME 001444RG 002 $ERROR 000012RG 002 . ABS. 000116 000 (RW,I,GBL,ABS,OVR) 000000 001 (RW,I,LCL,REL,CON) .CODE. 001626 002 (RW,I,LCL,REL,CON) .DATA. 000476 003 (RW,D,LCL,REL,CON) Errors detected: 0 *** Assembler statistics Work file reads: 559 Work file writes: 235 Size of work file: 10903 Words ( 43 Pages) Size of core pool: 5376 Words ( 21 Pages) Operating system: RT-11 Elapsed time: 00:00:25.09 LD0:HEATH,LD0:HEATH=LD0:HEATH