Mercurial > hg > Members > kono > nitros9-code
annotate level2/cmds/mfree.asm @ 3193:489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Infer functionality by code inspection and add comments accordingly.
Document bug that occurs when final block is free (does not occur on
coco but does occur on mc09).
author | Neal Crook <foofoobedoo@gmail.com> |
---|---|
date | Tue, 30 May 2017 23:45:40 +0100 |
parents | fa494f2dca9a |
children | 2ecebda8716b |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
2 * Mfree - Show free memory | |
3 * | |
4 * $Id$ | |
5 * | |
1255 | 6 * Edt/Rev YYYY/MM/DD Modified by |
7 * Comment | |
0 | 8 * ------------------------------------------------------------------ |
1255 | 9 * 2 ????/??/?? |
10 * Original Tandy/Microware version. | |
0 | 11 |
12 nam Mfree | |
13 ttl Show free memory | |
14 | |
15 * Disassembled 98/09/11 12:07:32 by Disasm v1.6 (C) 1988 by RML | |
16 | |
17 ifp1 | |
18 use defsfile | |
19 endc | |
20 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
21 tylg set Prgrm+Objct |
0 | 22 atrv set ReEnt+rev |
1255 | 23 rev set $00 |
0 | 24 edition set 2 |
25 | |
26 mod eom,name,tylg,atrv,start,size | |
27 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
28 freeblks rmb 2 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
29 mapsiz rmb 2 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
30 * pages per block (ie, MS byte of block size) |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
31 ppblk rmb 1 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
32 * 0: print number with leading spaces. 1: print number with leading 0. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
33 leadzero rmb 1 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
34 * u0006,7,8 store a 24-bit block begin/end address. |
0 | 35 u0006 rmb 1 |
36 u0007 rmb 1 | |
37 u0008 rmb 1 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
38 bufstrt rmb 2 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
39 bufcur rmb 2 |
1636 | 40 linebuf rmb 80 |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
41 mapbuf rmb 1274 |
0 | 42 size equ . |
43 | |
44 name fcs /Mfree/ | |
45 fcb edition | |
46 | |
1636 | 47 Hdr fcs " Blk Begin End Blks Size" |
0 | 48 fcs " --- ------ ------ ---- ------" |
1636 | 49 Ftr fcs " ==== ======" |
50 fcs " Total: " | |
0 | 51 |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
52 start leax linebuf,u get line buffer address |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
53 stx <bufstrt and store it away |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
54 stx <bufcur current output position output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
55 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
56 lbsr wrbuf print CR |
1636 | 57 leay <Hdr,pcr |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
58 lbsr tobuf 1st line of header to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
59 lbsr wrbuf ..print it |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
60 lbsr tobuf 2nd line of header to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
61 lbsr wrbuf ..print it |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
62 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
63 clr <freeblks total number of free blocks |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
64 clr <freeblks+1 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
65 leax <mapbuf,u |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
66 * In: X = 1024-byte buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
67 * Out: D = number of bytes per block |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
68 * Y = system memory block map size |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
69 os9 F$GBlkMp |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
70 sty <mapsiz save map size |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
71 sta <ppblk save MS byte of bytes per block |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
72 ldy #$0000 count of how many blocks we have inspected |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
73 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
74 * Main loop |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
75 * look for a free block (an entry of 0 in the block map) |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
76 loop ldu #$0000 number of free blocks in this sequence |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
77 L00AD tst ,x+ is this block 0? |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
78 beq L00BA yes - found a free block |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
79 leay $01,y total number of blocks we have inspected |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
80 cmpy <mapsiz at the end of the map? |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
81 bcs L00AD no, so carry on looking |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
82 bra alldone yes, and the last block was not free, so we're done. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
83 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
84 * Block number in Y is the first free block of a sequence (tho maybe a sequence of 1) |
0 | 85 L00BA tfr y,d |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
86 bsr buf4hex append start block, in hex, to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
87 lda <ppblk |
0 | 88 pshs y,a |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
89 clra |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
90 clrb |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
91 L00C4 addd $01,s multiply start block by block size to get |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
92 dec ,s begin address |
0 | 93 bne L00C4 |
94 leas $03,s | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
95 std <u0006 2 MS bytes of block begin address |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
96 clr <u0008 1 LS byte of block begin address is 0 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
97 bsr buf6hex append block begin address in hex, to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
98 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
99 * Look for the last free block in this sequence |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
100 L00D2 leau $01,u |
0 | 101 leay $01,y |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
102 cmpy <mapsiz |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
103 beq alldone ??should never exit at this point, but |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
104 * on mc09 we do - terminate part-way through an entry. |
0 | 105 tst ,x+ |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
106 beq L00D2 haven't found it yet.. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
107 last lda <ppblk |
0 | 108 pshs y,a |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
109 clra |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
110 clrb |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
111 L00E5 addd $01,s multiply end block by block size to get |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
112 dec ,s end address |
0 | 113 bne L00E5 |
114 leas $03,s | |
115 subd #$0001 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
116 std <u0006 2 MS bytes of block end address |
0 | 117 lda #$FF |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
118 sta <u0008 1 LS byte of block end address is $FF |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
119 bsr buf6hex append block end address in hex, to output buffer |
0 | 120 leax -$01,x |
121 tfr u,d | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
122 bsr buf4hex append number of blocks, in hex, to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
123 lbsr L0199 append size, in decimal, to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
124 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
125 addd <freeblks |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
126 std <freeblks total number of blocks |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
127 bsr wrbuf print this entry |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
128 bra loop loop for next entry |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
129 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
130 * All of the entries have been printed. Print the trailer and totals. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
131 * Bug: if the last block is unused, it and any unused blocks before it will |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
132 * not get reported, *and* the formatting of the last entry will be messed up. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
133 * That never happens on the Coco, because the last block is always used. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
134 * It does happen on mc09 though. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
135 alldone leay >Ftr,pcr |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
136 bsr tobuf 1st line of footer to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
137 bsr wrbuf ..print it |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
138 bsr tobuf 2nd line of footer to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
139 tfr u,d ..add total #blocks, total memory size |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
140 addd <freeblks |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
141 std <freeblks |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
142 bsr buf4hex append total number of blocks, in hex, to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
143 bsr L0199 append total size, in decimal, to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
144 bsr wrbuf ..print it |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
145 * Successful exit |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
146 clrb |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
147 os9 F$Exit |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
148 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
149 * convert value in D to ASCII hex (4 chars). Append to output buffer, then append "SPACE" to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
150 buf4hex pshs b,a |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
151 clr <leadzero |
0 | 152 bsr L0145 |
153 tfr b,a | |
154 bsr L0145 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
155 lda #C$SPAC append a space |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
156 bsr bufchr |
0 | 157 puls pc,b,a |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
158 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
159 * convert value in u0006,7,8 to ASCII hex (6 chars). Append to output buffer, then append "SPACE" to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
160 buf6hex clr <leadzero |
0 | 161 lda <u0006 |
162 bsr L0145 | |
163 lda <u0007 | |
164 bsr L0145 | |
165 lda <u0008 | |
166 bsr L0145 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
167 lda #C$SPAC append a space |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
168 bra bufchr |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
169 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
170 * convert value in A to ASCII hex (2 chars). Append to output buffer. |
0 | 171 L0145 pshs a |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
172 lsra |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
173 lsra |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
174 lsra |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
175 lsra |
0 | 176 bsr L014F |
177 puls a | |
178 L014F anda #$0F | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
179 tsta |
0 | 180 beq L0156 |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
181 sta <leadzero |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
182 L0156 tst <leadzero |
0 | 183 bne L015C |
184 lda #$F0 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
185 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
186 * FALL THROUGH |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
187 * Convert digit to ASCII with leading spaces, add to output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
188 * A is a 0-9 or A-F or $F0. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
189 * Add $30 converts 0-9 to ASCII "0" - "9"), $F0 to ASCII "SPACE" |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
190 * leaves A-F >$3A so a further 7 is added so $3A->$41 etc. (ASCII "A" - "F") |
0 | 191 L015C adda #$30 |
192 cmpa #$3A | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
193 bcs bufchr |
0 | 194 adda #$07 |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
195 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
196 * FALL THROUGH |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
197 * Store A at next position in output buffer. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
198 bufchr pshs x |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
199 ldx <bufcur |
0 | 200 sta ,x+ |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
201 stx <bufcur |
0 | 202 puls pc,x |
1636 | 203 |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
204 * Append CR to the output buffer then print the output buffer |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
205 wrbuf pshs y,x,a |
1636 | 206 lda #C$CR |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
207 bsr bufchr |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
208 ldx <bufstrt address of data to write |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
209 stx <bufcur reset output buffer pointer, ready for next line. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
210 ldy #80 maximum # of bytes - otherwise, stop at CR |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
211 lda #$01 to STDOUT |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
212 os9 I$WritLn |
0 | 213 puls pc,y,x,a |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
214 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
215 * Append string at Y to output buffer. String is terminated by MSB=1 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
216 tobuf lda ,y |
0 | 217 anda #$7F |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
218 bsr bufchr |
0 | 219 tst ,y+ |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
220 bpl tobuf |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
221 rts |
1636 | 222 |
223 DecTbl fdb 10000,1000,100,10,1 | |
224 fcb $FF | |
225 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
226 * value in ?? is a number of blocks. Convert to bytes by multiplying by the page size. |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
227 * Convert to ASCII decimal, append to output buffer, append "k" to output buffer |
0 | 228 L0199 pshs y,x,b,a |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
229 lda <ppblk |
0 | 230 pshs a |
231 lda $01,s | |
232 lsr ,s | |
233 lsr ,s | |
234 bra L01A9 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
235 |
0 | 236 L01A7 lslb |
237 rola | |
238 L01A9 lsr ,s | |
239 bne L01A7 | |
240 leas 1,s | |
1636 | 241 leax <DecTbl,pcr |
0 | 242 ldy #$2F20 |
1636 | 243 L01B6 leay >256,y |
0 | 244 subd ,x |
245 bcc L01B6 | |
246 addd ,x++ | |
247 pshs b,a | |
248 tfr y,d | |
249 tst ,x | |
250 bmi L01DE | |
251 ldy #$2F30 | |
1636 | 252 cmpd #'0*256+C$SPAC |
0 | 253 bne L01D8 |
254 ldy #$2F20 | |
1636 | 255 lda #C$SPAC |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
256 L01D8 bsr bufchr |
0 | 257 puls b,a |
258 bra L01B6 | |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
259 |
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
260 L01DE bsr bufchr |
1636 | 261 lda #'k |
3193
489617e567c5
mfree.asm: Improve comment and remove trailing white-space
Neal Crook <foofoobedoo@gmail.com>
parents:
1636
diff
changeset
|
262 bsr bufchr |
0 | 263 leas $02,s |
264 puls pc,y,x,b,a | |
265 | |
266 emod | |
267 eom equ * | |
268 end |