annotate level1/cmds/merge.asm @ 2668:07441dfebc27 lwtools-port

Make tocgen build with lwasm lwasm does not treat a trailing colon as part of the symbol name. Removed trailing colons on symbol references.
author William Astle <lost@l-w.ca>
date Sun, 10 Jun 2012 13:35:44 -0600
parents 0a3500c747de
children
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
1331
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
47 * Here's how registers are set when this process is forked:
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
48 *
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
49 * +-----------------+ <-- Y (highest address)
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
50 * ! Parameter !
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
51 * ! Area !
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
52 * +-----------------+ <-- X, SP
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
53 * ! Data Area !
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
54 * +-----------------+
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
55 * ! Direct Page !
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
56 * +-----------------+ <-- U, DP (lowest address)
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
57 *
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
58 * D = parameter area size
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
59 * PC = module entry point abs. address
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
60 * CC = F=0, I=0, others undefined
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
61
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
62 * The start of the program is here.
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
63 start subd #$0001 if this becomes zero,
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
64 beq Exit we have no parameters
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
65
1330
4f42a5a604d3 Fixed a bug
boisy
parents: 1329
diff changeset
66 leay d.buffer,u point Y to buffer offset in U
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
67 stx <param and parameter area start
1330
4f42a5a604d3 Fixed a bug
boisy
parents: 1329
diff changeset
68 tfr s,d place top of stack in D
4f42a5a604d3 Fixed a bug
boisy
parents: 1329
diff changeset
69 pshs y save Y on stack
4f42a5a604d3 Fixed a bug
boisy
parents: 1329
diff changeset
70 subd ,s++ get size of space between buff and X
4f42a5a604d3 Fixed a bug
boisy
parents: 1329
diff changeset
71 subd #STACKSZ+PARMSZ subtract out our stack/param size
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
72 std <d.size save size of data buffer
1331
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
73 leay d.buffer,u point to some data
0a3500c747de Fixed ANOTHER bug
boisy
parents: 1330
diff changeset
74 sty <d.ptr
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
75
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
76 do.opts ldx <param get first option
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
77 do.opts2 lbsr space
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
78
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
79 cmpa #C$CR was the character a CR?
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
80 beq do.file yes, parse files
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
81
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
82 cmpa #'- was the character a dash?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
83 beq do.dash yes, parse option
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
84 lbsr nonspace else skip nonspace chars
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
85
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
86 cmpa #C$CR end of line?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
87 beq do.file branch if so
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
88 bra do.opts2 else continue parsing for options
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
89
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
90 do.file ldx <param
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
91 lbsr space
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
92
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
93 cmpa #C$CR CR?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
94 beq Exit exit if so
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
95
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
96 cmpa #'- option?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
97 bne itsfile
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
98
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
99 bsr nonspace
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
100
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
101 cmpa #C$CR CR?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
102 beq Exit exit if so
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
103
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
104 itsfile bsr readfile
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
105 bcs Error
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
106 bra do.file
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
107
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
108 readfile lda #READ.
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
109 os9 I$Open open the file for reading
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
110 bcs read.ex crap out if error
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
111 sta <path save path number
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
112 stx <param and save new address of parameter area
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
113
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
114 read.lp lda <path get the current path number
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
115 ldy <d.size and size of data to read
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
116 ldx <d.ptr and pointer to data buffer
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
117 os9 I$Read read data into the buffer
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
118 bcs chk.err check errors
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
119
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
120 lda #$01 to STDOUT
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
121 os9 I$Write dump it out in one shot
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
122 bcc read.lp loop if no errors
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
123 read.ex rts
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
124
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
125 chk.err cmpb #E$EOF end of the file?
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
126 bne read.ex no, error out
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
127
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
128 lda <path otherwise get the current path number
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
129 os9 I$Close close it
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
130 rts return to caller
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
131
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
132 Error coma set carry
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
133 fcb $21 skip next byte
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
134 Exit clrb
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
135 os9 F$Exit and exit
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
136
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
137 do.dash leax 1,x skip over dash
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
138 lda ,x+ get char after dash
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
139 cmpa #C$CR CR?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
140 beq Exit yes, exit
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
141
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
142 anda #$DF make uppercase
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
143 cmpa #'Z input from stdin?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
144 bne Exit
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
145
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
146 * read from stdin until eof or blank line
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
147 * skip lines that begin with * (these are comments)
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
148 do.z leax d.buff,u
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
149 ldy #127
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
150 clra stdin
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
151 os9 I$ReadLn
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
152 bcc do.z2
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
153 cmpb #E$EOF end-of-file?
1330
4f42a5a604d3 Fixed a bug
boisy
parents: 1329
diff changeset
154 beq Exit nope, exit with error
4f42a5a604d3 Fixed a bug
boisy
parents: 1329
diff changeset
155 bra Error
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
156
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
157 do.z2 lda ,x
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
158 cmpa #'* asterisk? (comment)
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
159 beq do.z yep, ignore and get next line
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
160 bsr space skip space at X
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
161 cmpa #C$CR end of line?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
162 beq Exit yup, we're done
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
163
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
164 * X points to a filename...
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
165 pshs x
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
166 bsr readfile read contents of file and send to stdout
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
167 puls x
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
168 bcc do.z branch if ok
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
169 bra Error
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
170
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
171
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
172 space lda ,x+ grab a character
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
173 cmpa #C$SPAC space?
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
174 beq space yes, skip it
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
175 leax -1,x otherwise point to last non-space
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
176 rts
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
177
1329
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
178 nonspace lda ,x+ grab a character
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
179 cmpa #C$CR cr?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
180 beq nospacex yes, skip it
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
181 cmpa #C$SPAC nonspace?
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
182 bne nonspace yes, skip it
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
183 nospacex leax -1,x otherwise point to last space
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
184 rts
76b1793dbd1c Merge now supports -z
boisy
parents: 1325
diff changeset
185
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
186 emod
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
187 eom equ *
225
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
188 end
24637ab6e2b8 Moved a more commented version over
boisy
parents: 200
diff changeset
189