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.

Compiler/MSP430-GCC-OPENSOURCE: MSP430-GCC 9.2.0.0 Extra jump instruction generated in interrupt handler

Part Number: MSP430-GCC-OPENSOURCE

Tool/software: TI C/C++ Compiler

Compiled with MSP430-GCC 9.2.0.0

flags:

CFLAGS = -mmcu=$(MCU) -std=gnu11 -g -Os -fno-ipa-icf-functions \
-Wall -Wunused -ffunction-sections -fdata-sections -fomit-frame-pointer -fwrapv -MMD

The source code just determines whether to transmit another packet or stop.

__attribute((interrupt))
  void xmit_char_3(void)
{
  UCA0TXBUF_L = uart_txbuf.buff[3];
  if(uart_tx_msg_sent != uart_tx_msg_pending)
    IRQ_UART_TX = uart_tx_next;
  else
    IRQ_UART_TX = RETI;
}

The resulting assembler. Notice that the target of the bolded jump is just RETI.

In this case, the compiler should have simply emitted RETI, saving this handler 2 clock cycles.

0xe7fe: 0x42d2 mov.b &0x2569, &0x050e 6
0xe800: 0x2569
0xe802: 0x050e
0xe804: 0x9292 cmp.w &0x2564, &0x2562 6
0xe806: 0x2564
0xe808: 0x2562
0xe80a: 0x2404 jeq 0xe814 (offset: 8) 2
0xe80c: 0x4292 mov.w &0x2002, &0x27d6 6
0xe80e: 0x2002
0xe810: 0x27d6
0xe812: 0x1300 reti 5
0xe814: 0x40b2 mov.w #0xff88, &0x27d6 5
0xe816: 0xff88
0xe818: 0x27d6
0xe81a: 0x3ffb jmp 0xe812 (offset: -10) 2

 


**Attention** This is a public forum