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