2014년 10월 10일 금요일

Find Content

or
     
  • Tools
Instruction set
The MSP430 instruction set consists of 27 core instructions. Additionally, it supports 24 emulated instructions. The core instructions have unique op-codes decoded by the CPU, while the emulated ones need assemblers and compilers to generate their mnemonics.
There are three core-instruction formats:
- Double operand;
- Single operand;
- Program flow control - Jump.
Byte, word and address instructions are accessed using the .B, .W or .A extensions. If the extension is omitted, the instruction is interpreted as a word instruction.

Double operand instructions

The double operand instruction is formatted as follows:
1514131211109876543210
opcodeS-RegAdB/WAsD-Reg
BitDescription
15-12opcode
11-8S-RegThe working register used for the source operand (src)
7AdThe addressing bits responsible for the addressing mode used for the destination operand (dst)
6B/WByte or word operation:B/W=0: word operation; B/W=1: byte operation
5-4AsThe addressing bits responsible for the addressing mode used for the source operand (src)
3-0D-RegThe working register used for the destination operand (dst)
The next tableshows the double operand instructions that are not emulated.
MnemonicOperationDescription
Arithmetic instructions
ADD(.B or .W) src,dstsrc+dst→dstAdd source to destination
ADDC(.B or .W) src,dstsrc+dst+C→dstAdd source and carry to destination
DADD(.B or .W) src,dstsrc+dst+C→dst (dec)Decimal add source and carry to destination
SUB(.B or .W) src,dstdst+.not.src+1→dstSubtract source from destination
SUBC(.B or .W) src,dstdst+.not.src+C→dstSubtract source and not carry from destination
Logical and register control instructions
AND(.B or .W) src,dstsrc.and.dst→dstAND source with destination
BIC(.B or .W) src,dst.not.src.and.dst→dstClear bits in destination
BIS(.B or .W) src,dstsrc.or.dst→dstSet bits in destination
BIT(.B or .W) src,dstsrc.and.dstTest bits in destination
XOR(.B or .W) src,dstsrc.xor.dst→dstXOR source with destination
Data instructions
CMP(.B or .W) src,dstdst-srcCompare source to destination
MOV(.B or .W) src,dstsrc→dstMove source to destination
Depending on the double operand instruction result, the status bits may be affected. The following gives the conditions for setting and resetting the status bits.
Status bits
MnemonicVNZC
Arithmetic instructions
ADD(.B or .W) src,dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, null result=0, otherwise=1, carry from result=0, if not
ADDC(.B or .W) src,dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, null result=0, otherwise=1, carry from MSB result=0, if not
DADD(.B or .W) src,dst-=1, MSB=1=0, otherwise=1, null result=0, otherwise=1, result > 99(99)
SUB(.B or .W) src,dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, null result=0, otherwise=1, if no borrow=0, otherwise
SUBC(.B or .W) src,dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, null result=0, otherwise=1, if no borrow=0, otherwise
Logical and register control instructions
AND(.B or .W) src,dst=0=1, MSB result set=0, if not set=1, null result=0, otherwise=1, not zero=0, otherwise
BIC(.B or .W) src,dst----
BIS(.B or .W) src,dst----
BIT(.B or .W) src,dst=0=1, MSB result set=0, otherwise=1, null result=0, otherwise=1, not zero=0, otherwise
XOR(.B or .W) src,dst=1, both operands negative=1, MSB result set=0, otherwise=1, null result,=0, otherwise=1, not zero=0, otherwise
Data instructions
CMP(.B or .W) src,dst=1, Arithmetic overflow=0, otherwise=1, src>=dst=0, src=1, src=dst=0, otherwise=1, carry from MSB result=0, if not
MOV(.B or .W) src,dst----

Single operand instructions

The single operand instruction is formatted as follows:
1514131211109876543210
opcodeB/WAdD/S-Reg
BitDescription
15-7opcode
6B/WByte or word operation:B/W=0: word operation; B/W=1: byte operation
5-4AdThe addressing bits responsible for the addressing mode used for the source operand (src)
3-0D/S-RegThe working register used for the destination operand (dst) or for the source operand (src)
The next table shows the single operand instructions that are not emulated.
MnemonicOperationDescription
Logical and register control instructions
RRA(.B or .W) dstMSB→MSB→…LSB→CRoll destination right
RRC(.B or .W) dstC→MSB→…LSB→CRoll destination right through (from) carry
SWPB(.B or .W) dstSwap bytesSwap bytes in destination
SXT dstbit 7→bit 8…bit 15Sign extend destination
PUSH(.B or .W) srcSP-2→SP, src→@SPPush source to stack
Program flow control instructions
CALL(.B or .W) dstSP-2→SP, PC+2→@SPdst→PCSubroutine call to destination
RETITOS→SR, SP+2→SPTOS→PC, SP+2→SPReturn from interrupt
Conditions for status bits, depending on the single operand instruction result.
Status bits
MnemonicVNZC
Logical and register control instructions
RRA(.B or .W) dst=0=1, negative result=0, otherwise=1, null result,=0, otherwiseLoaded from LSB
RRC(.B or .W) dst=1, dst positive & C=1=0, otherwise=1, negative result=0, otherwise=1, null result,=0, otherwiseLoaded from LSB
SWPB(.B or .W) dst----
SXT dst=0=1, negative result=0, otherwise=1, null result,=0, otherwise=1, not zero=0, otherwise
PUSH(.B or .W) src----
Data instructions
CALL(.B or .W) dst-----
RETIrestored from stackrestored from stackrestored from stackrestored from stack

Program flow control - Jumps

The jump instruction is formatted as follows:
1514131211109876543210
opcodeC10 bit PC offset
BitDescription
15-13opcode
12-10C
9-0PC offsetPCnew = PCold + 2 + PCoffset × 2
The following table shows the program flow control (jump) instructions that are not emulated.
MnemonicDescription
Program flow control instructions
JEQ/JZ labelJump to label if zero flag is set
JNE/JNZ labelJump to label if zero flag is reset
JC labelJump to label if carry flag is set
JNC labelJump to label if carry flag is reset
JN labelJump to label if negative flag is set
JGE labelJump to label if greater than or equal
JL labelJump to label if less than
JMP labelJump to label unconditionally

Emulated instructions

The next gives the different emulated instructions. This table also contains the type of operation and the emulated instruction based on the core instructions.
MnemonicOperationEmulationDescription
Arithmetic instructions
ADC(.B or .W) dstdst+C→dstADDC(.B or .W) #0,dstAdd carry to destination
DADC(.B or .W) dstdst+C→dst (decimally)DADD(.B or .W) #0,dstDecimal add carry to destination
DEC(.B or .W) dstdst-1→dstSUB(.B or .W) #1,dstDecrement destination
DECD(.B or .W) dstdst-2→dstSUB(.B or .W) #2,dstDecrement destination twice
INC(.B or .W) dstdst+1→dstADD(.B or .W) #1,dstIncrement destination
INCD(.B or .W) dstdst+2→dstADD(.B or .W) #2,dstIncrement destination twice
SBC(.B or .W) dstdst+0FFFFh+C→dstdst+0FFh→dstSUBC(.B or .W) #0,dstSubtract source and borrow /.NOT. carry from dest.
Logical and register control instructions
INV(.B or .W) dst.NOT.dst→dstXOR(.B or .W) #0(FF)FFh,dstInvert bits in destination
RLA(.B or .W) dstCMSBMSB-1…LSB+1LSB0ADD(.B or .W) dst,dstRotate left arithmetically
RLC(.B or .W) dstCMSBMSB-1…LSB+1LSBCADDC(.B or .W) dst,dstRotate left through carry
Data instructions
CLR(.B or .W) dst0→dstMOV(.B or .W) #0,dstClear destination
CLRC0→CBIC #1,SRClear carry flag
CLRN0→NBIC #4,SRClear negative flag
CLRZ0→ZBIC #2,SRClear zero flag
POP(.B or .W) dst@SP→tempSP+2→SPtemp→dstMOV(.B or .W) @SP+,dstPop byte/word from stack to destination
SETC1→CBIS #1,SRSet carry flag
SETN1→NBIS #4,SRSet negative flag
SETZ1→ZBIS #2,SRSet zero flag
TST(.B or .W) dstdst + 0FFFFh + 1dst + 0FFh + 1CMP(.B or .W) #0,dstTest destination
Program flow control
BR dstdst→PCMOV dst,PCBranch to destination
DINT0→GIEBIC #8,SRDisable (general) interrupts
EINT1→GIEBIS #8,SREnable (general) interrupts
NOPNoneMOV #0,R3No operation
RET@SP→PCSP+2→SPMOV @SP+,PCReturn from subroutine
Conditions for status bits, depending on the emulated instruction result.
Status bits
MnemonicVNZC
Arithmetic instructions
ADC(.B or .W) dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, null result=0, otherwise=1, dst from 0FFFFh to 0000=0, otherwise
DADC(.B or .W) dst-=1, MSB=1=0, otherwise=1, dst=0=0, otherwise=1, dst from 99(99) to 00(00)=0, otherwise
DEC(.B or .W) dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, dst contained 1=0, otherwise=1, dst contained 0=0, otherwise
DECD(.B or .W) dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, dst contained 2=0, otherwise=1, dst contained 0 or 1=0, otherwise
INC(.B or .W) dst=1, dst contained 07(FF)h=0, otherwise=1, negative result=0, if positive=1, dst contained FF(FF)h=0, otherwise=1, dst contained FF(FF)h=0, otherwise
INCD(.B or .W) dst=1, dst contained 07(FFE)h=0, otherwise=1, negative result=0, if positive=1, dst contained FF(FE)h=0, otherwise=1, dst contained FF(FF)h or FF(FE)h=0, otherwise
SBC(.B or .W) dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, null result,=0, otherwise=1, if no borrow=0, otherwise
Logical and register control instructions
INV(.B or .W) dst=1, negative initial dst=0, otherwise=1, negative result=0, if positive=1, dst contained FF(FF)h=0, otherwise=1, not zero=0, otherwise
RLA(.B or .W) dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, null result,=0, otherwiseLoaded from MSB
RLC(.B or .W) dst=1, Arithmetic overflow=0, otherwise=1, negative result=0, if positive=1, null result,=0, otherwiseLoaded from MSB
Data instructions
CLR(.B or .W) dst----
CLRC---=0
CLRN-=0--
CLRZ--=0-
POP(.B or .W) dst----
SETC---=1
SETN-=1--
SETZ--=1-
TST(.B or .W) dst=0=1, dst negative=0, otherwise=1, dst contains zero=0, otherwise=1
Program flow control
BR dst----
DINT----
EINT----
NOP----
RET----
Request the MSP430 Teaching ROM Materials here https://www-a.ti.com/apps/dspuniv/teaching_rom_request.asp


댓글 없음:

댓글 쓰기