Trailing-Edge
-
PDP-10 Archives
-
AP-4178E-RM
-
swskit-sources/datime.mac
There are 50 other files named datime.mac in the archive. Click here to see a list.
;<3-MONITOR>DATIME.MAC.54, 7-Nov-77 12:59:36, EDIT BY KIRSCHEN
;MORE COPYRIGHT UPDATING...
;<3-MONITOR>DATIME.MAC.53, 4-Nov-77 15:50:48, EDIT BY KIRSCHEN
;ORDER ZONES TABLE CORRECTLY
;<3-MONITOR>DATIME.MAC.52, 1-Nov-77 17:39:16, EDIT BY HURLEY
;MAKE DAYLIGHT SAVINGS TURN ON ON THE LASY SUNDAY IN APRIL
;<3-MONITOR>DATIME.MAC.51, 10-Oct-77 10:06:29, EDIT BY KIRSCHEN
;UPDATE COPYRIGHT FOR RELEASE 3
;<3-MONITOR>DATIME.MAC.50, 12-Sep-77 16:46:36, EDIT BY CROSSLAND
;DOCUMENT IDCNV TO RETURN TIME ZONE IN 3 NOT 4.
;<3-MONITOR>DATIME.MAC.49, 1-Sep-77 09:18:52, EDIT BY KIRSCHEN
;<3-MONITOR>DATIME.MAC.48, 22-Aug-77 14:15:43, EDIT BY KIRSCHEN
;TCO 1854 - ADD KNOWLEDGE OF ATLANTIC, YUKON, ALASKA-HAWAII,
; AND BERING TIME ZONES.
;<3-MONITOR>DATIME.MAC.47, 28-Mar-77 15:18:03, Edit by HESS
;TCO 1760 - JULIAN DATE FORMAT STUFF
;<3-MONITOR>DATIME.MAC.46, 4-Mar-77 19:05:17, Edit by MCLEAN
;GET IT RIGHT
;<3-MONITOR>DATIME.MAC.45, 3-Mar-77 02:53:54, Edit by MCLEAN
;TCO 1749 REMOVE BUGCHK IDCNF AND REPLACE WITH RET
;<3-MONITOR>DATIME.MAC.44, 23-Jan-77 14:49:15, Edit by MCLEAN
;<3-MONITOR>DATIME.MAC.43, 27-Dec-76 17:30:37, EDIT BY HURLEY
;<3-MONITOR>DATIME.MAC.42, 20-Dec-76 14:55:20, Edit by MCLEAN
;<3-MONITOR>DATIME.MAC.41, 30-Nov-76 01:55:42, Edit by MCLEAN
;<3-MONITOR>DATIME.MAC.40, 28-Nov-76 22:35:50, Edit by MCLEAN
;<3-MONITOR>DATIME.MAC.39, 27-Nov-76 13:54:10, Edit by MCLEAN
;<MCLEAN>DATIME.MAC.6, 25-Sep-76 14:34:49, Edit by MCLEAN
;<MCLEAN>DATIME.MAC.2, 29-Jul-76 13:20:48, Edit by MCLEAN
;<2-MONITOR>DATIME.MAC.37, 23-Nov-76 10:28:17, Edit by MACK
;<2-MONITOR>DATIME.MAC.36, 16-Nov-76 18:46:33, EDIT BY MURPHY
;<2-MONITOR>DATIME.MAC.35, 16-Nov-76 14:39:28, Edit by MACK
;TCO 1666 - MAKE TIMZON GLOBAL
;<2-MONITOR>DATIME.MAC.34, 14-Oct-76 16:51:28, EDIT BY HURLEY
;TCO 1595 - FIX ODCNV TO NOT DIE ON 777777 SECONDS
;<2-MONITOR>DATIME.MAC.33, 6-Oct-76 08:38:10, EDIT BY HURLEY
;<2-MONITOR>DATIME.MAC.32, 4-Oct-76 14:05:30, EDIT BY HURLEY
;TCO 1565 - MAKE ERJMP'S VALID AFTER ALL DAYTIME JSYS'S
;<1B-MONITOR>DATIME.MAC.31, 14-JUN-76 21:10:56, EDIT BY OSMAN
;TRY ONE MORE TIME TO MAKE TCO 1411 WORK
;<1B-MONITOR>DATIME.MAC.30, 14-JUN-76 18:47:54, EDIT BY HURLEY
;<1B-MONITOR>DATIME.MAC.29, 14-JUN-76 16:23:47, Edit by MACK
;IDTNC JSYS FIXED TO CALL IDCNV PROPERLY
;<1B-MONITOR>DATIME.MAC.28, 14-JUN-76 16:06:21, EDIT BY HURLEY
;<1B-MONITOR>DATIME.MAC.27, 14-JUN-76 14:29:45, EDIT BY JMCCARTHY
;TCO 1411 - FIX IDTNC JSYS TO RETURN CORRECT DATA IN AC3
;<1B-MONITOR>DATIME.MAC.26, 11-JUN-76 15:58:53, Edit by HESS
; TCO 1400 - Upper/lower case message edit
;<2MONITOR>DATIME.MAC.25, 16-JAN-76 17:41:38, EDIT BY MURPHY
;<2MONITOR>DATIME.MAC.24, 23-DEC-75 12:45:51, EDIT BY LEWINE
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
; OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976, 1977, 1978 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
SEARCH PROLOG
TTITLE DATIME
SWAPCD
;TIME AND DATE ROUTINES
;JSYS'S HEREIN
; ODTIM
; IDTIM
; ODTNC
; IDTNC
; ODCNV
; IDCNV
INTERN .ODTIM,.IDTIM,.ODTNC,.IDTNC,.ODCNV,.IDCNV ;JSYS'S
;INTERN ODTIMS,IDTIMS,ODTNCS,IDTNCS ;SUBR ENTRIES TO JSYS'S
EXTERN MENT0,MRETN
EXTERN BIN1,BOUTA,NOUTXX,ITRAP,LGTAD,LSTERR,TMZONE
;PARAMETERS
;THE FOLLOWING PARAMETERS CONTROL HANDLING OF DAYLIGHT SAVING TIME.
;THERE ARE THREE POSSIBILITIES:
; 1. DST NEVER USED (SET NEVDST INTO DSTFLG)
; 2. DST ALWAYS USED (SET ALLDST INTO DSTFLG)
; 3. DST USED ACCORDING TO SOME RULE (SET 0 INTO DSTFLG).
;IF THE RULE IS BEING USED, THE FOLLOWING PARAMETERS MAY BE SET:
; 1. DSTBGN - THE YEAR IN WHICH THE RULE BECAME EFFECTIVE
; 2. DSTON - THE LAST DAY OF THE YEAR ON WHICH DST MAY START.
; THE PRESENT ALGORITHM WILL START IT ON THE SUNDAY PRECEEDING
; THIS DAY.
; 3. DSTOFF - THE LAST DAY OF THE YEAR ON WHICH DST MAY END.
; THE PRESENT ALGORITHM WILL END IT ON THE SUNDAY PRECEEDING
; THIS DAY.
;IF THIS IS INSUFFICIENT TO DESCRIBE THE CURRENT RULE, THE CODE WILL
;HAVE TO BE CHANGED.
ALLDST==1B0 ;DST ALWAYS IN EFFECT
NEVDST==1B1 ;DST NEVER IN EFFECT
DSTFLG::0 ;DST FLAG
DSTBGN::^D1975
DSTON:: ^D<31+29+31+30>-1 ;LAST SUNDAY IN APRIL
DSTOFF:^D<31+29+31+30+31+30+31+31+30+31>-1
;LAST SUNDAY IN OCTOBER
DWFUDG==2 ;CONSTANT TO NORMALIZE DAY OF WEEK
; = DAY OF WEEK OF 17 NOV 1858
;ACCUMULATORS
Z=0
A=1
B=2
C=3
D=4
E=5
F=6
G=7
AA=10
BB=11
CC=12
DD=13
EE=14
FF=15
GG=16
P=17
;HALF-WORD BIT SYMBOLS
B0==1B18
B1==1B19
B2==1B20
B3==1B21
B4==1B22
B5==1B23
B6==1B24
B7==1B25
B8==1B26
B9==1B27
B10==1B28
B11==1B29
B12==1B30
B13==1B31
B14==1B32
B15==1B33
B16==1B34
B17==1B35
REPEAT 0, <
ODTIM
OUTPUT DATE AND TIME
CONVERTS INTERNAL DATE AND TIME TO TEXT
TAKES: 1: TENEX DESTINATION DESIGNATOR
2: LEFT HALF: INTERNAL DATE
RIGHT HALF: INTERNAL TIME
OR ENTIRE WORD -1 TO USE CURRENT DATE AND TIME
3: FORMAT FLAGS, DESCRIBED BELOW
RETURNS: +1 ALWAYS: UPDATED STRING POINTER (IF PERTINENT) IN 1.
GENERATES ILLEGAL INSTRUCTION PSEUDO-INTERRUPT ON
ERROR CONDITIONS GIVEN BELOW.
ODTIM FORMAT FLAGS (AC 3):
B0: OFF, OUTPUT DATE
ON, OMIT DATE AND IGNORE B1-B8
B1: ON, OUTPUT DAY OF WEEK
OFF, OMIT DAY OF WEEK AND IGNORE B4
B2: ON, USE FULL TEXT FOR WEEKDAY
OFF, USE 3-LETTER ABBREVIATION FOR WEEKDAY
B3: ON, OUTPUT MONTH AS NUMBER AND IGNORE B4
OFF, OUTPUT MONTH AS TEXT
B4: ON, USE FULL TEXT FOR MONTH
OFF, USE 3-LETTER ABBREVIATION FOR MONTH
B5: ON, OUTPUT 4-DIGIT YEAR
OFF, OUTPUT 2-DIGIT YEAR IF BETWEEN 1900 AND 1999
B6: ON, OUTPUT DAY OF MONTH AFTER MONTH
OFF, OUTPUT DAY OF MONTH BEFORE MONTH
B7 AND B8: DATE PUNCTUATION CONTROL:
BOTH OFF, PUNCTUATE WITH DASHES, AS 13-APR-70
B7 ON, PUNCTUATE WITH SPACES, AS 13 APR 70.
A COMMA IS ALSO USED IF B6 IS ON, AS APRIL 13, 1970
B8 ON, PUNCTUATE WITH SLASHES, AS 5/13/70
BOTH B7 AND B8 ON, UNSPECIFIED
B9: OFF, OUTPUT TIME
ON, OMIT TIME AND IGNORE B10-B13
B10: OFF, INCLUDE SECONDS, PRECEDED BY A COLON
ON, OMIT SECONDS
B11: OFF, USE 24-HOUR TIME
ON, USE 12-HOUR TIME AND AM-PM
B12: OFF, COLON BETWEEN HOURS AND MINUTES
ON, NO COLON
B13: OFF, NO TIME ZONE GARBAGE
ON, ADD "-" AND TIME ZONE TO TIME, EG "-EDT" OR "-PST"
B17: OFF, COLUMNATE: USE LEADING SPACES AND ZEROES SO THAT
TTME AND DATE PRINTOUT IS CONSTANT-WIDTH REGARDLESS OF THE
PARTICULAR DATE AND TIME (NOTE: FULL MONTH AND WEEKDAY TEXTS
ARE NOT COLUMNATED).
ON, DON'T COLUMNATE.
NOTE: COLUMNATION WILL GENERALLY BE DESIRED IF THE PRINTOUT
IS PART OF A TABLE, BUT NO COLUMNATION PRODUCES A
SLIGHTLY BETTER LOOKING PRINTOUT WHEN PART OF A SENTENCE.
FOR CONVENIENCE, -1 IN 3 IS TAKEN AS EQUIVALENT TO 336001000000,
WHICH PRODUCES, FOR EXAMPLE, FRIDAY, APRIL 13, 1970 1:06:03.
EXAMPLES:
CONTENTS OF 3 TYPICAL TEXT
0 3-APR-70 1:06:03
202201000000 FRI 3 APR 70 1:06
336321000000 FRIDAY, APRIL 3, 1970 1:06AM-EST
041041000000 3/4/70 106:03
041040000000 3/04/70 106:03
ODTIM ERROR MNEMONICS:
STIMEX: SYSTEM HAS NO DATE AND TIME
TIMEX1: ILLEGAL TIME (GREATER THAN 24 HOURS)
ODCNV ERRORS (LIST THEM ALL HERE)
ODTNC ERRORS
FILE ERRORS
DESXN ERRORS
>
;NOTE: JSYS'S USING STRING I/O CANNOT BE NESTED BECAUSE STRING
;POINTER WOULD ALWAYS REFER TO MONITOR ADDR SPACE EVEN IF OUTER JSYS
;CALLED FROM USER SPACE.
;HENCE SUBROUTINE ENTRIES ARE USED FOR ODTNC AND IDTNC WHEN USED
;IN ODTIM AND IDTIM, AND SUBROUTINE ENTRIES ARE ALSO PROVIDED
;TO ODTIM AND IDTIM FOR USE ELSEWHERE IN THE MONITOR.
;ODTIM JSYS
.ODTIM: MCENT ;BECOME SLOW, ETC.
CALL ODTIMS ;ODTIM SUBROUTINE
MRETNG ;RETURN TO CALLER
;ODTIM SUBROUTINE, FOR ODTIM JSYS
; AND POSSIBLE OTHER FUTURE USES IN MONITOR INVOLVING STRING
; IN USER SPACE.
;TAKES: CALLER'S A: DESTINATION
; ACTUAL B: DATE & TIME OR -1
; ACTUAL C: FORMAT OPTION FLAGS
;RETURNS +1: WITH CALLERS A UPDATED (IF STRING POINTER)
;CLOBBERS MOST OR ALL OF AC'S B-DD.
ODTIMS: PUSH P,C ;SAVE FORMAT OPTION FLAGS
SETZ D, ;DEFUALT ZONE & DAYLIGHT STUFF
ODCNV ;CONVERT INTERNAL TO LOCAL DATE & TIME
POP P,F ;GET FORMAT OPTION FLAGS BACK INTO F
CALL ODTNCS ;SUBR ENTRY TO ODCNV JSYS (BELOW)
;CONVERTS LOCAL DATE & TIME TO STRING
RET ;RETURN
REPEAT 0, <
IDTIM
INPUT DATE AND TIME
CONVERTS TEXT TO INTERNAL DATE AND TIME
TAKES: 1: TENEX SOURCE DESIGNATOR
2: FORMAT OPTION FLAGS, DESCRIBED BELOW, 0 FOR NORMAL CASE
RETURNS: +1: FAIL, ERROR NUMBER IN 2,
UPDATED STRING PTR (IF PERTINENT) IN 1
+2: SUCCESS, 1: UPDATED STRING PTR (IF PERTINENT)
2: LH: DATE IN SYSTEM INTERNAL FORMAT (GREENWICH)
RH: TIME IN SYSTEM INTERNAL FORMAT
(GREENWICH MEAN TIME)
IDTIM DOES NOT ADMIT OF DOING CONVERSIONS FOR OTHER THAN THE
LOCAL TIME ZONE OR FOR DAYLIGHT SAVINGS TIME IF APPROPRIATE, EXCEPT IF
THE INPUT STRING CONTAINS A TIME ZONE CODE. HOWEVER, THE CALLER MAY
ADD OR SUBTRACT HOURS TO ADJUST TO OTHER TIME ZONES; HE MAY
DETERMINE THE LOCAL TIME ZONE USING "ODCNV" (BELOW).
IDTIM DOES NOT ADMIT OF INPUTTING EITHER THE DATE OR THE TIME ALONE.
SEE IDTNC, BELOW, FOR THIS.
IDTIM FORMAT OPTIONS (AC 2):
B1: ON, DISALLOW NUMERIC MONTH IN INPUT AND IGNORE B2-B3
B2: OFF, IF MONTH IS NUMERIC, AS IN "1/2/70", CONSIDER
THE FIRST NUMBER TO BE THE MONTH
ON, CONSIDER THE SECOND NUMBER TO BE THE MONTH. IE "1/2/70"
MEANS 1 FEB NOT JAN 2, AS IS CUSTOMARY IN ENGLAND.
B3: OFF, IF AN INVALID DATE CAN BE INTERPRETED SUCESSFULLY BY
ASSUMING MONTH AND DAY ARE IN OPPOSITE ORDER THAN
THAT SPECIFIED BY B2, INTERPRET IT THUS.
THIS WOULD APPLY, FOR EXAMPLE, TO "31/1/70" WITH B2 OFF.
ON, GIVE AN ERROR RETURN FOR SUCH DATES.
B7 AND B8 GOVERN INCLUSION OF SECONDS (PRECEDED BY COLON)
IN TIME.
BOTH OFF, SECONDS ARE OPTIONAL.
B7 ON, SECONDS ILLEGAL.
B8 ON, SECONDS MANDATORY.
B9 AND B10 GOVERN USE OF COLON BETWEEN HOURS AND MINUTES.
BOTH OFF, OPTIONAL
B9 ON, ILLEGAL.
B10 ON, MANDATORY.
B11 AND B12: WHEN BITS 7 THRU 10 ARE ALL OFF, THESE
BITS DETERMINE WHETHER A TIME WITH ONE COLON IS
INTERPRETED AS HOURS AND MINUTES OR HOURS, MINUTES,
AND SECONDS WITH NO COLON BETWEEN THE FORMER.
BOTH OFF, TAKE AS HH:MM IF FIRST FIELD IS SMALL ENOUGH,
ELSE AS HHMM:SS.
B11 ON, ALWAYS TAKE AS HHMM:SS.
B12 ON, ALWAYS TAKE AS HH:MM (GIVING AN ERROR IF
FIRST FIELD IS TOO BIG). THIS DIFFERS FROM
B7 ON IN THAT SECONDS CAN BE INCLUDED IF
PRECEDED BY A SECOND COLON.
B14: ON TO DISALLOW 24-HOUR TIME AND MAKE AM-PM MANDATORY
B15: ON TO DISALLOW AM-PM
B16: ON TO DISALLOW TIME ZONE
IDTIM ERROR MNEMONICS
IDTNC ERRORS
IDCNV ERRORS
FILE ERRORS
DESXN ERRORS
>
;IDTIM JSYS
.IDTIM: MCENT
CALL IDTIMS ;IDTIM SUBROUTINE
JRST [ UMOVEM B,B ;ERROR. RETURN CODE IN B
MOVE A,B ;GET ERROR CODE IN A
EMRETN()] ;GIVE +1 ERROR RETURN TO CALLER
UMOVEM B,B ;RETURN INTERNAL DATE & TIME IN B
SMRETN ;RETURN +2
;IDTIM SUBROUTINE, FOR IDTIM JSYS AND POSSIBLE OTHER USES
; (SEE NOTES WITH ODTIM)
;TAKES: CALLERS A: SOURCE
; ACTUAL B: FORMAT OPTION FLAGS
;RETURNS +1: ERROR CODE IN ACTUAL B, CALLERS A UPDATED
; +2: DATE & TIME IN ACTUAL B, CALLERS A UPDATED
;CLOBBERS C-DD.
IDTIMS: CALL IDTNCS ;SUBR ENTRY TO IDCNV JSYS (BELOW)
;INPUTS DATE & TIME AND RETURNS AS LOCAL NUMBERS
RET ;ERROR. # IN B.
IDCNV ;CONVERT LOCAL TO INTERNAL
RET ;ERROR, # IN B.
AOS (P)
RET
;ODTNC
; OUTPUT DATE AND/OR TIME WITHOUT CONVERSION FROM INTERNAL
;A SUBSET OF ODTIM, USED INTERNALLY BY ODTIM.
;TAKES: 1: TENEX DESTINATION DESIGNATOR
; 2: LH: REAL YEAR
; RH: MONTH (JANUARY=0)
; 3: LH: DAY OF MONTH
; RH: DAY OF WEEK IF PRINTOUT THEREOF REQUESTED
; 4: LH: NEEDED ONLY IF TIME ZONE PRINTOUT REQUESTED:
; B1: ON FOR DAYLIGHT SAVINGS
; B12-17: TIME ZONE
; RH: LOCAL TIME (SECONDS SINCE MIDNITE)
; 5: FORMAT OPTION FLAGS, SAME AS FOR ODTIM (ABOVE).
; NOTE: THE ONLY TIME ZONES WHICH CAN BE PRINTED (FLAG B13)
; ARE THOSE IN THE USA AND GREENWICH.
;RETURNS +1 WITH UPDATED STRING POINTER (IF PERTINENT) IN 1.
;TRAPS ON ERRORS.
;ERROR MNEMONICS
;DATEX1: ILLEGAL YEAR
;DATEX2: MONTH TOO LARGE
;DATEX3: DAY OF MONTH TOO LARGE
;DATEX4: DAY OF WEEK TOO LARGE
;ZONEX1: ILLEGAL TIME ZONE VALUE (NOT BETWEEN -12 AND 12)
;ODTNX1: UNPRINTABLE TIME ZONE
;FILE ERRORS
;DESXN ERRORS
;ODTNC JSYS
.ODTNC: MCENT
UMOVE F,E
CALL ODTNCS ;CALL ODTNC SUBROUTINE (NEXT IN LISTING)
MRETNG ;GIVE SUCCESSFUL RETURN
;ODTNCS
;ODTNC SUBROUTINE FOR ODTNC AND ODTIM JSYS'S
;CALL: ALL AC'S ARE ACTUAL EXCEPT THOSE NOTED AS "CALLER" WHICH ARE
; USER IF LAST JSYS WAS FROM USER SPACE.
;TAKES: CALLER A: DESTINATION
; B: YEAR,,MONTH
; C: MONTHDAY,,WEEKDAY
; D: TIME STUFF
; F: FORMAT OPTION FLAGS
;RETURNS +1: ON SUCCESS WITH CALLER A UPDATED,
; B-E,G,AA,BB,DD CLOBBERED
;TRAPS ON ERRORS
;INTERNAL AC USE
; D,E,AA: ARGS FROM B,C,D
; BB: LOCAL TIME FROM RH D, LH 0.
ODTNCS: SE1CAL
MOVE DD,P ;SAVE PD LEVEL TO RESTORE BEFORE ERROR RETURN
CAMN F,[-1]
HRLZI F,336001 ; DEFAULT FORMAT FOR -1
MOVE AA,D ;TIME STUFF TO AA
TLZ AA,B3 ;DISALLOW JULIAN FORMAT
MOVEI BB,(D) ;TIME ONLY, WITH LH 0, TO BB
CALL CKYMDT ;CHECK MOST ARGUMENTS. THIS SUBR IS WITH
;"IDCNV" BELOW. USES B,C,AA.
JRST ODTNCE ;BAD ARGUMENT. ERROR CODE IN B.
MOVE D,B ;LOCAL YEAR,,LOCAL MONTH TO D.
MOVE E,C ;LOCAL DAY OF MONTH,,DAY OF WEEK TO E.
MOVEI G,^D10 ;SET G FOR USE IN C FOR MOST NOUTS: DECIMAL,
TLNN F,B17 ;COLUMNATION SUPPRESSED?
HRLI G,B2+2 ;NO, 2 COLUMNS, LEADING SPACE.
TLNE F,B0 ;ARE WE GOING TO PRINT DATE?
JRST OTT1 ;NO, DATE SUPPRESSION REQUESTED.
;ODTNCS...
;DATE
TLNN F,B1
JRST ODB2
;DAY OF WEEK
HRRZ B,E
CAIL B,7
JRST [ MOVEI B,DATEX4 ;"DAY OF WEEK TOO LARGE"
JRST ODTNCE]
PUSH P,E ;SAVE E
HRRZS E ;GET RID OF HIGH ORDER BITS
HRROI B,[ASCIZ /Mon/
ASCIZ /Tue/
ASCIZ /Wed/
ASCIZ /Thu/
ASCIZ /Fri/
ASCIZ /Sat/
ASCIZ /Sun/](E)
TLNE F,B2 ;ON FOR VERBOSE
HRRO B,[[ASCIZ /Monday,/]
[ASCIZ /Tuesday,/]
[ASCIZ /Wednesday,/]
[ASCIZ /Thursday,/]
[ASCIZ /Friday,/]
[ASCIZ /Saturday,/]
[ASCIZ /Sunday,/] ] (E)
POP P,E ;RESTORE E
CALL SOUTA
MOVEI B," " ;ALWAYS A SPACE AFTER WEEKDAY
CALL BOUTA
;ODTNCS...
;DAY # IF BEFORE MONTH
ODB2: TLNE F,B6
JRST ODB3
HLRZ B,E
ADDI B,1 ;REAL DAY IS ARG +1.
MOVE C,G
CALL NOUTXX
;SEPERATOR
CALL ODTMSP ;DASH, SPACE, OR SLASH, DEPENDING ON FLAGS.
;MONTH
ODB3: TLNN F,B3
JRST ODB3A
;MONTH AS NUMBER
HRRZ B,D
ADDI B,1
MOVE C,G ;NOUT FORMAT
TLNN F,B6 ;IF DAY # WAS FIRST,
TLO C,B3 ;USE LEADING 0 NOT SPACE FOR MONTH
CALL NOUTXX ;MONTH
JRST ODB3B
;MONTH AS CONCISE OR VERBOSE TEXT
ODB3A: PUSH P,D ;SAVE D
HRRZS D ;GET RID OF HIGH ORDER BITS
HRROI B,[ASCIZ /Jan/
ASCIZ /Feb/
ASCIZ /Mar/
ASCIZ /Apr/
ASCIZ /May/
ASCIZ /Jun/
ASCIZ /Jul/
ASCIZ /Aug/
ASCIZ /Sep/
ASCIZ /Oct/
ASCIZ /Nov/
ASCIZ /Dec/ ] (D)
TLNE F,B4 ;ON FOR VERBOSE
HRRO B,[[ASCIZ /January/]
[ASCIZ /February/]
[ASCIZ /March/]
[ASCIZ /April/]
[ASCIZ /May/]
[ASCIZ /June/]
[ASCIZ /July/]
[ASCIZ /August/]
[ASCIZ /September/]
[ASCIZ /October/]
[ASCIZ /November/]
[ASCIZ /December/] ] (D)
POP P,D ;RESTORE D
CALL SOUTA
;SEPERATOR
ODB3B: CALL ODTMSP ;DASH, SLASH, OR SPACE PER FLAGS
;ODTNCS...
;DAY OF MONTH IF AFTER MONTH
TLNN F,B6
JRST ODB5
HLRZ B,E
ADDI B,1
MOVE C,G
TLNE F,B3 ;IF MONTH WAS NUMBER,
TLO C,B3 ;USE LEADING 0 NOT SPACE
CALL NOUTXX
;SEPERATOR: FIRST A COMMA IF MONTH WAS VERBOSE TEXT
TLNN F,B3
TLNN F,B4
JRST .+3
MOVEI B,","
CALL BOUTA
CALL ODTMSP ;DASH, SLASH, OR SPACE PER FLAGS
;YEAR
ODB5: HLRZ B,D
TLNE F,B5
JRST ODB5A ;VERBOSE YEAR REQUESTED
IDIVI B,^D100 ;SEPERATE CENTURY AND YEAR WITHIN CENTURY
EXCH B,C ;CONCISE YEAR: LAST 2 DIGITS ONLY
CAIE C,^D19
HLRZ B,D ;MAKE YEAR ALWAYS VERBOSE IF NOT 19XX
ODB5A: MOVE C,[1B2+1B3+2B17+^D10] ;NOUT FORMAT: 2 COLS, LEADING 0S.
CAIL B,^D100
HRLI C,B2+B3+4 ;BUT USE 4 COLS IF VERBOSE
CALL NOUTXX
;SPACE BETWEEN DATE AND TIME,
;NOT PRINTED IF EITHER IS SUPPRESSED.
TLNE F,B9
JRST OTT1
MOVEI B," "
CALL BOUTA
;ODTNCS...
OTT1: TLNE F,B9
JRST ODT8 ;TIME SUPPRESSED
;TIME
MOVEI D,(BB) ;MASK RH: LOCAL TIME IN MIUTES SINCE MIDNITE
IDIVI D,^D3600
MOVE B,D
TLNN F,B11 ;PRINTING 12-HOUR TIME?
JRST OTT2 ;NO
CAIGE B,1 ;12-HOUR PRINTOUT IS ALWAYS BETWEEN 1:00:00
ADDI B,^D12 ;...AND 12:59:59. SO ADD 12 IF BEFORE 1:00:00
CAILE B,^D12
SUBI B,^D12 ;SUBTRACT 12 HOURS IF AFTER 12:59:59
OTT2: MOVE C,G ;NOUT FORMAT SET UP AT ENTRY TO ODTIM.
TLNN F,(1B11) ;PRINTING AM/PM?
TLO C,(1B2+1B3+2B17) ;NO, USE LEADING 0 ON HOURS
CALL NOUTXX ;PRINT HOURS
MOVEI B,":"
TLNN F,B12 ;COLON REQUESTED BETWEEN HOURS AND MINUTES?
CALL BOUTA ;YES
MOVE D,E
IDIVI D,^D60
MOVE B,D
TLO C,B2+B3+2 ;ALWAYS LEADING 0 ON MINUTE AND SECONDS
CALL NOUTXX ;PRINT MINUTES
TLNE F,B10
JRST OTT4 ;SECONDS SUPPRESSED
MOVEI B,":"
CALL BOUTA ;SECONDS ARE ALWAYS PRECEDED BY COLON
MOVE B,E
CALL NOUTXX ;SECONDS
;ODTNCS...
OTT4: TLNN F,B11 ;12-HOUR TIME REQUESTED?
JRST OTT5 ;NO
HRROI B,[ASCIZ /AM/] ;YES, PRINT AM, PM, N, OR M.
CAIL BB,^D<12*3600>
HRROI B,[ASCIZ /PM/]
CAIN BB,^D<12*3600>
HRROI B,[ASCIZ /N/] ;"N" FOR NOON
CAIN BB,0
HRROI B,[ASCIZ /M/] ;"M" FOR MIDNITE
CALL SOUTA
OTT5: TLNN F,B13 ;PRINTING TIME ZONE REQUESTED?
JRST OTT6 ;NO
LDB E,[POINT 6,AA,17] ;TIME ZONE
JUMPE E,[HRROI B,[ASCIZ /-GMT/]
TLNE AA,B1 ;B1 OF ARG FROM D ON FOR DAYLIGHT
HRROI B,[ASCIZ /-GDT/] ;"GREENWICH DAYLIGHT TIME" !?
JRST OTT5A]
CAIG E,^D11 ;IS TIME ZONE IN RANGE FOR WHICH WE HAVE TEXTS?
CAIGE E,^D4
JRST [ MOVEI B,ODTNX1 ;"UNPRINTABLE TIME ZONE"
JRST ODTNCE]
HRROI B,[ASCIZ /-AST/ ;ATLANTIC
ASCIZ /-EST/ ;EASTERN
ASCIZ /-CST/ ;CENTRAL
ASCIZ /-MST/ ;MOUNTAIN
ASCIZ /-PST/ ;PACIFIC
ASCIZ /-YST/ ;YUKON
ASCIZ /-HST/ ;ALASKA-HAWAII
ASCIZ /-BST/]-4(E) ;BERING
TLNE AA,B1 ;DAYLIGHT SAVINGS IN EFFECT FOR THIS DATE?
HRROI B,[ASCIZ /-ADT/ ;ATLANTIC
ASCIZ /-EDT/ ;EASTERN
ASCIZ /-CDT/ ;CENTRAL
ASCIZ /-MDT/ ;MOUNTAIN
ASCIZ /-PDT/ ;PACIFIC
ASCIZ /-YDT/ ;YUKON
ASCIZ /-HDT/ ;ALASKA-HAWAII
ASCIZ /-BDT/]-4(E) ;BERING
OTT5A: CALL SOUTA
OTT6: TLNE F,B11 ;12-HOUR TIME REQUESTED?
TLNE F,B17 ;COLUMNATION SUPPRESSED?
JRST OTT9 ;NO OR YES
;IF N FOR NOON OR M FOR MIDNITE PRINTED WITH COLUMNATION,
;PRINT SPACE AFTER TIME ZONE, BECAUSE SPACE BEFORE TIME ZONE
;IS A FORMAT THAT CAN'T BE TYPED INTO "IDTIM".
MOVEI B," "
CAIE BB,^D<12*3600>
CAIN BB,0
CALL BOUTA
OTT9:
;ODTNCS...
;EXIT
ODT8: RET
ODTNCC: MOVE B,C ;HERE WHEN ERROR CODE IS IN C, AS AFTER "NOUT"
;ODTNC ERROR RETURN. ERROR CODE IN B.
ODTNCE: MOVEM B,LSTERR ;SAVE ERROR CODE IN PSB FOR "GETER"
MOVE P,DD ;CLEAR PD
JRST ITRAP
;SUBROUTINE TO OUTPUT APPROPRIATE SEPERATOR PER FLAGS 7 AND 8.
ODTMSP: MOVEI B,"-"
TLNE F,B7
MOVEI B," "
TLNE F,B8
MOVEI B,"/"
CALLRET BOUTA
;SOUTA
;MONITOR TO CALLER'S ADDRESS SPACE STRING OUTPUT SUBROUTINE
;FOR ODTNCS
;B POINTS TO SOURCE STRING; LH -1 => 440700
;CALLERS A IS DESTINATION. BOTH ARE UPDATED.
SOUTA: PUSH P,C
HLRZ C,B
CAIN C,-1
HRLI B,<POINT 7,0,-1>B53
MOVE C,B
SOUTA1: ILDB B,C
JUMPE B,[MOVE B,C
POP P,C
RET]
CALL BOUTA
JRST SOUTA1
REPEAT 0, <
IDTNC
INPUT DATE AND/OR TIME WITHOUT CONVERSION TO INTERNAL
THIS JSYS IS A SUBSET OF IDTIM AND WILL ONLY BE OF INTEREST TO THOSE
WHO WISH TO INPUT THE DATE AND TIME WITHOUT CONVERTING TO
INTERNAL, OR WHO WISH TO INPUT THE TWO QUANTITIES SEPERATELY, EG
BECAUSE OF INTERVENING TYPEOUT. (IDTIM CANNOT iNPUT EITHER
ALONE BECAUSE IT IS IMPOSSIBLE TO CONVERT ONE TO INTERNAL WITHOUT
THE OTHER.) IDTNC RETURNS VALUES SUITABLE FOR USE AS ARGUMENTS TO
IDCNV. IDTNC IS USED INTERNALLY BY IDTIM.
TAKES: 1: TENEX SOURCE DESIGNATOR
2: FORMAT OPTION FLAGS, DESCRIBED BELOW
RETURNS: +1: FAILURE, ERROR CODE IN 1,
UPDATED STRING POINTER (IF PERTINENT) IN 4
+2: SUCCESS, VALUES IN ACCUMULATORS:
1: UPDATED STRING POINTER IF PERTINENT
IF DATE INPUT WAS NOT SUPPRESSED:
2: LH: REAL YEAR
RH: MONTH (JANUARY=0)
3: LH: DAY OF MONTH (FIRST DAY=0)
RH: DAY OF WEEK (MONDAY=0)
IF TIME INPUT WAS NOT SUPPRESSED:
4: RH: TIME AS SECONDS SINCE MIDNIGHT
LH: B0: OFF UNLESS A TIME ZONE WAS INPUT
B1: ON IF A DAYLIGHT SAVING TIME ZONE
(EG EDT) WAS INPUT.
B2: OFF UNLESS A TIME ZONE WAS INPUT
B12-17: TIME ZONE, IF ONE WAS INPUT, ELSE
LOCAL TIME ZONE.
(SEE DESCRIPTION OF TIME ZONeS UNDER
IDCNV)
(REDUNDANT BITS B0 AND B2 ARE FOR
COMPATIBILITY WITH ODCNV)
IDTNC FORMAT OPTION FLAGS (AC 2):
ALL OF THOSE DESCRIBED ABOVE UNDER IDTIM APPLY, AND ALSO:
B0 ON, DON'T INPUT DATE, IGNORE B1-B3
B6 ON, DON'T INPUt TIME, IGNORE B8-B16
IDTNC ERROR MNEMONICS:
DILFX1: ILLEGAL FORMAT FOR DATE
TILFX1: ILLEGAL FORMAT FOR TIME
NOTE: IDTNC DOES NOT DETECT CERTAIN ERRORS IN DATE INPUT, SUCH AS
DAY 31 OF A 30-DAY MONTH. SUCH ERRORS ARE DETECTED IN IDCNV.
>
;IDTNC JSYS
.IDTNC: MCENT
CALL IDTNCS ;IDTNC SUBROUTINE, NEXT
JRST [ UMOVEM B,B ;ERROR, RETURN CODE IN CALLER'S B.
MOVE A,B ;GET ERROR CODE IN A
EMRETN()] ;GIVE +1 ERROR RETURN TO CALLER
UMOVEM B,B ;RETURN RESULTS
UMOVEM C,C
UMOVEM D,D
SMRETN ;GIVE SKIP RETURN
;IDTNCS
;IDTNC SUBROUTINE, FOR IDTIM AND IDTNC JSYS'S
;CALL SAME AS JSYS EXCEPT ALL AC'S ACTUAL EXCEPT A IS CALLER
; (IE CALLER OF JSYS THAT CALLS SUBROUTINE)
;CLOBBERS B-DD.
;IDTNC INTERNAL AC USE
; A: SOURCE DESIGNATOR
; B,C,D,E: TEMPS
; F: FLAGS
; G: LAST CHARACTER READ
; AA, BB, CC: WHAT WILL BE RETURNED IN B, C, D
; DD: SAVED P
;IDTNCS
IDTNCS: MOVE DD,P ;SAVE P: USED WHEN MAKING AN ERROR RETURN
MOVE F,B ;FLAGS REMAIN IN F THROUGHOUT
MOVEI G," " ;G CONTAINS CHARACTER: PRESET TO SPACE SO
;"GNSC" SUBR WILL READ FIRST CHARACTER
TLNE F,B0 ;ON TO SUPPRESS DATE INPUT
JRST ITN1 ;DATE INPUT SUPPRESSED
;INPUT DATE
CALL MONTH ;TRY INPUTTING ALPHA MONTH
JRST IDN2 ;NOT A LETTER, GO TRY NUMBER
;PROCESS REST OF DATE WHICH BEGINS WITH ALPHABETIC MONTH
CALL DNIN ;INPUT NUMBER FOR DAY OF MONTH -1 INTO B
HRL BB,B ;RETURN DAY OF MONTH IN LH C
CALL GNSC ;NON-SPACE CHARACTER
CAIN G,"," ;COMMA ALLOWED IN THIS CONTEXT ONLY
JRST [ CALL IDCHAR ;PASS THE COMMA. "YEAR" PASSES SPACES.
JRST .+2]
CALL IDSEP ;SEPERATING DASH OR SLASH AND SPACES
CALL YEAR ;INPUT YEAR
JRST IDN7
;DATE MUST BEGIN WITH A NUMBER
IDN2: CALL DNIN ;READ NUMBER: VALUE-1 TO B
HRL BB,B ;STORE VALUE IN DAY OF MONTH
CALL IDSEP ;SEPERATING DASH OR SLASH AND SPACES
CALL MONTH ;ALPHANUMERIC MONTH NEXT?
JRST IDN3 ;NO, GO TRY NUMBER
CALL YEAR ;INPUT YEAR
JRST IDN7
;IDTNCS...
;SECOND FIELD OF DATE MUST ALSO BE A NUMBER
IDN3: TLNE F,B1 ;NUMERIC MONTH ALLOWED?
JRST IDILF ;NO, "ILLEGAL FORMAT" ERROR
CALL DNIN ;GET SECOND NUMBER -1 INTO B.
HLRZ C,BB ;FIRST NUMBER TO C
TLNE F,B2 ;IS FIRST NUMBER SUPPOSED TO BE MONTH?
EXCH C,B ;NO, SWAP. MONTH TO C, DAY TO B.
CAIG C,^D11 ;IS "MONTH" TOO LARGE
JRST IDN4 ;OK
CAIG B,^D11 ;IS OTHER NUMBER ALSO TO LARGE TO BE MONTH?
TLNE F,B3 ;WILL CALLER LET US SWAP THEM?
JRST IDILF ;YES OR NO, ERROR.
EXCH B,C
IDN4: HRR AA,C ;RETURN MONTH IN RH B
HRL BB,B ;RETURN DAY IN RH C
CALL IDSEP ;SEPERATING SPACES, DASH OR SLASH, SPACES.
CALL YEAR ;GET YEAR
IDN7: TLNE F,B6 ;ON TO SUPPRESS TIME INPUT
JRST IDTNC8 ;TIME INPUT SUPPRESSED
;SEPERATOR BETWEEN DATE AND TIME: ONE TAB, ANY NUMBER OF SPACES.
CALL GNSC
CAIN G,11 ;ASCII TAB
CALL IDCHAR
;IDTNCS...
;INPUT TIME
ITN1: TLNE F,B6
JRST IDTNC8 ;BOTH TIME AND DATE SUPPRESSED, JSYS IS NOP.
SETZ E, ;ZERO FOR SECONDS IF OMITTED
CALL IDNIN ;PASS SPACES, READ NUMBER
JRST ITILF ;NO NUMBER, "ILLEGAL FORMAT FOR TIME" ERROR
PUSH P,B
;THIS NUMBER MAY BE HOURS OR HOURS AND MINUTES.
CAILE B,^D2400 ;BUT CAN NEVER BE GREATER THAN 2400.
JRST ITILF
;MAKE SURE MINUTES PART OK (THIS ALWAYS SUCCEEDS IF ITS
;JUST HOURS)
IDIVI B,^D100
CAIL C,^D60
JRST ITILF
;DON'T CHECK HOURS PART YET - ITS MAX VALUE DEPENDS ON
;MANY THINGS INCLUDING FOLLOWING INPUT, AND THIS FIELD
;(ONLY) CAN BE CHECKED AFTER CASES CONVERGE AND VALUES ARE
;COMBINED.
POP P,C ;FIRST VALUE IN C
CAIE G,":" ;COLON AFTER NUMBER?
JRST ITN4 ;NO, ONLY ONE NUMBER IN INPUT.
;COLON SEEN IN TIME, THERE WILL BE AT LEAST TWO NUMBERS
TLNE F,B7 ;SECONDS ILLEGAL?
TLNN F,B9 ;COLON ILLEGAL BETWEEN HRS AND MINS ALSO?
JRST .+2
JRST ITILF ;BOTH TRUE, NO COLONS ALLOWED
CALL TNIN ;PASS SPACES, READ NUMBER <60.
MOVE D,B ;VALUE OF SECOND NUMBER IN D
CAIE G,":"
JRST ITN5 ;TIME CONSISTS OF TWO NUMBERS
;SECOND COLON SEEN, THERE WILL BE THREE NUMBERS
TLNN F,B7 ;SECONDS ILLEGAL?
TLNE F,B9 ;COLON ALLOWED BETWEEN HOURS AND MINS?
JRST ITILF ;TWO COLONS NOT ALLOWED
CALL TNIN ;PASS SPACES, READ THIRD NUMBER
MOVE E,B ;THIRD VALUE IN E
JRST ITN7 ;GO COMBINE VALUES
;ONLY ONE NUMBER IN TIME
ITN4: TLNN F,B10 ;COLON MANDATORY BETWEEN HOURS AND MINS?
TLNE F,B8 ;SEcONDS MANDATORY?
JRST ITILF
JRST ITN5B ;GO SEPERATE HOURS AND MINUTES.
;SECONDS ALREADY ZEROED.
;IDTNCS...
;TWO NUMBERS IN TIME
ITN5: TLNE F,B8 ;SECONDS REQUIRED?
TLNN F,B10 ;COLON REQUIRED BETWEEN HOURS AND MINUTES?
JRST .+2
JRST ITILF ;YES AND YES, TWO COLONS REQUIRED.
TLNN F,B9 ;COLON ILLEGAL?
TLNE F,B8 ;SECONDS REQUIRED?
JRST ITN5A ;YES OR YES, TAKE IT AS HHMM:SS
TLNN F,B7 ;SECONDS ILLEGAL?
TLNE F,B10+B12 ;COLON REQ'D OR "TAKE AS HH:MM IF B7-10 OFF"?
JRST ITN7 ;YES, YES, OR YES, TAKE AS HH:MM
TLNE F,B11 ;"TAKE AS HHMM:SS IF B7-B10 OFF"?
JRST ITN5A ;YES. THIS TEST MUST BE AFTER B7-10!
;B7-B12 ALL OFF, TAKE AS HH:MM IF POSSIBLE, ELSE HHMM:SS.
;WE MUST SEE WHETHER AM-PM IS PRESENT TO KNOW MAXIMUM
;HOUR VALUE IN ORDER TO DECIDE WHETHER WE CAN TAKE IT AS
;HH:MM.
TLNE F,B14
JRST ITN58 ;24-HOUR TIME ILLEGAL, 12 HOURS.
TLNE F,B15
JRST ITN59 ;AM-PM ILLEGAL, 24 HOURS.
CAIG G,"Z"
CAIGE G,"A"
JRST ITN59 ;NO LETTER, NO AM-PM.
ITN58: CAILE C,^D12 ;AM-PM WILL BE PRESENT, MAX TIME 12:59.
JRST ITN5A ;HOURS TOO BIG, HHMM:SS.
;JRST ITN7 ;HH:MM. FALLING THRU WILL GET TO ITN7.
ITN59: CAIN C,^D24 ;NO AM-PM, MAX TIME 24:00
JUMPE D,ITN7 ;HOURS=24, HH:MM IF MINS =0.
CAIGE C,^D24
JRST ITN7 ;FIRST NUMBER SMALL ENOUGH FOR HH:MM.
;TWO NUMBERS IN TIME, TO BE TAKEN AS HHMM:SS
ITN5A: MOVE E,D ;SECONDS
ITN5B: IDIVI C,^D100 ;SEPERATE HOURS AND MINUTES.
;COMBINE HOURS, MINUTES, SECONDS INTO C.
ITN7: IMULI C,^D60
ADD C,D
IMULI C,^D60
ADD C,E
CAIL C,^D<24*3600> ;MAX VALUE IN ANY CASE
JRST ITILF
TLNE F,B14 ;24-HOUR TIME DISALLOWED?
JRST ITN8 ;YES, AM-PM MANDATORY.
TLNE F,B15 ;AM-PM ALLOWED?
JRST ITN9 ;NO
CAIG G,"Z" ;AM-PM OPTIONAL. LETTER NEXT?
CAIGE G,"A" ;..
JRST ITN9 ;NO
;IDTNCS...
;INPUT AM-PM AND MAKE APPROPRIATE CHECKS AND ADJUSTMENTS TO YIELD
;24-HOUR TIME.
;THE TIMES PRECEDING AM-PM MUST BE BETWEEN 1:00:00 AND 12:59:59.
ITN8: CAIG C,^D<<12*60+59>*60+59>
CAIA C,^D3600 ;NO, ALSO ALLOW 0:00:00 TO 0:59:59
JRST ITILF
CALL AMPM ;READ STRING, SEARCH TABLE, RETURN +1 - +4.
JRST [ CAIL C,^D<12*3600> ;+1: AM
SUBI C,^D<12*3600> ;12AM=MIDNITE, AFTER 12=MORNING
JRST .+4]
JRST [ CAIGE C,^D<12*3600> ;+2: PM
ADDI C,^D<12*3600> ;BEFORE 12=AFTERNOON, 12PM=NOON
JRST .+3]
JRST [ CAIE C,^D<12*3600> ;+3: NOON
JRST ITILF ;ONLY 12 NOON ALLOWED
JRST .+2]
JRST [ CAIE C,^D<12*3600> ;+4: MIDNITE
JRST ITILF
JRST .-2] ;GO ADD 12 HOURS
;ABOVE MANIPULATIONS CAN MAKE MIDNITE COME OUT 24:00:00
;AS OPPOSED TO 0:00:00. THE FOLLOWING FIXES THAT,
;AND ALSO CHANGES 24:00:00 (WHICH IS OK TO INPUT WITHOUT
;AM-PM) TO 0.
ITN9: HRR CC,C ;RETURN LOCAL TIME IN RH D.
SETZ C, ;IF NO TIME ZONE, RETURN LH D ZERO
;EXCEPT FOR LOCAL TIME ZONE (BELOW).
TLNE F,B16 ;TIME ZONE ALLOWED IN INPUT?
JRST ITN10
CAIE G,"-" ;"-" PRECEDES TIME ZONE
JRST ITN10 ;NO TIME ZONE
CALL IDCHAR ;NEXT CHARACTER
CAIG G,"Z" ;LETTER NEXT?
CAIGE G,"A" ;..
JRST ITN10 ;NO, NO TIME ZONE (EXTRA CHAR READ)
CALL ZONE ;INPUT STRING, SEARCH TIME ZONES TABLE,
;RETURN THE RIGHT THING IN C (INCL B2 ON).
;(NOTE THAT "DAYL" OR "STD" CAN BE INPUT,
;WHICH LEAVES B2 OFF.)
ITN10: MOVE B,TIMZON ;LOCAL TIME ZONE
TRNN C,B2 ;UNLESS A TIME ZONE WAS INPUT,
DPB B,[POINT 6,C,35] ;RETURN LOCAL TIME ZONE IN C B12-17
HRL CC,C ;RETURN THIS STUFF IN LH D.
;IDTNCS...
;NOW DONE DECODING DATE AND TIME.
;CHECK TERMINATOR: IT SHOULD BE NON-ALPHANUMERIC
IDTNC8: CAIG G,"Z"
CAIGE G,"A"
JRST [ CAIG G,"9"
CAIGE G,"0"
JRST .+2
JRST .+1]
JRST [ TLNN F,B6
JRST ITILF
JRST IDILF]
;GIVE GOOD RETURN
TLNE F,B0 ;ON TO SUPPRESS DATE INPUT
JRST IDTN11 ;DATE INPUT SUPPRESSED
MOVE B,AA ;B/YEAR,,MONTH
HLLZ C,BB ;C/DAY OF MONTH,,0
MOVE D,CC ;FIRST ASSUME USER TYPED IN A TIME
TXNE F,IT%NTI ;SKIP IF WE'RE RIGHT
HRRI D,1 ;NO TIME INPUT, SO PICK ONE
IDCNV ;GET INTERNAL DATE AND TIME
RETBAD (,<MOVE B,A>) ;RETBAD (,<MOVE B,A>)URN WITH ERROR (THIS CAN OCCUR WITH BAD DATE TO IDTIM ETC.)
ODCNV ;THIS IS JUST TO GET DAY OF THE WEEK
AOS (P) ;SKIP
RET ;RETURN
IDTN11: MOVE B,AA ;PUT RESULTS IN PROPER AC'S
MOVE C,BB
MOVE D,CC
AOS (P) ;SKIP
RET ;RETURN
;ERROR RETURN STUFF
IDILF: SKIPA B,[DILFX1] ;"ILLEGAL FORMAT FOR DATE"
ITILF: MOVEI B,TILFX1 ;"ILLEGAL FORMAT FOR TIME"
;COME HERE WITH ERROR CODE IN B
MOVE P,DD ;RESTORE P (CAN GET HERE FROM SUBRS WITH AN
;INDEFINITE NUMBER OF EXTRANEOUS WORDS IN PD).
MOVEM B,LSTERR ;SAVE ERR CODE IN PSB FOR "GETER", ETC
SE1CAL ;ENTER SECTION 1 FOR RETURN
RET ;RETURN +1 WITH ERROR CODE IN ACTUAL B
;SUBROUTINES FOR IDTNCS
;INPUT ALPHANUMERIC MONTH
;ACCEPTS ANY "UNIQUE SUBSTRING" OF A MONTH NAME.
;IGNORES PRECEDING SPACES AND (ON R2) PASSES FOLLOWING SEPERATING CHARS.
;R1: NEXT NON-SPACE CHAR NOT A LETTER.
;R2: SUCCESS, MONTH # IN RH AA.
;CLOBBERSS B,C,D,E.
MONTH: CALL GNSC ;GET NON-SPACE CHARACTER
CAIG G,"Z"
CAIGE G,"A"
RET ;NO LETTER: R1
CALL IDSTR ;READ STRING. BUFFERS IT IN PD. PUTS OLD
;P VALUE IN E.
XMOVEI C,MONTHS ;TABLE ADDRESS
CALL FSYM ;SEARCH TABLE
JRST IDILF ;NOT FOUND, ILLEGAL DATE FORMAT
HRR AA,C ;RETURN MONTH
MOVE P,E ;DEALLOCATE STRING SPACE IN PD
AOS (P) ;SKIP
JRST IDSEP ;RETURN VIA SUBR TO PASS SEPERATING CHARS
;MACRO FOR TABLES OF MONTHS, AM-PM'S, TIME ZONES
DEFINE TM (TEXT,VALUE)
<XWD VALUE,[ASCIZ /TEXT/]>
;MONTH TEXTS TABLE, IN FSYSM FORMAT
MONTHS: ^D12 ;WORD 0 OF TABLES IS NUMBER OF ENTRIES
TM APRIL,3
TM AUGUST,7
TM DECEMBER,^D11
TM FEBRUARY,1
TM JANUARY,0
TM JULY,6
TM JUNE,5
TM MARCH,2
TM MAY,4
TM NOVEMBER,^D10
TM OCTOBER,^D9
TM SEPTEMBER,^D8
;IDTNCS SUBROUTINES...
;SUBROUTINE TO INPUT YEAR
;RETURNS YEAR IN LH AA
YEAR: CALL IDNIN ;INPUT NUMBER
JRST IDILF ;NONE, ILLEGAL DATE FORMAT ERROR
CAIGE B,^D100
ADDI B,^D1900
CAIL B,^D1858
CAILE B,^D2576
JRST IDILF ;OUT OF RANGE, "ILLEGAL FORMAT"
HRL AA,B
RET
;AM-PM LOOKUP ROUTINE. FIRST CHARACTER MUST BE IN G.
;ACCEPTS ONE OF MORE LETTERS OF -- AND RETURNS + --
; AM 1
; PM 2
; NOON 3
; MIDNIGHT 4
;CLOBBERS B,D,E
;ONLY CALLED IN ONE PLACE; CODED AS A SUBR TO FACILITATE CHANGE SUCH
;AS SUBSTITUTION OF A SIMPLER SYMBOL TABLE SEARCH.
AMPM: PUSH P,C
CALL IDSTR
XMOVEI C,AMPMS
CALL FSYM
JRST ITILF
MOVE P,E
ADDM C,-1(P) ;INCREMENT RETURN BY VALUE FROM TABLE
POP P,C
RET
AMPMS: 4
TM AM,0
TM MIDNIGHT,3
TM NOON,2
TM PM,1
;IDTNCS SUBROUTINES...
;TIME ZONE LOOKUP SUBROUTINE. FIRST CHAR MUST BE IN G.
;ACCEPTS ANY UNIQUE SUBSTRING OF ANY OF THE US STANDARD OR
;DAYLIGHT TIME ZONE ABBREVIATIONS, ALSO "STANDARD" AND "DAYLIGHT".
;RETURNS IN RH C WHAT IDTNC SHOULD RETURN IN LH D,
;EXCEPT THAT LOCAL TIME ZONE ISN'T FILLED IN FOR "DAY" OR "STD".
;CLOBBERS B,D,E.
;LIKE "AMPM", THIS SUBR IS ONLY USED IN ONE PLACE.
ZONE: CALL IDSTR
XMOVEI C,ZONES
CALL FSYM
JRST ITILF
MOVE P,E
RET
ZONES: EXP ZONSIZ
TM ADT,B0+B1+B2+4 ;ATLANTIC DAYLIGHT TIME
TM AST,B0+B2+4 ;ATLANTIC STANDARD TIME
TM BDT,B0+B1+B2+^D11 ;BERING DAYLIGHT TIME
TM BST,B0+B2+^D11 ;BERING STANDARD TIME
TM CDT,B0+B1+B2+6 ;CENTRAL DAYLIGHT TIME
TM CST,B0+B2+6 ;CENTRAL STANDARD TIME
TM DAYLIGHT,B0+B1 ;LOCAL DAYLIGHT TIME
TM EDT,B0+B1+B2+5 ;EASTERN DAYLIGHT TIME
TM EST,B0+B2+5 ;EASTERN STANDARD TIME
TM GDT,B0+B1+B2+0 ;GREENWICH DAYLIGHT TIME
TM GMT,B0+B2+0 ;GREENWICH MEAN TIME
TM GST,B0+B2+0 ;GREENWICH STANDARD TIME
TM HDT,B0+B1+B2+^D10 ;ALASKA-HAWAII DAYLIGHT TIME
TM HST,B0+B2+^D10 ;ALASKA-HAWAII STANDARD TIME
TM MDT,B0+B1+B2+7 ;MOUNTAIN DAYLIGHT TIME
TM MST,B0+B2+7 ;MOUNTAIN STANDARD TIME
TM PDT,B0+B1+B2+^D8 ;PACIFIC DAYLIGHT TIME
TM PST,B0+B2+^D8 ;PACIFIC STANDARD TIME
TM ST,B0 ;"ST" OK FOR "STANDARD"
TM STANDARD,B0
TM STD,B0 ;"STD" OK FOR "STANDARD"
TM YDT,B0+B1+B2+^D9 ;YUKON DAYLIGHT TIME
TM YST,B0+B2+^D9 ;YUKON STANDARD TIME
ZONSIZ==.-ZONES
;IDTNCS SUBROUTINES...
;SUBROUTINE FOR "MONTH", "AMPM", AND "ZONE" TO READ A STRING OF LETTERS.
;FIRST CHARACTER MUST BE IN G. STORES IN ASCIZ FORM IN PUSHDOWN,
;RETURNING PREVIOUS P VALUE IN E AND STRING POINTER IN B.
;CLOBBERS C,D.
IDSTR: MOVE E,P ;SAVE PUSHDOWN LEVEL
SUB E,BHC+1 ;...BEFORE THIS ROUTINE WAS CALLED
HRRI C,1(P)
HRLI C,<POINT 7,0,-1>B53 ;FORM BYTE PTR INTO PUSHDOWN
MOVEI D,^D14 ;MAX LENGTH 3 WORDS
PUSH P,[0] ;ALLOCATE 3 WORD OF BUFFER SPACE, ALSO
PUSH P,[0] ;ZEROS REST OF LAST WORD
PUSH P,[0] ;(NEEDED FOR SEARCH ROUTINE "FSYM")
IDSTR2: IDPB G,C ;STORE CHARACTER
CALL IDCHAR
CAIG G,"Z"
CAIGE G,"A"
JRST IDSTR9 ;NON-LETTER ENDS STRING
SOJG D,IDSTR2 ;GO STORE CHARACTER
;STOP ANYWAY AT 14 CHARS. THE APPROPRIATE "ILLEGAL FORMAT"
;ERROR WILL HAPPEN IN CALLING ROUTINE BECUASE NOTHING
;14 CHARS LONG IS IN TABLES.
IDSTR9: HRRI B,2(E) ;RETURN BYTE PTR TO STRING IN B
HRLI B,<POINT 7,0,-1>B53
MOVE C,1(E) ;FETCH RETURN ADDR FROM PD
JRST (C) ;RETURN
;IDTNCS SUBROUTINES...
;TABLE SEARCH FOR "MONTH", "AMPM", "ZONE"
;TAKES IN B: POINTER TO LEFT ADJUSTED ASCIZ STRING
; C: POINTER TO TABLE OF THE FORM:
; WORD 0: N=NUMBER OF ENTRIES
; WORDS 1-N: LH: V=VALUE
; RH: POINTER TO ASCIZ STRING
; ENTRIES MUST BE IN ALPHABETICAL ORDER
;RETURNS +1: NO MATCH OR AMBIGUOUS
; +2: UNIQUE SUBSET OR EXACT MATCH, VALUE "V" IN RH C.
;AC USE
; A POINTS AT LAST ENTRY IN TABLE
; B POINTER WHICH IS INDEXED THRU INPUT TEXT
; C POINTER INTO TABLE
; D WORD OF INPUT TEXT
; E POINTER WHICH IS INDEXED THROUGH THE TEXT OF A TABLE ENTRY
; F WORD OF TEXT FROM TABLE ENTRY
; G "DELTA" - THE BINARY SEARCH INCREMENT
IFN E-D-1,<PRINTX FSYM WON'T WORK CAUSE E IS NOT D+1
>
;IDTNCS SUBROUTINE FSYM...
FSYM: PUSH P,A ;SAVE AC'S
PUSH P,B
PUSH P,C
PUSH P,D
PUSH P,E
PUSH P,F
PUSH P,G
MOVE A,C ;TABLE LOCATION
;INIT DELTA TO HIGHEST POWER OF 2 IN TABLE LENGTH
MOVE D,(A) ;TABLE LENGTH
JFFO D,.+2
JRST NOMAT ;0 LENGTH: NO MATCH
MOVEI G,1
MOVN E,E
LSH G,43(E) ;SHIFT BY 35 - # OF 0 BITS TO GET POWER
MOVEI C,(A) ;INIT POINTER THAT RUNS OVER TABLE
ADD A,(A) ;LOCATION OF LAST USED ENTRY IN TABLE
;IDTNCS SUBROUTINE FSYM...
; BINARY SEARCH. STOPS AT = ENTRY OR SMALLEST > ENTRY.
FSRC1: ADDI C,(G) ;ADD DELTA TO TABLE POINTER
FSRC1A: LSH G,-1 ;HALVE DELTA FOR NEXT TIME AROUND
CAILE C,(A)
JRST FSRC4 ;POINTS BEYOND END OF TABLE, GO BACK UP.
;COMPARE THE INPUT TEXT TO A TEXT IN THE TABLE
MOVE B,-5(P) ;GET VALUE THAT CAME IN B AS PTR TO INPUT TEXT
HRRZ E,(C) ;POINTER INTO TABLE TEXT FROM TABLE WORD
FSRC2: MOVE D,(B) ;GET AN INPUT WORD
LSH D,-1 ;POSITION SO DATA ISN'T IN SIGN BIT
MOVEI B,1(B) ;INDEX INPUT POINTER
MOVE F,(E) ;GET A WORD OF TABLE TEXT
LSH F,-1
CAMGE F,D
JRST FSRC3 ;TABLE ENTRY LESS THAN INPUT
CAME F,D
JRST FSRC4 ;TABLE ENTRY GREATER THAN INPUT
TRNE D,177 ;THESE WORDS EQUAL, AT END OF INPUT?
AOJA E,FSRC2 ;NO, INDEX TABLE TEXT PTR, CONTINUE COMPARE.
;MATCH FOUND.
;CODE FOR EXITS, SEARCH STUFF CONTINUES AFTER THIS.
UPAR: AOS -7(P)
HLRZ D,(C) ;VALUE FIELD FROM TABLE ENTRY WHICH MATCHED
MOVEM D,-4(P) ;RETURN SAME IN C
APAR:
NOMAT: POP P,G ;RESTORE AC'S
POP P,F
POP P,E
POP P,D
POP P,C
POP P,B
POP P,A
RET ;RETURN
;THE TEXT OF THIS TABLE ENTRY IS LESS THAN INPUT STRING
FSRC3: JUMPN G,FSRC1 ;DELTA><0, GO MOVE DOWN AND CONTINUE SEARCH
AOJA C,NEM1 ;DONE SEARCH. NEXT ENTRY IN TABLE IS THE
;SMALLEST LARGER ENTRY. IF THERE IS NO NEXT ENTRY, THEN
;THERE IS NO MATCH. "SBST" SUBR IS CODED TO HANDLE THIS CASE.
;THIS TABLE ENTRY GREATER THAN INPUT, OR POINTER IS OF END OF TABLE
FSRC4: SUBI C,(G) ;MOVE UP IN TABLE
JUMPN G,FSRC1A ;UNLESS DELTA=0, CONTINUE SEARCH.
;IDTNCS SUBROUTINE FSYM...
;WE GET TO "NEM1" WHEN THE SEARCH COMPLETES WITHOUT FINDING AN EXACT
;MATCH. C POINTS TO SMALLEST TABLE ENTRY GREATER THAN INPUT.
;THIS ENTRY MAY OR MAY NOT BE A SUBSET MATCH; IF IT IS, THEN IT IS
;AMBIGUOUS IF AND ONLY IF NEXT ENTRY IS ALSO A SUBSET MATCH.
;NOTE ALSO THAT WE CAN TEST NEXT ENTRY FIRST, AND IF IT IS SUBSET,
;THEN WE KNOW INPUT IS AMBIGUOUS WITHOUT TESTING THIS ENTRY.
;TEST NEXT ENTRY
NEM1: ADDI C,1 ;POINT C AT NEXT ENTRY
CALL SBST ;SUBSET TEST SUBR COMPARES ENTRY C TO INPUT
SOJA C,NEM2 ;R1: NOT A SUBSET (INCLUDES NO NEXT ENTRY)
SOJA C,APAR ;R2: IS A SUBSET, SO INPUT IS AMBIG. GIVE R2.
;NOT AMBIGUOUS, SO TEST THIS ENTRY
NEM2: CALL SBST
JRST NOMAT ;INPUT NOT SUBSET THIS ENTRY, NO MATCH
JRST UPAR
;IDTNCS SUBROUTINE FSYM...
;SUBSET TEST SUBROUTINE FOR "FSYM".
;COMPARES INPUT STRING AND STRING FOR TABLE ENTRY C POINTS TO,
; SKIPS IF FORMER IS INITIAL SUBSTRING OF LATTER.
;ON R2, RETURNS IN E A BYTE POINTER TO REST OF TABLE ENTRY STRING
;MUST BE CALLED ONLY WHEN INPUT STRING IS LESS THAN TABLE STRING
;SEE "FSYM"'S COMMENTS ON AC USE. CLOBBERS B,D,E,F,G.
SBST: CAILE C,(A) ;C BEYOND END OF TABLE?
RET ;YES, NO ENTRY, INPUT ISN'T SUBSET, RETURN.
;FIND FIRST WORD OF STRINGS IN WHICH THEY DIFFER
MOVE B,-6(P) ;POINTER TO INPUT TEXT
HRRZ E,(C) ;POINTER TO TABLE ENTRY'S TEXT
SBST1: MOVE D,(B) ;WORD OF INPUT
LSH D,-1 ;POSITION FOR COMPARE
MOVEI B,1(B) ;INDEX INPUT POINTER
MOVE F,(E) ;WORD OF TABLE ENTRY
LSH F,-1 ;POSITION
CAMG F,D
AOJA E,SBST1 ;IF ITS = IT MUST NOT BE END.
TRNE D,177 ;IS DIFFERENCE IN LAST WORD OF INPUT?
RET ;NO, INPUT CAN'T BE SUBSTRING OF TABLE ENTRY.
;MASK OFF TABLE TEXT TO LENGTH OF INPUT
HRLZI G,-4
TDNE D,TBLBTS(G) ;LOOP TO SEE HOW MANY BYTEST OF D ARE 0
AOBJN G,.-1
ANDCM F,TBLBTS(G) ;THIS CLEARS F WHERE THERE ARE BITS IN TABLE
;CONVERT WORD PTR IN E TO BYTE POINTER AS REQUIRED ON R2.
HLL E, [POINT 7,0,-1
POINT 7,0,6
POINT 7,0,13
POINT 7,0,20
POINT 7,0,27 ] (G)
;NOW IF MASKED PART OF TABLE WORD = INPUT WORD, INPUT IS SUBSET.
CAMN F,D
AOS (P) ;SKIP
RET
TBLBTS:-1
1777777777
7777777
37777
177
;IDTNCS SUBROUTINES...
;NUMBER INPUT CONVERSION: CAN'T USE SYSTEM'S NIN BECAUSE STRING
;POINTER MUST ADDRESS CALLER'S, NOT CURRENT PC'S, ADDRESS SPACE,
; AND IN ANY CASE NOT UNTIL BKJFN
; WORKS FOR ALL DEVICES OR ANOTHER MEANS OF RETURNING TERMINATOR
; IS ESTABLISHED.
;R1: NO DIGIT OR OVERFLOW (18 BITS)
;R2: VALUE IN B
IDNIN: CALL GNSC ;GET NON-SPACE CHARACTER
CAIG G,"9"
CAIGE G,"0"
RET
MOVEI B,-60(G)
NIN1: CALL IDCHAR
CAIG G,"9"
CAIGE G,"0"
JRST [ AOS (P)
RET]
IMULI B,^D10
ADDI B,-60(G)
TLNN B,-1
JRST NIN1
RET ;OVERFLOW
;NIN FOR MONTH OR DAY OF MONTH
;ERR