annotate level1/cmds/date.asm @ 1891:5f8822fb42e0

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