0
|
1 ********************************************************************
|
|
2 * MMap - Show memory block map
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * From Kevin Darling, "Inside OS9 Level II"
|
|
7 *
|
|
8 * Ed. Comments Who YY/MM/DD
|
|
9 * ------------------------------------------------------------------
|
|
10 * ? Original verison KKD 88/??/??
|
|
11 * 4 Modified by Ken Drexler fr various block sizes KD 89/07/30
|
|
12
|
|
13 nam MMap
|
|
14 ttl Memory Block Utility
|
|
15
|
|
16 ifp1
|
|
17 use defsfile
|
|
18 endc
|
|
19
|
|
20 Revs set ReEnt+1
|
|
21 Type set Prgrm+Objct
|
|
22 edition set 4
|
|
23
|
|
24 mod prglen,name,type,revs,MMap,datsiz
|
|
25
|
|
26 Name fcs /MMap/
|
|
27 fcb edition
|
|
28
|
|
29 ***************************************************
|
|
30 *
|
|
31 * Data
|
|
32 *
|
|
33 buffsiz set 512
|
|
34
|
|
35 numflag rmb 1 flag for leading zeros
|
|
36 rowcnt rmb 1 no rows to print
|
|
37 free rmb 1 no free blocks
|
|
38 rowno rmb 1 row number
|
|
39 lcnt rmb 1 line length counter
|
|
40 outptr rmb 2 output pointer
|
|
41 out rmb 80 output buffer
|
|
42 mapsiz rmb 2 size of map block
|
|
43 blksiz rmb 2 block size
|
|
44 buffer rmb buffsiz map itself
|
|
45 stack rmb 200
|
|
46 datsiz equ .
|
|
47
|
|
48 pag
|
|
49 ***************************************************
|
|
50 *
|
|
51 * Messages
|
|
52 *
|
|
53 header fcc / 0 1 2 3 4 5 6 7 8 9 A B C D E F/
|
|
54 fcb C$CR
|
|
55 hdrlen equ *-header
|
|
56
|
|
57 hdr2 fcc / # = = = = = = = = = = = = = = = =/
|
|
58 fcb C$CR
|
|
59 hdrlen2 equ *-hdr2
|
|
60
|
|
61 BlockMsg fcc / Block Size: /
|
|
62 blklen equ *-Blockmsg
|
|
63
|
|
64 Freemsg fcc / Free Blocks: /
|
|
65 freelen equ *-Freemsg
|
|
66
|
|
67 Rammsg fcc / KBytes Free: /
|
|
68 ramlen equ *-Rammsg
|
|
69
|
|
70 **********************************************
|
|
71 *
|
|
72 MMap lbsr pcrtn print line
|
|
73 leax header,pcr print headers
|
|
74 lda #1
|
|
75 ldy #hdrlen
|
|
76 os9 I$WritLn
|
|
77 leax hdr2,pcr
|
|
78 ldy #hdrlen2
|
|
79 os9 I$WritLn
|
|
80 leax buffer,u get block map to read
|
|
81 os9 F$GBlkMp
|
|
82 lbcs error
|
|
83 std blksiz save block size
|
|
84 sty mapsiz save map size
|
|
85 clr free
|
|
86 clr rowno
|
|
87 ldd mapsiz compute number of rows
|
|
88 lsra at 16 per row
|
|
89 rorb
|
|
90 lsra
|
|
91 rorb
|
|
92 lsra
|
|
93 rorb
|
|
94 lsra
|
|
95 rorb
|
|
96 stb rowcnt save count
|
|
97 leax out,u
|
|
98 stx outptr
|
|
99 leax buffer,u point at map
|
|
100 pshs x
|
|
101 bra loop2
|
|
102
|
|
103 loop dec lcnt count -= 1
|
|
104 bne loop3 if more, skip line print
|
|
105
|
|
106 * print line, start next line
|
|
107 loop1 pshs x save map pointer
|
|
108 lbsr prline print line
|
|
109 dec rowcnt done?
|
|
110 beq exit yes
|
|
111 loop2 lda #16 set line length count
|
|
112 sta lcnt
|
|
113 lbsr Space 1 space
|
|
114 lda rowno print row number
|
|
115 lbsr Hex1
|
|
116 inc rowno row number += 1
|
|
117 lbsr space2 2 spaces
|
|
118 puls x
|
|
119
|
|
120 * Print one block status
|
|
121 loop3 ldb ,x+ get next block
|
|
122 beq freeram
|
|
123 bmi noram
|
|
124 bitb #2 module?
|
|
125 bne module
|
|
126 lda #'U must be ram in use
|
|
127 bra put
|
|
128
|
|
129 freeram lda #'_ not used
|
|
130 inc free count it
|
|
131 bra put
|
|
132
|
|
133 module lda #'M module
|
|
134 bra put
|
|
135
|
|
136 noram lda #'. not ram
|
|
137
|
|
138 * Print character in A and space
|
|
139 put equ *
|
|
140 lbsr print put character in output buffer
|
|
141 lda #C$SPAC add space
|
|
142 lbsr print
|
|
143
|
|
144 bra loop
|
|
145
|
|
146 * Add summary messages
|
|
147 Exit equ *
|
|
148 leax BlockMsg,pcr print "Block Size"
|
|
149 ldy #blklen
|
|
150 lbsr Prstr
|
|
151 ldd blksiz
|
|
152 clr numflag suppress zeros
|
|
153 bsr outdec
|
|
154 lbsr prline print line
|
|
155 leax freemsg,pcr print "Free Blocks"
|
|
156 ldy #freelen
|
|
157 lbsr Prstr
|
|
158 ldb free get number of blocks
|
|
159 clra
|
|
160 clr numflag suppress zeros
|
|
161 bsr outdec print in decimal
|
|
162 bsr prline
|
|
163 leax rammsg,pcr print "Ram Free"
|
|
164 ldy #ramlen
|
|
165 lbsr Prstr
|
|
166 ldb free get number of blocks
|
|
167 lda blksiz get #k/block
|
|
168 lsra by dividing msb by 4
|
|
169 lsra
|
|
170 mul
|
|
171 clr numflag suppress zeros
|
|
172 bsr outdec print in decimal
|
|
173 bsr prline
|
|
174
|
|
175 bye clrb no errors
|
|
176
|
|
177 error os9 F$Exit
|
|
178
|
|
179
|
|
180 **********************************************
|
|
181 *
|
|
182 * Subroutines
|
|
183 *
|
|
184 Pcrtn pshs a,x Output carriage return
|
|
185 lda #C$CR
|
|
186 sta out
|
|
187 leax out,u point at buffer
|
|
188 ldy #1 one char.
|
|
189 lda #1
|
|
190 os9 I$WritLn
|
|
191 puls a,x,pc
|
|
192
|
|
193
|
|
194 ** Decimal output routine
|
|
195 * IN: D - number to output
|
|
196 * X - destination buffer
|
|
197 * OUT: X,Y,U preserved
|
|
198 *
|
|
199 Outdec pshs b,x,y,u
|
|
200 ldx outptr get pointer
|
|
201 leau <dectbl,pcr
|
|
202 ldy #5 set counter
|
|
203
|
|
204 Outdec1 clr ,s clear workspace
|
|
205
|
|
206 Outdec2 subd ,u subtract power of ten
|
|
207 bcs outdec3
|
|
208 inc ,s
|
|
209 bra outdec2
|
|
210
|
|
211 outdec3 addd ,u++ add back one power
|
|
212 pshs b save b
|
|
213 ldb 1,s
|
|
214 addb #'0 convert to ascii
|
|
215 cmpb #'0 zero?
|
|
216 bne outdec4 no, print it
|
|
217 tst numflag suppress zero?
|
|
218 beq outdec5 yes
|
|
219 outdec4 inc numflag
|
|
220 stb ,x+ put in buffer
|
|
221 outdec5 puls b restore b
|
|
222 leay -1,y counter -= 1
|
|
223 bne outdec1
|
|
224 stx outptr update pointer
|
|
225 puls b,x,y,u,pc
|
|
226
|
|
227 Dectbl fdb 10000
|
|
228 fdb 1000
|
|
229 fdb 100
|
|
230 fdb 10
|
|
231 fdb 1
|
|
232
|
|
233
|
|
234 * Print Line
|
|
235 Prline ldx outptr now print line
|
|
236 lda #C$CR
|
|
237 sta ,x terminate line
|
|
238 leax out,u
|
|
239 ldy #80
|
|
240 lda #1
|
|
241 os9 I$Writln
|
|
242 bcs error
|
|
243 leax out,u set pointer
|
|
244 stx outptr
|
|
245 rts
|
|
246
|
|
247
|
|
248 * Print Spaces
|
|
249 Space2 bsr Space
|
|
250
|
|
251 Space lda #C$SPAC
|
|
252 bra Print
|
|
253
|
|
254 * Print Hexidecimal Digit in A
|
|
255 Hex1 tfr a,b
|
|
256 lsra
|
|
257 lsra
|
|
258 lsra
|
|
259 lsra
|
|
260 bsr outhex
|
|
261 tfr b,a
|
|
262 Outhex anda #$0f
|
|
263 cmpa #$0a 0 - 9
|
|
264 bcs outdig
|
|
265 adda #$07 A - F
|
|
266 outdig adda #'0 make ASCII
|
|
267 print pshs X
|
|
268 ldx outptr
|
|
269 sta ,X+
|
|
270 stx outptr
|
|
271 puls x,pc
|
|
272
|
|
273
|
|
274 * Print string to output buffer
|
|
275 * IN: X - string pointer
|
|
276 * Y - string length
|
|
277 *
|
|
278 Prstr equ *
|
|
279 lda ,x+ get character
|
|
280 bsr print put in buffer
|
|
281 leay -1,y
|
|
282 bne Prstr
|
|
283 rts
|
|
284
|
|
285 emod
|
|
286 Prglen equ *
|
|
287 end
|