; BDOS TEST6 COMPARE
;2012/3/7 8/21
;
ORG $0100
FCALL=$0005
FCBWK=$003B
RECNO2=$005B
FCB=$005C
FCB2=$006C
RECNO=$007C
DMA1=$0080
DMA2=$0300
BYTECNTR=$0380
AWK=$0382
;
LD HL,FCB2
LD DE,FCBWK
LD B,11;=17
LOOP1:LD A,(HL)
LD (DE),A
INC HL
INC DE
DEC B
JP NZ,LOOP1
;
LD C,0F;open
LD DE,FCB
CALL FCALL
INC A;if FFH?
JP Z,NOFILERR
;
LD C,0F;open
LD DE,FCBWK
CALL FCALL
INC A;if FFH?
JP Z,NOFILERR
;
XOR A
LD (RECNO),A
LD (RECNO2),A
LD HL,BYTECNTR
LD (HL),A
INC HL
LD (HL),A
;
LOOP2:LD C,1A;DMA address set
LD DE,DMA1
CALL FCALL
LD C,14;read
LD DE,FCB
CALL FCALL
OR A
JP NZ,CMPEND;read end
;
LD C,1A;DMA address set
LD DE,DMA2
CALL FCALL
LD C,14;read
LD DE,FCBWK
CALL FCALL
OR A
JP NZ,CMPEND;read end
;
LD C,80
LD HL,DMA1
LD DE,DMA2
LOOP3:LD A,(DE)
CP (HL)
CALL NZ,NOTEQ
INC HL
INC DE
PUSH HL
LD HL,(BYTECNTR)
INC HL
LD (BYTECNTR),HL
POP HL
DEC C
JP NZ,LOOP3
JP LOOP2
;
NOFILERR:LD DE,CANTOPN
LD C,09
CALL FCALL
CMPEND:LD C,1A;DMA address set
LD DE,DMA1
CALL FCALL
RET
;
NOTEQ:PUSH BC
PUSH DE
PUSH HL
LD HL,(BYTECNTR)
CALL HEX4DP
CALL SPDP
POP HL
LD A,(HL)
LD (AWK),A
POP DE
LD A,(DE)
PUSH DE
PUSH HL
PUSH AF
LD A,(AWK)
CALL B2HEXDP
LD A,2D;"-"
CALL ADP
POP AF
CALL B2HEXDP
CALL CRLF
POP HL
POP DE
POP BC
RET
;
;CL & LF
CRLF:LD A,0D
CALL ADP
LD A,0A
JP ADP
;space disp
SPDP:LD A,20
;A disp
ADP:PUSH BC
PUSH HL
LD E,A
LD C,02
CALL FCALL
POP HL
POP BC
RET
;HL(bynary 2bytes) to asckii 4bytes & disp
HEX4DP:PUSH BC
PUSH HL
CALL B2HEX4;binary 2 bytes to ascii HEX 4bytes
PUSH DE
EX DE,HL
CALL DEDP
POP DE
CALL DEDP
POP HL
POP BC
RET
;A(binary) to asckii 2bytes HEX & disp
B2HEXDP:PUSH BC
PUSH HL
CALL B2HEX2
CALL DEDP
POP HL
POP BC
RET
;
;DE(asckii 2bytes) disp
DEDP:PUSH DE
LD E,D
LD C,02
CALL FCALL
POP DE
LD C,02
CALL FCALL
RET
;
;binary to hex, 2bytes data to ascii 4charactors,HL to HL,DE
B2HEX4:LD A,H
CALL B2HEX2
EX DE,HL
LD A,E
;binary to hex, 1byte data to ascii 2charactors,A to DE
B2HEX2:PUSH AF
RRCA
RRCA
RRCA
RRCA
CALL B2HEX1
LD D,A
POP AF
CALL B2HEX1
LD E,A
RET
;binary to hex, low 4bit to ascii 1charactor
B2HEX1:AND 0F
ADD A,30
CP 3A
RET C;0-9
ADD A,07;A-F
RET
;
CANTOPN:"can'"
"t op"
"en!"
DB 0D
DB 0A
DB 24;$
;
|