; ; COMP13 ASM - CP/M file comparison program - 10/27/87 ; VER EQU 13 ; Current version number MONTH EQU 10 ; Month last modified DAY EQU 27 ; Day YEAR EQU 87 ; Year ; ; NOTE: This program starts the display of any discrepancies ; at page 1 (0100H) rather than at page 0 (0000H). This ; gives absolute addresses for normal CP/M files which ; permits easy use of DDT or SID or an assembled print ; copy to check the discrepancies. Relative addresses ; are relatively worthless for this purpose. ; ; If for some reason you want relative addresses, change ; the label area RPRT1: INR H to RPRT1: DB 0 instead. ; Then reassemble and reload. ; - Irv Hoff ; ;----------------------------------------------------------------------- ; 10/27/87 Fixed a incorrect address display. ; v13 (Cleared register BC in initialization routine.) ; - Bill Duerr ; ; 05/06/85 Fixed a problem if the length of the two files are unequal. ; v12 (Took the comment out of the "JMP EOF" which made program ; fall into SETUP routine). - Bill Duerr ; ; 09/07/84 Fixed a major error. Values for FILE1 and FILE2 were being ; v11 exchanged on the display. Changed to start display on page ; 1 (0100H) rather than page 0 (0000H). Read note, above, for ; reason. Changed totals at end for characters checked and ; number of errors encountered to read in decimal rather than ; in hex, which was rather useless. Added an equate to select ; total columns in display (now set to 5 rather than 4.) Some ; other minor changes in the display. Changed buffer size to ; 16k each rather than 1k. (The disk system runs a fraction ; as much, now.) Re-enamed the program to COMP11, to protect ; the original BINCOM version in case the author does not care ; for these changes. Alphabetized subroutines. Rewrote the ; help guide. Standardized the format - the source code was ; nearly all in lower case. - Irv Hoff ; ; 09/16/83 Original version BINCOM.ASM - Harold McIntosh ; ;----------------------------------------------------------------------- ; ; COMP12 is a program which can be used to compare two CP/M files (which ; will usually binary .COM object code files) to find any differences ; between them. The files are compared byte for byte. No attempt is ; made to vary the match points to establish a different synchronization ; if a prolonged mismatch is found, as would be done for ASCII files ; when using DIF2, etc. ; ; The command line is: ; ; COMP B:FILE1.COM A:FILE2.COM ; ; Discrepancies will be noted at the console in a line of the form: ; ; XXXX YY ZZ ; ; where XXXX is the number of the discrepant byte, YY in FILE1, ZZ in ; FILE2. Pressing any key at the console will stop the comparison, but ; in any event there will be a final total shown of the bytes compared ; and the number of mismatches encountered. ; ;----------------------------------------------------------------------- ; ; This program is modified from BINCOM.ASM written by Harold McIntosh ; ; BINCOM.ASM Copyright (C) 1983 ; Universidad Autonoma de Puebla ; September 16, 1983 ; ;======================================================================= ; LF EQU 0AH ; Line feed CR EQU 0DH ; Carriage return NOCLMN EQU 5 ; Number of columns across page ; BDOS EQU 0005H ; Jump to BDOS TFCB EQU 005CH ; CCP's file control block TSIZ EQU 0080H ; Size of record buffer ; ORG 0100H ; BEGIN: LXI H,0 DAD SP SHLD STACK LXI SP,STACK ; LXI H,LOGO CALL MSSG LDA TFCB+1 ; File name CPI ' ' JZ TUTO CPI '?' JZ TUTO CALL SETUP MVI C,15 ; Open file LXI D,FCB1 CALL BDOS INR A JZ ERR1 MVI C,15 ; Open file LXI D,FCB2 CALL BDOS INR A JZ ERR2 XRA A STA FCB1+32 STA FCB2+32 STA BYCT STA NEQL INR A STA RECT MVI A,NOCLMN STA CLMN LXI H,0000 PUSH H POP B ; Initialize "BC" to zeros ; LOOP: LDA BYCT ANI 07FH JNZ RNB ; Bytes in the buffer LDA RECT DCR A JNZ RNA PUSH B LXI B,0080H ; 16k buffer LXI D,BUF1 LXI H,FCB1 CALL FILB PUSH B LXI B,0080H ; 16k buffer LXI D,BUF2 LXI H,FCB2 CALL FILB POP PSW CMP B JZ EQL LXI H,NEQL JC NEQ MOV A,B MVI M,'2' JMP EQL ; NEQ: MVI M,'1' ; EQL: POP B CPI 00 JZ ENFI ; End of record LXI D,BUF1 LXI H,BUF2 ; RNA: STA RECT MVI A,80H ; RNB: DCR A ; Read next pair of bytes STA BYCT LDAX D CMP M CNZ RPRT ; Report discrepancy CALL RECS JNZ QUIT CALL CHCNT INX B INX D INX H JMP LOOP ; ;======================================================================= ; ; ROUTINES ; ; "A" to console ; AOUT: PUSH H PUSH D PUSH B MOV E,A MVI C,2 CALL BDOS POP B POP D POP H RET ; ; Character count ; CHCNT: PUSH H LXI H,ME11+5 JMP COUNT ; ; Count events in decimal, by incrementing a buffer ; COUNT: PUSH D ; Save the register values PUSH B MVI C,6 ; COUNT1: CALL COUNT2 ; Increment the storage count JNZ COUNT4 ; Finished if not going any further DCX H DCR C JNZ COUNT1 JMP COUNT4 ; COUNT2: MOV A,M CPI ' ' JNZ COUNT3 MVI A,'0' ; COUNT3: INR A MOV M,A CPI '9'+1 RNZ MVI A,'0' MOV M,A RET ; COUNT4: POP B POP D POP H RET ; ENF: CALL MSSG CALL CRLF ; Turn up an extra line JMP EXIT ; ; Error count ; ERCNT: PUSH H LXI H,ME22+5 JMP COUNT ; ERR1: LXI H,ER1 JMP CMSS ; ERR2: LXI H,ER2 JMP CMSS ; EXIT: LHLD STACK SPHL RET ; ; Fill buffer DE using FCB HL. On return, B = number of sectors read. ; FILB: PUSH B PUSH D PUSH H MVI C,26 ; Set DMA address CALL BDOS POP D PUSH D MVI C,20 ; Read one record CALL BDOS POP D POP H LXI B,TSIZ DAD B XCHG POP B CPI 00 JNZ FIC INR B DCR C JNZ FILB RET ; FIC: CPI 01 RZ RET ; MOOV: LDAX D MOV M,A INX D INX H DCR B JNZ MOOV LXI D,-7 DAD D MOV A,M CPI ' ' RNZ MVI M,'C' INX H MVI M,'O' INX H MVI M,'M' RET ; ; Message terminated by zero to console ; MSSG: MOV A,M ORA A RZ CALL AOUT ; "A" to console INX H JMP MSSG ; ; Read console status: nz/z = character waiting/not ; RECS: PUSH B PUSH D PUSH H MVI C,11 CALL BDOS ANI 01 PUSH PSW JZ RCS MVI C,1 CALL BDOS ; RCS: POP PSW POP H POP D POP B RET ; ; Type discrepancy report. ; RPRT: PUSH H ; Save address PUSH B ; Save record count CALL ERCNT ; Increment the error count POP H ; Get "BC" into "HL" ; RPRT1: INR H ; Output starts on page 1 (0100H) CALL WORD CALL DUBL LDAX D ; Show FILE1 byte CALL BYTE CALL SNGL POP H ; Get original address back MOV A,M ; Show FILE2 byte CALL BYTE ;;;; CALL SNGL CALL QUAD LDA CLMN DCR A JNZ RPR CALL CRLF MVI A,NOCLMN ; RPR: STA CLMN RET ; ; Type one, two, or four spaces. ; QUAD: CALL DUBL ; Sends two spaces DUBL: CALL SNGL ; Sends a space, then the next below SNGL: MVI A,' ' ; Sends a space JMP AOUT ; ; Type summary message at the end of the run. ; QUIT: CALL CRLF LXI H,ME3 CALL MSSG ; ENFI: PUSH B ; Save the number of bytes counted CALL CRLF LXI H,ME1 CALL MSSG LXI H,ME2 CALL MSSG LDA NEQL ORA A JZ EXIT ; LXI H,ME4 CALL MSSG LXI H,FCB1+1 ; Address of first file LDA NEQL ; Get back length indicator CPI '1' ; If first was shorter, exit JZ ENF ; If not, get. LXI H,FCB2+1 ; Address of second file JMP ENF ; SETUP: MVI B,16 LXI D,TFCB LXI H,FCB1 CALL MOOV LXI H,ME5 CALL MSSG LXI H,FCB1+1 CALL MSSG CALL CRLF MVI B,16 LXI D,TFCB+16 LXI H,FCB2 CALL MOOV LXI H,ME6 CALL MSSG LXI H,FCB2+1 CALL MSSG CALL CRLF ; Fall through ; ; Send CR,LF ; CRLF: MVI A,CR CALL AOUT ; "A" to console MVI A,LF JMP AOUT ; "A" to console ; TUTO: LXI H,SCRP ; CMSS: CALL MSSG JMP EXIT ; ; Type A as two nibbles ; WORD: MOV A,H CALL BYTE MOV A,L ; BYTE: PUSH PSW RAR RAR RAR RAR CALL NYBL POP PSW ; NYBL: ANI 0FH ADI 90H DAA ACI 40H DAA JMP AOUT ; "A" to console ; ;----------------------------------------------------------------------- ; LOGO: DB 'COMP Version ',VER / 10 + '0','.',VER MOD 10 + '0',' -- ' DB MONTH/10+'0',MONTH MOD 10+'0','/' DB DAY/10+'0',DAY MOD 10+'0','/' DB YEAR/10+'0',YEAR MOD 10+'0',CR,LF,CR,LF,0 ER1: DB '++ Cannot open first file ++',CR,LF,0 ER2: DB '++ Cannot open second file ++',CR,LF,0 ME1: DB CR,LF,'Number of bytes compared : ' ME11: DB ' 0',CR,LF,0 ME2: DB 'Number of mismatches found: ' ME22: DB ' 0',CR,LF,0 ME3: DB CR,LF,'Comparison interrupted.',0 ME4: DB CR,LF,'Shorter of the two is: ',0 ME5: DB 'File 1: ',0 ME6: DB 'File 2: ',0 ; SCRP: DB 'Compares the length and content of two files (usually .COM',CR,LF DB 'files). Mismatches, along with the address are displayed.',CR,LF DB CR,LF,'To use:',CR,LF,CR,LF DB ' B>COMP FILE1.COM A:FILE2.COM',CR,LF,CR,LF ; FCB1: DS 33 FCB2: DS 33 BYCT: DS 1 ; Byte count RECT: DS 1 ; Record count NEQL: DS 1 ; FF=different file lengths CLMN: DS 1 ; Column counter BORG: DS 2 DS 32 ; Minimum stack size ; EVEN EQU ($+256-1)/256*256 ; To start on an even page ; ORG EVEN ; STACK EQU EVEN-2 ; Save two bytes for original CCP return BUF1: DS 4000H ; 16k buffer BUF2: DS 4000H ; 16k buffer ; END