A2osX/BIN/CMP.S.txt

317 lines
5.3 KiB
Plaintext
Raw Normal View History

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
jsr CS.RUN.CheckOpt
bcc .1
2020-01-29 21:20:43 +00:00
.99 >PUSHW L.MSG.USAGE
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
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
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
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
tay
bne .1 no char
>SYSCALL GetChar
bcs .9 IO error
cmp #$03 Ctrl-C
beq .9 Abort....
cmp #$13 Ctrl-S
bne .1
lda bPause
eor #$ff
sta bPause
bne CS.RUN.LOOP
.1 lda bPause
bne CS.RUN.LOOP Pause...
jsr CS.RUN.READ1
bcc .2
cmp #MLI.E.EOF
bne .9
bra .99
.2 >STYA BufCnt
jsr CS.RUN.READ2
bcc .20
cmp #MLI.E.EOF
bne .9
bra .99
.20 cpy BufCnt
pha
sbc BufCnt+1
pla
bcc .3
>STYA BufCnt
.3 ldy #0
.4 lda (ZPBufPtr1),y
cmp (ZPBufPtr2),y
beq .8
2019-09-24 15:25:07 +00:00
lda #$E0
2019-09-12 15:56:38 +00:00
sta bDiff
bit bVerbose
bpl .5
jsr CS.RUN.Print
bcs .9
.5 bit bAll
bpl .99
.8 iny
cpy BufCnt
bne .4
inc Offset
bne CS.RUN.LOOP
inc Offset+1
bra CS.RUN.LOOP
.99 lda bDiff
.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
lda bSkip1
bmi .1
>PUSHBI SEEK.SET
>PUSHL SeekOfs
lda hFile1
2019-09-24 15:25:07 +00:00
2020-03-02 16:49:47 +00:00
>SYSCALL FSeek
2019-09-13 15:39:37 +00:00
bcs .9
.1 >PUSHBI SEEK.SET
>PUSHL SeekOfs
lda hFile2
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
*--------------------------------------
CS.RUN.READ1 >PUSHWI 256
>PUSHW ZPBufPtr1
lda hFile1
>SYSCALL FRead
rts
*--------------------------------------
CS.RUN.READ2 >PUSHWI 256
>PUSHW ZPBufPtr2
lda hFile2
>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
>SYSCALL FClose
.1 lda hFile1
beq .2
>SYSCALL FClose
.2 lda hBuf2
beq .3
>SYSCALL FreeMem
.3 lda hBuf1
beq .8
>SYSCALL FreeMem
.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
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
*--------------------------------------
2019-09-16 20:50:08 +00:00
MSG.USAGE .AS "Usage : CMP File1 File2 [SKIP1 [SKIP2]]\r\n"
2019-09-12 15:56:38 +00:00
.AS " -A : Shows All differences\r\n"
.AZ " -V : Verbose Mode\r\n"
MSG.DIFF .AZ "%H%h:%h %h\r\n"
*--------------------------------------
.DUMMY
.OR 0
DS.START
DS.END
.ED
*--------------------------------------
MAN
2020-05-26 14:23:09 +00:00
SAVE usr/src/bin/cmp.s
2019-09-12 15:56:38 +00:00
ASM