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