This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Assembly IF statement simple question

If I say,

if a == 10 b = b * 4 + 2

if it does then do 'b = b * 4 + 2' or skip doing it? Would it be BNE or BEQ?

Something tells me it's DON'T DO...

Thanks

Parents
  • Something tells me you suck at helping and possibly are a troll.

    Stop being so negative!

    Either BEQ or BNE could be used. It simply depends on how your code flows.

    Why don't you try breaking your code up a little more and see what might be the best solution?

    if a == 10 b = b * 4 + 2
    

    You must surely be able to see that it could flow something like:

    
      CMP  A,#10
      BNE  Skip
    
      Do the maths
    
    Skip:
    
      Continue
    
    

    But if your code was part of a subroutine it might be:

    
      CMP  A,#10
      BEQ  Continue
    
      return
    
    Continue:
    
      Do the maths
    
      return
    
    

    I'll assume you can interpret my pseudo code/instructions.

Reply
  • Something tells me you suck at helping and possibly are a troll.

    Stop being so negative!

    Either BEQ or BNE could be used. It simply depends on how your code flows.

    Why don't you try breaking your code up a little more and see what might be the best solution?

    if a == 10 b = b * 4 + 2
    

    You must surely be able to see that it could flow something like:

    
      CMP  A,#10
      BNE  Skip
    
      Do the maths
    
    Skip:
    
      Continue
    
    

    But if your code was part of a subroutine it might be:

    
      CMP  A,#10
      BEQ  Continue
    
      return
    
    Continue:
    
      Do the maths
    
      return
    
    

    I'll assume you can interpret my pseudo code/instructions.

Children
No data