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