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
|
|
22 use os9defs.l2v3
|
|
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
|
|
33 fcs /OS9P4/ name of this module
|
|
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 *
|
|
58 pshs cc,a,b,dp,x,y,u save all registers
|
|
59 tfr u,y transfer addresses
|
|
60 leas -60,s back up for some variable storage
|
|
61 leau 4,s buffer starts here
|
|
62 clr ,u+ set flag to print ascii char
|
|
63 lda #$20 get a space
|
|
64 ldb #50 number of chars to clear
|
|
65 tfr u,x set register for loop
|
|
66
|
|
67 clrloop
|
|
68 sta ,x+ initialize a space
|
|
69 decb decrement counter
|
|
70 bne clrloop if more..loop back & clear another
|
|
71 lbsr reg060 send a <cr>
|
|
72 leax reg080,pcr point to start of control table
|
|
73 clra clear msb of register
|
|
74 ldb R$A,y get register from stack
|
|
75 bsr reg000 dump register A
|
|
76 ldb R$B,y get register from stack
|
|
77 bsr reg000 dump regsietr B
|
|
78 inc -1,u turn off ascii char print flag
|
|
79 ldd R$X,y get register from stack
|
|
80 bsr reg000 dump register X
|
|
81 ldd R$Y,y get register from stack
|
|
82 bsr reg000 dump regisetr Y
|
|
83 ldd R$U,y get register from stack
|
|
84 bsr reg000 dump register U
|
|
85 ldb R$CC,y get register from stack
|
|
86 bsr reg000 dump register CC
|
|
87 ldb R$DP,y get register from stack
|
|
88 bsr reg000 dump register DP
|
|
89 ldd R$PC,y get user Task Number
|
|
90 bsr reg000 dump register PC
|
|
91 ldy <D.Proc get address of users process descriptor
|
|
92 ldd P$Sp,y get users stack address
|
|
93 addd #12 add on for registers which were saved
|
|
94 bsr reg000 dump register S
|
|
95 lbsr reg060 send a <CR>
|
|
96 leas 60,s restore stack pointer
|
|
97 puls cc,a,b,dp,x,y,u,pc restore all registers and return
|
|
98
|
|
99 * Dump a register in "D"
|
|
100 * X = Control Table Location
|
|
101 * U = Output buffer Location
|
|
102
|
|
103 reg000
|
|
104 pshs y save y register
|
|
105 tfr d,y register in y
|
|
106 lda ,x # of bytes
|
|
107 leax 3,x point past table entry
|
|
108 pshs a,x,y,u save registers
|
|
109 ldd -2,x get register name
|
|
110 std ,u++ move to buffer
|
|
111 ldd #"=$ get chars
|
|
112 std ,u++ move to buffer
|
|
113 ldd 3,s get reg
|
|
114 lbsr gethex convert to hex
|
|
115 tst 0,s 1 byte ?
|
|
116 bne reg010 no...skip this
|
|
117 ldd 2,u get 2 lsb's
|
|
118 std ,u store in msb's
|
|
119 ldd #$2020 get two blanks
|
|
120 std 2,u store in lsb's
|
|
121
|
|
122 reg010
|
|
123 ldd #$2023 get a space and "#"
|
|
124 std 4,u move in two spaces
|
|
125 leau 6,u point to start of decimal output buffer
|
|
126 ldd 3,s get register
|
|
127 lbsr getdec convert to decimal
|
|
128 tst 0,s is it one byte
|
|
129 bne reg020 no..skip this
|
|
130 ldd 2,u else get third & fourth chars
|
|
131 std ,u store as first two
|
|
132 lda 4,u get fifth char
|
|
133 sta 2,u store as third
|
|
134 ldd #$2020 get two spaces
|
|
135 std 3,u store as 4th & 5th chars
|
|
136
|
|
137 reg020
|
|
138 ldd #$2025 get a blank & "%"
|
|
139 std 5,u move it to buffer
|
|
140 leau 7,u point to start of binary output area
|
|
141 tfr a,b space in 'b'
|
|
142 std 16,u space out ascii char
|
|
143 ldd 3,s get register
|
|
144 bsr getbin convert to binary
|
|
145 tst 0,s check byte count
|
|
146 bne reg040 skip if two bytes
|
|
147 ldb #8 loop counter
|
|
148
|
|
149 reg030
|
|
150 lda 8,u get two chars from second 8 digits
|
|
151 sta ,u+ store in first 8 digits
|
|
152 lda #$20 get two blanks
|
|
153 sta 7,u store in second 8 digits
|
|
154 decb decrement counter
|
|
155 bne reg030 loop back if not done
|
|
156 leau -8,u back up to beginning of binary digit output
|
|
157 ldb 4,s get lsb of register
|
|
158 tst -18,u check if we want to print ascii char
|
|
159 bne reg040 nope..skip this
|
|
160 cmpb #$20 compare char with space
|
|
161 blo reg040 if lower..skip this
|
|
162 cmpb #'z compare with last alpha char
|
|
163 bhi reg040 if higher..skip this
|
|
164 stb 17,u else store the char
|
|
165
|
|
166 reg040
|
|
167 lda #$0d get a <cr>
|
|
168 sta 18,u and store it
|
|
169 leax -17,u back up to buffer start
|
|
170 bsr reg070 send it
|
|
171 clra clear msb for next reg
|
|
172 puls b,x,y,u restore registers
|
|
173 puls y,pc restore y & return
|
|
174
|
|
175 reg050
|
|
176 fcb $0d
|
|
177
|
|
178 reg060
|
|
179 leax <reg050,pcr point to <cr>
|
|
180
|
|
181 reg070
|
|
182 pshs x,y,u,a,b save registers
|
|
183 ldy <D.Proc get process descriptor address
|
|
184 lda P$Path+2,y get user error path number
|
|
185 pshs a save it
|
|
186 ldu P$Sp,y get user stack address
|
|
187 leau -50,u back off to make room
|
|
188 lda <D.SysTsk get system task number
|
|
189 ldb P$Task,y get users task number
|
|
190 ldy #40 chars to move
|
|
191 os9 F$Move move from system to user space
|
|
192 tfr u,x restore buffer address
|
|
193 puls a restore user error path number
|
|
194 os9 I$WritLn send it
|
|
195 puls x,y,u,a,b,pc restore registers & return
|
|
196
|
|
197 * Control Table - Format is :
|
|
198 * Byte count (0=1,1=2)
|
|
199 * Register name (Two chars)
|
|
200
|
|
201 reg080
|
|
202 fcb 0
|
|
203 fcc /a /
|
|
204 fcb 0
|
|
205 fcc /b /
|
|
206 fcb 1
|
|
207 fcc /x /
|
|
208 fcb 1
|
|
209 fcc /y /
|
|
210 fcb 1
|
|
211 fcc /u /
|
|
212 fcb 0
|
|
213 fcc /cc/
|
|
214 fcb 0
|
|
215 fcc /dp/
|
|
216 fcb 1
|
|
217 fcc /pc/
|
|
218 fcb 1
|
|
219 fcc /s /
|
|
220
|
|
221
|
|
222 * Convert "D" to binary digits in buffer "U"
|
|
223
|
|
224 getbin
|
|
225 pshs u,b save 'u', second byte of register
|
|
226 bsr bin010 convert first byte
|
|
227 puls a get second byte
|
|
228 bsr bin010 convert it
|
|
229 puls u,pc restore 'u' and return
|
|
230
|
|
231 bin010
|
|
232 bita #%10000000 check bit
|
|
233 bsr bin020 print result
|
|
234 bita #%01000000
|
|
235 bsr bin020
|
|
236 bita #%00100000
|
|
237 bsr bin020
|
|
238 bita #%00010000
|
|
239 bsr bin020
|
|
240 bita #%00001000
|
|
241 bsr bin020
|
|
242 bita #%00000100
|
|
243 bsr bin020
|
|
244 bita #%00000010
|
|
245 bsr bin020
|
|
246 bita #%00000001
|
|
247
|
|
248 bin020
|
|
249 beq bin030 skip this if bit was set
|
|
250 ldb #'1 else get an ascii '1'
|
|
251 bra bin040 skip next
|
|
252
|
|
253 bin030
|
|
254 ldb #'0 bit not set...get an ascii '0'
|
|
255
|
|
256 bin040
|
|
257 stb ,u+ store the ascii char
|
|
258 rts
|
|
259
|
|
260 * Convert "D" to 4 hex digits in buffer "U"
|
|
261
|
|
262 gethex
|
|
263 pshs u,b save 'u',second register byte
|
|
264 bsr gth010 convert first byte
|
|
265 puls a restore second byte
|
|
266 bsr gth010 convert it
|
|
267 puls u,pc restore 'u' and return
|
|
268
|
|
269 gth010
|
|
270 pshs a save the byte
|
|
271 lsra shift left 4 bits to right
|
|
272 lsra
|
|
273 lsra
|
|
274 lsra
|
|
275 bsr gth020 convert to hex digit
|
|
276 puls a restore the byte
|
|
277 anda #$0f strip off high 4 digits
|
|
278
|
|
279 gth020
|
|
280 adda #'0 make it ascii
|
|
281 cmpa #$3a is it a letter
|
|
282 blt gth030 nope..skip this
|
|
283 adda #7 else add bias
|
|
284
|
|
285 gth030
|
|
286 sta ,u+ store the ascii character
|
|
287 rts return
|
|
288
|
|
289 * Convert "D" to 5 decimal digits in buffer at "U"
|
|
290
|
|
291
|
|
292 getdec
|
|
293 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
|
|
307 pshs x,a save x register & extra byte
|
|
308 clr ,s clear counter
|
|
309
|
|
310 gtd020
|
|
311 cmpd 1,s compare 'd' with 'x' on stack
|
|
312 blo gtd030 less...skip this
|
|
313 subd 1,s else subtract number on stack
|
|
314 inc ,s increment digit counter
|
|
315 bra gtd020 and loop back
|
|
316
|
|
317 gtd030
|
|
318 std 1,s save remainder of number
|
|
319 ldb ,s+ get counter
|
|
320 addb #$30 make it ascii
|
|
321 stb ,u+ and move it as output
|
|
322 puls d,pc restore remainder & return
|
|
323
|
|
324 emod
|
|
325 eom
|
|
326 end
|
|
327
|
|
328
|