<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Assembly IF statement simple question</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/33880/assembly-if-statement-simple-question</link><description> 
If I say, 

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

 
if it does then do &amp;#39;b = b * 4 + 2&amp;#39; or skip doing it? Would it be
BNE or BEQ? 

 
Something tells me it&amp;#39;s DON&amp;#39;T DO... 

 
Thanks 
 </description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Assembly IF statement simple question</title><link>https://community.arm.com/thread/133959?ContentTypeID=1</link><pubDate>Sun, 09 Oct 2016 13:06:04 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2752f5c1-6ae6-4853-af40-ce0076baee26</guid><dc:creator>A Turner</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;It easier for me to understand by looking at the solution with
comments rather than reading text.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Both can be useful, but the Internet is truly resplendent with
examples. It&amp;#39;s well worth taking to learn to use sensible search
parameters.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assembly IF statement simple question</title><link>https://community.arm.com/thread/120885?ContentTypeID=1</link><pubDate>Sun, 09 Oct 2016 12:42:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:84f7c798-1ffb-40ab-8cec-1aab1b10102a</guid><dc:creator>Elias Gold</dc:creator><description>&lt;p&gt;&lt;p&gt;
Ok, I apologize. The thing is that I don&amp;#39;t know C or any other
programming languages. I started learning Assembly a few weeks ago.
It easier for me to understand by looking at the solution with
comments rather than reading text. Maybe that&amp;#39;s wrong but for now
this is grasp the material I&amp;#39;m learning.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assembly IF statement simple question</title><link>https://community.arm.com/thread/108916?ContentTypeID=1</link><pubDate>Sun, 09 Oct 2016 01:45:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9dbc7751-bbb9-4d02-80f6-a4d8016785ce</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
It&amp;#39;s good that you know that conditional branches looks at
flags.&lt;/p&gt;

&lt;p&gt;
But a couple of questions:&lt;/p&gt;

&lt;p&gt;
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.&lt;/p&gt;

&lt;p&gt;
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.&lt;/p&gt;

&lt;p&gt;
You did get excellent help, but decided to ignore it, because it
involved own work.&lt;/p&gt;

&lt;p&gt;
Why do students often get own assignments - might it be because
it&amp;#39;s a great way to learn? You can&amp;#39;t expect to learn if you aren&amp;#39;t
willing to spend time thinking. And you can&amp;#39;t expect to get good help
if you claim &amp;quot;troll&amp;quot; if the help requires you to think.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assembly IF statement simple question</title><link>https://community.arm.com/thread/108930?ContentTypeID=1</link><pubDate>Sun, 09 Oct 2016 00:31:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d22a6132-ffa7-45ee-8901-f362ae90d986</guid><dc:creator>A Turner</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;Something tells me you suck at helping and possibly are a
troll.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Stop being so negative!&lt;/p&gt;

&lt;p&gt;
Either BEQ or BNE could be used. It simply depends on how your
code flows.&lt;/p&gt;

&lt;p&gt;
Why don&amp;#39;t you try breaking your code up a little more and see what
might be the best solution?&lt;/p&gt;

&lt;pre&gt;
if a == 10 b = b * 4 + 2
&lt;/pre&gt;

&lt;p&gt;
You must surely be able to see that it could flow something
like:&lt;/p&gt;

&lt;pre&gt;

  CMP  A,#10
  BNE  Skip

  Do the maths

Skip:

  Continue

&lt;/pre&gt;

&lt;p&gt;
But if your code was part of a subroutine it might be:&lt;/p&gt;

&lt;pre&gt;

  CMP  A,#10
  BEQ  Continue

  return

Continue:

  Do the maths

  return

&lt;/pre&gt;

&lt;p&gt;
I&amp;#39;ll assume you can interpret my pseudo code/instructions.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assembly IF statement simple question</title><link>https://community.arm.com/thread/83366?ContentTypeID=1</link><pubDate>Sat, 08 Oct 2016 23:04:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3c806d3a-4c76-4eec-a3ef-b72f3601d657</guid><dc:creator>Elias Gold</dc:creator><description>&lt;p&gt;&lt;p&gt;
Something tells me you suck at helping and possibly are a
troll.&lt;/p&gt;

&lt;p&gt;
I&amp;#39;m aware that conditional branch looks at flags.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assembly IF statement simple question</title><link>https://community.arm.com/thread/69676?ContentTypeID=1</link><pubDate>Sat, 08 Oct 2016 22:26:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:668f62ef-cf10-49a7-b5e3-89dc81d136b7</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Something tells me you should learn how to use a debugger.&lt;/p&gt;

&lt;p&gt;
And maybe look at the assembler output of a C compiler.&lt;/p&gt;

&lt;p&gt;
Consider the difference between jumping to code or jumping around
code - that represents a negation of the conditional test.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>