This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

.h in assembly

.h in assemblym works beautifully as far as #define, sfr and sbit being useful in assembly.

Now I have a case of conditional compile that I need reflected in an assembly module. I have tried to make the assembly IF and $IF work based on a #define.

Using IF it works if I do a #define 1 or #define 0, that, however wil require replacing all #ifdefs in the C. $IF seems not to react to #define

any suggestions?

Erik

Parents
  • If you have recent versions of Keil assembler (older versions didn't work):
    You can write the same syntax of conditional expressions as in C, e.g.
    #if instead of "old" $IF

    In include file "numbers.h" (which is used by assembly and c modules) you define:

    #define DEVELOP 2
    

    In Assembly file "example.a51":
    #include <numbers.h>
    
    #if ( DEVELOP >= 1 )
            MOV  A,P3
            MOV  SBUF,A
    #else
            MOV  var,#0
    #endif
    

    It works fine.

    But: An Assembler will not work if you have defined enum's in include files....

    Martin

Reply
  • If you have recent versions of Keil assembler (older versions didn't work):
    You can write the same syntax of conditional expressions as in C, e.g.
    #if instead of "old" $IF

    In include file "numbers.h" (which is used by assembly and c modules) you define:

    #define DEVELOP 2
    

    In Assembly file "example.a51":
    #include <numbers.h>
    
    #if ( DEVELOP >= 1 )
            MOV  A,P3
            MOV  SBUF,A
    #else
            MOV  var,#0
    #endif
    

    It works fine.

    But: An Assembler will not work if you have defined enum's in include files....

    Martin

Children