* * CMPF PTDOS command by TMQ 4/7/79 * format: CMPF original file name,duplicate file name * compares two files for identical contents * not safe * ORG 100H load address XEQ 100H start address * CR EQU 0DH carriage return LF EQU 0AH line feed BYTBZ EQU 256 # of bytes in block transfer * COPY NPTDEFS get system definitions * LXI SP,STACK initialize stack * * Open both files * CALL PASCN open the original file CPI ',' comma JNZ ERRNC file name missing MOV A,E get file # STA FINU1 store its file # CALL PASCN open duplicate file MOV A,E get file # STA FINU2 store its file # MVI A,8 STA 9D98H set PTDOS scroll speed to slow * * Initialize parameters before comparison * COMP CALL READ read a block or less of bytes from both files * * subtract remaining transfer count from block size * LXI B,BLKSZ point to block size (BYTBZ) LXI H,TRFCT point to transfer count remaining (usually 0) XRA A clear carry bit LDAX B get block size low byte SBB M subtract transfer count remaining MOV E,A save low transfer count in E INX B point to high byte INX H same LDAX B get block size high byte SBB M subtract transfer count remaining MOV D,A save high transfer count in D * * DE now holds actual transfer count * LXI B,MBUF1 BC points to start of original file buffer LXI H,MBUF2 HL points to start of duplicate file buffer * * comparison begins here * AGNM PUSH H save addr LHLD COUNT get comparison counter (starts at 0) INX H increase count by one SHLD COUNT put count back POP H restore addr LDAX B get original data byte CMP M compare with duplicate data byte CNZ NOMAT if not the same INX B point to next original file addr INX H point to next duplicate file addr DCX D decrease block count by one MOV A,E inclusive OR the low ORA D and the high count JNZ AGNM look some more if not zero LDA EOFG get end of file flag CPI EREOF does it match EOF error byte JZ MATCH yes, files must be the same CALL MOABT see if MODE typed JMP COMP not at EOF so get another block and compare again * * Files match routine * MATCH LDA ERFLG ORA A JNZ MAT0 LXI D,MESM point to 'files are identical' message CALL PRTMSG print it MAT0 CALL ADOUT LXI D,MESB CALL PRTMSG MAT1 CALL CLOSE close files * * Return to PTDOS routine * SYRET CALL SYS system call DB RETOP return to system * * Files do not match routine * NOMAT PUSH B PUSH H CALL ADOUT convert counter to hex & print POP H POP B PUSH B LDAX B CALL BYTES MOV A,M CALL BYTES MVI A,0DH STA ERFLG CALL CONOUT CALL MOABT POP B RET . * BYTES PUSH PSW MVI A,' ' CALL CONOUT POP PSW CALL HEXOT RET . * * Parameter scanner routine * PASCN MVI A,PSOP open file LXI D,BUFPS point to buffer CALL PSCAN parameter scanner JC ERRPS field syntax error JZ ERRNC no file name found RET done * * Transfer a block of data to memory for both files * READ LDA FINU1 get original file # LXI D,MBUF1 point to its buffer LXI B,BYTBZ load transfer count CALL SYS system call DB RBLOP read data STA EOFG error return, set EOF flag MOV H,B normal return, BC holds the MOV L,C remaining unsucessful transfer count (normally 0) SHLD TRFCT store here LDA FINU2 get duplicate file # LXI D,MBUF2 point to its buffer LXI B,BYTBZ load transfer count CALL SYS system call DB RBLOP read data STA EOFG error return, set EOF flag RET normal return, done * * Close files routine * CLOSE XRA A STA 9D98H reset PTDOS speed byte CMA . close all open files CALL SYS system call DB CAOP close all open files DB 0,0,0 error return, not used RET done * * Print string message till delimiter (0) * PRTMSG MVI A,1 console file # MVI L,0 let delimiter be 0 LXI B,38 max transfer count CALL SYS system call DB DWROP delimited write DB 0,0,0 error return RET normal return, done * * Convert comparison count to hex and print * ADOUT LHLD COUNT get comparison count ADOU1 MOV A,H move high byte CALL HEXOT convert it and print MOV A,L get low byte CALL HEXOT convert it and print RET done * * Binary byte to hex and print subroutine * HEXOT PUSH PSW save byte for later RRC prepare RRC upper RRC four RRC bits CALL HASCI convert them to a hex chr CALL CONOUT print the higher hex chr POP PSW retrieve the lower four bits CALL HASCI convert them to a hex chr CALL CONOUT print the lower hex byte RET done * * convert four bits to a ASC hex chr * HASCI ANI 0FH mask off upper four bits ADI 90H DAA ACI 40H DAA RET done * * No file name error handler * ERRNC CALL CLOSE close any open files LXI D,MNOF point to 'file name missing' message CALL PRTMSG print it JMP ABORT abort & return to system * * Parameter scanner error handler * ERRPS MOV A,E move error code STA ERRCD store it * * Utility error handler * UTILEP CALL CLOSE close any open files MVI A,0 control word LXI H,-1 no 2nd line message CALL UTIL system utility call DB UXOP explain error JMP ABORT error return ERROP DB -1 no operation code ERRCD DB 0 error code storage * MOABT CALL CONTST see if char waiting RZ . go back if none CALL CONIN get it ORA A see if MODE JZ MAT1 exit if so * * Abort all * ABORT CALL SYS system call DB RESOP abort and return * * Message area * MESM ASC 'Files are identical' DB CR,LF,0 MESB ASC 'H bytes compared' DB CR,LF,0 MESE ASC 'H' DB CR,LF,0 MNOF ASC 'File name missing' DB CR,LF,0 * * Storage area * BLKSZ DW BYTBZ block transfer size COUNT DW -1 comparisons made counter TRFCT DW 0 incomplete transfer count FINU1 DB 0 original file # assigned FINU2 DB 0 duplicate file # assigned EOFG DB 0 end of file flag (set=high) ERFLG DB 0 compare error flag BUFPS DS 20 parameter scanner buffer MBUF1 DS BYTBZ+2 original file buffer MBUF2 DS BYTBZ+2 duplicate file buffer STACK EQU $+32 program stack END *.