comparison 3rdparty/utils/boisy/timer.asm @ 0:6641a883d6b0

Initial revision
author boisy
date Thu, 04 Apr 2002 16:34:12 +0000
parents
children 0e08f0830fd8
comparison
equal deleted inserted replaced
-1:000000000000 0:6641a883d6b0
1 ************************************************************
2 * Timer - Benchmarks a program with accuracy to one second
3 *
4 * By: Boisy G. Pitre
5 * Southern Station, Box 8455
6 * Hattiesburg, MS 39406-8455
7 * Internet: bgpitre@seabass.st.usm.edu
8 *
9 * Usage: Timer <program> [params]
10 *
11 * Timer is a benchmark utility that is used to rate the speed of an
12 * OS-9 program.
13 *
14
15 nam Timer
16 ttl Benchmark utility
17
18 ifp1
19 use defsfile
20 endc
21
22 mod Size,Name,Prgrm+Objct,Reent+1,Start,Fin
23
24 Name fcs /Timer/
25 Ed fcb $02
26
27 Delim rmb 1
28 TempX rmb 2
29 Count rmb 1
30 ProgName rmb 70
31 ParmBuff rmb 200
32 OldTime rmb 6
33 NewTime rmb 6
34 Digit rmb 2
35 Stack rmb 200
36 Parms rmb 200
37 Fin equ .
38
39 HelpMsg fcc /Usage: Timer <progname> [params]/
40 SpCR fcb $20,$0a,$0d
41 HelpLen equ *-HelpMsg
42
43
44 Header fdb $0a0d
45 fcc /Timer Statistics:/
46 fdb $0a0d,$0a0d
47 fcc /Command line: /
48 Header1 fcc /Date: /
49 Header2 fcc /Start Time: /
50 Header3 fcc /Stop Time: /
51 Colon fcc /:/
52 Slash fcc "/"
53
54 Start decb Check for params
55 lbeq Help if none, show help
56 lda #$0d
57 leay ParmBuff,u Else put a CR in param buffer
58 sta ,y
59
60 leay ProgName,u and put progname in progname buffer
61 GetName lda ,x+
62 sta ,y+
63 cmpa #$20 any space after name?
64 beq PlaceCR Yep, assume params are on line
65 cmpa #$0d Is next char a CR?
66 bne GetName nope, not finished getting name
67 bra GetTime else assume no params...
68
69 PlaceCR lda #$0D Put CR behind progname,
70 sta -1,y
71
72 SkipSpac lda ,x+ skip leading spaces
73 cmpa #$20
74 beq SkipSpac
75 leax -1,x
76
77 SaveParm leay ParmBuff,u and store params in param buffer
78 Loop lda ,x+
79 sta ,y+
80 cmpa #$0d Is char a CR?
81 beq GetTime Yep, we're finished parsing
82 bra Loop else get next char
83
84 GetTime lda #Prgrm+Objct We'll take care of some F$FORK
85 ldb #8 params to minimize the time between
86 ldy #200 grabbing the time and forking.
87 leax OldTime,u
88 os9 F$Time Now we get the time
89 lbcs Error
90
91 leax ProgName,u and point to the program name
92 pshs u save the u pointer value
93 leau ParmBuff,u and point u to the param buffer
94 os9 F$Fork Fork the program
95 bcs Error
96 os9 F$Wait and wait for it to complete
97
98 puls u get the u pointer value
99 leax NewTime,u and get the new time
100 os9 F$Time
101 bcs Error
102
103
104 * Print the Header and command line
105
106 leax Header,pcr
107 ldy #38
108 lda #2
109 os9 I$Write
110 bcs Error
111
112 leax ProgName,u
113 ldb #$0d
114 bsr PrnNam
115
116 leax SpCR,pcr
117 ldy #1
118 lda #2
119 os9 I$Write
120 bcs Error
121
122 leax ParmBuff,u
123 ldy #200
124 lda #2
125 os9 I$Writln
126 bcs Error
127 bra DateShow
128
129 **********************************************************************
130 * PrnNam - Prints a string character-by-character until it encounters
131 * a specific character in B
132 *
133 * Entry: X - Address of string
134 * B - Byte character to halt at
135 *
136 * Exit: None
137 *
138
139 PrnNam lda #2
140 ldy #1
141 Prn2 cmpb ,x compare B to char
142 bne Prn3 if not equal, print...
143 rts else return
144 Prn3 os9 I$Write Write out character
145 bcs Error
146 leax 1,x
147 bra Prn2
148
149
150 * Print the date
151
152 DateShow leax Header1,pcr
153 ldy #7
154 os9 I$Write
155 bcs Error
156 leax Slash,pcr
157 lda ,x
158 sta Delim,u
159 leax OldTime,u Set X to old time packet+3
160 ldb #2
161 bsr ShowTime and sub to showtime
162 bra OldShow
163
164 * We're done!
165
166 Done clrb
167 Error os9 F$Exit
168
169 * Show the Old Time
170
171 OldShow lda #2
172 leax Header2,pcr Write the old time message
173 ldy #13
174 os9 I$Write
175 bcs Error
176 leax Colon,pcr
177 lda ,x
178 sta Delim,u
179 leax OldTime+3,u Set X to old time packet+3
180 ldb #2
181 bsr ShowTime and sub to showtime
182
183 NewShow leax Header3,pcr Write the new time message
184 ldy #13
185 os9 I$Write
186 bcs Error
187 leax NewTime+3,u Set X to new time packet+3
188 ldb #2
189 bsr ShowTime and sub to showtime
190 bra Done
191
192 * Help routine
193
194 Help leax HelpMsg,pcr Point to the help message
195 ldy #HelpLen and load the length
196 lda #2 we'll write to StdErr
197 os9 I$Write
198 bcs Error
199 bra Done and leave!
200
201 *******************************************************
202 * ShowTime routine - Prints date/time format
203 *
204 * Entry: X - Address of packet
205 * B - (Number of bytes to convert)-1
206 *
207 * Exit: None
208 *
209
210 ShowTime stb Count,u store count in counter address
211 ShowLoop ldb ,x+ load X with byte
212 stx TempX,u save the X value
213 pshs u save the U value
214 leau Digit,u and point to the digit buffer
215 bsr Str2Num sub to the actual conversion routine
216 puls u get the U value
217 lda #2
218 ldy #2
219 leax Digit,u and write the two digits
220 os9 I$Write
221 bcs Error
222 tst Count,u is count at 0?
223 beq PutCR yep, put a CR
224 dec Count,u else decrement count
225 ldy #1 and print the delimiter
226 leax Delim,u
227 os9 I$Write
228 bcs Error
229 ldx TempX,u get the X value
230 bra ShowLoop and get the next time byte
231 PutCR lda #2
232 ldy #2
233 leax SpCR+1,pcr print a CR for next line
234 os9 I$Write
235 lbcs Error
236 Return rts Return to caller!
237
238 ************************************************************
239 * Str2Num: Converts a one byte representation to its string
240 * counterpart in the range of 0-255.
241 *
242 * Entry: U - Address to store text digits
243 * B - Byte to convert
244 *
245 * Exit: None
246 *
247
248 Str2Num pshs a,b,u
249 lda #$2f
250 inca
251 p1 subb #$64
252 bcc p1
253 sta ,u+
254 cmpa #$30
255 bne P2
256 leau -1,u
257 p2 lda #$3a
258 p3 deca
259 addb #$0a
260 bcc p3
261 sta ,u+
262 addb #$30
263 stb ,u+
264 puls a,b,u
265 rts
266 emod
267 Size equ *
268 end