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
  • It's good that you know that conditional branches looks at flags.

    But a couple of questions:

    Have you tried to write the code in C and then tried to singlestep through the code in a debugger? No need to use the Keil compiler/debugger - the concept is the same with other compilers or other processor architectures. The only important thing is to not turn on optimization, since that makes it harder to follow the code flow. That would have let you quickly see how a compiler implements comparisons and jumps and from that builds different conditional and loop constructs.

    And did you consider the difference of jumping to code, or jumping around code? Because that answers your question if you should use a test for equal or not equal.

    You did get excellent help, but decided to ignore it, because it involved own work.

    Why do students often get own assignments - might it be because it's a great way to learn? You can't expect to learn if you aren't willing to spend time thinking. And you can't expect to get good help if you claim "troll" if the help requires you to think.

Reply
  • It's good that you know that conditional branches looks at flags.

    But a couple of questions:

    Have you tried to write the code in C and then tried to singlestep through the code in a debugger? No need to use the Keil compiler/debugger - the concept is the same with other compilers or other processor architectures. The only important thing is to not turn on optimization, since that makes it harder to follow the code flow. That would have let you quickly see how a compiler implements comparisons and jumps and from that builds different conditional and loop constructs.

    And did you consider the difference of jumping to code, or jumping around code? Because that answers your question if you should use a test for equal or not equal.

    You did get excellent help, but decided to ignore it, because it involved own work.

    Why do students often get own assignments - might it be because it's a great way to learn? You can't expect to learn if you aren't willing to spend time thinking. And you can't expect to get good help if you claim "troll" if the help requires you to think.

Children