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