1706
|
1 *
|
|
2 * Debug routines
|
|
3 *
|
|
4
|
|
5 ifp1
|
1912
|
6 use os9defs.d
|
1706
|
7 endc
|
|
8
|
|
9 psect debug_a,0,0,0,0,0
|
|
10 *
|
|
11 * Output bin byte in A to stdout
|
|
12 *
|
|
13 binout:
|
|
14 pshs a,b,cc,x,y
|
|
15 ldx #8 8 bits to write out.
|
|
16 binout1
|
|
17 ldb #'0
|
|
18 lsra Get next least significant bit
|
|
19 adcb #0 B will be 0 or 1
|
|
20 pshs b Save the digit.
|
|
21 leax -1,x
|
|
22 bne binout1
|
|
23 tfr s,x Now, output the 8 digits.
|
|
24 ldy #8
|
|
25 lda #2
|
|
26 os9 I$Write
|
|
27 leas 8,s
|
|
28 puls a,b,cc,x,y,pc
|
|
29
|
|
30
|
|
31 *
|
|
32 * Output hex byte in A to stdout
|
|
33 *
|
|
34 hexout:
|
|
35 pshs a,b,cc,x,y
|
|
36 tfr a,b
|
|
37 anda #$0f
|
|
38 adda #$90
|
|
39 daa
|
|
40 adca #$40
|
|
41 daa
|
|
42 pshs a
|
|
43 lda #$10
|
|
44 mul
|
|
45 adda #$90
|
|
46 daa
|
|
47 adca #$40
|
|
48 daa
|
|
49 pshs a
|
|
50 lda #2
|
|
51 tfr s,x
|
|
52 ldy #2
|
|
53 os9 I$Write
|
|
54 leas 2,s
|
|
55 puls a,b,cc,x,y,pc
|
|
56
|
|
57 CCdat fcc "efhinzvc"
|
|
58
|
|
59 CCOut
|
|
60 pshs cc,dp,a,b,x,y,u
|
|
61 pshs a
|
|
62 leau CCdat,pcr
|
|
63 pulu cc,dp,a,b,x,y Move 8 bytes to the stack.
|
|
64 pshs cc,dp,a,b,x,y
|
|
65 leax -1,s X points to CC info - 1
|
|
66 ldb #8
|
|
67 lda #'-
|
|
68 CCOloop
|
|
69 ror 8,s
|
|
70 bcs CCOSet
|
|
71 sta b,x
|
|
72 CCOSet
|
|
73 decb
|
|
74 bne CCOloop
|
|
75 lda #2
|
|
76 leax ,s
|
|
77 ldy #8
|
|
78 os9 I$Write
|
|
79 leas 9,s Clean up stack
|
|
80 puls a,b,cc,dp,x,y,u,pc
|
|
81
|
|
82 *
|
|
83 * Output byte in D to stderr
|
|
84 hexout2
|
|
85 pshs a,b,cc
|
|
86 bsr hexout
|
|
87 exg b,a
|
|
88 bsr hexout
|
|
89 puls a,b,cc,pc
|
|
90
|
|
91 *
|
|
92 * for single-byte regs, output hex + ASCII
|
|
93 hexout1
|
|
94 pshs a,b,x,y,cc
|
|
95 bsr hexout
|
|
96 anda #$7f Strip off high bit
|
|
97 cmpa #$7f
|
|
98 beq ho0
|
|
99 cmpa #$20
|
|
100 bhs ho1
|
|
101 ho0
|
|
102 lda #'.
|
|
103 ho1
|
|
104 pshs a Put character on stack.
|
|
105 ldb #$20
|
|
106 pshs b Put space before it.
|
|
107 lda #2
|
|
108 ldy #2
|
|
109 tfr s,x
|
|
110 os9 I$Write
|
|
111 puls x Clean up stack.
|
|
112 puls a,b,x,y,cc,pc
|
|
113
|
|
114 CCreg fcc " CC:"
|
|
115 Areg fcc " A:"
|
|
116 Breg fcc " B:"
|
|
117 DPreg fcc " DP:"
|
|
118 Xreg fcc " X:"
|
|
119 Yreg fcc " Y:"
|
|
120 Sreg fcc " S:"
|
|
121 Ureg fcc " U:"
|
|
122 PCreg fcc " PC:"
|
|
123
|
|
124 regdmp:
|
|
125 pshs u Push actual U
|
|
126 leau 4,s Make U be S (Note: no CC flags affected.)
|
|
127 pshs cc,a,b,dp,x,y,u Now push rest.
|
|
128 tfr s,u
|
|
129
|
|
130 leax CCreg,pcr
|
|
131 ldy #4 First do CC register.
|
|
132 lda #2
|
|
133 os9 I$Write
|
|
134 lda ,u+
|
|
135 lbsr CCOut
|
|
136 leax 4,x
|
|
137
|
|
138 ldb #3
|
|
139 dmpregs1
|
|
140 pshs b
|
|
141 ldy #4
|
|
142 lda #2
|
|
143 os9 I$Write
|
|
144 lda ,u+
|
|
145 bsr hexout1
|
|
146 leax 4,x
|
|
147 puls b
|
|
148 decb
|
|
149 bne dmpregs1
|
|
150
|
|
151 ldb #5
|
|
152 dmpregs2
|
|
153 pshs b
|
|
154 ldy #4
|
|
155 lda #2
|
|
156 os9 I$Write
|
|
157 ldd ,u++
|
|
158 lbsr hexout2
|
|
159 leax 4,x
|
|
160 puls b
|
|
161 decb
|
|
162 bne dmpregs2
|
|
163
|
|
164 bsr crlf Output the final CR.
|
|
165
|
|
166 * ldx #300 Sleep for 5 seconds.
|
|
167 * os9 F$Sleep
|
|
168
|
|
169 puls cc,a,b,dp,x,y,u
|
|
170 puls u,pc
|
|
171
|
|
172
|
|
173 *
|
|
174 * Miscellaneous output routines
|
|
175 *
|
|
176 crlf:
|
|
177 pshs a,b,cc,x,y
|
|
178 lda #$0d
|
|
179 bra Chrout
|
|
180 Space:
|
|
181 pshs a,b,cc,x,y
|
|
182 lda #$20
|
|
183 Chrout
|
|
184 pshs a
|
|
185 tfr s,x
|
|
186 ldy #1
|
|
187 lda #2
|
|
188 os9 I$WritLn
|
|
189 puls a
|
|
190 puls a,b,cc,x,y,pc
|
|
191
|
|
192 endsect
|