PDA

View Full Version : Macro CMPEQ?TTT not found in macro file



BigWumpus
- 13th May 2006, 08:45
Yesterday, compiling for a PIC18F4585 I got this error.
You can made it by your own:

Dummy_Bit VAR Bit
Dummy_Bit=(Dummy_Bit=Dummy_Bit) ;just 3 Bit-Vars in this equation !

Then I get this error.

Mel, some macros are missing ????

Melanie
- 13th May 2006, 10:00
How can you have two equal signs in that statement? Mathematically or Logically it doesn't make sense, and the compiler is telling you it doesn't like it. It is however trying to Parse that line and attempting to call a routine to handle that expression... but there isn't one. When mathematicians figure out a way of handling that, you are safe in the knowledge that your PICBasic compiler already has the internal hooks to slot-in a routine for it...

After you correct that, you'll also discover you've a ; (Assembler comment marker) when you should have had a ' (the PICBasic comment marker)... but a lot of people don't know that PICBasic will accept that... so you've discovered one of those undocumented features...

BigWumpus
- 13th May 2006, 11:46
Melanie,

OK, look at this (more complicated)

Flag_Switch_activ_on_ Var Bit (1=activ on high, 0=activ on low)
Switch Var PortC.0
Is_Switch_aktiv Var Bit

Is_Switch_aktiv= ( Flag_Switch_activ_on_ = Switch )
(In Pascal ^ you would use ":=" in order to see the difference between a "fill that variable" and "compare/eqal")

In words: If the content of "Flag_Switch_activ_on" is the same as the content of "Switch", the variable "Is_Switch_activ" should be set.

If the second "=" would be changed to a "<>", it is easy to use a "^" XOR instead...

I have managed it in another way, maybe I write this missing macro on my own... ;-)

Melanie
- 13th May 2006, 12:56
You can only do mathematical equations or compares within parenthisis within a stacked statement. With this item...

Flag_Switch_activ_on_ = Switch

... you are asking the contents of a Port PIN to be transferred into a variable... this is NOT an equation or a compare function and cannot be included in a single valid BASIC statement whilst simultaneously elsewhere within that same statement you are performing an equation.

It still comes down to the fact you have TWO (or more) equal signs at different parts of a single statement which is not legal. Put Flag_Switch_activ_on_ = Switch on it's own line, then build your IF/THEN accordingly.

Darrel Taylor
- 13th May 2006, 19:32
In other languages such as Pascal, Logical comparisons are treated like a Mathmatical formula. Then after the formula is calculated, any non-zero number is considered TRUE. Consequently, the result of that formula can be assigned to another variable if so desired.

In PicBasic, that would require additional time, temporary variables and code space. Things that don't matter on a computer with GIGA hz, ram, and disk space. But matters alot for a PIC.

Fotunately, the same things can be accomplished in different ways. For instance...

Is_Switch_aktiv= ( Flag_Switch_activ_on_ = Switch )

can be like this...

Is_Switch_aktiv= ( Flag_Switch_activ_on_ ^/ Switch ) &nbsp; &nbsp; &nbsp; ; ^/ is "Not Exclusive OR"


To see how that works we can look at the Truth Tables.
<table border="0" cellspacing="7" cellpadding="4"> <tr> <td> <table CELLSPACING="0" BORDER="1" CELLPADDING="2" WIDTH="202"> <tr> <td WIDTH="99%" HEIGHT="16" colspan="3"> <p align="center">Equals sign</td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">A</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">B</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">Out</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> </tr> </table> </td> <td> <table CELLSPACING="0" BORDER="1" CELLPADDING="2" WIDTH="202"> <tr> <td WIDTH="99%" HEIGHT="16" colspan="3"> <p align="center">Exclusive OR&nbsp; ^ </td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">A</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">B</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">Out</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"> <p ALIGN="CENTER"><font face="Arial" size="2">0</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"> <p ALIGN="CENTER"><font face="Arial" size="2">1</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"> <p ALIGN="CENTER"><font face="Arial" size="2">1</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"> <p ALIGN="CENTER"><font face="Arial" size="2">0</font></td> </tr> </table> </td> <td> <table CELLSPACING="0" BORDER="1" CELLPADDING="2" WIDTH="202"> <tr> <td WIDTH="99%" HEIGHT="16" colspan="3"> <p align="center">Not Exclusive OR&nbsp; ^/</td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">A</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">B</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">Out</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">0</font></td> </tr> <tr> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> <td WIDTH="33%" HEIGHT="16"><font FACE="Arial" SIZE="2"> <p ALIGN="CENTER">1</font></td> </tr> </table> </td> </tr> </table>
An Exclusive OR outputs a 1 when either of the inputs are a 1 but not both. This is the same as != in a logical expression.
Since we want "=", simply invert the XOR result with "^/".
<br>

BigWumpus
- 14th May 2006, 00:20
OK(8chars)

Darrel Taylor
- 14th May 2006, 00:36
:D<!--8chars-->