Mercurial > hg > Members > kono > nitros9-code
annotate level2/modules/krnp4_regdump.asm @ 2111:6ccd6e25a441
Fixed issues with pshs and puls of 6309 registers -- a nono!
author | boisy |
---|---|
date | Thu, 26 Jul 2007 16:41:45 +0000 |
parents | 949d4df97cca |
children | ebf319736e9c |
rev | line source |
---|---|
747 | 1 ******************************************************************** |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1369
diff
changeset
|
2 * krnp4 - User Register Dump System Call for NitrOS9 Level 2 |
747 | 3 * |
4 * $Id$ | |
5 * | |
6 * Copyright February,1989 by Ron Lammardo | |
7 * | |
8 * This system call can be used in an application program to dump the | |
9 * current contents of all user registers in Hex,Decimal,Binary and Ascii | |
10 * (Registers "A" and "B" Only). This module MUST be present in the | |
1748 | 11 * bootfile. If no krnp5 module is found,change the "mname" and "nextname" |
747 | 12 * as appropriate. |
13 * | |
14 * If there is a conflict with the code used for this system called, it can | |
15 * be changed by resetting the equate at "F$RegDmp" | |
16 * | |
1369 | 17 * NOTE: All registers EXCEPT 'CC' are preserved....NitrOS9 internally resets |
747 | 18 * the condition code register upon service call exit. |
19 * | |
1348 | 20 * Edt/Rev YYYY/MM/DD Modified by |
21 * Comment | |
747 | 22 * ------------------------------------------------------------------ |
1348 | 23 * 1 1989/02/?? Ron Lammardo |
24 * Started. | |
747 | 25 |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1369
diff
changeset
|
26 nam krnp4 |
1369 | 27 ttl User Register Dump System Call for NitrOS9 Level 2 |
747 | 28 |
29 ifp1 | |
30 use defsfile | |
31 endc | |
32 | |
1748 | 33 tylg set Systm+Objct |
34 atrv set ReEnt+revision | |
1289 | 35 revision set 0 |
747 | 36 edition set 1 |
37 | |
38 mod eom,name,tylg,atrv,start,0 | |
39 | |
1668 | 40 name fcs /KrnP4/ name of this module |
747 | 41 fcb edition |
42 | |
43 svctabl fcb F$RegDmp F$RegDmp code | |
44 fdb regdmp-*-2 offset to actual code | |
45 fcb $80 end of table | |
46 | |
47 start leay <svctabl,pcr point to service table | |
48 os9 F$SSvc insert the new op code in the table | |
49 lda #tylg get next module type (same as this one!) | |
50 leax <nextname,pcr get address of next module name | |
51 os9 F$Link attempt to link to it | |
52 bcs endsetup no good...skip this | |
53 jsr ,y else go execute it | |
54 endsetup rts return back to previous module | |
55 | |
1587
5f18094d961d
kernel modules renamed to krn, updated makefiles, clock2_tc3 now clock2_cloud9...
boisy
parents:
1369
diff
changeset
|
56 nextname fcc /krnp5/ next module name to link to |
1748 | 57 fcb C$CR |
747 | 58 |
59 regdmp equ * | |
2111
6ccd6e25a441
Fixed issues with pshs and puls of 6309 registers -- a nono!
boisy
parents:
1748
diff
changeset
|
60 pshs cc,a,b,dp,x,y,u save all registers |
747 | 61 IFNE H6309 |
2111
6ccd6e25a441
Fixed issues with pshs and puls of 6309 registers -- a nono!
boisy
parents:
1748
diff
changeset
|
62 pshsw |
747 | 63 ENDC |
64 tfr u,y transfer addresses | |
65 leas -60,s back up for some variable storage | |
66 leau 4,s buffer starts here | |
67 clr ,u+ set flag to print ascii char | |
1748 | 68 lda #C$SPAC get a space |
747 | 69 ldb #50 number of chars to clear |
70 tfr u,x set register for loop | |
71 | |
72 clrloop sta ,x+ initialize a space | |
73 decb decrement counter | |
74 bne clrloop if more..loop back & clear another | |
75 lbsr reg060 send a <cr> | |
76 leax reg080,pcr point to start of control table | |
77 clra clear msb of register | |
78 ldb R$A,y get register from stack | |
79 bsr reg000 dump register A | |
80 ldb R$B,y get register from stack | |
81 bsr reg000 dump register B | |
82 IFNE H6309 | |
83 ldb R$E,y get register from stack | |
84 bsr reg000 dump register E | |
85 ldb R$F,y get register from stack | |
86 bsr reg000 dump register F | |
87 ENDC | |
88 inc -1,u turn off ascii char print flag | |
89 ldd R$X,y get register from stack | |
90 bsr reg000 dump register X | |
91 ldd R$Y,y get register from stack | |
92 bsr reg000 dump regisetr Y | |
93 ldd R$U,y get register from stack | |
94 bsr reg000 dump register U | |
95 ldb R$CC,y get register from stack | |
96 bsr reg000 dump register CC | |
97 ldb R$DP,y get register from stack | |
98 bsr reg000 dump register DP | |
99 ldd R$PC,y get user Task Number | |
100 bsr reg000 dump register PC | |
101 ldy <D.Proc get address of users process descriptor | |
102 ldd P$SP,y get users stack address | |
1748 | 103 addd #R$Size add on for registers which were saved |
747 | 104 bsr reg000 dump register S |
105 lbsr reg060 send a <CR> | |
106 leas 60,s restore stack pointer | |
107 IFNE H6309 | |
2111
6ccd6e25a441
Fixed issues with pshs and puls of 6309 registers -- a nono!
boisy
parents:
1748
diff
changeset
|
108 pulsw |
6ccd6e25a441
Fixed issues with pshs and puls of 6309 registers -- a nono!
boisy
parents:
1748
diff
changeset
|
109 ENDC |
747 | 110 puls cc,a,b,dp,x,y,u,pc restore all registers and return |
111 | |
112 * Dump a register in "D" | |
113 * X = Control Table Location | |
114 * U = Output buffer Location | |
115 | |
116 reg000 pshs y save y register | |
117 tfr d,y register in y | |
118 lda ,x # of bytes | |
119 leax 3,x point past table entry | |
120 pshs a,x,y,u save registers | |
121 ldd -2,x get register name | |
122 std ,u++ move to buffer | |
123 ldd #"=$ get chars | |
124 std ,u++ move to buffer | |
125 ldd 3,s get reg | |
126 lbsr gethex convert to hex | |
127 tst 0,s 1 byte ? | |
128 bne reg010 no...skip this | |
129 ldd 2,u get 2 lsb's | |
130 std ,u store in msb's | |
1748 | 131 ldd #C$SPAC*256+C$SPAC get two spaces |
747 | 132 std 2,u store in lsb's |
133 | |
1748 | 134 reg010 ldd #C$SPAC*256+'# get a space and "#" |
747 | 135 std 4,u move in two spaces |
136 leau 6,u point to start of decimal output buffer | |
137 ldd 3,s get register | |
138 lbsr getdec convert to decimal | |
139 tst 0,s is it one byte | |
140 bne reg020 no..skip this | |
141 ldd 2,u else get third & fourth chars | |
142 std ,u store as first two | |
143 lda 4,u get fifth char | |
144 sta 2,u store as third | |
1748 | 145 ldd #C$SPAC*256+C$SPAC get two spaces |
747 | 146 std 3,u store as 4th & 5th chars |
147 | |
1748 | 148 reg020 ldd #C$SPAC*256+'% get a blank & "%" |
747 | 149 std 5,u move it to buffer |
150 leau 7,u point to start of binary output area | |
151 tfr a,b space in 'b' | |
152 std 16,u space out ascii char | |
153 ldd 3,s get register | |
154 bsr getbin convert to binary | |
155 tst 0,s check byte count | |
156 bne reg040 skip if two bytes | |
157 ldb #8 loop counter | |
158 | |
159 reg030 lda 8,u get two chars from second 8 digits | |
160 sta ,u+ store in first 8 digits | |
1748 | 161 lda #C$SPAC get space |
747 | 162 sta 7,u store in second 8 digits |
163 decb decrement counter | |
164 bne reg030 loop back if not done | |
165 leau -8,u back up to beginning of binary digit output | |
166 ldb 4,s get lsb of register | |
167 tst -18,u check if we want to print ascii char | |
168 bne reg040 nope..skip this | |
1748 | 169 cmpb #C$SPAC compare char with space |
747 | 170 blo reg040 if lower..skip this |
171 cmpb #'z compare with last alpha char | |
172 bhi reg040 if higher..skip this | |
173 stb 17,u else store the char | |
174 | |
175 reg040 lda #C$CR get a <cr> | |
176 sta 18,u and store it | |
177 leax -17,u back up to buffer start | |
178 bsr reg070 send it | |
179 clra clear msb for next reg | |
180 puls b,x,y,u restore registers | |
181 puls y,pc restore y & return | |
182 | |
1748 | 183 reg050 fcb C$CR |
747 | 184 |
185 reg060 leax <reg050,pcr point to <cr> | |
186 | |
187 reg070 pshs x,y,u,a,b save registers | |
188 ldy <D.Proc get process descriptor address | |
189 lda P$Path+2,y get user error path number | |
190 pshs a save it | |
191 ldu P$SP,y get user stack address | |
192 leau -50,u back off to make room | |
193 lda <D.SysTsk get system task number | |
194 ldb P$Task,y get users task number | |
195 ldy #40 chars to move | |
196 os9 F$Move move from system to user space | |
197 tfr u,x restore buffer address | |
198 puls a restore user error path number | |
199 os9 I$WritLn send it | |
200 puls x,y,u,a,b,pc restore registers & return | |
201 | |
202 * Control Table - Format is : | |
203 * Byte count (0=1,1=2) | |
204 * Register name (Two chars) | |
205 | |
206 reg080 fcb 0 | |
207 fcc /a / | |
208 fcb 0 | |
209 fcc /b / | |
210 IFNE H6309 | |
211 fcb 0 | |
212 fcc /e / | |
213 fcb 0 | |
214 fcc /f / | |
215 ENDC | |
216 fcb 1 | |
217 fcc /x / | |
218 fcb 1 | |
219 fcc /y / | |
220 fcb 1 | |
221 fcc /u / | |
222 fcb 0 | |
223 fcc /cc/ | |
224 fcb 0 | |
225 fcc /dp/ | |
226 fcb 1 | |
227 fcc /pc/ | |
228 fcb 1 | |
229 fcc /s / | |
230 | |
231 | |
232 * Convert "D" to binary digits in buffer "U" | |
233 | |
234 getbin pshs u,b save 'u', second byte of register | |
235 bsr bin010 convert first byte | |
236 puls a get second byte | |
237 bsr bin010 convert it | |
238 puls u,pc restore 'u' and return | |
239 | |
240 bin010 bita #%10000000 check bit | |
241 bsr bin020 print result | |
242 bita #%01000000 | |
243 bsr bin020 | |
244 bita #%00100000 | |
245 bsr bin020 | |
246 bita #%00010000 | |
247 bsr bin020 | |
248 bita #%00001000 | |
249 bsr bin020 | |
250 bita #%00000100 | |
251 bsr bin020 | |
252 bita #%00000010 | |
253 bsr bin020 | |
254 bita #%00000001 | |
255 | |
256 bin020 beq bin030 skip this if bit was set | |
257 ldb #'1 else get an ascii '1' | |
258 bra bin040 skip next | |
259 | |
260 bin030 ldb #'0 bit not set...get an ascii '0' | |
261 | |
262 bin040 stb ,u+ store the ascii char | |
263 rts | |
264 | |
265 * Convert "D" to 4 hex digits in buffer "U" | |
266 | |
267 gethex pshs u,b save 'u',second register byte | |
268 bsr gth010 convert first byte | |
269 puls a restore second byte | |
270 bsr gth010 convert it | |
271 puls u,pc restore 'u' and return | |
272 | |
273 gth010 pshs a save the byte | |
274 lsra shift left 4 bits to right | |
275 lsra | |
276 lsra | |
277 lsra | |
278 bsr gth020 convert to hex digit | |
279 puls a restore the byte | |
280 anda #$0f strip off high 4 digits | |
281 | |
282 gth020 adda #'0 make it ascii | |
283 cmpa #$3a is it a letter | |
284 blt gth030 nope..skip this | |
285 adda #7 else add bias | |
286 | |
287 gth030 sta ,u+ store the ascii character | |
288 rts return | |
289 | |
290 * Convert "D" to 5 decimal digits in buffer at "U" | |
291 getdec pshs x,y,u save registers | |
292 ldx #10000 get decimal number for subtraction | |
293 bsr gtd010 get the decimal digit | |
294 ldx #01000 | |
295 bsr gtd010 | |
296 ldx #00100 | |
297 bsr gtd010 | |
298 ldx #00010 | |
299 bsr gtd010 | |
300 ldx #00001 | |
301 bsr gtd010 | |
302 puls x,y,u,pc restore registers & return | |
303 | |
304 gtd010 pshs x,a save x register & extra byte | |
305 clr ,s clear counter | |
306 | |
307 gtd020 cmpd 1,s compare 'd' with 'x' on stack | |
308 blo gtd030 less...skip this | |
309 subd 1,s else subtract number on stack | |
310 inc ,s increment digit counter | |
311 bra gtd020 and loop back | |
312 | |
313 gtd030 std 1,s save remainder of number | |
314 ldb ,s+ get counter | |
1748 | 315 addb #'0 make it ascii |
747 | 316 stb ,u+ and move it as output |
317 puls d,pc restore remainder & return | |
318 | |
319 emod | |
320 eom equ * | |
321 end |