Menu

Duplicate EQU values in .lst file?

Help
MBB
2012-09-05
2013-05-30
  • MBB

    MBB - 2012-09-05

    I'm using a PIC16F876.

    When I look at the .lst file I see many variables have the same EQU value.  I thought EQU were supposed to be unique.

    For example, in a recent program I found these variables all assigned an EQU of 5:

    ACKDT EQU 5
    BASPROGRAMSTART EQU 5
    CCP1X EQU 5
    CCP2X EQU 5
    CHS2 EQU 5
    D EQU 5
    DATA_ADDRESS EQU 5
    D_A EQU 5
    I2C_DATA EQU 5
    NOT_A EQU 5
    NOT_ADDRESS EQU 5
    PORTA EQU 5
    RCIE EQU 5
    RCIF EQU 5
    RP0 EQU 5
    SREN EQU 5
    SSPEN EQU 5
    T0CS EQU 5
    T0IE EQU 5
    T1CKPS1 EQU 5
    TOUTPS2 EQU 5
    TXEN EQU 5

    Is this correct?

     
  • Hugh Considine

    Hugh Considine - 2012-09-05

    Yes, that's normal! The assembler doesn't really have a concept of variables, so the EQU directive creates a constant.

    For example, somewhere you might find "movwf PORTB" in a program. PORTB isn't a a variable as far as the assembler is concerned, it is a constant that represents 6 (from memory). So the "movwf PORTB" is changed to "movwf 6", which will move the value in W to memory location 6. On a 16F, memory location 6 is where the value for PORTB is kept, so W ends up getting moved to PORTB.

    As well as creating constants to specify which memory location each variable lives in, you can also see some constants that show where each bit is. SSPEN is a bit (inside the SSPCON variable I think) that controls whether or not the SSP module of the chip is enabled. From that code above, SSPEN is defined as 5, which means that the SSPEN bit is bit 5 of SSPCON. So something like "bsf SSPCON, SSPEN" would get translated to "bsf , 5", then converted to machine code.

    Everything with a name ultimately ends up as a constant in the assembler, even labels like BASPROGRAMSTART.

    Sometimes you may find two variables with the same location - that may or may not be intentional. I've tried to set up the memory allocation code so that variables used internally by the delay code share the same locations as variables used internally for calculations, for example. But if you do see anything else that looks a bit odd, please post it!

     
  • Nobody/Anonymous

    Hugh

    Where is the .lst file saved? I'm working with PIC18 devices and I haven't seen the .lst, but maybe I overlooked it?

    Joe

     
  • MBB

    MBB - 2012-09-05

    Thanks Hugh.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.