File comparitor

I thought Taper might do it but its not quite what I was after. Unless I misunderstood that shows if tapes are identical or not but not the differences.

Lets say I have two blocks of code, can be either straightforward tape images of a block or maybe even binary files.

What (Windows I'd guess) program can I use to compare them and list all the differences please ? :)
Post edited by spider on

Comments

  • edited April 2013
    If you've got a version of Windows - such as XP - which provides a DOS Command Prompt option, then you can use FC for text or binary file comparisons. Type "HELP FC" at the prompt for the command line options.
  • edited April 2013
    Thanks will have to try that.

    I think I was sort of after something that would display side by side byte differences with two almost identical blocks of code but that would work otherwise just more work. :)
  • edited April 2013
    Well, in that case I'd use HxD by Mael Horz, an excellent free hex editor program for Windows which has a file comparison option which shows the two file hex dumps one above the other and highlights each difference in turn. It does a byte comparison, so would be a bit tedious if there are lots of differences, or if one file is slightly offset from the other (ie. where the files are mostly the same, but one has an extra chunk near the start), but that feature is very handy for tracking down minor discrepancies. I use the comparison feature mostly for tracking down the alterations in hacked versions of games.
  • edited April 2013
    Thanks again. That's more or less what I'm after its minor differences I think. Its just determining the original version(s) to see what was changed. :)

    * Off to download HxD to try later.
  • edited April 2013
    In theory I could write something (with practise!) to load each block of code into a 128 machine, putting it into a bank and then have some (basic hopefully) program to list each address / change but that seems a bit of trouble as the hex tool may be ideal.
  • edited April 2013
    If block1 starts at "first" and block2 starts at "last+1" then a BASIC comparison routine could be just this one-liner:
      10 LET b=last-first+1:
         FOR a=first TO last:
           POKE 23618,10: POKE 23620,5+NOT (PEEK a-PEEK (a+b)):
           PRINT a;" ";PEEK a,a+b;" ";PEEK (a+b):
         NEXT a
    
    Each iteration jumps to statement 5 (PRINT) or 6 (NEXT) depending upon whether corresponding bytes are different or not.
  • edited April 2013
    Total Commander allow to compare two files - difference highlightning. nice GUI:)
  • edited April 2013
    g0blinish wrote: »
    Total Commander allow to compare two files - difference highlightning. nice GUI:)

    I use a similar one called Beyond Compare, which has a hex compare option as well as text compare... although I haven't used it for Speccy programming (mainly because I'm not a Speccy programmer!) (or any sort of programmer really, I'm just a bad haxx0r)
    The comp.sys.sinclair crap games competition 2015
    "Let's not be childish. Let's play Spectrum games."
  • edited April 2013
    Do you know "Windows Commander" ?
    It is now called "Total Commander" because Microsoft complained it was called something with "Windows" :-)
    It has the Feature to compare 2 files - and list the differences !
  • edited April 2013
    The two blocks of code would not fit into a 48K machine. :)

    I used HxD and made notes of the difference bytes, then converted them to decimal and finally fired up an emulator to look at the disassembly and compare the differences.

    Only 15 bytes are different some grouped some spread around.

    I even worked out what some of the changes did although I want to learn so instead of posting a "what does xyz do" I'll see if I can figure some more out myself first. :)
  • edited April 2013
    Here's a more advanced version of my earlier routine. It reads the blocks from +3 disk 32 bytes at a time so it's not restricted by what can fit into memory. This is the controlling routine; the external GOSUBs refer to routines in my +3DOS_Demo library. It's too slow in BASIC, but it gives an example of the type of structure which might be used for a simple byte comparison; comparing narrative text files efficiently is a whole lot more complicated. The full listing is in the DOS_FC archive; the assembler listing for the DOS routines is in the other one.
    dos_fc.gif
    Each pair of 32 byte blocks is printed one on top of the other if different, or skipped if not; only mis-matched bytes are printed. Printable characters are printed plain; non-printable are printed as a compressed hex byte. In the example picture the end of the shorter file has already been reached, so only the longer file is printing.
       2 LET DOS=32000+11: CLEAR DOS-12: GO SUB 900:
         LOAD "miniset-LH"CODE VAL "32512+256":
         LOAD "miniset-RH"CODE VAL "33280+256":
         CLS : DIM r$(k2,kC): DIM r(k2,k5):
         INPUT "file#1",r$(k1)'"file#2",r$(k2): LET off=k0
       3 FOR i=k1 TO k2:
           PRINT "Opening ";r$(i): GO SUB FN a("O",r$(i),i+k2,k1,k0,k1):
           GO SUB FN a("g","",i+k2,k0,k0,k0): LET r(i,k1)=cde: REM get SOF
           GO SUB FN a("e","",i+k2,k0,k0,k0): LET r(i,k2)=cde: REM get EOF
           LET r(i,k3)=r(i,k2)-r(i,k1): LET r(i,k4)=134+i-k1:  REM size : load point
           LET r(i,k5)=k32-(k32-r(i,k3) AND r(i,k3) < k32):    REM block length
         NEXT i
      11 FOR i=k1 TO k2
      12   LET r(i,k5)=k32-(k32-r(i,k3) AND r(i,k3) < k32):
           IF r(i,k5) THEN
             GO SUB FN a("R","=r(i,k5)",i+k2,k0,r(i,k4),k0):   REM read a block
             LET r(i,k3)=r(i,k3)-r(i,k5): REM deduct from size
      13 NEXT i
      14 LET dif=k0: REM check if the blocks differ
      15 FOR j=k1 TO k32: FOR i=k1 TO k2: REM pad a short block with spaces
      16     IF j > r(i,k5) THEN POKE r(i,k4)*kFG+j-k1,k32:
      17    NEXT i:
            LET dif=[color=green][b]dif+[/b][/color](PEEK (34304+j-k1)<>PEEK (34560+j-k1)):
         NEXT j
      18 PRINT off;AT 24-PEEK 23689,k0;:
         IF NOT dif THEN GO TO 20: REM no diff = no print
      19 PRINT : LET set=+kFG: REM print a block from each file
         FOR j=34304 TO 34560 STEP kFG: FOR i=k1 TO k32:
             GO SUB 30:
           NEXT i: LET set=-set: BRIGHT k1:
         NEXT j: BRIGHT k0
      20 LET off=off+k32: REM loop back if either file is not finished
         IF r(k1,[color=green][b]k5[/b][/color]) OR r(k2,[color=green][b]k5[/b][/color]) THEN GO TO kB
      28 FOR i=k1 TO k2:
           PRINT "Closing ";r$(i): GO SUB FN a("C","",i+k2,k0,k0,k0):
         NEXT i
      29 GO TO 5260
      30 LET ch1=PEEK (j+i-k1): LET ch2=PEEK (j+i-k1+set): REM print a block from each file
         IF ch1=ch2 THEN PRINT " ";: RETURN: REM if pair matches print space
      31 IF ch1>=k32 AND ch1<=k7F THEN PRINT CHR$ ch1;: RETURN: REM if printable char, print
      32 LET ch2=FN l(ch1,kG): LET ch1=(ch1-ch2)/kG: REM if non-printable char, print hex byte
         POKE 23607,127: PRINT CHR$ FN m(ch1);:      REM using compressed font
         POKE 23607,130: PRINT OVER k1;CHR$ k8;CHR$ FN m(ch2);:
         POKE 23607,60:
         RETURN : DEF FN m(v)=v+48+(k7 AND v > k9)
    
Sign In or Register to comment.