Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/error.asm @ 1919:028161cd3535
uses ss.fd
author | boisy |
---|---|
date | Fri, 25 Nov 2005 12:39:54 +0000 |
parents | 84ea83668304 |
children |
rev | line source |
---|---|
324 | 1 ******************************************************************** |
937 | 2 * Error - Show text error messages |
324 | 3 * |
4 * $Id$ | |
5 * | |
937 | 6 * By Bob Devries (c) 2003; bdevries@gil.com.au |
7 * | |
8 * Released under the GNU public licence | |
9 * | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
946
diff
changeset
|
10 * Edt/Rev YYYY/MM/DD Modified by |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
946
diff
changeset
|
11 * Comment |
324 | 12 * ------------------------------------------------------------------ |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
946
diff
changeset
|
13 * 1 2003/01/20 Bob Devries |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
946
diff
changeset
|
14 * Rewrote in assembler for size. |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
946
diff
changeset
|
15 * |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
946
diff
changeset
|
16 * 2003/01/21 Bob Devries |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
946
diff
changeset
|
17 * Fixed problem with trailing space. |
324 | 18 |
937 | 19 nam Error |
20 ttl Show text error messags | |
324 | 21 |
22 ifp1 | |
23 use defsfile | |
24 endc | |
25 | |
26 tylg set Prgrm+Objct | |
27 atrv set ReEnt+rev | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
946
diff
changeset
|
28 rev set $00 |
937 | 29 edition set 1 |
324 | 30 |
937 | 31 mod eom,name,tylg,atrv,start,size |
324 | 32 |
937 | 33 name fcs /Error/ |
324 | 34 fcb edition |
35 | |
937 | 36 org 0 |
37 path rmb 1 | |
38 same rmb 1 | |
39 prmptr rmb 2 | |
946
5c80e10a5d03
renamed variable that was clashing with one in systype
boisy
parents:
938
diff
changeset
|
40 prmend rmb 2 |
937 | 41 length rmb 2 |
42 parbuff rmb 256 | |
43 filbuff rmb 256 | |
44 stack rmb 350 | |
45 size equ . | |
46 | |
47 start cmpd #1 1 char == CR | |
48 lbeq help | |
49 tfr d,y length of parameters | |
50 bsr open | |
51 bcs exit | |
52 pshs u | |
938 | 53 leau parbuff,u point to buffer |
937 | 54 entry0 lda ,x+ |
55 cmpa #C$SPAC is it a space (between parameters?) | |
56 beq entry1 | |
57 cmpa #C$CR | |
58 bne nocr | |
59 entry1 clra yes, null it | |
60 nocr sta ,u+ store in buffer | |
61 leay -1,y decrement length counter | |
62 bne entry0 | |
63 clr ,u | |
64 tfr u,y | |
65 puls u | |
946
5c80e10a5d03
renamed variable that was clashing with one in systype
boisy
parents:
938
diff
changeset
|
66 sty <prmend store end of all parameters |
938 | 67 leax parbuff,u load address of parbuff into X |
937 | 68 stx <prmptr save parameter pointer |
69 entry2 lda ,x | |
70 bne entry3 | |
71 leax 1,x | |
72 bra rered2 | |
73 entry3 bsr strlen go get string length of first param | |
74 std <length store it | |
75 reread bsr readlin read line from errmsg file | |
76 bcc rered0 | |
77 cmpb #E$EOF did we find end-of-file? | |
78 lbeq unknown yep, tell user we don't know his error num | |
79 rered0 bsr compare compare user number with 1st 3 chars of line | |
80 beq reread compare returns 0 if failed | |
81 bsr print else go print the errmsg line | |
82 bcs exit exit if I$WritLn problem | |
83 rered1 ldd <length get length | |
84 ldx prmptr get parameter pointer | |
85 leax d,x add length to it | |
86 leax 1,x increment past null byte | |
87 rered2 clrb | |
946
5c80e10a5d03
renamed variable that was clashing with one in systype
boisy
parents:
938
diff
changeset
|
88 cmpx <prmend |
937 | 89 bge exit |
90 stx <prmptr store it | |
91 lbsr seek0 rewind the file | |
92 bra entry2 loop around again | |
93 | |
94 exit os9 F$Exit | |
95 | |
96 open pshs x | |
97 leax errmsg,pcr point to file name | |
98 lda #READ. read mode | |
99 os9 I$Open | |
100 bcs open0 | |
101 sta <path store path number | |
102 open0 puls x,pc | |
103 | |
104 readlin pshs x,y | |
105 lda <path get file path number | |
106 ldy #256 read max 256 bytes | |
938 | 107 leax filbuff,u into memory pointed to by filbuff |
937 | 108 os9 I$ReadLn |
109 puls x,y,pc | |
110 | |
111 print pshs x,y,a | |
112 lda #1 STDOUT | |
938 | 113 leax filbuff,u point to buffer |
937 | 114 ldy #256 max of 256 chars |
115 os9 I$WritLn | |
116 puls x,y,a,pc | |
324 | 117 |
937 | 118 strlen pshs x,y |
119 ldy #0 initialise count | |
120 strl0 tst ,x+ is it a char > null | |
121 beq strl1 nope, exit | |
122 leay 1,y yep, increment count | |
123 bra strl0 do again | |
124 strl1 tfr y,d return with length in D | |
125 puls x,y,pc | |
126 | |
127 compare pshs x,y | |
128 clr <same comparison indicator | |
129 ldx prmptr get address of next cmd line param | |
938 | 130 leay filbuff,u point to file buffer |
937 | 131 comp0 lda ,x+ get char from cmd line |
132 beq comp1 is it null (end of param) | |
133 cmpa ,y+ compare to file buffer | |
134 bne comp2 not same, exit | |
135 inc <same yep, in comparison counter | |
136 bra comp0 'round again | |
137 comp1 lda ,y | |
138 cmpa #C$SPAC was it end of number in errmsg file? | |
139 bne comp2 | |
140 tst <same test indicator | |
141 puls x,y,pc | |
142 comp2 clr <same clear the counter | |
143 puls x,y,pc | |
324 | 144 |
937 | 145 unknown leax unkmsg,pcr point to message |
146 ldy #unkmsgl num of chars to print | |
147 lda #1 to STDOUT | |
148 os9 I$Write | |
149 lbcs exit exit if problem with I$Write | |
150 ldx prmptr put pointer into parameter buffer in X | |
151 lda #1 STDOUT | |
152 ldy <length get length of user's param | |
153 os9 I$Write | |
154 lbcs exit | |
155 lda #1 STDOUT | |
156 leax return,pcr point to CR char | |
157 ldy #1 print 1 char | |
158 os9 I$WritLn | |
159 lbcs exit | |
160 ldx prmptr put point into parameter buffer in X | |
161 ldd <length get length of user's param | |
162 leax d,x add to X | |
163 leax 1,x increment past null byte | |
164 clrb | |
946
5c80e10a5d03
renamed variable that was clashing with one in systype
boisy
parents:
938
diff
changeset
|
165 cmpx prmend |
937 | 166 lbge exit |
167 stx <prmptr store X | |
168 bsr seek0 rewind file | |
169 lbra entry2 | |
324 | 170 |
937 | 171 seek0 pshs x,u |
172 lda <path | |
173 ldx #0 | |
174 ldu #0 | |
175 os9 I$Seek | |
176 puls x,u,pc | |
177 | |
178 help leax hlpmsg,pcr point to help message | |
179 lda #2 STDERR | |
180 ldy #256 max of 256 bytes (arbitrary, really) | |
181 os9 I$WritLn | |
182 lbcs exit | |
183 leax hlpmsg2,pcr 2nd line of message | |
184 lda #2 | |
185 ldy #256 | |
186 os9 I$WritLn | |
187 lbcs exit | |
188 clrb | |
189 lbra exit | |
190 | |
191 hlpmsg fcc /Error errno [errno...]/ | |
192 fcb C$CR | |
193 hlpmsg2 fcc /Usage: returns error message for given error numbers/ | |
194 fcb C$CR | |
195 errmsg fcc "/DD/SYS/errmsg" | |
196 fcb 0 | |
197 unkmsg fcc /Unknown error number - / | |
198 unkmsgl equ *-unkmsg | |
199 return fcb C$CR | |
200 | |
201 emod | |
202 eom equ * | |
203 end |