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.

Where is MSP430 Opcode List and What happens if I try executing an illegal opcode?



Hi,

 

Where can I find opcode list of MSP430 family? What is the behavior of this family if I try executing an illegal opcode? Can I catch this condition?

 

Thank you,

BP.

 

  • The answer of this question (and most of your other questions) can be found in "MSP430x4xx Family User's Guide" (slau056j.pdf).

     

  • There are only very few opcodes that do not have a meaning. On the old 1x series, there have been almost all opcodes below 0x2000 no meaning, except for the 0x1000-0x133f range.

    On newer MSPs, there are only a few holes in the 0x1000-0x13ff range.

    Since input and output operand and addressing mdoe are part of the opcodes, there are few commands covering almost all ofo the 64k of possible opcodes.

    There is no way to catch an illegal opcode condition and I don't know what the CPU will do if you try. It might cause a RESET, bu tthen I didn't see any flag for it in the reset interrupt vector table and I didn't see anything about it mentioned anywhere.

    The question is: why do you think that it might be necessary to catch an invalid opcode? Unless you load data from an unsafe source and try to execute it, there should never be an invalid opcode anywhere. This is a microcontroller and not a general-purpose CPU like an Intel/AMD x86. :)
    If it ever should happen that an invalid opcode is executed on a finished device, you should buy a new device (or hire a better programmer).
    Even if you update your code online, it should be secured by CRCs and other ways that only 100% checked and valid code is written to it.

    So the question is not 'how to detect an invalid opcode' but 'how to prevent an invalid opcode 100% for sure'

     

  • Hello,

    I was looking for some similar info.

    Here is an external link that is helpful: http://mspgcc.sourceforge.net/assemble.html

    Disclaimer: Use at your own risk!

    Regards,

    PT

  • An example of illegal op-code:
    - Alignment error,
    - An erroneous execution of code from the data area
    - etc
    (during debugging programs on XXXX-RTOS)

  • Well, an alignment error is technically no illegal opcode. The alignment is either part of the data fetched during opcode execution (the opcode, even though sometimes containing part of the operands, cannot contain misaligned data) or content of a register, but not part of the opcode itself.
    Yet if such an instruction is executed, the CPU will silently ingore the LSB (forcing alignment).

    Erroneous execution of data is indeed a situation where opcodes can appear that are not defined. But in this case, any data that is erroneously executed could randomly do anything, even if it consists (concidentally) of valid opcodes. So detection of illegal opodes won't be of any help.

    On a microcontoller, all those security mechanisms should be applied to the code generation instead of being done at runtime. It makes development more difficult (especially for lazy coders), but makes the devices smaller, cheaper, lower power and in general way more efficient. :)

**Attention** This is a public forum