Announcement

Collapse
No announcement yet.

My custom rule is going wrong; please help!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • My custom rule is going wrong; please help!

    Hi Guys,

    Love the product, but am having some trouble with the following (I am comparing two disassembled functions):

    File1:
    Code:
    7F0C8018: SB      s6,0001h(v1)
    7F0C801C: SB      s7,0008h(v1)
    7F0C8020: MULTU   s6,s7
    7F0C8024: SLL     t5,v0,0002h
    7F0C8028: MFLO    s5
    File2:
    Code:
    7F0C68A0: SB      s6,0001h(v1)				//			1(v1)=
    7F0C68A4: SB      v0,0008h(v1)
    
    7F0C68A8: MULTU   s6,v0						//		}
    7F0C68AC: LUI     a0,FFFF8009h
    7F0C68B0: OR      a1,s4,r0					//		a1 = s4
    And I've created my own rules with the following settings:
    Whitespace Includes : Tabs and spaces
    Max Line Len : 4096
    Char set : ANSI
    *Unimportant Text*
    [TICK] Character case
    [TICK] Leading whitespace
    [TICK] Embedded whitespace
    [TICK] Trailing whitespace
    [TICK] Blank lines
    Regex : Text matching ^9[0-9A-Fa-f]*:
    Regex : Text matching \s*//.$

    The first regex says "The leading address doesn't matter".
    The second says "Whitespace and any comments following don't matter".

    What happens is that it matches the MULTU in fileA with the blank line in fileB and the SLL in fileA with the MULTU in fileB.

    Can you explain what I am doing wrong? I would have thought that we these two regexs and the "[TICK] Blank Lines unimportant" setting, it'd match the MULTUs up.

    p.s. I tried this in both 2.3 and 2.4 beta. Are there any more recent versions?

    Thanks in advance,

    Ray.

  • #2
    Re: My custom rule is going wrong; please help!

    Sorry about posting the above anonymously!

    I forgot to log-on.. obviously.

    Ray.

    Comment


    • #3
      Re: My custom rule is going wrong; please help!

      One further thing:

      "Text matching ^9[0-9A-Fa-f]*:"

      Should have been:

      "Text matching ^[0-9A-Fa-f]*:"

      Cheers!

      Comment


      • #4
        Re: My custom rule is going wrong; please help!

        You're comments expression is wrong; you're missing a '*' after the period. You could use a delimited rule instead by using "starting with //" and ending at the end of the line.

        I tested it here though, and everything lined up correctly. Make sure that your "Line Alignment" is set to the "Standard Method", and "Align Similar Lines" is checked. If you move the slider to the middle it'll set that up for you.
        Zoë P Scooter Software

        Comment


        • #5
          Re: My custom rule is going wrong; please help!

          Thanks for the help.

          My comments error was a transcription error when I posted to the forum, in my rule it contained the * after the period.

          Setting things up as you suggested helped with the case I provided, but they were only snippets from two larger files. I've pasted a larger snippet where the rule still goes wrong:
          FileA
          Code:
          7F0C8008: ADDIU   t8,t8,FFFFC730h
          7F0C800C: SLL     t4,t7,0004h
          7F0C8010: ADDU     t9,t4,a1
          7F0C8014: ADDU     v1,t9,t8
          7F0C8018: SB      s6,0001h(v1)
          7F0C801C: SB      s7,0008h(v1)
          7F0C8020: MULTU   s6,s7
          7F0C8024: SLL     t5,v0,0002h
          7F0C8028: MFLO    s5
          7F0C802C: SLTI    at,s5,2001h
          7F0C8030: BNEL    at,r0,7F0C8044h
          7F0C8034: SLTIU   at,v0,000Ah
          7F0C8038: BEQ     r0,r0,7F0C8724h
          7F0C803C: OR      v0,r0,r0
          7F0C8040: SLTIU   at,v0,000Ah
          7F0C8044: BEQ     at,r0,7F0C8534h
          7F0C8048: LUI     at,FFFF8006h
          7F0C804C: ADDU     at,at,t5
          7F0C8050: LW      t5,FFFFBD30h(at)
          7F0C8054: JR      t5
          7F0C8058: NOP
          7F0C805C: LW      t6,30ACh(sp)
          7F0C8060: LW      t3,0088h(sp)
          FileB
          Code:
          7F0C6890: ADDIU   t5,t5,FFFFC730h			//			t5=8008c730
          7F0C6894: SLL     t2,t4,0004h				//			t2=global_8008d090<<4
          7F0C6898: ADDU     t3,t2,s3					//			t3=global_8008d090<<4+s3
          7F0C689C: ADDU     v1,t3,t5					//			v1=8008c730+global_8008d090<<4+s3
          7F0C68A0: SB      s6,0001h(v1)				//			1(v1)=
          7F0C68A4: SB      v0,0008h(v1)
          
          7F0C68A8: MULTU   s6,v0						//		}
          7F0C68AC: LUI     a0,FFFF8009h
          7F0C68B0: OR      a1,s4,r0					//		a1 = s4
          7F0C68B4: ADDIU   a2,sp,0270h
          7F0C68B8: MFLO    t6						//		t6 = width * height
          7F0C68BC: SLTI    at,t6,1001h				//		if( width * height > 0x1000 )
          7F0C68C0: BNE     at,r0,7F0C68D0h			//			return 0
          7F0C68C4: NOP
          If you have any time to look into this, I'd really appreciate it.

          Comment


          • #6
            Re: My custom rule is going wrong; please help!

            Text like this is challenging because BC's File Viewer doesn't have a way to make the operation name more important for alignment than the arguments while still showing the arguments as important differences.

            One option for this might be to compare the files in our Data Viewer plug-in. If you mark the address as an unimportant column and mark the operation column a key column it should give you pretty good alignment. You can find details on the Data Viewer at: http://www.scootersoftware.com/download.php?c=dataview It does require a registered copy of BC to use.

            There is a workaround for the File Viewer, although it isn't optimal. Get rid of all your unimportant text items and enter the regular expression : [A-Z]+\s+ as a String Literal. Then check "All other text is unimportant". Back in the File Viewer, turn off View|Ignore Unimportant Differences. This will force BC to align only on the operation names, but you'll still be able to see differences in the arguments in blue.
            Chris K Scooter Software

            Comment


            • #7
              Re: My custom rule is going wrong; please help!

              Hi Chris,

              I am a registered user, so no worries there.

              I had assumed that BC perfomed as described:

              1. Conceptually strip out all unimportant text (which would get rid of the blank line)
              2. Compare the two stripped files.
              3. Present the results by coloring the original files according to the match results from the stripped files.

              Being a programmer, I understand that it's probably a lot of work, but if not, it'd be great if this mode of operation could be given as an option for the Rules.

              Thanks a lot,

              Ray.

              Comment


              • #8
                Re: My custom rule is going wrong; please help!

                Using standard alignment, BC gives a weight to all lines for alignment. Unimportant text is still included in the line alignment, it just has less weight than important text. There is a pretty detailed description of how BC aligns text in the Rules>File Alignment Rules section of the help file.

                It might also be worth setting BC to use the "Alternate Method" of line alignment. This tends to be slower, but it can work better on some files.

                Your files are tough for BC's current alignment algorithm to work well with, but we're keeping this scenario in mind as we work on the next major release of BC.
                Chris K Scooter Software

                Comment

                Working...
                X