Searching \ for '[PIC]: MPASM conditional assembly' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=asm
Search entire site for: 'MPASM conditional assembly'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: MPASM conditional assembly'
2001\01\14@135417 by David VanHorn

flavicon
face
Is it possible to do something like this, for N cases?

;Set which codeset you'd like to generate:
;
FALSE           equ     0       ;Universal Truths
TRUE            equ     1       ;
;
;These equates ARE MUTUALLY EXCLUSIVE.
;
Case1           equ     FALSE   ;These classes of device are mutually exclusive
Case2           equ     TRUE    ;They define I/O pin assignments, and the inclusion/
Case3           equ     FALSE   ;exclusion of source modules
                               ;Set exactly ONE to true, or wierd things will happen.

 if Case1              ;Force an error in case someone sets more than one
X       equ     0       ;to true.
 else                  ;
 if Case2              ;
X       equ     1       ;
 else                  ;
 if Case3              ;
X       equ     2       ;
 endif                 ;

Two cases seems to work, but three seems to be a problem, or I'm not doing
it right..
--
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@145032 by Bob Ammerman

picon face
----- Original Message -----
From: David VanHorn <spam_OUTdvanhornTakeThisOuTspamCEDAR.NET>
To: <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU>
Sent: Sunday, January 14, 2001 1:51 PM
Subject: Re: [PIC]: MPASM conditional assembly


> Is it possible to do something like this, for N cases?
>
> ;Set which codeset you'd like to generate:
> ;
> FALSE           equ     0       ;Universal Truths
> TRUE            equ     1       ;
> ;
> ;These equates ARE MUTUALLY EXCLUSIVE.
> ;
> Case1           equ     FALSE   ;These classes of device are mutually
exclusive
> Case2           equ     TRUE    ;They define I/O pin assignments, and the
inclusion/
> Case3           equ     FALSE   ;exclusion of source modules
>                                 ;Set exactly ONE to true, or wierd things
will happen.
{Quote hidden}

If you already know your cases are mutually exclusive then just:

   if Case1
X equ 0
   endif

   if Case2
X equ 1
   endif

   if Case3
X equ 2
   endif

You _can_ do the following, but it gets rather confusing very quickly:

   if Case1
X equ 0
   else
   if Case2
X equ 1
   else
   if Case3
X equ2
   endif
   endif    <- notice double endif

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@145452 by David VanHorn

flavicon
face
>
>If you already know your cases are mutually exclusive then just:

In the particular case I cited, it's an "idiot trap" in case you
accidentally set two that are supposed to be exclusive to true.


>     endif
>     endif    <- notice double endif

Ah! Ok, someone else sent me some examples, but I thought the double endif
was a typo.

Is this needed on any if-else if, or only in 3 or more?
--
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@150110 by Bob Ammerman

picon face
David,

Syntactically the IF/ELSE/ENDIFs are nested, so you need 1 ENDIF for each
IF. If you have 3 IFs you need 3 ENDIFs. If you have 20 IFs you need 20
ENDIFs. (yech!)

Here is a good idiot proofing technique:

   IF Case1+Case2+Case3 != 1
       ERROR "You must enable exactly one case!"
   ENDIF

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

{Original Message removed}

2001\01\14@152443 by Olin Lathrop

face picon face
>   if Case1              ;Force an error in case someone sets more than one
> X       equ     0       ;to true.
>   else                  ;
>   if Case2              ;
> X       equ     1       ;
>   else                  ;
>   if Case3              ;
> X       equ     2       ;
>   endif                 ;

This won't do what the comment says.  I've done something like this before
by counting the number of CASEx symbols that were true.  If the answer isn't
1, then it's an error.  You can see an example of this.  Go to
http://www.embedinc.com/pic and look near the bottom of STD_DEF.INS.ASPIC
where it ensures that exactly one processor family was selected.


*****************************************************************
Olin Lathrop, embedded systems consultant in Devens Massachusetts
(978) 772-3129, olinspamKILLspamembedinc.com, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\01\14@233621 by Andrew Warren

face
flavicon
face
David VanHorn <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU> wrote:

> In the particular case I cited, it's an "idiot trap" in case you
> accidentally set two that are supposed to be exclusive to true.

   David:

   Personally, I'd replace your:

       Case1   equ     FALSE   ;Set exactly ONE of these to true
       Case2   equ     FALSE   ;or weird things will happen.
       Case3   equ     FALSE

   with:

       Case    equ     1       ;Set this to 1, 2, or 3.

   But that's just me.

> > endif
> > endif    <- notice double endif
>
> Ah! Ok, someone else sent me some examples, but I thought the
> double endif was a typo.
>
> Is this needed on any if-else if, or only in 3 or more?

   Actually, EVERY "if" should have an "endif".

   -Andy


=== Andrew Warren - EraseMEfastfwdspam_OUTspamTakeThisOuTix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...