для gcc-4.9.x (последний msp430-gcc на ti.com v4.9.3):
CODE
int asm_goto_example(int x) {
// switch (__even_in_range(x, 10))
asm goto ("add.w %0, PC\n\t"
"jmp %l[case_0]\n\t"
"jmp %l[case_2]\n\t"
"jmp %l[case_4]\n\t"
"jmp %l[case_6]\n\t"
"jmp %l[case_8]\n\t"
:
: "r"(x)
:
:case_0,case_2,case_4,case_6,case_8);
// case 10:
x ^= __LINE__;
goto case_break;
case_0: // case 0:
x ^= __LINE__;
goto case_break;
case_2: // case 0:
x ^= __LINE__;
goto case_break;
case_4: // case 0:
x ^= __LINE__;
goto case_break;
case_6: // case 0:
x ^= __LINE__;
goto case_break;
case_8: // case 0:
x ^= __LINE__;
case_break: // switch end
return ~x;
}
asm получается такой же как и у техасского cl430:
CODE
add.w R12, PC
jmp .L38
jmp .L39
jmp .L40
jmp .L41
jmp .L42
XOR.W #146, R12
.LVL52:
BR #.L43
.L38:
XOR.W #150, R12
.LVL53:
BR #.L43
.L39:
XOR.W #154, R12
.LVL54:
BR #.L43
.L40:
XOR.W #158, R12
.LVL55:
BR #.L43
.L41:
XOR.W #162, R12
.LVL56:
BR #.L43
.L42:
XOR.W #166, R12
.LVL57:
.L43:
INV.W R12
.LVL58:
RET