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