forked from n6il/sysgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregdump.a
264 lines (232 loc) · 8.76 KB
/
regdump.a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
*
*
*
psect _regdump,0,0,0,0,0
DoDump:
lbsr RegDump
pshs d,x,y
leas -1,s
tfr s,x
clra
ldy #1
os9 I$Read
lda ,s+
puls d,x,y,pc
RegDump:
pshs cc,a,b,dp,x,y,u save all registers
tfr s,y transfer addresses
leas -60,s back up for some variable storage
leau 4,s buffer starts here
clr ,u+ set flag to print ascii char
lda #$20 get a space
ldb #50 number of chars to clear
tfr u,x set register for loop
clrloop sta ,x+ initialize a space
decb decrement counter
bne clrloop if more..loop back & clear another
lbsr reg060 send a <cr>
leax reg080,pcr point to start of control table
clra clear msb of register
ldb 1,y get register from stack
bsr reg000 dump register A
ldb 2,y get register from stack
bsr reg000 dump register B
inc -1,u turn off ascii char print flag
ldd 4,y get register from stack
bsr reg000 dump register X
ldd 6,y get register from stack
bsr reg000 dump regisetr Y
ldd 8,y get register from stack
bsr reg000 dump register U
ldb ,y get register from stack
bsr reg000 dump register CC
ldb 3,y get register from stack
bsr reg000 dump register DP
ldd 10,y get user Task Number
bsr reg000 dump register PC
ldy <D.Proc get address of users process descriptor
tfr y,d get users stack address
addd #12 add on for registers which were saved
bsr reg000 dump register S
lbsr reg060 send a <CR>
leas 60,s restore stack pointer
puls cc,a,b,dp,x,y,u,pc restore all registers and return
* Dump a register in "D"
* X = Control Table Location
* U = Output buffer Location
reg000 pshs y save y register
tfr d,y register in y
lda ,x # of bytes
leax 3,x point past table entry
pshs a,x,y,u save registers
ldd -2,x get register name
std ,u++ move to buffer
lda #'= get chars
ldb #'$
std ,u++ move to buffer
ldd 3,s get reg
lbsr gethex convert to hex
tst 0,s 1 byte ?
bne reg010 no...skip this
ldd 2,u get 2 lsb's
std ,u store in msb's
ldd #$2020 get two blanks
std 2,u store in lsb's
reg010 ldd #$2023 get a space and "#"
std 4,u move in two spaces
leau 6,u point to start of decimal output buffer
ldd 3,s get register
lbsr getdec convert to decimal
tst 0,s is it one byte
bne reg020 no..skip this
ldd 2,u else get third & fourth chars
std ,u store as first two
lda 4,u get fifth char
sta 2,u store as third
ldd #$2020 get two spaces
std 3,u store as 4th & 5th chars
reg020 ldd #$2025 get a blank & "%"
std 5,u move it to buffer
leau 7,u point to start of binary output area
tfr a,b space in 'b'
std 16,u space out ascii char
ldd 3,s get register
bsr getbin convert to binary
tst 0,s check byte count
bne reg040 skip if two bytes
ldb #8 loop counter
reg030 lda 8,u get two chars from second 8 digits
sta ,u+ store in first 8 digits
lda #$20 get two blanks
sta 7,u store in second 8 digits
decb decrement counter
bne reg030 loop back if not done
leau -8,u back up to beginning of binary digit output
ldb 4,s get lsb of register
tst -18,u check if we want to print ascii char
bne reg040 nope..skip this
cmpb #$20 compare char with space
blo reg040 if lower..skip this
cmpb #'z compare with last alpha char
bhi reg040 if higher..skip this
stb 17,u else store the char
reg040 lda #C$CR get a <cr>
sta 18,u and store it
leax -17,u back up to buffer start
bsr reg070 send it
clra clear msb for next reg
puls b,x,y,u restore registers
puls y,pc restore y & return
reg050 fcb $0d
reg060 leax <reg050,pcr point to <cr>
reg070 pshs x,y,u,a,b save registers
lda #2
ldy #40
os9 I$WritLn
* ldy <D.Proc get process descriptor address
* lda P$Path+2,y get user error path number
* pshs a save it
* ldu P$SP,y get user stack address
* leau -50,u back off to make room
* lda <D.SysTsk get system task number
* ldb P$Task,y get users task number
* ldy #40 chars to move
* os9 F$Move move from system to user space
* tfr u,x restore buffer address
* puls a restore user error path number
* os9 I$WritLn send it
puls x,y,u,a,b,pc restore registers & return
* Control Table - Format is :
* Byte count (0=1,1=2)
* Register name (Two chars)
reg080 fcb 0
fcc /a /
fcb 0
fcc /b /
fcb 1
fcc /x /
fcb 1
fcc /y /
fcb 1
fcc /u /
fcb 0
fcc /cc/
fcb 0
fcc /dp/
fcb 1
fcc /pc/
fcb 1
fcc /s /
* Convert "D" to binary digits in buffer "U"
getbin pshs u,b save 'u', second byte of register
bsr bin010 convert first byte
puls a get second byte
bsr bin010 convert it
puls u,pc restore 'u' and return
bin010 bita #%10000000 check bit
bsr bin020 print result
bita #%01000000
bsr bin020
bita #%00100000
bsr bin020
bita #%00010000
bsr bin020
bita #%00001000
bsr bin020
bita #%00000100
bsr bin020
bita #%00000010
bsr bin020
bita #%00000001
bin020 beq bin030 skip this if bit was set
ldb #'1 else get an ascii '1'
bra bin040 skip next
bin030 ldb #'0 bit not set...get an ascii '0'
bin040 stb ,u+ store the ascii char
rts
* Convert "D" to 4 hex digits in buffer "U"
gethex pshs u,b save 'u',second register byte
bsr gth010 convert first byte
puls a restore second byte
bsr gth010 convert it
puls u,pc restore 'u' and return
gth010 pshs a save the byte
lsra shift left 4 bits to right
lsra
lsra
lsra
bsr gth020 convert to hex digit
puls a restore the byte
anda #$0f strip off high 4 digits
gth020 adda #'0 make it ascii
cmpa #$3a is it a letter
blt gth030 nope..skip this
adda #7 else add bias
gth030 sta ,u+ store the ascii character
rts return
* Convert "D" to 5 decimal digits in buffer at "U"
getdec pshs x,y,u save registers
ldx #10000 get decimal number for subtraction
bsr gtd010 get the decimal digit
ldx #01000
bsr gtd010
ldx #00100
bsr gtd010
ldx #00010
bsr gtd010
ldx #00001
bsr gtd010
puls x,y,u,pc restore registers & return
gtd010 pshs x,a save x register & extra byte
clr ,s clear counter
gtd020 cmpd 1,s compare 'd' with 'x' on stack
blo gtd030 less...skip this
subd 1,s else subtract number on stack
inc ,s increment digit counter
bra gtd020 and loop back
gtd030 std 1,s save remainder of number
ldb ,s+ get counter
addb #$30 make it ascii
stb ,u+ and move it as output
puls d,pc restore remainder & return
endsect