1. 9

Despite how trivial this is, I’m not 100% sure that it’s correct. Posting it here so it can have some more experienced eyes reading it.

  1.  

  2. 3

    != is probably the wrong operator in bcmp. Most implementations use xor.

    1. 1

      Using xor is just a tiny optimization (makes it 3 bytes smaller and, in theory, saves a clock cycle per iteration):

      < cmp    %al,%dl
      < setne  %al
      ---
      > xor    %edx,%eax
      
      1. 5

        Until you use a different compiler/CPU and end up with the equivalent of:

        if (a[i] == b[i])
             rv |= 1;
        

        And suddenly you have data dependent branches again. That’s very unlikely, but since the point of the exercise is to avoid branching instructions, best to avoid potentially branching operators entirely.