PDA

View Full Version : Logical vs Bitwise ==



Archangel
- 16th February 2010, 06:59
Hello Everyone,
I understand the difference between & vs &&, and I understand >= , <= , but what is the difference between = , and ==, is this just some "C" sneaking into peoples code or is there an esoteric difference here ? Or did I just miss that page in DAS BOOK ? As a comparison operator is there a difference ?
Bewildered

mackrackit
- 16th February 2010, 09:13
As a comparision operator they both do the same thing.
As a statement only "=" will work.

Why the MeLabs folks did it this way is anyones guess.

Archangel
- 17th February 2010, 00:51
Thanks Dave, I pretty much thought so, Never tried using double = as a statement, so that's good to know too.

Archangel
- 19th February 2010, 05:48
Ok I just found this, re: double equal sign in " C "


From Jan 2010 Circuit Cellar
author: George Martin
page 70
"Consider the statements if (a=b) and if (a==b). Both are

correct, but they are vastly different operations. The former copies the

value of variable b into variable a, and then if that value

is nonzero (TRUE) it executes the next statement. The latter compares

variable a to variable b . If they are equal, then the next

statement is executed. It is a common mistake to leave out the double

equal sign."

Is this true for PBP ?

mackrackit
- 19th February 2010, 05:58
PBP


XRUN:
IF (A == B) THEN X = Z

RUNX:
IF (A = B) THEN X = Z

Generated ASM


LABEL?L _XRUN
CMPNE?BBL _A, _B, L00001
MOVE?BB _Z, _X
LABEL?L L00001

LABEL?L _RUNX
CMPNE?BBL _A, _B, L00003
MOVE?BB _Z, _X
LABEL?L L00003

Looks the same to me..

Archangel
- 19th February 2010, 06:11
C != pbp . . . . .

mackrackit
- 19th February 2010, 06:16
C != pbp . . . . .
That will not compile...
Can not use a comparison operator as a statement.... :D

Archangel
- 19th February 2010, 06:22
That will not compile...
Can not use a comparison operator as a statement.... :D
You're right! it should be
main:
If C != PBP Then Gosub buy
goto main
Buy:
Buy PBP
return
:cool: