annotate level1/cmds/cmp.asm @ 2798:b70d93f8d7ce lwtools-port

Updated coco1/modules/makefile and coco3/modules/makefile to help resolve issues with i(x) and s(x) descriptors. Updated level1/coco1/modules/makefile & level2/coco3/modules/makefile so that correct values would be sent to assembler when building superdesc.asm for s(x).dd and i(x).dd descriptors.
author drencor-xeen
date Mon, 28 Jan 2013 16:13:05 -0600
parents 20841f236e32
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
1 ********************************************************************
936
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
2 * Cmp - Binary file comparison utility
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: 936
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: 936
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: 936
diff changeset
9 * 1 2003/01/20 Boisy G. Pitre
84ea83668304 Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents: 936
diff changeset
10 * Rewritten in assembly for size.
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
11
936
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
12 nam Cmp
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
13 ttl Binary file comparison utility
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
14
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
15 ifp1
322
0d2d4a28c490 cmp.asm and help.asm now assemble correctly
boisy
parents: 200
diff changeset
16 use defsfile
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
17 endc
200
e9ce43cc215e Made major changes to headers for consistency and identification
boisy
parents: 0
diff changeset
18
936
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
19 * Here are some tweakable options
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
20 DOHELP set 0 1 = include help info
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
21 CMPBUFSZ set 1024
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
22 STACKSZ set 128 estimated stack size in bytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
23 PARMSZ set 256 estimated parameter size in bytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
24
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
25 * Module header definitions
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
26 tylg set Prgrm+Objct
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
27 atrv set ReEnt+rev
1325
84ea83668304 Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents: 936
diff changeset
28 rev set $00
936
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
29 edition set 1
200
e9ce43cc215e Made major changes to headers for consistency and identification
boisy
parents: 0
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
936
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
33 org 0
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
34 headdone rmb 1 if 1, means byte #1 #2 header shown
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
35 noneflag rmb 1 if 1, means there were differences
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
36 f1path rmb 1 file 1 path
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
37 f2path rmb 1 file 2 path
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
38 f1read rmb 2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
39 f2read rmb 2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
40 f1namptr rmb 2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
41 f2namptr rmb 2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
42 f1namsiz rmb 2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
43 f2namsiz rmb 2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
44 cmpbytes rmb 4 bytes compared
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
45 difbytes rmb 4 bytes different
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
46 cleartop equ . everything up to here gets cleared at start
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
47 diffbuff rmb 32
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
48 f1buff rmb CMPBUFSZ
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
49 f2buff rmb CMPBUFSZ
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
50 * Finally the stack for any PSHS/PULS/BSR/LBSRs that we might do
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
51 rmb STACKSZ+PARMSZ
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
52 size equ .
200
e9ce43cc215e Made major changes to headers for consistency and identification
boisy
parents: 0
diff changeset
53
936
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
54 * The utility name and edition goes here
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
55 name fcs /Cmp/
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
56 fcb edition
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
57
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
58 * Place constant strings here
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
59 IFNE DOHELP
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
60 HlpMsg fcb C$LF
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
61 fcc /Use: Cmp <file1> <file2>/
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
62 fcb C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
63 HlpMsgL equ *-HlpMsg
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
64 ENDC
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
65 CmpHead fcb C$LF
322
0d2d4a28c490 cmp.asm and help.asm now assemble correctly
boisy
parents: 200
diff changeset
66 fcc " Differences"
0d2d4a28c490 cmp.asm and help.asm now assemble correctly
boisy
parents: 200
diff changeset
67 fcb C$LF
936
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
68 CrRtn fcb C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
69 None fcc " None ..."
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
70 fcb C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
71 CmpHead2 fcc "byte #1 #2"
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
72 fcb C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
73 CmpHead3 fcc "======== == =="
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
74 fcb C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
75 ByteCmp fcb C$LF
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
76 fcc "Bytes compared: "
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
77 ByteCmpL equ *-ByteCmp
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
78 ByteDif fcc "Bytes different: "
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
79 ByteDifL equ *-ByteDif
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
80 IsLonger fcc " is longer"
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
81 fcb C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
82
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
83 * Here's how registers are set when this process is forked:
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
84 *
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
85 * +-----------------+ <-- Y (highest address)
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
86 * ! Parameter !
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
87 * ! Area !
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
88 * +-----------------+ <-- X, SP
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
89 * ! Data Area !
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
90 * +-----------------+
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
91 * ! Direct Page !
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
92 * +-----------------+ <-- U, DP (lowest address)
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
93 *
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
94 * D = parameter area size
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
95 * PC = module entry point abs. address
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
96 * CC = F=0, I=0, others undefined
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
97
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
98 * This routine skip over spaces and commas
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
99 *
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
100 * Entry:
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
101 * X = ptr to data to parse
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
102 * Exit:
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
103 * X = ptr to first non-whitespace char
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
104 * A = non-whitespace char
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
105 SkipSpcs lda ,x+
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
106 cmpa #C$SPAC
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
107 beq SkipSpcs
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
108 leax -1,x
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
109 rts
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
110
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
111 * This routine counts the number of non-whitespace characters
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
112 * starting at X
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
113 *
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
114 * Entry:
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
115 * X = ptr to string (space, comma or CR terminated)
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
116 * Exit:
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
117 * Y = length of string
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
118 * X = ptr to byte after string
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
119 StrLen pshs a
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
120 ldy #$0000
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
121 StrLenLp lda ,x+
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
122 cmpa #C$SPAC
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
123 beq StrLenEx
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
124 cmpa #C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
125 beq StrLenEx
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
126 leay 1,y
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
127 bra StrLenLp
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
128 StrLenEx puls a,pc
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
129
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
130 * The start of the program is here.
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
131 * Before any command line processing is done, we clear out
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
132 * our static memory from U to cleartop, then determine the
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
133 * size of our data area (minus the stack).
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
134 start pshs u,x save registers for later
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
135 leax <cleartop,u point to end of area to zero out
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
136 IFNE H6309
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
137 subr u,x subtract U from X
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
138 tfr x,w and put X in W
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
139 clr ,-s put a zero on the stack
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
140 tfm s,u+ and use TFM to clear starting at U
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
141 leas 1,s clean up the stack
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
142 ELSE
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
143 pshs x save end pointer on stack
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
144 clrnxt clr ,u+ clear out
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
145 cmpu ,s done?
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
146 bne clrnxt branch if not
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
147 leas 2,s else clear stack
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
148 ENDC
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
149 puls x,u and restore our earlier saved registers
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
150
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
151 lda ,x get first char
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
152 cmpa #C$CR CR?
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
153 lbeq ShowHelp if so, no parameters... show help and exit
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
154 * Open first file on command line
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
155 bsr SkipSpcs
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
156 stx f1namptr,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
157 bsr StrLen
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
158 sty f1namsiz
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
159 ldx f1namptr,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
160 lda #READ.
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
161 os9 I$Open
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
162 lbcs ShutDown
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
163 sta <f1path
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
164 * Open second file on command line
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
165 bsr SkipSpcs
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
166 stx f2namptr,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
167 bsr StrLen
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
168 sty f2namsiz
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
169 ldx f2namptr,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
170 lda #READ.
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
171 os9 I$Open
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
172 lbcs ShutDown
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
173 sta <f2path
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
174
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
175 * Write "Differences" to standard output
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
176 lda #$01
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
177 leax CmpHead,pcr
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
178 ldy #128
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
179 os9 I$WritLn
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
180
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
181 DoCmp lda f1path
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
182 leax f1buff,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
183 ldy #CMPBUFSZ
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
184 os9 I$Read
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
185 lbcs ShutDown
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
186 sty <f1read
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
187
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
188 lda f2path
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
189 leax f2buff,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
190 ldy #CMPBUFSZ
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
191 os9 I$Read
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
192 lbcs ShutDown
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
193 sty <f2read
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
194
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
195 * Actual compare is done here
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
196 ldd f1read,u get read amount for file 1
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
197 cmpd f2read,u compare against read amount for file2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
198 ble Compare branch if f1read less than or equal
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
199 ldd f2read,u else get f2read size
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
200 Compare leax f1buff,u point X to f1 buff
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
201 leay f2buff,u point Y to f2 buff
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
202 CmpLoop pshs d
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
203 lda ,x get f1 byte in A
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
204 cmpa ,y compare against f2 byte at Y
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
205 beq CmpOk if same, go on
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
206 bsr ShowDiff else show diff
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
207 CmpOk leax 1,x
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
208 leay 1,y
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
209 ldd <cmpbytes+2 get lo 16 bits
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
210 addd #$0001
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
211 std <cmpbytes+2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
212 bcc CmpFwd
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
213 ldd <cmpbytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
214 addd #$0001
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
215 std <cmpbytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
216 CmpFwd ldd ,s++
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
217 subd #$0001
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
218 bne CmpLoop
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
219 bra DoCmp else read more
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
220
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
221 ShowDiff pshs x,y
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
222 tst <headdone did we already show header?
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
223 bne ShowDif1 branch if so
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
224 lda #$01 stdout
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
225 sta <noneflag we won't be showing none when done!
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
226 sta <headdone set head done flag
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
227 leax CmpHead2,pcr print header 2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
228 ldy #128
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
229 os9 I$WritLn
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
230 leax CmpHead3,pcr and header 3
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
231 os9 I$WritLn
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
232 ShowDif1 leax diffbuff,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
233 ldd <cmpbytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
234 bsr MkHexWrd
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
235 ldd <cmpbytes+2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
236 bsr MkHexWrd
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
237 ldd #C$SPAC*256+C$SPAC
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
238 std ,x++
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
239 ldb [,s]
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
240 bsr MkHexByt
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
241 lda #C$SPAC
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
242 sta ,x+
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
243 ldb [2,s]
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
244 bsr MkHexByt
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
245 lda #C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
246 sta ,x
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
247 leax diffbuff,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
248 lda #$01
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
249 ldy #128
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
250 os9 I$WritLn
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
251
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
252 * Increment diff count
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
253 ldd <difbytes+2 get lo 16 bits
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
254 addd #$0001
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
255 std <difbytes+2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
256 bcc ShowDif2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
257 ldd <difbytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
258 addd #$0001
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
259 std <difbytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
260 ShowDif2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
261 puls x,y,pc
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
262
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
263 * Entry: X = buffer to place 4 byte Hex char in
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
264 * D = word to convert to Hex
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
265 * Exit : X = ptr to location after 4 byte Hex
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
266 MkHexWrd exg a,b
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
267 bsr MkHexByt
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
268 exg a,b
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
269 bsr MkHexByt
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
270 rts
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
271
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
272 * Entry: X = buffer to place 2 byte Hex char in
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
273 * B = byte to convert to Hex
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
274 * Exit : X = ptr to location after 2 byte Hex
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
275 MkHexByt pshs d
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
276 tfr b,a
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
277 lsrb shift upper nibble to lower
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
278 lsrb
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
279 lsrb
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
280 lsrb
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
281 bsr MakeChar
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
282 tfr a,b
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
283 andb #$0F
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
284 bsr MakeChar
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
285 puls d,pc
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
286 MakeChar cmpb #$09
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
287 bhi IsLetter
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
288 addb #'0
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
289 fcb $8C skip next two bytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
290 IsLetter addb #55
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
291 stb ,x+
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
292 rts
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
293
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
294 ShutDown lda <f1path get file 1 path number
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
295 beq CloseF2 if empty, close file 2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
296 os9 I$Close
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
297 CloseF2 lda <f2path get file 2 path number
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
298 lbeq ExitOk
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
299 os9 I$Close
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
300 lda #$01 stdout for later
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
301 tst <noneflag any differences?
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
302 bne Summary1
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
303 leax None,pcr
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
304 ldy #128
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
305 os9 I$WritLn
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
306 Summary1 leax ByteCmp,pcr
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
307 ldy #ByteCmpL
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
308 os9 I$Write
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
309 leax diffbuff,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
310 ldd <cmpbytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
311 bsr MkHexWrd
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
312 ldd <cmpbytes+2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
313 bsr MkHexWrd
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
314 ldb #C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
315 stb ,x
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
316 leax diffbuff,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
317 lda #$01
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
318 ldy #128
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
319 os9 I$WritLn
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
320 Summary2 leax ByteDif,pcr
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
321 ldy #ByteDifL
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
322 os9 I$Write
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
323 leax diffbuff,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
324 ldd <difbytes
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
325 bsr MkHexWrd
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
326 ldd <difbytes+2
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
327 lbsr MkHexWrd
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
328 ldb #C$CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
329 stb ,x
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
330 leax diffbuff,u
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
331 lda #$01
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
332 ldy #128
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
333 os9 I$WritLn
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
334
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
335 * See if one file is longer than other
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
336 ldd <f1read
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
337 cmpd <f2read
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
338 beq ExitOk if same, go on
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
339 * Write CR
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
340 lda #1
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
341 leax CrRtn,pcr
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
342 ldy #1
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
343 os9 I$WritLn
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
344 ldx <f1namptr
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
345 ldy <f1namsiz
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
346 * Assume file 1 is longer
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
347 ldd <f1read
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
348 cmpd <f2read
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
349 bgt ShowLong
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
350 * Otherwise file 2 is longer
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
351 ldx <f2namptr
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
352 ldy <f2namsiz
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
353 ShowLong lda #1
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
354 os9 I$Write
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
355 leax IsLonger,pcr
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
356 ldy #128
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
357 os9 I$WritLn
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
358
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
359 ExitOk clrb
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
360 Exit os9 F$Exit
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
361
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
362 ShowHelp equ *
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
363 IFNE DOHELP
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
364 leax >HlpMsg,pcr point to help message
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
365 ldy #HlpMsgL get length
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
366 lda #$02 std error
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
367 os9 I$WritLn write it
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
368 ENDC
0fc7dce414db Rewrote cmp in assembler for size
boisy
parents: 322
diff changeset
369 bra ExitOk
322
0d2d4a28c490 cmp.asm and help.asm now assemble correctly
boisy
parents: 200
diff changeset
370
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
371 emod
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
372 eom equ *
322
0d2d4a28c490 cmp.asm and help.asm now assemble correctly
boisy
parents: 200
diff changeset
373 end