annotate level1/cmds/date.asm @ 1211:f54f04a78c54

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