This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

PROBLEMS WITH SIMPLE CONDITIONAL ASSEMBLY

Hi, I HAVE SOME PROBLEMS WITH SIMPLE CONDITIONAL ASSEMBLY.
Error[57]:
Unbalanced conditional assembly directives C:\Program Files\IAR
Systems\Embedded Workbench 6.0 Kickstart\430\PVCD-29.s43 2889
In conditional assembly started in line 46

ALLWAYS THE SECOND CONDITION CAUSES AN ERROR.

THANK YOU.

REGARDS,

VANESA / DANIEL

cCODE:

 

VARIANTE        EQU 1           ;1 : 1 BOMBA
                                                  ;2 : 2 BOMBAS
                                                  ;3 : 3 BOMBAS
 ;##############################
 IF VARIANTE=1
 ;
 CANTANA EQU 4
 CANTINC EQU 1
 CANTFL  EQU 2
 CANTPAR EQU 3
 ;
 ENDIF
 ;###############
 IF VARIANTE=3                                    ( <--- LINE 46  )
 ;
 CANTANA EQU 4
 CANTINC EQU 1
 CANTFL  EQU 2
 CANTPAR EQU 9
 ;
 ENDIF
 ;##############################;
 ;
 ;
 ;*************************************

;DEFINICIONES
 ;*************************************;
 #include "A-ASIGNACIÓN DE RAM.h"
 #include "A-ASIGNACIÓN DE FLASH.h"
 #include "SUB29\X29\A-DEFINICIONES GENERALES-G03.h"
 #include "SUB29\X29\A-DEFINICIONES GENERALES-Gx.h"
 #include "SUB29\X29\A-DEFINICIONES MEMODAT PARA IrDA.h"
 #include "A-DEFINICIONES PARTICULARES.h"
 #include "SUB29\X29\A-DEFINICIONES DX-DS6-MX.h"
 ;
 ;*************************************;
         ASEG INFO_B
 ;
EQyPROGR        DB      'LK7-PVCA'
OPCyNSER        DB      ' CMX112-1101E003'
IDNUMBER        DW      00030h                  ;2 BYTES.
....
....
....

      END

  • Maybe it's not the second conditional that causes the error, but the last one (the innermost open one). What happens if you remove the second? Does the first one give you an error then?

    It's possible that you inserted a shift-enter instead of an enter before the ENDIF? Then the assembler might think that the ENDIF is still behind the ';' of the preceding code line (therefor disabled), and only your editor shows it in a new line.

    P.s.: In your code, you mix up C-style preprocessor directives (#include) with Assembler control directives (which would be '$' for including a file). Normally not  a problem, I just noticed it.

  • Thank you Jens-Michael.

    a) I removed the second conditional: no error.

    b) I added only the second Endif:

    Error[59]: ENDIF without IF
    C:\Program Files\IAR Systems\Embedded Workbench 6.0 Kickstart\430\PVCD-29.s43 58

    c) I added the second If:

    Error[57]: Unbalanced conditional assembly directives   
    C:\Program Files\IAR Systems\Embedded Workbench 6.0 Kickstart\430\PVCD-29.s43 2889
    In conditional assembly started in line 46

    Any other suggestion?

    Best regards,
    DANIEL

  • Vanesa Aloisio said:
    Any other suggestion?

    Actually I'm at my wits end.What you tried renders all explanations invalid, which come to my mind.

    Perhaps you should post this question in the IAR support forum, as this sems to be a problem with their assembler.

  • Vanesa Aloisio said:
    Any other suggestion?

    I think what the error means is that somehow there is an IF that doesn't match an ENDIF. Could you provide a very small assembly file (just the offending lines please!) that demonstrates the issue so that I can play with it?

     

    Jens-Michael Gross said:
    Perhaps you should post this question in the IAR support forum, as this seems to be a problem with their assembler.

    To my knowledge, there isn't an IAR forum (at least, I've never been able to find one on their website; If you know where one is, please show me!). I happen to have a support license, so I can email support. But unfortunately people using kickstart are SOL.

    As far as bugs in the assembler, yes, there are a few. A particular item of interest is that they use a different parser for the assembly files than the C files, which can lead to some interesting incongruities (for example, with C-style preprocessor directives). Forum member "old_cow_yellow" probably has more experience with this, being an IAR assembly user.

  • Thank all of  you.

    I have the answer: although I am programming in assembler,  the command must be in C:

    #if  instead of IF

    #endif instead of ENDIF.

    Best regards,

    Daniel

     

  • Vanesa Aloisio said:
    although I am programming in assembler,  the command must be in C

    Following the IAR assembly guide, both versions should work.

    But maybe the conditional assembly instructions are  somehow broken while the conditional compilation instructions still work.

    I guess, the #xxx is parsed by teh precompiler as if it were a C file, so the assembler will never see the conditional commands and will see the included files as part of its input file.

    Using the direct assembler instructions should be faster (no parsing first and no intermediate file created that is passed to the assembler), but if it solves your problem this way, you're welcome.

    p.s.: I don't know of any IAR support forum. I don't use IAR and never checked. I was just assuming that there is one.

     

**Attention** This is a public forum