0
|
1 ********************************************************************
|
|
2 * Date - Print Date/Time
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Greetings; September 25, 1996
|
|
7 *
|
|
8 * This 'Date' module, date5, has been expanded a wee bit to
|
|
9 * make it smart enough to handle dates to the year 2099.
|
|
10 *
|
|
11 * In order to have it do it in a math conversion, I would have had to
|
|
12 * make the 8 bit math it does into 16 bit, and there aren't enough
|
|
13 * registers in the 6809 to pull that off in a reasonable code size.
|
|
14 * So it still does 8 bit math, but only has a 1900-2099 year total
|
|
15 * range. This is more than the recently converted clock for the Disto
|
|
16 * 4n1 I just uploaded, as that clock now has a range from 1980 to 2079.
|
|
17 * A simple subtraction determines if it prints a leading 20, and the
|
|
18 * contents of the register after the subtraction, or it reloads the
|
|
19 * string pointer to point at 19 and reloads the year register to get
|
|
20 * the year 00-99 to print.
|
|
21 *
|
|
22 * This contains no 6309 specific code, so Nitros9 and a 6309 cpu
|
|
23 * are not required to use it, box stock is fine.
|
|
24 *
|
|
25 * Gene Heskett, <gene_heskett@wvlink.mpl.com>
|
|
26 *
|
|
27 * Ed. Comments Who YY/MM/DD
|
|
28 * ------------------------------------------------------------------
|
|
29 * 5 Made Y2K compliant GH 96/09/25
|
|
30 * 6 Made compliant with 1900-2155 BGP 99/05/07
|
834
|
31 * 7 New option is now -t, code compacted a bit BGP 03/01/14
|
0
|
32
|
|
33 nam Date
|
|
34 ttl Print Date/Time
|
|
35
|
|
36 ifp1
|
|
37 use defsfile
|
|
38 endc
|
|
39
|
|
40 tylg set Prgrm+Objct
|
|
41 atrv set ReEnt+rev
|
|
42 rev set $01
|
834
|
43 edition set 7
|
0
|
44
|
|
45 mod eom,name,tylg,atrv,start,size
|
|
46
|
834
|
47 org 0
|
924
|
48 sysyear rmb 1
|
|
49 sysmonth rmb 1
|
|
50 sysday rmb 1
|
|
51 syshour rmb 1
|
|
52 sysmin rmb 1
|
|
53 syssec rmb 1
|
0
|
54 u0006 rmb 2
|
|
55 u0008 rmb 440
|
|
56 size equ .
|
|
57
|
|
58 name fcs /Date/
|
|
59 fcb edition
|
|
60
|
834
|
61 MonTable fcs '???'
|
|
62 fcs 'January'
|
|
63 fcs 'February'
|
|
64 fcs 'March'
|
|
65 fcs 'April'
|
|
66 fcs 'May'
|
|
67 fcs 'June'
|
|
68 fcs 'July'
|
|
69 fcs 'August'
|
|
70 fcs 'September'
|
|
71 fcs 'October'
|
|
72 fcs 'November'
|
|
73 fcs 'December'
|
0
|
74
|
|
75 start pshs x
|
924
|
76 leax sysyear,u
|
0
|
77 leau u0008,u
|
|
78 stu <u0006
|
|
79 os9 F$Time
|
834
|
80 bsr Add2Buff go print the date in buffer
|
|
81 ldd [,s++] now, did we have a -t
|
|
82 andb #$DF
|
|
83 cmpd #$2D54 -T?
|
|
84 bne PrBuff wasn't
|
0
|
85 ldd #C$SPAC*256+C$SPAC else space it out
|
|
86 std ,u++
|
834
|
87 bsr DoTime and go add the time to the buffer
|
|
88 PrBuff lda #C$CR terminate the line to print
|
0
|
89 sta ,u+
|
834
|
90 lda #1 standard out
|
0
|
91 ldx <u0006
|
834
|
92 ldy #40
|
|
93 os9 I$WritLn and go print it
|
|
94 bcs Exit
|
0
|
95 clrb
|
834
|
96 Exit os9 F$Exit
|
|
97
|
924
|
98 DoTime ldb <syshour
|
834
|
99 bsr Byte2ASC
|
924
|
100 ldb <sysmin
|
0
|
101 bsr L00AB
|
924
|
102 ldb <syssec
|
834
|
103 L00AB lda #':
|
0
|
104 sta ,u+
|
834
|
105 bra Byte2ASC
|
|
106
|
|
107 Add2Buff leay >MonTable,pcr point to month table
|
924
|
108 ldb <sysmonth get month byte
|
834
|
109 beq L00C4 branch if zero (illegal)
|
|
110 cmpb #12 compare against last month of year
|
|
111 bhi L00C4 if too high, branch
|
|
112 L00BD lda ,y+ get byte
|
|
113 bpl L00BD keep going if hi bit not set
|
|
114 decb else decrement month
|
|
115 bne L00BD if not 0, keep going
|
0
|
116 L00C4 bsr PrtStrng
|
924
|
117 ldb <sysday
|
834
|
118 bsr Byte2ASC
|
|
119 ldd #C$COMA*256+C$SPAC get comma and space in D
|
|
120 std ,u++ store in buffer and increment twice
|
|
121 lda #19
|
924
|
122 ldb <sysyear get year
|
834
|
123 CntyLp subb #100
|
|
124 bcs pr we have century we need
|
|
125 inca
|
|
126 bra CntyLp
|
|
127 pr addb #100
|
|
128 pshs b
|
|
129 tfr a,b
|
|
130 bsr Byte2ASC
|
0
|
131 puls b
|
834
|
132
|
|
133 Byte2ASC lda #$2F start A out just below $30 (0)
|
|
134 Hundreds inca inc it
|
|
135 subb #100 subtract 100
|
|
136 bcc Hundreds if result >= 0, continue
|
|
137 cmpa #'0 zero?
|
|
138 beq Tens if so, don't add to buffer
|
|
139 sta ,u+ else save at U and inc.
|
|
140 Tens lda #$3A start A out just above $39 (9)
|
|
141 TensLoop deca dec it
|
|
142 addb #10 add 10
|
|
143 bcc TensLoop if carry clear, continue
|
|
144 sta ,u+ save 10's digit
|
|
145 addb #'0
|
|
146 stb ,u+ and 1's digit
|
0
|
147 rts
|
|
148
|
|
149 * * * * * * * * * * *
|
|
150 * make fcs strings printable
|
|
151 PrtStrng lda ,y
|
|
152 anda #$7F
|
|
153 sta ,u+
|
|
154 lda ,y+
|
|
155 bpl PrtStrng
|
834
|
156 lda #C$SPAC
|
|
157 sta ,u+
|
0
|
158 rts
|
|
159
|
|
160 * * * * * * * * * * *
|
|
161 * all done here folks
|
|
162 emod
|
|
163 eom equ *
|
|
164 end
|
|
165
|