0
|
1
|
|
2 *
|
|
3 * Copyright February,1989 by Ron Lammardo
|
|
4 *
|
|
5 * This system call can be used in an application program to dump the
|
|
6 * current contents of all user registers in Hex,Decimal,Binary and Ascii
|
|
7 * (Registers "A" and "B" Only). This module MUST be present in the
|
|
8 * bootfile. If no OS9P3 module is found,change the "mname" and "nextname"
|
|
9 * as appropriate.
|
|
10 *
|
|
11 *
|
|
12 * If there is a conflict with the code used for this system called, it can
|
|
13 * be changed by resetting the equate at "F$RegDmp"
|
|
14 *
|
|
15 * NOTE: All registers EXCEPT 'CC' are preserved....OS9 internally resets
|
|
16 * the condition code register upon service call exit.
|
|
17
|
|
18 nam os9p4
|
|
19 ttl User Register Dump System Call for OS9 Level-II
|
|
20
|
|
21 ifp1
|
4
|
22 use defsfile
|
0
|
23 endc
|
|
24
|
|
25 typelang set systm+objct
|
|
26 attrev set reent+revision
|
|
27 revision set 1
|
|
28 edition set 1
|
|
29
|
|
30 mod Eom,Mname,Typelang,Attrev,Start,0
|
|
31
|
|
32 mname
|
628
|
33 fcs /OS9p4/ name of this module
|
0
|
34 fcb edition
|
|
35
|
|
36 svctabl
|
|
37 fcb F$RegDmp F$RegDmp code
|
|
38 fdb regdmp-*-2 offset to actual code
|
|
39 fcb $80 end of table
|
|
40
|
|
41 start
|
|
42 leay <svctabl,pcr point to service table
|
|
43 os9 F$SSvc insert the new op code in the table
|
|
44 lda #typelang get next module type (same as this one!)
|
|
45 leax <nextname,pcr get address of next module name
|
|
46 os9 F$Link attempt to link to it
|
|
47 bcs endsetup no good...skip this
|
|
48 jsr ,y else go execute it
|
|
49
|
|
50 endsetup
|
|
51 rts return back to previous module
|
|
52
|
|
53 nextname
|
|
54 fcc /OS9P5/ next module name to link to
|
|
55 fcb $0d
|
|
56
|
|
57 regdmp equ *
|
627
|
58 IFNE H6309
|
|
59 pshs cc,a,b,e,f,dp,x,y,u save all registers
|
|
60 ELSE
|
0
|
61 pshs cc,a,b,dp,x,y,u save all registers
|
627
|
62 ENDC
|
0
|
63 tfr u,y transfer addresses
|
|
64 leas -60,s back up for some variable storage
|
|
65 leau 4,s buffer starts here
|
|
66 clr ,u+ set flag to print ascii char
|
|
67 lda #$20 get a space
|
|
68 ldb #50 number of chars to clear
|
|
69 tfr u,x set register for loop
|
|
70
|
|
71 clrloop
|
|
72 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
|
627
|
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
|
0
|
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
|
627
|
102 ldd P$SP,y get users stack address
|
|
103 IFNE H6309
|
|
104 addd #14 add on for registers which were saved
|
|
105 ELSE
|
0
|
106 addd #12 add on for registers which were saved
|
627
|
107 ENDC
|
0
|
108 bsr reg000 dump register S
|
|
109 lbsr reg060 send a <CR>
|
|
110 leas 60,s restore stack pointer
|
627
|
111 IFNE H6309
|
|
112 puls cc,a,b,e,f,dp,x,y,u,pc restore all registers and return
|
|
113 ELSE
|
0
|
114 puls cc,a,b,dp,x,y,u,pc restore all registers and return
|
627
|
115 ENDC
|
0
|
116
|
|
117 * Dump a register in "D"
|
|
118 * X = Control Table Location
|
|
119 * U = Output buffer Location
|
|
120
|
|
121 reg000
|
|
122 pshs y save y register
|
|
123 tfr d,y register in y
|
|
124 lda ,x # of bytes
|
|
125 leax 3,x point past table entry
|
|
126 pshs a,x,y,u save registers
|
|
127 ldd -2,x get register name
|
|
128 std ,u++ move to buffer
|
|
129 ldd #"=$ get chars
|
|
130 std ,u++ move to buffer
|
|
131 ldd 3,s get reg
|
|
132 lbsr gethex convert to hex
|
|
133 tst 0,s 1 byte ?
|
|
134 bne reg010 no...skip this
|
|
135 ldd 2,u get 2 lsb's
|
|
136 std ,u store in msb's
|
|
137 ldd #$2020 get two blanks
|
|
138 std 2,u store in lsb's
|
|
139
|
|
140 reg010
|
|
141 ldd #$2023 get a space and "#"
|
|
142 std 4,u move in two spaces
|
|
143 leau 6,u point to start of decimal output buffer
|
|
144 ldd 3,s get register
|
|
145 lbsr getdec convert to decimal
|
|
146 tst 0,s is it one byte
|
|
147 bne reg020 no..skip this
|
|
148 ldd 2,u else get third & fourth chars
|
|
149 std ,u store as first two
|
|
150 lda 4,u get fifth char
|
|
151 sta 2,u store as third
|
|
152 ldd #$2020 get two spaces
|
|
153 std 3,u store as 4th & 5th chars
|
|
154
|
|
155 reg020
|
|
156 ldd #$2025 get a blank & "%"
|
|
157 std 5,u move it to buffer
|
|
158 leau 7,u point to start of binary output area
|
|
159 tfr a,b space in 'b'
|
|
160 std 16,u space out ascii char
|
|
161 ldd 3,s get register
|
|
162 bsr getbin convert to binary
|
|
163 tst 0,s check byte count
|
|
164 bne reg040 skip if two bytes
|
|
165 ldb #8 loop counter
|
|
166
|
|
167 reg030
|
|
168 lda 8,u get two chars from second 8 digits
|
|
169 sta ,u+ store in first 8 digits
|
|
170 lda #$20 get two blanks
|
|
171 sta 7,u store in second 8 digits
|
|
172 decb decrement counter
|
|
173 bne reg030 loop back if not done
|
|
174 leau -8,u back up to beginning of binary digit output
|
|
175 ldb 4,s get lsb of register
|
|
176 tst -18,u check if we want to print ascii char
|
|
177 bne reg040 nope..skip this
|
|
178 cmpb #$20 compare char with space
|
|
179 blo reg040 if lower..skip this
|
|
180 cmpb #'z compare with last alpha char
|
|
181 bhi reg040 if higher..skip this
|
|
182 stb 17,u else store the char
|
|
183
|
|
184 reg040
|
|
185 lda #$0d get a <cr>
|
|
186 sta 18,u and store it
|
|
187 leax -17,u back up to buffer start
|
|
188 bsr reg070 send it
|
|
189 clra clear msb for next reg
|
|
190 puls b,x,y,u restore registers
|
|
191 puls y,pc restore y & return
|
|
192
|
|
193 reg050
|
|
194 fcb $0d
|
|
195
|
|
196 reg060
|
|
197 leax <reg050,pcr point to <cr>
|
|
198
|
|
199 reg070
|
|
200 pshs x,y,u,a,b save registers
|
|
201 ldy <D.Proc get process descriptor address
|
|
202 lda P$Path+2,y get user error path number
|
|
203 pshs a save it
|
627
|
204 ldu P$SP,y get user stack address
|
0
|
205 leau -50,u back off to make room
|
|
206 lda <D.SysTsk get system task number
|
|
207 ldb P$Task,y get users task number
|
|
208 ldy #40 chars to move
|
|
209 os9 F$Move move from system to user space
|
|
210 tfr u,x restore buffer address
|
|
211 puls a restore user error path number
|
|
212 os9 I$WritLn send it
|
|
213 puls x,y,u,a,b,pc restore registers & return
|
|
214
|
|
215 * Control Table - Format is :
|
|
216 * Byte count (0=1,1=2)
|
|
217 * Register name (Two chars)
|
|
218
|
|
219 reg080
|
|
220 fcb 0
|
|
221 fcc /a /
|
|
222 fcb 0
|
|
223 fcc /b /
|
627
|
224 IFNE H6309
|
|
225 fcb 0
|
|
226 fcc /e /
|
|
227 fcb 0
|
|
228 fcc /f /
|
|
229 ENDC
|
0
|
230 fcb 1
|
|
231 fcc /x /
|
|
232 fcb 1
|
|
233 fcc /y /
|
|
234 fcb 1
|
|
235 fcc /u /
|
|
236 fcb 0
|
|
237 fcc /cc/
|
|
238 fcb 0
|
|
239 fcc /dp/
|
|
240 fcb 1
|
|
241 fcc /pc/
|
|
242 fcb 1
|
|
243 fcc /s /
|
|
244
|
|
245
|
|
246 * Convert "D" to binary digits in buffer "U"
|
|
247
|
|
248 getbin
|
|
249 pshs u,b save 'u', second byte of register
|
|
250 bsr bin010 convert first byte
|
|
251 puls a get second byte
|
|
252 bsr bin010 convert it
|
|
253 puls u,pc restore 'u' and return
|
|
254
|
|
255 bin010
|
|
256 bita #%10000000 check bit
|
|
257 bsr bin020 print result
|
|
258 bita #%01000000
|
|
259 bsr bin020
|
|
260 bita #%00100000
|
|
261 bsr bin020
|
|
262 bita #%00010000
|
|
263 bsr bin020
|
|
264 bita #%00001000
|
|
265 bsr bin020
|
|
266 bita #%00000100
|
|
267 bsr bin020
|
|
268 bita #%00000010
|
|
269 bsr bin020
|
|
270 bita #%00000001
|
|
271
|
|
272 bin020
|
|
273 beq bin030 skip this if bit was set
|
|
274 ldb #'1 else get an ascii '1'
|
|
275 bra bin040 skip next
|
|
276
|
|
277 bin030
|
|
278 ldb #'0 bit not set...get an ascii '0'
|
|
279
|
|
280 bin040
|
|
281 stb ,u+ store the ascii char
|
|
282 rts
|
|
283
|
|
284 * Convert "D" to 4 hex digits in buffer "U"
|
|
285
|
|
286 gethex
|
|
287 pshs u,b save 'u',second register byte
|
|
288 bsr gth010 convert first byte
|
|
289 puls a restore second byte
|
|
290 bsr gth010 convert it
|
|
291 puls u,pc restore 'u' and return
|
|
292
|
|
293 gth010
|
|
294 pshs a save the byte
|
|
295 lsra shift left 4 bits to right
|
|
296 lsra
|
|
297 lsra
|
|
298 lsra
|
|
299 bsr gth020 convert to hex digit
|
|
300 puls a restore the byte
|
|
301 anda #$0f strip off high 4 digits
|
|
302
|
|
303 gth020
|
|
304 adda #'0 make it ascii
|
|
305 cmpa #$3a is it a letter
|
|
306 blt gth030 nope..skip this
|
|
307 adda #7 else add bias
|
|
308
|
|
309 gth030
|
|
310 sta ,u+ store the ascii character
|
|
311 rts return
|
|
312
|
|
313 * Convert "D" to 5 decimal digits in buffer at "U"
|
|
314
|
|
315
|
|
316 getdec
|
|
317 pshs x,y,u save registers
|
|
318 ldx #10000 get decimal number for subtraction
|
|
319 bsr gtd010 get the decimal digit
|
|
320 ldx #01000
|
|
321 bsr gtd010
|
|
322 ldx #00100
|
|
323 bsr gtd010
|
|
324 ldx #00010
|
|
325 bsr gtd010
|
|
326 ldx #00001
|
|
327 bsr gtd010
|
|
328 puls x,y,u,pc restore registers & return
|
|
329
|
|
330 gtd010
|
|
331 pshs x,a save x register & extra byte
|
|
332 clr ,s clear counter
|
|
333
|
|
334 gtd020
|
|
335 cmpd 1,s compare 'd' with 'x' on stack
|
|
336 blo gtd030 less...skip this
|
|
337 subd 1,s else subtract number on stack
|
|
338 inc ,s increment digit counter
|
|
339 bra gtd020 and loop back
|
|
340
|
|
341 gtd030
|
|
342 std 1,s save remainder of number
|
|
343 ldb ,s+ get counter
|
|
344 addb #$30 make it ascii
|
|
345 stb ,u+ and move it as output
|
|
346 puls d,pc restore remainder & return
|
|
347
|
|
348 emod
|
|
349 eom
|
|
350 end
|