Inline asm code porting from Arm compiler 5 to 6.11

Hello,

I am porting inline asm code from Arm compiler 5 to 6.11 version, but after compilation I got the error: branch target out of range. My original code:

static inline signed short MLIB_AbsSat_F16_FAsmi(register signed short f16Val)
{
        __asm volatile{ lsls f16Val, f16Val, #16        /* f16Val << 16 */
                        bpl AbsEnd                      /* If f16Val >= 0, then goes to AbsEnd */
                        rsbs f16Val, f16Val, #0         /* If f16Val < 0, then f16Val = 0 - f16Val */
                        bpl AbsEnd                      /* If f16Val >= 0, then goes to AbsEnd */
                        subs f16Val, f16Val, #1         /* If f16Val == 0xFFFF8000, f16Val = f16Val - 1 */
                    AbsEnd:
                        lsrs f16Val, f16Val, #16};      /* f16Val >> 16 */

    return f16Val;
}

my ported code is:

static inline signed short MLIB_AbsSat_F16_FAsmi(register signed short f16Val)
{
        __asm volatile(
                        "lsls %0, %0, #16 \n\t"           /* f16Val << 16 */
                        "bpl .+8 \n\t"                    /* If f16Val >= 0, then jumps through three commands */
                        "rsbs %0, %0, #0 \n\t"            /* If f16Val < 0, then f16Val = 0 - f16Val */
                        "bpl .+4 \n\t"                    /* If f16Val >= 0, then jumps through next command */
                        "subs %0, %0, #1 \n\t"            /* If f16Val = 0x80000000, f16Val = 0x7FFFFFFF */
                        "lsrs %0, %0, #16 \n\t"           /* f16Val >> 16 */
                        : "=r" (f16Val));
    return f16Val;
}

Probably there is incorrect syntax in branch instruction I suppose. Could you explain what is not correct ?

Thanks.

Pavel

Parents Reply Children
No data
More questions in this forum