Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/merge.asm @ 1329:76b1793dbd1c
Merge now supports -z
author | boisy |
---|---|
date | Sat, 06 Sep 2003 22:51:41 +0000 |
parents | 84ea83668304 |
children | 4f42a5a604d3 |
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 |
0 | 27 mod eom,name,tylg,atrv,start,size |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
0
diff
changeset
|
28 |
924 | 29 org 0 |
225 | 30 path rmb 1 |
31 param rmb 2 | |
32 d.ptr rmb 2 | |
33 d.size rmb 2 | |
1329 | 34 d.buff rmb 128 |
225 | 35 d.buffer rmb 2496 should reserve 7k, leaving some room for parameters |
0 | 36 size equ . |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
0
diff
changeset
|
37 |
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
0
diff
changeset
|
38 name fcs /Merge/ |
225 | 39 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
|
40 |
1329 | 41 start subd #$0001 if this becomes zero, |
42 beq Exit we have no parameters | |
43 | |
44 pshs u save start address of memory | |
225 | 45 stx <param and parameter area start |
0 | 46 tfr x,d |
225 | 47 subd #$0107 take out 1 bytes in DP, and 1 page for the stack |
48 subd ,s++ take out start address of data area | |
49 std <d.size save size of data buffer | |
50 leau d.buffer,u point to some data | |
51 stu <d.ptr save another pointer | |
52 | |
1329 | 53 do.opts ldx <param get first option |
54 do.opts2 lbsr space | |
225 | 55 |
56 cmpa #C$CR was the character a CR? | |
1329 | 57 beq do.file yes, parse files |
58 | |
59 cmpa #'- was the character a dash? | |
60 beq do.dash yes, parse option | |
61 lbsr nonspace else skip nonspace chars | |
62 | |
63 cmpa #C$CR end of line? | |
64 beq do.file branch if so | |
65 bra do.opts2 else continue parsing for options | |
66 | |
67 do.file ldx <param | |
68 lbsr space | |
69 | |
70 cmpa #C$CR CR? | |
71 beq Exit exit if so | |
225 | 72 |
1329 | 73 cmpa #'- option? |
74 bne itsfile | |
75 | |
76 bsr nonspace | |
77 | |
78 cmpa #C$CR CR? | |
79 beq Exit exit if so | |
80 | |
81 itsfile bsr readfile | |
82 bcs Error | |
83 bra do.file | |
84 | |
85 readfile lda #READ. | |
225 | 86 os9 I$Open open the file for reading |
1329 | 87 bcs read.ex crap out if error |
225 | 88 sta <path save path number |
89 stx <param and save new address of parameter area | |
90 | |
91 read.lp lda <path get the current path number | |
92 ldy <d.size and size of data to read | |
93 ldx <d.ptr and pointer to data buffer | |
94 os9 I$Read read data into the buffer | |
95 bcs chk.err check errors | |
96 | |
97 lda #$01 to STDOUT | |
98 os9 I$Write dump it out in one shot | |
99 bcc read.lp loop if no errors | |
1329 | 100 read.ex rts |
225 | 101 |
102 chk.err cmpb #E$EOF end of the file? | |
1329 | 103 bne read.ex no, error out |
104 | |
225 | 105 lda <path otherwise get the current path number |
106 os9 I$Close close it | |
1329 | 107 rts return to caller |
225 | 108 |
109 Error coma set carry | |
1329 | 110 fcb $21 skip next byte |
111 Exit clrb | |
112 os9 F$Exit and exit | |
113 | |
114 do.dash leax 1,x skip over dash | |
115 lda ,x+ get char after dash | |
116 cmpa #C$CR CR? | |
117 beq Exit yes, exit | |
118 | |
119 anda #$DF make uppercase | |
120 cmpa #'Z input from stdin? | |
121 bne Exit | |
122 | |
123 * read from stdin until eof or blank line | |
124 * skip lines that begin with * (these are comments) | |
125 do.z leax d.buff,u | |
126 ldy #127 | |
127 clra stdin | |
128 os9 I$ReadLn | |
129 bcc do.z2 | |
130 cmpb #E$EOF end-of-file? | |
131 bne Error nope, exit with error | |
132 | |
133 do.z2 lda ,x | |
134 cmpa #'* asterisk? (comment) | |
135 beq do.z yep, ignore and get next line | |
136 bsr space skip space at X | |
137 cmpa #C$CR end of line? | |
138 beq Exit yup, we're done | |
139 | |
140 * X points to a filename... | |
141 pshs x | |
142 bsr readfile read contents of file and send to stdout | |
143 puls x | |
144 bcc do.z branch if ok | |
145 bra Error | |
146 | |
225 | 147 |
148 space lda ,x+ grab a character | |
149 cmpa #C$SPAC space? | |
150 beq space yes, skip it | |
151 leax -1,x otherwise point to last non-space | |
152 rts | |
153 | |
1329 | 154 nonspace lda ,x+ grab a character |
155 cmpa #C$CR cr? | |
156 beq nospacex yes, skip it | |
157 cmpa #C$SPAC nonspace? | |
158 bne nonspace yes, skip it | |
159 nospacex leax -1,x otherwise point to last space | |
160 rts | |
161 | |
0 | 162 emod |
163 eom equ * | |
225 | 164 end |
165 |