Kĩ thuật vi xử lý Instruction Set MSP430 Summary
MSP430 Family Instruction Set Summary Topics Instruction Set Summary 5-3 5.1 5.2 5.3 5.4 5.4.1 5.4.2 5.4.3 5.4.4 Symbols and Abbreviations Addressing Modes Instruction Set Summary Clock cycles, Length of Instruction Format I Instructions Format II Instructions Format III Instructions Miscellanous Instructions or Operators 5-4 5-5 5-6 5-8 5-8 5-9 5-9 5-9 Tables Table 5.1 5.2 5.3 5.4 5.5 Title Symbols and Abbreviations used in the Instruction Set Summary Addressing Modes MSP430 Family Instruction Set Summary Format I Instructions Format II Instructions Page 5-4 5-5 5-6 5-8 5-9 Notes Title 5.1 5.2 5.3 5.4 Addressing Modes Emulated Instructions Cycle Time of the DADD Instruction Immediate mode in destination field Page 5-5 5-7 5-8 5-9 5-1 Instruction Set Summary 5-2 MSP430 Family MSP430 Family Instruction Set Summary Instruction Set Summary This chapter summarizes the MSP430 family instruction set 5-3 Instruction Set Summary 5.1 MSP430 Family Symbols and Abbreviations The following table lists the instruction set symbols and abbreviations used throughout the rest of this chapter Symbol Definition Symbol Definition src The source operand defined by As and S-reg dst The destination operand defined by Ad and D-reg As The bits representing the addressing mode used for the source Ad The bit representing the addressing mode used for the destination S-reg The used Working Register for the source src D-reg The used Working Register for the destination dst R0 or PC Register or Program Counter R1 or SP Register or Stack Pointer R2 or SR/CG1 Register or Status Register/Constant Generator R3 or CG2 Register or Constant Generator R4 to R15 Working Register, general purpose Rn Working Register with n=4-15, general purpose # Immediate Data @ Register indirect addressing & Absolute address > Data transfer direction label 16-bit label TOS Top of Stack C Carry Bit N Negative Bit V Overflow Bit Z Zero Bit B The suffix B at the instruction memonic will result in a byte operation W The suffix W or no suffix at the instruction memonic will result in a word operation MSB Most significant Bit LSB Least significant Bit Table 5.1: Symbols and Abbreviations used in the Instruction Set Summary 5-4 MSP430 Family 5.2 Instruction Set Summary Addressing Modes All seven addressing modes for the source operand and all four addressing modes for the destination operand can address the complete address space The bit numbers show the contents of the As resp Ad mode bits As Ad Addressing Mode Syntax Description 00 Register Mode Rn Register contents are operand 01 Indexed Mode X(Rn) (Rn + X) points to the operand X is stored in the next word 01 Symbolic Mode ADDR (PC + X) points to the operand X is stored in the next word Indexed Mode X(PC) is used 01 Absolute Mode &ADDR The word following the instruction contains the absolute address 10 - Indirect Register Mode @Rn Rn is used as a pointer to the operand 11 - Indirect Autoincrement @Rn+ Rn is used as a pointer to the operand Rn is incremented afterwards 11 - Immediate Mode #N The word following the instruction contains the immediate constant N Indirect Autoincrement Mode @PC+ is used Table 5.2: Addressing Modes Note: Addressing Modes The addressing modes using the PC as the working register use the normal effects of the addressing modes The special addressing modes are caused by the pointing of the PC to the ROM word following the currently executed instruction 5-5 Instruction Set Summary 5.3 MSP430 Family Instruction Set Summary Status Bits * ADC(.B) ADD(.B) ADDC(.B) AND(.B) BIC(.B) BIS(.B) BIT(.B) * BR CALL * CLR(.B) * CLRC * CLRN * CLRZ CMP(.B) * DADC(.B) DADD(.B) * DEC(.B) * DECD(.B) * DINT * EINT * INC(.B) * INCD(.B) * INV(.B) JC/JHS JEQ/JZ JGE JL JMP JN Legend: x * dst src,dst src,dst src,dst src,dst src,dst src,dst dst dst dst src,dst dst src,dst dst dst dst dst dst Label Label Label Label Label Label dst + C → dst src + dst → dst src + dst + C → dst src and dst → dst not.src and dst → dst src or dst → dst src and dst Branch to PC+2 → stack, dst → PC Clear destination Clear carry bit Clear negative bit Clear zero bit dst - src dst + C → dst (decimal) src + dst + C → dst (decimal) dst - → dst dst - → dst Disable interrupt Enable interrupt Increment destination, dst +1 → dst Double-Increment destination, dst+2→dst Invert destination Jump to Label if Carry-bit is set Jump to Label if Zero-bit is set Jump to Label if (N XOR V) = Jump to Label if (N XOR V) = Jump to Label unconditionally Jump to Label if Negative-bit is set Status bit always cleared Status bit cleared or set on results Emulated Instructions - Status bit always set Status bit not affected Table 5.3: MPS430 Family Instruction Set Summary 5-6 V x x x 0 x x x x x x x x - N x x x x x x x x x x x x x - Z x x x x x x x x x x x x x - C x x x x x x x x x x x x x - MSP430 Family Instruction Set Summary Status Bits JNC/JLO JNE/JNZ MOV(.B) * NOP * POP(.B) PUSH(.B) RETI Label Label src,dst dst src * RET * RLA(.B) * RLC(.B) RRA(.B) RRC(.B) * SBC(.B) * SETC * SETN * SETZ SUB(.B) SUBC(.B) SWPB SXT * TST(.B) XOR(.B) Legend: x * dst dst dst dst dst src,dst src,dst dst dst dst src,dst Jump to Label if Carry-bit is reset Jump to Label if Zero-bit is reset src → dst No operation Item from stack, SP+2 → SP SP - → SP, src → @SP Return from interrupt TOS → SR, SP + → SP TOS → PC, SP + → SZP Return from subroutine TOS → PC, SP + → SP Rotate left arithmetically Rotate left through carry MSB → MSB LSB → C C → MSB LSB → C Subtract carry from destination Set carry bit Set negative bit Set zero bit dst + not.src + → dst dst + not.src + C → dst swap bytes Bit7 → Bit8 Bit15 Test destination src xor dst → dst The Status Bit is cleared The Status Bit is affected Emulated Instructions - V x N x Z x C x - - - - x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x The Status Bit is set The Status Bit is not affected Table 5.3: MPS430 Family Instruction Set Summary (Concluded) Note: Emulated Instructions All marked instructions ( * ) are emulated instructions The emulated instructions use core instructions combined with the architecture and implementation of the CPU for higher code efficiency and faster execution 5-7 Instruction Set Summary 5.4 MSP430 Family Clock cycles, Length of Instruction The operating speed of the CPU is independent from individual instructions It depends on the instruction format and the addressing modes The number of clock cycles refer to the internal oscillator frequency 5.4.1 Format I Instructions Address Mode As Ad 00, Rn 0, Rm 0,PC 00, Rn 1, x(Rm) 1, EDE 1, &EDE 01, x(Rn) 0, Rm 01, EDE 01, &EDE 01, x(Rn) 1, x(Rm) 01, EDE 1, TONI 01, &EDE 1, &TONI 10, @Rn 10, @Rn 11, @Rn+ 11, #N 11, @Rn+ 11, #N 11, @Rn+ 11, #N 0, Rm 1, x(Rm) 1, EDE 1, &EDE 0, Rm 0, PC 0, Rm 0, PC 1, x(Rm) 1, EDE 1, &EDE #of cycles 3 2 1 2 3 2 Table 5.4: Format I Instructions Note: Cycle Time of the DADD Instruction The DADD instruction needs extra cycle 5-8 Length of instruction 1 2 2 Example MOV R5,R8 BR R9 ADD R5,3(R6) XOR R8,EDE MOV R5,&EDE MOV 2(R5),R7 AND EDE,R6 MOV &EDE,R8 ADD 3(R4),6(R9) CMP EDE,TONI MOV 2(R5),&TONI ADD EDE,&TONI AND @R4,R5 XOR @R5,8(R6) MOV @R5,EDE XOR @R5,&EDE ADD @R5+,R6 BR @R9+ MOV #20,R9 BR #2AEh MOV @R9+,2(R4) ADD #33,EDE MOV @R9+,&EDE ADD #33,&EDE MSP430 Family 5.4.2 Instruction Set Summary Format II Instructions Address Mode A(s/d) #of cycles RRC PUSH/ RRA CALL SWPB SXT 3/4 5 00, Rn 01, x(Rn) 01, EDE 10, @Rn 11, @Rn+ see Note 11, #N 3 4/5 4/5 Length of instruction [words] Example 2 SWPB R5 CALL 2(R7) PUSH EDE RRC @R9 SWPB @R10+ CALL #81h Table 5.5: Format II Instructions Note: Immediate mode in destination field Instructions should not use immediate mode in the destination field This would result in unpredictable program operation 5.4.3 Format III Instructions Jxx - instructions need all the same #-of-cycles independent of a successfull Jump or not Clock Cycle: Cycle Length of Instruction: word 5.4.4 RETI Miscellanous Instructions or Operators Clock Cycle: Cycle Length of instruction: word Interrupt Clock Cycle: Cycle 5-9 Instruction Set Summary 5-10 MSP430 Family .. .Instruction Set Summary 5-2 MSP430 Family MSP430 Family Instruction Set Summary Instruction Set Summary This chapter summarizes the MSP430 family instruction set 5-3 Instruction Set Summary. .. of the PC to the ROM word following the currently executed instruction 5-5 Instruction Set Summary 5.3 MSP430 Family Instruction Set Summary Status Bits * ADC(.B) ADD(.B) ADDC(.B) AND(.B) BIC(.B)... 5.3: MPS430 Family Instruction Set Summary (Concluded) Note: Emulated Instructions All marked instructions ( * ) are emulated instructions The emulated instructions use core instructions combined