#361 weird offset in msp430-as assembler code

4.7.x_development
open
nobody
None
5
2014-03-21
2014-03-21
No

I am trying to compile an IAR project with MSPGCC. I am able to build the project. It contains also some assembly sources. In one of them I encountered a weird jump offset problem. I minimized the (demonstration) source file to bare essential, see attached file

The code result shows that the target label for the jump is at relative address (forward) 0x0e. However the offset in the JZ is calculated as if the target label was at (relative) address 0x0..........

best regards

Kees

1 Attachments

Discussion

  • Peter A. Bigot
    Peter A. Bigot
    2014-03-21

    It appears to be due to the use of .global, which may be confusing part of the assembler into thinking the symbol may be redefined at link time and thus generating code that is intended to be a relocatable jump. Off-hand, it doesn't appear to do this correctly. This is probably a bug, but mspgcc is no longer supported so it won't be fixed.

    Work around it by either eliminating the global annotation for I2cStop, or adding a non-local label and jumping to it instead.

    #include "io.h"
    
            .global    I2cStop,I2cWrite,I2cRead
    I2cRead:         BIT.W       #0x0FF00,r15
    I2cWrite:        BIT.W       #0x0FF00,r15
                     TST         r13
                     JZ          1f     ; I2cStop
                     RET
    1:
    I2cStop:         BIC.B       #1,&P3OUT
                     RET
            .END