https://en.wikipedia.org/wiki/TI_MSP430
Comment passer de l'assembleur aux codes , fournit par TI
All instructions are 16 bits long, and there are only three instruction formats:
As and Ad are the source and destination addressing modes. B/W is a bit that is set to 1 for byte instructions. 2-operand opcodes begin at 0100 = 4.
As you can see, there are at most 8+8+12 = 28 instructions to keep track of, which is nice and simple.
One-operand instructions:
The status flags are set by RRA, RRC, SXT, and RETI.
The status flags are NOT set by PUSH, SWPB, and CALL.
Relative jumps. These are all PC-relative jumps, adding twice the sign-extended offset to the PC, for a jump range of -1024 to +1022.
Two-operand instructions. These basically perform dest = src op dest operations. However, MOV doesn't fetch the destination, and CMP and BIT do not write to the destination. All are valid in their 8 and 16 bit forms.
Operands are written in the order src,dest.
There are a number of zero- and one-operand pseudo-operations that can be built from these two-operand forms. These are usually referred to as "emulated" instructions:
Note that other forms of a NOP instruction can be constructed as emulated instructions, which take different numbers of cycles to execute. These can sometimes be useful in constructing accurate timing patterns in software.
Branch and return can be done by moving to PC (r0):
The constants were chosen to make status register (r2) twiddling efficient:
Shift and rotate left is done with add:
Some common one-operand instructions:
increment and decrement (by one or two):
Adding and subtracting only the carry bit: