Mercurial > hg > Members > kono > nitros9-code
comparison 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 |
comparison
equal
deleted
inserted
replaced
1328:4f37bc455854 | 1329:76b1793dbd1c |
---|---|
6 * Edt/Rev YYYY/MM/DD Modified by | 6 * Edt/Rev YYYY/MM/DD Modified by |
7 * Comment | 7 * Comment |
8 * ------------------------------------------------------------------ | 8 * ------------------------------------------------------------------ |
9 * 4 ????/??/?? | 9 * 4 ????/??/?? |
10 * From Tandy OS-9 Level One VR 02.00.00. | 10 * From Tandy OS-9 Level One VR 02.00.00. |
11 * | |
12 * 5 2003/09/06 | |
13 * Added -z option to read files from stdin | |
11 | 14 |
12 nam Merge | 15 nam Merge |
13 ttl Merge files into one file | 16 ttl Merge files into one file |
14 | 17 |
15 ifp1 | 18 ifp1 |
17 endc | 20 endc |
18 | 21 |
19 tylg set Prgrm+Objct | 22 tylg set Prgrm+Objct |
20 atrv set ReEnt+rev | 23 atrv set ReEnt+rev |
21 rev set $00 | 24 rev set $00 |
22 edition set 4 | 25 edition set 5 |
23 | 26 |
24 mod eom,name,tylg,atrv,start,size | 27 mod eom,name,tylg,atrv,start,size |
25 | 28 |
26 org 0 | 29 org 0 |
27 path rmb 1 | 30 path rmb 1 |
28 param rmb 2 | 31 param rmb 2 |
29 d.ptr rmb 2 | 32 d.ptr rmb 2 |
30 d.size rmb 2 | 33 d.size rmb 2 |
34 d.buff rmb 128 | |
31 d.buffer rmb 2496 should reserve 7k, leaving some room for parameters | 35 d.buffer rmb 2496 should reserve 7k, leaving some room for parameters |
32 size equ . | 36 size equ . |
33 | 37 |
34 name fcs /Merge/ | 38 name fcs /Merge/ |
35 fcb edition change to 6, as merge 5 has problems? | 39 fcb edition change to 6, as merge 5 has problems? |
36 | 40 |
37 start pshs u save start address of memory | 41 start subd #$0001 if this becomes zero, |
42 beq Exit we have no parameters | |
43 | |
44 pshs u save start address of memory | |
38 stx <param and parameter area start | 45 stx <param and parameter area start |
39 tfr x,d | 46 tfr x,d |
40 subd #$0107 take out 1 bytes in DP, and 1 page for the stack | 47 subd #$0107 take out 1 bytes in DP, and 1 page for the stack |
41 subd ,s++ take out start address of data area | 48 subd ,s++ take out start address of data area |
42 std <d.size save size of data buffer | 49 std <d.size save size of data buffer |
43 leau d.buffer,u point to some data | 50 leau d.buffer,u point to some data |
44 stu <d.ptr save another pointer | 51 stu <d.ptr save another pointer |
45 | 52 |
46 do.file ldx <param get first filename | 53 do.opts ldx <param get first option |
47 bsr space | 54 do.opts2 lbsr space |
48 | 55 |
49 clrb | |
50 cmpa #C$CR was the character a CR? | 56 cmpa #C$CR was the character a CR? |
51 beq Exit yes, exit | 57 beq do.file yes, parse files |
52 | 58 |
53 lda #READ. | 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 | |
72 | |
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. | |
54 os9 I$Open open the file for reading | 86 os9 I$Open open the file for reading |
55 bcs Exit crap out if error | 87 bcs read.ex crap out if error |
56 sta <path save path number | 88 sta <path save path number |
57 stx <param and save new address of parameter area | 89 stx <param and save new address of parameter area |
58 | 90 |
59 read.lp lda <path get the current path number | 91 read.lp lda <path get the current path number |
60 ldy <d.size and size of data to read | 92 ldy <d.size and size of data to read |
63 bcs chk.err check errors | 95 bcs chk.err check errors |
64 | 96 |
65 lda #$01 to STDOUT | 97 lda #$01 to STDOUT |
66 os9 I$Write dump it out in one shot | 98 os9 I$Write dump it out in one shot |
67 bcc read.lp loop if no errors | 99 bcc read.lp loop if no errors |
68 bra Exit otherwise exit ungracefully | 100 read.ex rts |
69 | 101 |
70 chk.err cmpb #E$EOF end of the file? | 102 chk.err cmpb #E$EOF end of the file? |
71 bne Error no, error out | 103 bne read.ex no, error out |
104 | |
72 lda <path otherwise get the current path number | 105 lda <path otherwise get the current path number |
73 os9 I$Close close it | 106 os9 I$Close close it |
74 bcc do.file if no error, go get next filename | 107 rts return to caller |
75 | 108 |
76 Error coma set carry | 109 Error coma set carry |
77 Exit os9 F$Exit and exit | 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 | |
78 | 147 |
79 space lda ,x+ grab a character | 148 space lda ,x+ grab a character |
80 cmpa #C$SPAC space? | 149 cmpa #C$SPAC space? |
81 beq space yes, skip it | 150 beq space yes, skip it |
82 leax -1,x otherwise point to last non-space | 151 leax -1,x otherwise point to last non-space |
83 rts | 152 rts |
84 | 153 |
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 | |
85 emod | 162 emod |
86 eom equ * | 163 eom equ * |
87 end | 164 end |
88 | 165 |