Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/krnp3_perr.asm @ 1919:028161cd3535
uses ss.fd
author | boisy |
---|---|
date | Fri, 25 Nov 2005 12:39:54 +0000 |
parents | 949d4df97cca |
children | 00dc1ef6a7aa |
rev | line source |
---|---|
747 | 1 ******************************************************************** |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1482
diff
changeset
|
2 * krnp3 - Printerr functionality for Level 2 |
747 | 3 * |
4 * $Id$ | |
5 * | |
6 * Peter E. Durham | |
7 * The New Wentworth Timesharing System | |
8 * summer: 6 Twin Brook Circle school: Quincy House D-24 | |
9 * Andover, MA 01810 58 Plympton St. | |
10 * (617) 475-4243 Cambridge, MA 02138 | |
11 * (617) 498-3209 | |
12 * cis: 73177,1215 delphi: PEDXING | |
13 * unix: harvard!husc4!durham_2 intnet: durham_2@husc4.harvard.edu | |
14 * | |
15 * COPYRIGHT (C) 1987 by Peter Durham | |
16 * Permission is given to all members of the OS-9 community to use, | |
17 * modify, and share this program for their personal enjoyment. | |
18 * Commercial use of this program, which was written for fun to share with | |
19 * the community, is prohibited without the consent of the author. | |
20 * Please share any extensions or modifications with the author, who | |
21 * would be interested in hearing about them. | |
22 * | |
23 * NOTE | |
24 * Quick poll... how does the above sound as a copyright notice? Clearly, | |
25 * authors like to share their work while maintaining some control on it. | |
26 * And it doesn't seem fair for someone else to make $ from something | |
27 * someone else made for fun. I think the above conditions are what most | |
28 * people want. Let me know what you think. | |
29 * | |
30 * NOTE | |
31 * The inspiration for this utility was the os9p3 example in | |
1369 | 32 * the Tandy Level 2 manual. Tandy deserves praise for |
747 | 33 * including examples such as this one in their manuals. |
34 * | |
35 * NOTE | |
1748 | 36 * There is something funny about KrnP3 modules... some versions |
747 | 37 * are not liked, others are. When developing this module, often |
38 * a version would fail... but if I added a "leas 0,s" right before | |
39 * the "rts" in PrinBuf, it would work! Probably the location and | |
40 * operation are not significant. This version here has never failed | |
41 * to boot on my system; however, if it does on yours (or you change | |
42 * it), try putting such things in. | |
43 * | |
44 * NOTE | |
1748 | 45 * For those people who just can't have enough... KrnP3 will look for |
46 * a module called KrnP4, and link to it, and execute it. Thanks to | |
747 | 47 * Kev for this idea. Now we can keep additions to the kernel in nice |
1748 | 48 * separate chunks. (How long 'til KrnP11 comes around...?) |
747 | 49 * |
1348 | 50 * Edt/Rev YYYY/MM/DD Modified by |
51 * Comment | |
747 | 52 * ------------------------------------------------------------------ |
1348 | 53 * 1 1987/06/23 Peter E. Durham |
54 * First release. | |
55 | |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1482
diff
changeset
|
56 nam krnp3 |
1369 | 57 ttl Printerr functionality for Level 2 |
747 | 58 |
59 ifp1 | |
60 use defsfile | |
61 endc | |
62 | |
63 type set Systm ;System module, 6809 object code | |
1289 | 64 revs set 0 ; |
747 | 65 edition set 1 |
66 | |
1289 | 67 mod eom,name,type,ReEnt+revs,entry,256 |
747 | 68 |
1668 | 69 name fcs "KrnP3" |
747 | 70 fcb edition |
71 | |
72 *+ | |
73 * Initialization routine and table | |
74 *- | |
75 Entry equ * | |
76 leay SvcTbl,pcr ;Get address of table | |
77 os9 F$SSvc ;Install services in table | |
1748 | 78 lda #Type ;Get system module type for KrnP4 |
79 leax P4Name,pcr ;Get name for KrnP4 | |
747 | 80 os9 F$Link ;Try to link to it |
81 bcs Exit ;If not found, exit | |
82 jsr ,y ;Go execute it! | |
1748 | 83 Exit rts ;Return to KrnP2 |
747 | 84 |
85 SvcTbl equ * | |
86 fcb F$PErr ;System call number | |
87 fdb PErr-*-2 ;Offset to code | |
88 fcb $80 ;End of table | |
89 | |
90 *+ | |
91 * The new F$Perr service call | |
92 *- | |
93 *+ | |
94 * Data (in user space!) | |
95 *- | |
96 BufLen equ 80 | |
97 Buf rmb BufLen | |
98 HunDig equ Buf+7 | |
99 TenDig equ Buf+8 | |
100 OneDig equ Buf+9 | |
101 DataMem equ . | |
102 | |
103 *+ | |
104 * FUNCTION PErr | |
105 * PURPOSE Top level routine | |
106 * REGISTERS B = Error code (after Setup) | |
107 * U = User memory area (after Setup) | |
108 * Y = User process descriptor (after Setup) | |
109 * A = Error file path number (after OpenFil) | |
110 * X = Pointer to strings | |
111 *- | |
112 PErr equ * | |
113 bsr Setup ;Go set up registers | |
114 leax ErrMsg,pcr ;Get pointer to "Error #000" | |
115 bsr MoveBuf ;Go copy it over | |
116 bsr WritNum ;Go copy the number into it | |
117 lbsr PrinMsg ;Go print the message | |
118 bcs PErrBye ;If error, abort | |
119 leax FilNam,pcr ;Get pointer to "/dd/sys/errmsg" | |
120 bsr MoveBuf ;Go copy it over | |
121 lbsr OpenFil ;Go open the file | |
122 bcs PErrBye ;If error, abort | |
123 Loop lbsr RdBuf ;Go read a line from the file | |
124 bcs Error ;If error, print CR, and abort | |
125 pshs b ;Save error code | |
126 pshs b ;Save error code again for compare | |
127 bsr CalcNum ;What number is on this line? | |
128 cmpb ,s+ ;Is this line the right line? | |
129 puls b ;Restore error code | |
130 bne Loop ;If not right line, loop again | |
131 lbsr PrinBuf ;If right line, write line out | |
132 bra Close ;Done, so close the file | |
133 Error lbsr DoCR ;Go print a carriage return | |
134 Close lbsr ClosFil ;Go close the file | |
135 PErrBye rts ;Return from system call | |
136 | |
137 *+ | |
138 * FUNCTION SetUp | |
139 * PURPOSE Sets up registers | |
140 * GIVES B = Error code | |
141 * U = Pointer to data memory on user stack in user space | |
142 * Y = Pointer to user process descriptor in system space | |
143 *- | |
144 SetUp equ * | |
145 ldb R$B,u ;Get error code | |
146 ldy D.Proc ;Get user's process descriptor | |
147 ldu P$SP,y ;Get user's stack pointer | |
148 leau -DataMem,u ;Reserve a little space | |
149 rts | |
150 | |
151 *+ | |
152 * FUNCTION MoveBuf | |
153 * PURPOSE Copies string to user space | |
154 * TAKES X = location of string in system space | |
155 *- | |
156 MoveBuf equ * | |
157 pshs u,y,d ;Save registers | |
158 lda D.SysTsk ;Get system process task number | |
159 ldb P$Task,y ;Get user process task number | |
160 leau Buf,u ;Get pointer to destination buffer | |
161 ldy #BufLen ;Copy BufLen characters over (extras, oh well) | |
162 os9 F$Move ;Move string to user space | |
163 puls d,y,u,pc ;Restore registers and return | |
164 | |
165 *+ | |
166 * FUNCTION WriteNum | |
167 * PURPOSE Puts the ASCII value of the error code in user space | |
168 * TAKES B = error code | |
169 *- | |
170 WritNum equ * | |
171 pshs x,d ;Save registers | |
172 clra ;Start A as 0 | |
173 Huns cmpb #100 ;Is B >= 100? | |
174 blo HunDone ;If not, go do Tens | |
175 inca ;Increment hundreds digit | |
176 subb #100 ;Subtract 100 from B | |
177 bra Huns ;Go do again | |
178 HunDone leax HunDig,u ;Where to put digit | |
179 bsr WritDig ;Go put it there | |
180 clra ;Start A again as 0 | |
181 Tens cmpb #10 ;Is B >= 10? | |
182 blo TenDone ;If not, go do Ones | |
183 inca ;Increment hundreds digit | |
184 subb #10 ;Subtract 10 from B | |
185 bra Tens ;Go do again | |
186 TenDone leax TenDig,u ;Where to put digit | |
187 bsr WritDig ;Go put it there | |
188 tfr b,a ;Get ones digit | |
189 leax OneDig,u ;Where to put digit | |
190 bsr WritDig ;Go put it there | |
191 puls d,x,pc ;Restore registers and return | |
192 | |
193 *+ | |
194 * FUNCTION WritDig | |
195 * PURPOSE Copy digit into user space | |
196 * TAKES A = digit to copy (not in ASCII yet) | |
197 * X = where to put digit | |
198 *- | |
199 WritDig equ * | |
200 pshs d ;Save registers | |
201 adda #'0 ;Convert A to ASCII | |
202 ldb P$Task,y ;Get task number | |
203 os9 F$StABX ;Write that digit to user space | |
204 puls d,pc ;Restore registers and return | |
205 | |
206 *+ | |
207 * FUNCTION CalcNum | |
208 * PURPOSE Converts ASCII number in user space to binary | |
209 * TAKES Buf (in user space) = ASCII number | |
210 * GIVES B = number converted | |
211 * X = points to first nonnumeric character | |
212 *- | |
213 CalcNum equ * | |
214 pshs a ;Save register | |
215 leax Buf,u ;Get pointer to buffer | |
216 clrb ;Set accumulator to zero | |
217 NextDig bsr LoadDig ;Get digit from user space | |
218 suba #'0 ;Convert to binary; is it less than zero? | |
219 bmi CalcBye ;If so, return | |
220 cmpa #9 ;Is the digit more than nine? | |
221 bhi CalcBye ;If so, return | |
222 pshs a ;Save the digit while we multiply | |
223 lda #10 ;Multiply current number by 10 | |
224 mul ;Do it | |
225 addb ,s+ ;Add new digit to number | |
226 leax 1,x ;Advance X to next digit | |
227 bra NextDig ;Go get the next digit | |
228 CalcBye puls a,pc ;Restore register and return | |
229 | |
230 *+ | |
231 * FUNCTION LoadDig | |
232 * PURPOSE Get digit from user space | |
233 * TAKES X = pointer to digit in user space | |
234 * GIVES A = digit in user space | |
235 *- | |
236 LoadDig equ * | |
237 pshs b ;Save register | |
238 ldb P$Task,y ;Get user process task number | |
239 os9 F$LdABX ;Get digit | |
240 puls b,pc ;Restore register and return | |
241 | |
242 *+ | |
243 * FUNCTION PrinMsg | |
244 * PURPOSE Prints out the Error #xxx message | |
245 *- | |
246 PrinMsg equ * | |
247 pshs y,x,a ;Save registers | |
248 lda P$Path+2,y ;Get StdErr path number | |
249 leax Buf,u ;Get pointer to message | |
250 ldy #ErrLen ;Maximum ErrLen characters to print | |
251 os9 I$Write ;Write out error message | |
252 puls a,x,y,pc ;Restore registers and return | |
253 | |
254 *+ | |
255 * FUNCTION DoCR | |
256 * PURPOSE Prints a carriage return | |
257 *- | |
258 DoCR equ * | |
259 pshs x,d ;Save registers | |
260 ldb P$Task,y ;Get user task number | |
1748 | 261 lda #C$CR ;Load A with a CR |
747 | 262 leax Buf,u ;Get pointer to buffer |
263 os9 F$StABX ;Move the CR to the buffer | |
264 bsr PrinBuf ;Go print it | |
265 puls d,x,pc ;Restore registers and return | |
266 | |
267 *+ | |
268 * FUNCTION PrinBuf | |
269 * PURPOSE Prints out the string from user space | |
270 * TAKES X (in user space) = String to print | |
271 *- | |
272 PrinBuf equ * | |
273 pshs y,a ;Save registers | |
274 lda P$Path+2,y ;Get StdErr path number | |
275 ldy #BufLen ;Maximum BufLen characters to print | |
276 os9 I$WritLn ;Write out message | |
277 puls a,y,pc ;Restore registers and return | |
278 | |
279 *+ | |
280 * FUNCTION RdBuf | |
281 * PURPOSE Reads in a string from file to user space | |
282 * TAKES A = path number | |
283 * GIVES Buf (in user space) = String read in | |
284 *- | |
285 RdBuf equ * | |
286 pshs y,x ;Save registers | |
287 leax Buf,u ;Get pointer to buffer | |
288 ldy #BufLen ;Maximum BufLen characters to read | |
289 os9 I$ReadLn ;Read in line from file | |
290 puls x,y,pc ;Restore registers and return | |
291 | |
292 *+ | |
293 * FUNCTION OpenFil | |
294 * PURPOSE Open path to error message file | |
295 * TAKES Buf (in user space) = name of file | |
296 * GIVES A = Path number | |
297 *- | |
298 OpenFil equ * | |
299 pshs x ;Save register | |
300 lda #READ. ;Open path for read access | |
301 leax Buf,u ;Get pointer to string | |
302 os9 I$Open ;Open path | |
303 puls x,pc ;Restore registers and return A | |
304 | |
305 *+ | |
306 * FUNCTION ClosFil | |
307 * PURPOSE Close path to error message file | |
308 * TAKES A = Path number | |
309 *- | |
310 ClosFil equ * | |
311 os9 I$Close ;Close file | |
312 rts ;Return | |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1482
diff
changeset
|
313 P4Name fcc "krnp4" |
1748 | 314 fcb C$CR |
747 | 315 ErrMsg fcc "Error #000" |
316 ErrLen equ *-ErrMsg | |
317 FilNam fcc "/dd/sys/errmsg" | |
1748 | 318 fcb C$CR |
747 | 319 FilLen equ *-FilNam |
320 | |
321 emod | |
322 eom equ * | |
323 end |