2019-09-12 15:56:38 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2020-08-23 19:46:37 +00:00
|
|
|
|
.TF bin/cmp
|
2019-09-12 15:56:38 +00:00
|
|
|
|
*--------------------------------------
|
2020-05-26 14:23:09 +00:00
|
|
|
|
.INB inc/macros.i
|
|
|
|
|
.INB inc/a2osx.i
|
|
|
|
|
.INB inc/mli.i
|
|
|
|
|
.INB inc/mli.e.i
|
2019-09-12 15:56:38 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
|
|
|
|
ArgIndex .BS 1
|
2020-03-02 16:49:47 +00:00
|
|
|
|
ZPPtr1 .BS 2
|
2019-09-12 15:56:38 +00:00
|
|
|
|
|
|
|
|
|
bPause .BS 1
|
|
|
|
|
bAll .BS 1
|
|
|
|
|
bVerbose .BS 1
|
|
|
|
|
bDiff .BS 1
|
|
|
|
|
|
|
|
|
|
hFile1 .BS 1
|
|
|
|
|
hBuf1 .BS 1
|
|
|
|
|
ZPBufPtr1 .BS 2
|
|
|
|
|
bSkip1 .BS 1
|
|
|
|
|
hFile2 .BS 1
|
|
|
|
|
hBuf2 .BS 1
|
|
|
|
|
ZPBufPtr2 .BS 2
|
|
|
|
|
bSkip2 .BS 1
|
|
|
|
|
|
|
|
|
|
Offset .BS 2
|
|
|
|
|
BufCnt .BS 2
|
2019-09-13 15:39:37 +00:00
|
|
|
|
SeekOfs .BS 4
|
2019-09-12 15:56:38 +00:00
|
|
|
|
ZS.END .ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* File Header (16 Bytes)
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.START cld
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
.DA #$61 6502,Level 1 (65c02)
|
|
|
|
|
.DA #1 BIN Layout Version 1
|
|
|
|
|
.DA #S.PS.F.EVENT S.PS.F
|
|
|
|
|
.DA #0
|
|
|
|
|
.DA CS.END-CS.START CS
|
|
|
|
|
.DA DS.END-DS.START DS
|
|
|
|
|
.DA #64 SS
|
|
|
|
|
.DA #ZS.END-ZS.START Zero Page Size
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Relocation Table
|
2019-10-03 06:25:27 +00:00
|
|
|
|
*--------------------------------------
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.1 .DA CS.INIT
|
|
|
|
|
.DA CS.RUN
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
|
|
|
|
L.MSG.DIFF .DA MSG.DIFF
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN
|
|
|
|
|
.1 inc ArgIndex
|
|
|
|
|
lda ArgIndex
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
bcs .7
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .2
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
jsr CS.RUN.CheckOpt
|
|
|
|
|
bcc .1
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2022-11-02 06:54:30 +00:00
|
|
|
|
.99 >LDYA L.MSG.USAGE
|
|
|
|
|
>SYSCALL PutS
|
2019-09-12 15:56:38 +00:00
|
|
|
|
lda #E.SYN
|
|
|
|
|
sec
|
|
|
|
|
.9 rts
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.2 lda hFile1
|
|
|
|
|
bne .3
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
jsr CS.RUN.OPEN
|
|
|
|
|
bcs .9
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
sta hFile1
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
bra .1
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.3 lda hFile2
|
|
|
|
|
bne .4
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
jsr CS.RUN.OPEN
|
|
|
|
|
bcs .9
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
sta hFile2
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2019-09-13 15:39:37 +00:00
|
|
|
|
.4 bit bSkip1
|
2019-09-12 15:56:38 +00:00
|
|
|
|
bmi .5
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
jsr CS.RUN.SEEK
|
|
|
|
|
bcs .9
|
2019-09-13 15:39:37 +00:00
|
|
|
|
sec
|
|
|
|
|
ror bSkip1
|
2019-09-12 15:56:38 +00:00
|
|
|
|
bra .1
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.5 bit bSkip2
|
|
|
|
|
bmi .99
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
sta bSkip2
|
|
|
|
|
jsr CS.RUN.SEEK
|
|
|
|
|
bcs .9
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-13 15:39:37 +00:00
|
|
|
|
sec
|
|
|
|
|
ror bSkip2
|
2019-09-12 15:56:38 +00:00
|
|
|
|
jmp .1
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.7 lda hFile2
|
|
|
|
|
beq .99
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
lda hFile1
|
|
|
|
|
beq .99
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
|
|
|
|
.8 >LDYAI 256
|
|
|
|
|
>SYSCALL GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPBufPtr1
|
|
|
|
|
stx hBuf1
|
|
|
|
|
|
|
|
|
|
>LDYAI 256
|
|
|
|
|
>SYSCALL GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA ZPBufPtr2
|
|
|
|
|
stx hBuf2
|
2019-09-12 15:56:38 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.LOOP ldy #S.PS.hStdIn
|
|
|
|
|
lda (pPS),y
|
2020-03-02 16:49:47 +00:00
|
|
|
|
>SYSCALL FEOF
|
2019-09-12 15:56:38 +00:00
|
|
|
|
bcs .9 IO error
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
tay
|
|
|
|
|
bne .1 no char
|
|
|
|
|
|
|
|
|
|
>SYSCALL GetChar
|
|
|
|
|
bcs .9 IO error
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
cmp #$03 Ctrl-C
|
|
|
|
|
beq .9 Abort....
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
cmp #$13 Ctrl-S
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
lda bPause
|
|
|
|
|
eor #$ff
|
|
|
|
|
sta bPause
|
|
|
|
|
bne CS.RUN.LOOP
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.1 lda bPause
|
|
|
|
|
bne CS.RUN.LOOP Pause...
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.READ1
|
|
|
|
|
bcc .2
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
cmp #MLI.E.EOF
|
|
|
|
|
bne .9
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
bra .99
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.2 >STYA BufCnt
|
|
|
|
|
jsr CS.RUN.READ2
|
|
|
|
|
bcc .20
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
cmp #MLI.E.EOF
|
|
|
|
|
bne .9
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
bra .99
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.20 cpy BufCnt
|
|
|
|
|
pha
|
|
|
|
|
sbc BufCnt+1
|
|
|
|
|
pla
|
|
|
|
|
bcc .3
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>STYA BufCnt
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.3 ldy #0
|
|
|
|
|
|
|
|
|
|
.4 lda (ZPBufPtr1),y
|
|
|
|
|
cmp (ZPBufPtr2),y
|
|
|
|
|
beq .8
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-24 15:25:07 +00:00
|
|
|
|
lda #$E0
|
2019-09-12 15:56:38 +00:00
|
|
|
|
sta bDiff
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
bit bVerbose
|
|
|
|
|
bpl .5
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
jsr CS.RUN.Print
|
|
|
|
|
bcs .9
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.5 bit bAll
|
|
|
|
|
bpl .99
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.8 iny
|
|
|
|
|
cpy BufCnt
|
|
|
|
|
bne .4
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
inc Offset
|
|
|
|
|
bne CS.RUN.LOOP
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
inc Offset+1
|
|
|
|
|
bra CS.RUN.LOOP
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.99 lda bDiff
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2020-02-27 16:46:40 +00:00
|
|
|
|
CS.RUN.OPEN >PUSHW ZPPtr1
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>PUSHBI O.RDONLY
|
2020-02-27 16:46:40 +00:00
|
|
|
|
>PUSHBI 0 Type
|
|
|
|
|
>PUSHWZ Aux type
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>SYSCALL FOpen
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2019-09-13 15:39:37 +00:00
|
|
|
|
CS.RUN.SEEK >LDYA ZPPtr1
|
2020-03-02 16:49:47 +00:00
|
|
|
|
>SYSCALL AToL
|
2019-09-13 15:39:37 +00:00
|
|
|
|
bcs .9
|
2019-09-24 15:25:07 +00:00
|
|
|
|
|
2019-09-13 15:39:37 +00:00
|
|
|
|
>PULLL SeekOfs
|
2021-05-14 20:58:20 +00:00
|
|
|
|
|
2019-09-13 15:39:37 +00:00
|
|
|
|
lda bSkip1
|
|
|
|
|
bmi .1
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2021-05-14 20:58:20 +00:00
|
|
|
|
>PUSHB hFile1
|
2019-09-13 15:39:37 +00:00
|
|
|
|
>PUSHL SeekOfs
|
2021-05-14 20:58:20 +00:00
|
|
|
|
>PUSHBI SEEK.SET
|
2020-03-02 16:49:47 +00:00
|
|
|
|
>SYSCALL FSeek
|
2019-09-13 15:39:37 +00:00
|
|
|
|
bcs .9
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2021-05-14 20:58:20 +00:00
|
|
|
|
.1 >PUSHB hFile2
|
2019-09-13 15:39:37 +00:00
|
|
|
|
>PUSHL SeekOfs
|
2021-05-14 20:58:20 +00:00
|
|
|
|
>PUSHBI SEEK.SET
|
2020-03-02 16:49:47 +00:00
|
|
|
|
>SYSCALL FSeek
|
2019-09-13 15:39:37 +00:00
|
|
|
|
|
|
|
|
|
.9 rts
|
2019-09-12 15:56:38 +00:00
|
|
|
|
*--------------------------------------
|
2021-05-14 20:58:20 +00:00
|
|
|
|
CS.RUN.READ1 >PUSHB hFile1
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>PUSHW ZPBufPtr1
|
2021-05-14 20:58:20 +00:00
|
|
|
|
>PUSHWI 256
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>SYSCALL FRead
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2021-05-14 20:58:20 +00:00
|
|
|
|
CS.RUN.READ2 >PUSHB hFile2
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>PUSHW ZPBufPtr2
|
2021-05-14 20:58:20 +00:00
|
|
|
|
>PUSHWI 256
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>SYSCALL FRead
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.Print phy
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
|
|
|
|
>PUSHW L.MSG.DIFF
|
|
|
|
|
>PUSHW Offset
|
2019-09-12 15:56:38 +00:00
|
|
|
|
tya
|
|
|
|
|
>PUSHA
|
2020-01-29 21:20:43 +00:00
|
|
|
|
>PUSHB (ZPBufPtr1),y
|
|
|
|
|
>PUSHB (ZPBufPtr2),y
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>PUSHBI 5
|
2020-02-28 07:21:46 +00:00
|
|
|
|
>SYSCALL PrintF
|
2020-01-29 21:20:43 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
ply
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.QUIT lda hFile2
|
|
|
|
|
beq .1
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>SYSCALL FClose
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.1 lda hFile1
|
|
|
|
|
beq .2
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>SYSCALL FClose
|
|
|
|
|
|
|
|
|
|
.2 lda hBuf2
|
|
|
|
|
beq .3
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>SYSCALL FreeMem
|
|
|
|
|
|
|
|
|
|
.3 lda hBuf1
|
|
|
|
|
beq .8
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2019-09-12 15:56:38 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.DOEVENT sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.CheckOpt ldy #1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
|
2020-03-03 16:44:52 +00:00
|
|
|
|
ldy #OptionVars-OptionList-1
|
2019-09-12 15:56:38 +00:00
|
|
|
|
|
2020-03-03 16:44:52 +00:00
|
|
|
|
.2 cmp OptionList,y
|
2019-09-12 15:56:38 +00:00
|
|
|
|
beq .3
|
2021-02-26 20:13:48 +00:00
|
|
|
|
|
2020-03-03 16:44:52 +00:00
|
|
|
|
dey
|
2019-09-12 15:56:38 +00:00
|
|
|
|
bpl .2
|
|
|
|
|
|
|
|
|
|
sec
|
|
|
|
|
rts
|
2020-03-03 16:44:52 +00:00
|
|
|
|
|
|
|
|
|
.3 ldx OptionVars,y
|
2019-09-12 15:56:38 +00:00
|
|
|
|
lda #$ff
|
2020-03-03 16:44:52 +00:00
|
|
|
|
sta 0,x
|
2019-09-12 15:56:38 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
OptionList .AS "AaVv"
|
|
|
|
|
OptionVars .DA #bAll,#bAll,#bVerbose,#bVerbose
|
|
|
|
|
*--------------------------------------
|
2022-11-02 06:54:30 +00:00
|
|
|
|
MSG.USAGE .CS "Usage : CMP File1 File2 [SKIP1 [SKIP2]]\r\n"
|
|
|
|
|
.CS " -A : Shows All differences\r\n"
|
|
|
|
|
.CZ " -V : Verbose Mode\r\n"
|
|
|
|
|
MSG.DIFF .CZ "%H%h:%h %h\r\n"
|
2019-09-12 15:56:38 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2021-05-19 12:44:47 +00:00
|
|
|
|
DS.END .ED
|
2019-09-12 15:56:38 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2020-05-26 14:23:09 +00:00
|
|
|
|
SAVE usr/src/bin/cmp.s
|
2019-09-12 15:56:38 +00:00
|
|
|
|
ASM
|