Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
David Prentice
01/17/12 03:31
Read: 417 times
Wormshill
England


 
#185524 - What is the octothorpe?
Responding to: ???'s previous message
Donagh Choghlan said:
Hello,
At the moment Iím trying to get a conditional statement to work in Keil.
Here is my code in assembly

IF A>=#0x03
 SETB GAIN_ERROR
 RET
ENDIF
;an other variation of it is
IF A=#0x00
 SETB GAIN_ERROR
 RET
ENDIF

 


It compiles without a bother but when I run the code it does not react the way I was hoping it would, does anyone have any suggestions?
Donagh.

I am not sure what the hash sign does in Keil. It should understand both 0x12 and 012h as expressions.
As a general rule, IF will be expanded if the expression is non-zero, and not if zero.

I would avoid using a single = as a comparison operator. I know that the Help Examples use it. Use EQ or ==.

Note that to test for inequality you can do:
IF expr - value
 

But I find it less intuitive.

You should also find you can use whitespace in parenthesised expressions. This is for your benefit.

Untested. I am not a Keil expert.

David.

List of 17 messages in thread
TopicAuthorDate
Conditional Statements      Donagh Choghlan      01/17/12 02:57      
   Hex constants?      Oliver Sedlacek      01/17/12 03:18      
      0x00, 0x01, 0x02??      Donagh Choghlan      01/17/12 03:28      
   What is the octothorpe?      David Prentice      01/17/12 03:31      
      #      Donagh Choghlan      01/17/12 03:40      
         Immediate or not      Per Westermark      01/17/12 07:31      
      what is an octothorpe?      Andy Peters      01/17/12 10:49      
         Previously, on 8052.com      Andy Neil      01/17/12 15:02      
   Problem solved, query still remains      Donagh Choghlan      01/17/12 03:54      
      Do some trial and error      David Prentice      01/17/12 04:14      
      Check the CJNE instruction...      Robert Revens      01/17/12 06:31      
         Handy that!      Donagh Choghlan      01/17/12 07:18      
      run time vs compile time      Maarten Brock      01/17/12 07:14      
         IF only at assemble      Donagh Choghlan      01/17/12 07:23      
            Not Really!!      Michael Karas      01/17/12 08:47      
               I second that      Erik Malund      01/17/12 08:58      
            Hw variants or debugging are big users of conditionals      Per Westermark      01/17/12 09:40      

Back to Subject List