[011] [ARM-Cortex-M3/4] CM3指令集与CMSIS函数汇总

本文详细介绍了ARM架构的指令集,包括加减运算、移位、比较、分支、加载和存储等基本操作,并提供了每个指令的用法、效果和相关标志。此外,还阐述了CMSIS(Cortex Microcontroller Software Interface Standard)库中的函数,如中断管理、内存屏障和特殊寄存器访问,为Cortex-M3处理器的软件开发提供了便利。
摘要由CSDN通过智能技术生成
ARM
Contents
指令集
CMSIS函数··

1 指令集

MnemonicOperandsBrief descriptionFlagsSee
ADC, ADCS{Rd,} Rn, Op2Add with CarryN,Z,C,VADD, ADC, SUB, SBC, and RSB
ADD, ADDS{Rd,} Rn, Op2AddN,Z,C,VADD, ADC, SUB, SBC, and RSB
ADD, ADDW{Rd,} Rn, #imm12AddN,Z,C,VADD, ADC, SUB, SBC, and RSB
ADRRd, labelLoad PC-relative Address-ADR
AND, ANDS{Rd,} Rn, Op2Logical ANDN,Z,CAND, ORR, EOR, BIC, and ORN
ASR, ASRSRd, Rm, <Rs|#n>Arithmetic Shift RightN,Z,CASR, LSL, LSR, ROR, and RRX
BlabelBranch-B, BL, BX, and BLX
BFCRd, #lsb, #widthBit Field Clear-BFC and BFI
BFIRd, Rn, #lsb, #widthBit Field Insert-BFC and BFI
BIC, BICS{Rd,} Rn, Op2Bit ClearN,Z,CAND, ORR, EOR, BIC, and ORN
BKPT#immBreakpoint-BKPT
BLlabelBranch with Link-B, BL, BX, and BLX
BLXRmBranch indirect with Link-B, BL, BX, and BLX
BXRmBranch indirect-B, BL, BX, and BLX
CBNZRn, labelCompare and Branch if Non Zero-CBZ and CBNZ
CBZRn, labelCompare and Branch if Zero-CBZ and CBNZ
CLREX-Clear Exclusive-CLREX
CLZRd, RmCount Leading Zeros-CLZ
CMNRn, Op2Compare NegativeN,Z,C,VCMP and CMN
CMPRn, Op2CompareN,Z,C,VCMP and CMN
CPSIDiChange Processor State, Disable Interrupts-CPS
CPSIEiChange Processor State, Enable Interrupts-CPS
DMB-Data Memory Barrier-DMB
DSB-Data Synchronization Barrier-DSB
EOR, EORS{Rd,} Rn, Op2Exclusive ORN,Z,CAND, ORR, EOR, BIC, and ORN
ISB-Instruction Synchronization Barrier-ISB
IT-If-Then condition block-IT
LDMRn{!}, reglistLoad Multiple registers, increment after-LDM and STM
LDMDB, LDMEARn{!}, reglistLoad Multiple registers, decrement before-LDM and STM
LDMFD, LDMIARn{!}, reglistLoad Multiple registers, increment after-LDM and STM
LDRRt, [Rn, #offset]Load Register with word-Memory access instructions
LDRB, LDRBTRt, [Rn, #offset]Load Register with byte-Memory access instructions
LDRDRt, Rt2, [Rn, #offset]Load Register with two bytes-LDR and STR, immediate offset
LDREXRt, [Rn, #offset]Load Register Exclusive-LDREX and STREX
LDREXBRt, [Rn]Load Register Exclusive with Byte-LDREX and STREX
LDREXHRt, [Rn]Load Register Exclusive with Halfword-LDREX and STREX
LDRH, LDRHTRt, [Rn, #offset]Load Register with Halfword-Memory access instructions
LDRSB, LDRSBTRt, [Rn, #offset]Load Register with Signed Byte-Memory access instructions
LDRSH, LDRSHTRt, [Rn, #offset]Load Register with Signed Halfword-Memory access instructions
LDRTRt, [Rn, #offset]Load Register with word-Memory access instructions
LSL, LSLSRd, Rm, <Rs|#n>Logical Shift LeftN,Z,CASR, LSL, LSR, ROR, and RRX
LSR, LSRSRd, Rm, <Rs|#n>Logical Shift RightN,Z,CASR, LSL, LSR, ROR, and RRX
MLARd, Rn, Rm, RaMultiply with Accumulate, 32-bit result-MUL, MLA, and MLS
MLSRd, Rn, Rm, RaMultiply and Subtract, 32-bit result-MUL, MLA, and MLS
MOV, MOVSRd, Op2MoveN,Z,CMOV and MVN
MOVTRd, #imm16Move Top-MOVT
MOVW, MOVRd, #imm16Move 16-bit constantN,Z,CMOV and MVN
MRSRd, spec_regMove from Special Register to general register-MRS
MSRspec_reg, RmMove from general register to Special RegisterN,Z,C,VMSR
MUL, MULS{Rd,} Rn, RmMultiply, 32-bit resultN,ZMUL, MLA, and MLS
MVN, MVNSRd, Op2Move NOTN,Z,CMOV and MVN
NOP-No Operation-NOP
ORN, ORNS{Rd,} Rn, Op2Logical OR NOTN,Z,CAND, ORR, EOR, BIC, and ORN
ORR, ORRS{Rd,} Rn, Op2Logical ORN,Z,CAND, ORR, EOR, BIC, and ORN
POPreglistPop registers from stack-PUSH and POP
PUSHreglistPush registers onto stack-PUSH and POP
RBITRd, RnReverse Bits-REV, REV16, REVSH, and RBIT
REVRd, RnReverse byte order in a word-REV, REV16, REVSH, and RBIT
REV16Rd, RnReverse byte order in each halfword-REV, REV16, REVSH, and RBIT
REVSHRd, RnReverse byte order in bottom halfword and sign extend-REV, REV16, REVSH, and RBIT
ROR, RORSRd, Rm, <Rs|#n>Rotate RightN,Z,CASR, LSL, LSR, ROR, and RRX
RRX, RRXSRd, RmRotate Right with ExtendN,Z,CASR, LSL, LSR, ROR, and RRX
RSB, RSBS{Rd,} Rn, Op2Reverse SubtractN,Z,C,VADD, ADC, SUB, SBC, and RSB
SBC, SBCS{Rd,} Rn, Op2Subtract with CarryN,Z,C,VADD, ADC, SUB, SBC, and RSB
SBFXRd, Rn, #lsb, #widthSigned Bit Field Extract-SBFX and UBFX
SDIV{Rd,} Rn, RmSigned Divide-SDIV and UDIV
SEV-Send Event-SEV
SMLALRdLo, RdHi, Rn, RmSigned Multiply with Accumulate (32 x 32 + 64), 64-bit result-UMULL, UMLAL, SMULL, and SMLAL
SMULLRdLo, RdHi, Rn, RmSigned Multiply (32 x 32), 64-bit result-UMULL, UMLAL, SMULL, and SMLAL
SSATRd, #n, Rm {,shift #s}Signed SaturateQSSAT and USAT
STMRn{!}, reglistStore Multiple registers, increment after-LDM and STM
STMDB, STMEARn{!}, reglistStore Multiple registers, decrement before-LDM and STM
STMFD, STMIARn{!}, reglistStore Multiple registers, increment after-LDM and STM
STRRt, [Rn, #offset]Store Register word-Memory access instructions
STRB, STRBTRt, [Rn, #offset]Store Register byte-Memory access instructions
STRDRt, Rt2, [Rn, #offset]Store Register two words-LDR and STR, immediate offset
STREXRd, Rt, [Rn, #offset]Store Register Exclusive-LDREX and STREX
STREXBRd, Rt, [Rn]Store Register Exclusive Byte-LDREX and STREX
STREXHRd, Rt, [Rn]Store Register Exclusive Halfword-LDREX and STREX
STRH, STRHTRt, [Rn, #offset]Store Register Halfword-Memory access instructions
STRTRt, [Rn, #offset]Store Register word-Memory access instructions
SUB, SUBS{Rd,} Rn, Op2SubtractN,Z,C,VADD, ADC, SUB, SBC, and RSB
SUB, SUBW{Rd,} Rn, #imm12SubtractN,Z,C,VADD, ADC, SUB, SBC, and RSB
SVC#immSupervisor Call-SVC
SXTB{Rd,} Rm {,ROR #n}Sign extend a byte-SXT and UXT
SXTH{Rd,} Rm {,ROR #n}Sign extend a halfword-SXT and UXT
TBB[Rn, Rm]Table Branch Byte-TBB and TBH
TBH[Rn, Rm, LSL #1]Table Branch Halfword-TBB and TBH
TEQRn, Op2Test EquivalenceN,Z,CTST and TEQ
TSTRn, Op2TestN,Z,CTST and TEQ
UBFXRd, Rn, #lsb, #widthUnsigned Bit Field Extract-SBFX and UBFX
UDIV{Rd,} Rn, RmUnsigned Divide-SDIV and UDIV
UMLALRdLo, RdHi, Rn, RmUnsigned Multiply with Accumulate (32 x 32 + 64), 64-bit result-UMULL, UMLAL, SMULL, and SMLAL
UMULLRdLo, RdHi, Rn, RmUnsigned Multiply (32 x 32), 64-bit result-UMULL, UMLAL, SMULL, and SMLAL
USATRd, #n, Rm {,shift #s}Unsigned SaturateQSSAT and USAT
UXTB{Rd,} Rm {,ROR #n}Zero extend a Byte-SXT and UXT
UXTH{Rd,} Rm {,ROR #n}Zero extend a Halfword-SXT and UXT
WFE-Wait For Event-WFE
WFI-Wait For Interrupt-WFI

2 CMSIS函数

InstructionCMSIS function
CPSIE Ivoid __enable_irq(void)
CPSID Ivoid __disable_irq(void)
CPSIE Fvoid __enable_fault_irq(void)
CPSID Fvoid __disable_fault_irq(void)
ISBvoid __ISB(void)
DSBvoid __DSB(void)
DMBvoid __DMB(void)
REVuint32_t __REV(uint32_t int value)
REV16uint32_t __REV16(uint32_t int value)
REVSHuint32_t __REVSH(uint32_t int value)
RBITuint32_t __RBIT(uint32_t int value)
SEVvoid __SEV(void)
WFEvoid __WFE(void)
WFIvoid __WFI(void)
▲ CMSIS functions to generate some Cortex-M3 instructions

使用`MRS`和`MSR`指令访问特殊寄存器的函数:
Special registerAccessCMSIS function
PRIMASKReaduint32_t __get_PRIMASK (void)
Writevoid __set_PRIMASK (uint32_t value)
FAULTMASKReaduint32_t __get_FAULTMASK(void)
Writevoid __set_FAULTMASK (uint32_t value)
BASEPRIReaduint32_t __get_BASEPRI (void)
Writevoid __set_BASEPRI (uint32_t value)
CONTROLReaduint32_t __get_CONTROL (void)
Writevoid __set_CONTROL (uint32_t value)
MSPReaduint32_t __get_MSP (void)
Writevoid __set_MSP (uint32_t TopOfMainStack)
PSPReaduint32_t __get_PSP (void)
Writevoid __set_PSP (uint32_t TopOfProcStack)
▲ CMSIS functions to access the special registers

END

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

柯西的彷徨

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值