Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/date.asm @ 1402:cd2c72039609
Made source more better :)
author | boisy |
---|---|
date | Thu, 27 Nov 2003 03:32:41 +0000 |
parents | 84ea83668304 |
children | ecffde67b7be |
rev | line source |
---|---|
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 * | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
27 * Edt/Rev YYYY/MM/DD Modified by |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
28 * Comment |
0 | 29 * ------------------------------------------------------------------ |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
30 * 5 1996/09/25 Gene Heskett |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
31 * Made Y2K compliant. |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
32 * |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
33 * 6 1999/05/07 Boisy G. Pitre |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
34 * Made compliant with 1900-2155. |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
35 * |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
36 * 7 2003/01/14 Boisy G. Pitre |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
37 * New option is now -t, code compacted a bit. |
0 | 38 |
39 nam Date | |
40 ttl Print Date/Time | |
41 | |
42 ifp1 | |
43 use defsfile | |
44 endc | |
45 | |
46 tylg set Prgrm+Objct | |
47 atrv set ReEnt+rev | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
48 rev set $00 |
834 | 49 edition set 7 |
0 | 50 |
51 mod eom,name,tylg,atrv,start,size | |
52 | |
834 | 53 org 0 |
924 | 54 sysyear rmb 1 |
55 sysmonth rmb 1 | |
56 sysday rmb 1 | |
57 syshour rmb 1 | |
58 sysmin rmb 1 | |
59 syssec rmb 1 | |
0 | 60 u0006 rmb 2 |
61 u0008 rmb 440 | |
62 size equ . | |
63 | |
64 name fcs /Date/ | |
65 fcb edition | |
66 | |
834 | 67 MonTable fcs '???' |
68 fcs 'January' | |
69 fcs 'February' | |
70 fcs 'March' | |
71 fcs 'April' | |
72 fcs 'May' | |
73 fcs 'June' | |
74 fcs 'July' | |
75 fcs 'August' | |
76 fcs 'September' | |
77 fcs 'October' | |
78 fcs 'November' | |
79 fcs 'December' | |
0 | 80 |
81 start pshs x | |
924 | 82 leax sysyear,u |
0 | 83 leau u0008,u |
84 stu <u0006 | |
85 os9 F$Time | |
834 | 86 bsr Add2Buff go print the date in buffer |
87 ldd [,s++] now, did we have a -t | |
88 andb #$DF | |
89 cmpd #$2D54 -T? | |
90 bne PrBuff wasn't | |
0 | 91 ldd #C$SPAC*256+C$SPAC else space it out |
92 std ,u++ | |
834 | 93 bsr DoTime and go add the time to the buffer |
94 PrBuff lda #C$CR terminate the line to print | |
0 | 95 sta ,u+ |
834 | 96 lda #1 standard out |
0 | 97 ldx <u0006 |
834 | 98 ldy #40 |
99 os9 I$WritLn and go print it | |
100 bcs Exit | |
0 | 101 clrb |
834 | 102 Exit os9 F$Exit |
103 | |
924 | 104 DoTime ldb <syshour |
834 | 105 bsr Byte2ASC |
924 | 106 ldb <sysmin |
0 | 107 bsr L00AB |
924 | 108 ldb <syssec |
834 | 109 L00AB lda #': |
0 | 110 sta ,u+ |
834 | 111 bra Byte2ASC |
112 | |
113 Add2Buff leay >MonTable,pcr point to month table | |
924 | 114 ldb <sysmonth get month byte |
834 | 115 beq L00C4 branch if zero (illegal) |
116 cmpb #12 compare against last month of year | |
117 bhi L00C4 if too high, branch | |
118 L00BD lda ,y+ get byte | |
119 bpl L00BD keep going if hi bit not set | |
120 decb else decrement month | |
121 bne L00BD if not 0, keep going | |
0 | 122 L00C4 bsr PrtStrng |
924 | 123 ldb <sysday |
834 | 124 bsr Byte2ASC |
125 ldd #C$COMA*256+C$SPAC get comma and space in D | |
126 std ,u++ store in buffer and increment twice | |
127 lda #19 | |
924 | 128 ldb <sysyear get year |
834 | 129 CntyLp subb #100 |
130 bcs pr we have century we need | |
131 inca | |
132 bra CntyLp | |
133 pr addb #100 | |
134 pshs b | |
135 tfr a,b | |
136 bsr Byte2ASC | |
0 | 137 puls b |
834 | 138 |
139 Byte2ASC lda #$2F start A out just below $30 (0) | |
140 Hundreds inca inc it | |
141 subb #100 subtract 100 | |
142 bcc Hundreds if result >= 0, continue | |
143 cmpa #'0 zero? | |
144 beq Tens if so, don't add to buffer | |
145 sta ,u+ else save at U and inc. | |
146 Tens lda #$3A start A out just above $39 (9) | |
147 TensLoop deca dec it | |
148 addb #10 add 10 | |
149 bcc TensLoop if carry clear, continue | |
150 sta ,u+ save 10's digit | |
151 addb #'0 | |
152 stb ,u+ and 1's digit | |
0 | 153 rts |
154 | |
155 * * * * * * * * * * * | |
156 * make fcs strings printable | |
157 PrtStrng lda ,y | |
158 anda #$7F | |
159 sta ,u+ | |
160 lda ,y+ | |
161 bpl PrtStrng | |
834 | 162 lda #C$SPAC |
163 sta ,u+ | |
0 | 164 rts |
165 | |
166 * * * * * * * * * * * | |
167 * all done here folks | |
168 emod | |
169 eom equ * | |
170 end | |
171 |