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