Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/merge.asm @ 2668:07441dfebc27 lwtools-port
Make tocgen build with lwasm
lwasm does not treat a trailing colon as part of the symbol name. Removed
trailing colons on symbol references.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sun, 10 Jun 2012 13:35:44 -0600 |
parents | 0a3500c747de |
children |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
225 | 2 * Merge - Merge files into one file |
0 | 3 * |
4 * $Id$ | |
5 * | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
6 * Edt/Rev YYYY/MM/DD Modified by |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
7 * Comment |
0 | 8 * ------------------------------------------------------------------ |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
9 * 4 ????/??/?? |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
10 * From Tandy OS-9 Level One VR 02.00.00. |
1329 | 11 * |
12 * 5 2003/09/06 | |
13 * Added -z option to read files from stdin | |
0 | 14 |
15 nam Merge | |
225 | 16 ttl Merge files into one file |
0 | 17 |
18 ifp1 | |
225 | 19 use defsfile |
0 | 20 endc |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
0
diff
changeset
|
21 |
0 | 22 tylg set Prgrm+Objct |
23 atrv set ReEnt+rev | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
924
diff
changeset
|
24 rev set $00 |
1329 | 25 edition set 5 |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
0
diff
changeset
|
26 |
1330 | 27 * Here are some tweakable options |
28 STACKSZ set 128 estimated stack size in bytes | |
29 PARMSZ set 256 estimated parameter size in bytes | |
30 | |
0 | 31 mod eom,name,tylg,atrv,start,size |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
0
diff
changeset
|
32 |
924 | 33 org 0 |
225 | 34 path rmb 1 |
35 param rmb 2 | |
36 d.ptr rmb 2 | |
37 d.size rmb 2 | |
1329 | 38 d.buff rmb 128 |
225 | 39 d.buffer rmb 2496 should reserve 7k, leaving some room for parameters |
1330 | 40 * Finally the stack for any PSHS/PULS/BSR/LBSRs that we might do |
41 rmb STACKSZ+PARMSZ | |
0 | 42 size equ . |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
0
diff
changeset
|
43 |
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
0
diff
changeset
|
44 name fcs /Merge/ |
225 | 45 fcb edition change to 6, as merge 5 has problems? |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
0
diff
changeset
|
46 |
1331 | 47 * Here's how registers are set when this process is forked: |
48 * | |
49 * +-----------------+ <-- Y (highest address) | |
50 * ! Parameter ! | |
51 * ! Area ! | |
52 * +-----------------+ <-- X, SP | |
53 * ! Data Area ! | |
54 * +-----------------+ | |
55 * ! Direct Page ! | |
56 * +-----------------+ <-- U, DP (lowest address) | |
57 * | |
58 * D = parameter area size | |
59 * PC = module entry point abs. address | |
60 * CC = F=0, I=0, others undefined | |
61 | |
62 * The start of the program is here. | |
1329 | 63 start subd #$0001 if this becomes zero, |
64 beq Exit we have no parameters | |
65 | |
1330 | 66 leay d.buffer,u point Y to buffer offset in U |
225 | 67 stx <param and parameter area start |
1330 | 68 tfr s,d place top of stack in D |
69 pshs y save Y on stack | |
70 subd ,s++ get size of space between buff and X | |
71 subd #STACKSZ+PARMSZ subtract out our stack/param size | |
225 | 72 std <d.size save size of data buffer |
1331 | 73 leay d.buffer,u point to some data |
74 sty <d.ptr | |
225 | 75 |
1329 | 76 do.opts ldx <param get first option |
77 do.opts2 lbsr space | |
225 | 78 |
79 cmpa #C$CR was the character a CR? | |
1329 | 80 beq do.file yes, parse files |
81 | |
82 cmpa #'- was the character a dash? | |
83 beq do.dash yes, parse option | |
84 lbsr nonspace else skip nonspace chars | |
85 | |
86 cmpa #C$CR end of line? | |
87 beq do.file branch if so | |
88 bra do.opts2 else continue parsing for options | |
89 | |
90 do.file ldx <param | |
91 lbsr space | |
92 | |
93 cmpa #C$CR CR? | |
94 beq Exit exit if so | |
225 | 95 |
1329 | 96 cmpa #'- option? |
97 bne itsfile | |
98 | |
99 bsr nonspace | |
100 | |
101 cmpa #C$CR CR? | |
102 beq Exit exit if so | |
103 | |
104 itsfile bsr readfile | |
105 bcs Error | |
106 bra do.file | |
107 | |
108 readfile lda #READ. | |
225 | 109 os9 I$Open open the file for reading |
1329 | 110 bcs read.ex crap out if error |
225 | 111 sta <path save path number |
112 stx <param and save new address of parameter area | |
113 | |
114 read.lp lda <path get the current path number | |
115 ldy <d.size and size of data to read | |
116 ldx <d.ptr and pointer to data buffer | |
117 os9 I$Read read data into the buffer | |
118 bcs chk.err check errors | |
119 | |
120 lda #$01 to STDOUT | |
121 os9 I$Write dump it out in one shot | |
122 bcc read.lp loop if no errors | |
1329 | 123 read.ex rts |
225 | 124 |
125 chk.err cmpb #E$EOF end of the file? | |
1329 | 126 bne read.ex no, error out |
127 | |
225 | 128 lda <path otherwise get the current path number |
129 os9 I$Close close it | |
1329 | 130 rts return to caller |
225 | 131 |
132 Error coma set carry | |
1329 | 133 fcb $21 skip next byte |
134 Exit clrb | |
135 os9 F$Exit and exit | |
136 | |
137 do.dash leax 1,x skip over dash | |
138 lda ,x+ get char after dash | |
139 cmpa #C$CR CR? | |
140 beq Exit yes, exit | |
141 | |
142 anda #$DF make uppercase | |
143 cmpa #'Z input from stdin? | |
144 bne Exit | |
145 | |
146 * read from stdin until eof or blank line | |
147 * skip lines that begin with * (these are comments) | |
148 do.z leax d.buff,u | |
149 ldy #127 | |
150 clra stdin | |
151 os9 I$ReadLn | |
152 bcc do.z2 | |
153 cmpb #E$EOF end-of-file? | |
1330 | 154 beq Exit nope, exit with error |
155 bra Error | |
1329 | 156 |
157 do.z2 lda ,x | |
158 cmpa #'* asterisk? (comment) | |
159 beq do.z yep, ignore and get next line | |
160 bsr space skip space at X | |
161 cmpa #C$CR end of line? | |
162 beq Exit yup, we're done | |
163 | |
164 * X points to a filename... | |
165 pshs x | |
166 bsr readfile read contents of file and send to stdout | |
167 puls x | |
168 bcc do.z branch if ok | |
169 bra Error | |
170 | |
225 | 171 |
172 space lda ,x+ grab a character | |
173 cmpa #C$SPAC space? | |
174 beq space yes, skip it | |
175 leax -1,x otherwise point to last non-space | |
176 rts | |
177 | |
1329 | 178 nonspace lda ,x+ grab a character |
179 cmpa #C$CR cr? | |
180 beq nospacex yes, skip it | |
181 cmpa #C$SPAC nonspace? | |
182 bne nonspace yes, skip it | |
183 nospacex leax -1,x otherwise point to last space | |
184 rts | |
185 | |
0 | 186 emod |
187 eom equ * | |
225 | 188 end |
189 |