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