2351
|
1 ********************************************************************
|
|
2 * SFree - Show free memory for NitrOS-9 Level 3
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
|
8 * ------------------------------------------------------------------
|
|
9 * 1 ????/??/?? Alan DeKok
|
|
10 * Written from scratch.
|
|
11
|
|
12 nam SFree
|
|
13 ttl program module
|
|
14
|
|
15
|
|
16 ifp1
|
|
17 use defsfile
|
|
18 endc
|
|
19
|
|
20 tylg set Prgrm+Objct
|
|
21 atrv set ReEnt+rev
|
|
22 rev set $01
|
|
23 edition set 1
|
|
24
|
|
25 mod eom,name,tylg,atrv,start,size
|
|
26
|
|
27 Cnt rmb 1 number of free blocks found
|
|
28 MaxCnt rmb 1 size of maximum free block
|
|
29
|
|
30 u000F rmb 256
|
|
31 rmb 200 for the stack
|
|
32 size equ .
|
|
33
|
|
34 name fcs /SFree/
|
|
35 fcb edition
|
|
36
|
|
37 L005A fcb $00 temporary DAT image
|
|
38 fcb $00
|
|
39
|
|
40 Global fcb C$LF
|
|
41 fcc /----- Level III System Memory -----/
|
|
42 fcb C$LF
|
|
43 fcc /System memory:/
|
|
44 fcb C$CR
|
|
45
|
|
46 SCF fcb C$LF
|
|
47 fcc /SCF local memory:/
|
|
48 fcb C$CR
|
|
49
|
|
50 RBF fcb C$LF
|
|
51 fcc /RBF local memory:/
|
|
52 fcb C$CR
|
|
53
|
|
54 skip leax 1,x
|
|
55 start lda ,x
|
|
56 cmpa #C$SPAC
|
|
57 beq skip
|
|
58 cmpa #C$CR CR? (no parameters)
|
|
59 lbne Help no, print out help
|
|
60
|
|
61 leax >L005A,pcr
|
|
62 tfr x,d
|
|
63 ldx #D.SysMem ptr to system global memory map
|
|
64 ldy #$0002 2 bytes
|
|
65 ldu #u000F to a buffer
|
|
66 os9 F$CpyMem copy the memory
|
|
67 lbcs Exit exit on error
|
|
68 ldx ,u grab the offset to the buffer
|
|
69 leax $40,x ignore the first 2 8k blocks
|
|
70 ldy #$00C0 grab the rest of the page
|
|
71 os9 F$CpyMem copy the buffer
|
|
72 lbcs Exit exit on error
|
|
73
|
|
74 leax >Global,pc
|
|
75 lbsr Print
|
|
76 lda #$C0 maximum number of pages to check
|
|
77 bsr Dump
|
|
78
|
|
79 leax >L005A,pc
|
|
80 tfr x,d
|
|
81 ldx #$0660 Level III blocks
|
|
82 leas -2,s reserve 2 bytes on-stack
|
|
83 leau ,s point to the bytes
|
|
84 ldy #2 copy 2 bytes over
|
|
85 OS9 F$CpyMem
|
|
86
|
|
87 lda ,s get SCF block number
|
|
88 ora 1,s and RBF block number
|
|
89 beq Level.2 if none, we're on a Level II system
|
|
90
|
|
91 clr ,-s make a temporary DAT image
|
|
92 leax SCF,pc
|
|
93 bsr Local
|
|
94
|
|
95 leas 1,s
|
|
96 clr ,s
|
|
97 leax RBF,pc
|
|
98 bsr Local
|
|
99
|
|
100 Level.2 leas 2,s
|
|
101
|
|
102 ClnExit clrb
|
|
103 Exit OS9 F$Exit
|
|
104
|
|
105 Local lbsr Print print out the header
|
|
106 leax 2,s
|
|
107 tfr x,d
|
|
108 ldu #u000F
|
|
109 ldx #$0000 from the start of the block
|
|
110 ldy #$0040 64 bytes only
|
|
111 OS9 F$CpyMem
|
|
112 lda #$40 64 pages, and fall through to DUMP
|
|
113
|
|
114 Dump clr <MaxCnt no maximum count of free blocks yet
|
|
115 clr <Cnt total count is zero, too.
|
|
116 ldx #u000F point to the buffer where the blocks are
|
|
117 pshs a save number of pages to check
|
|
118 clra we haven't found a free block yet
|
|
119
|
|
120 d.skip ldb ,x+ grab a page flag
|
|
121 beq d.loop this page is free, go check it
|
|
122 d.skip1 dec ,s done one more byte
|
|
123 bne d.skip if we're not done them all yet, continue
|
|
124 bra d.done go to the 'done' routine
|
|
125
|
|
126 d.loop inca found a maximum series of free page
|
|
127 inc <Cnt another total free page
|
|
128 dec ,s count down by one byte
|
|
129 beq d.done exit if we're done everything
|
|
130
|
|
131 ldb ,x+ grab a page flag
|
|
132 beq d.loop if it's free, increment counters, etc.
|
|
133 cmpa <MaxCnt is this block larger than the previous free block?
|
|
134 bls d.skip1 if not, exit
|
|
135 sta <MaxCnt it's larger, so save it.
|
|
136 clra reset the count to zero
|
|
137 bra d.skip1 decrement counters, and find another free block
|
|
138
|
|
139 d.done leas 1,s kill counter off of the stack
|
|
140 cmpa <MaxCnt A=maximum series of free pages
|
|
141 bls d.done1
|
|
142 sta <MaxCnt
|
|
143
|
|
144 d.done1 ldb <Cnt get total count of free pages
|
|
145 bsr PNum print out a decimal number in B
|
|
146 leax MSize,pc
|
|
147 ldy #MLen
|
|
148 lda #$01 STDOUT
|
|
149 OS9 I$Write dump it out
|
|
150
|
|
151 ldb <MaxCnt get maximum size of the free area
|
|
152 bsr PNum print out the number
|
|
153
|
|
154 leax ZSize,pc to maximum free size message
|
|
155 bsr Print go print it out
|
|
156
|
|
157 ldb <Cnt get size again
|
|
158 lsrb
|
|
159 lsrb get number of K free
|
|
160 bsr PNum print it out
|
|
161 leax KFree,pc
|
|
162 bra Print
|
|
163
|
|
164 PNum pshs a save a junk byte
|
|
165 ldx #$2F3A other data
|
|
166 pshs x
|
|
167 do.100 inc ,s
|
|
168 subb #100
|
|
169 bcc do.100
|
|
170 do.10 dec 1,s
|
|
171 addb #10
|
|
172 bcc do.10
|
|
173 addb #$30
|
|
174 stb 2,s
|
|
175
|
|
176 leax ,s point to the numbers
|
|
177 ldy #3 number of bytes to print out
|
|
178 ldd ,s
|
|
179 cmpa #'0 leading 0?
|
|
180 bne pn.ok no, go print
|
|
181 leax 1,x skip this byte
|
|
182 leay -1,y one less to print
|
|
183 cmpb #'0 another leading 0?
|
|
184 bne pn.ok no, go print
|
|
185 leax 1,x skip this byte
|
|
186 leay -1,y one less to print.
|
|
187
|
|
188 pn.ok lda #1
|
|
189 OS9 I$Write dump it out
|
|
190 puls a,x,pc dump 3 bytes off of the stack, and return
|
|
191
|
|
192 MSize fcc / free pages, largest block /
|
|
193 Mlen equ *-MSize
|
|
194 ZSize fcc / pages./
|
|
195 fcb C$CR
|
|
196 KFree fcc /K of free RAM./
|
|
197 fcb C$CR
|
|
198
|
|
199 Print ldy #$0200
|
|
200 lda #$01 to STDOUT
|
|
201 OS9 I$WritLn
|
|
202 rts
|
|
203
|
|
204 Help leax HMsg,pc point to the message
|
|
205 bsr Print dump it out
|
|
206 lbra ClnExit and exit
|
|
207
|
|
208 HMsg fcc /SFree: Level III utility to show free system memory./
|
|
209 fcb C$LF
|
|
210 fcc / Beta version 0.9/
|
|
211 fcb C$CR
|
|
212
|
|
213 emod
|
|
214 eom equ *
|
|
215 end
|
|
216
|