Common ARM instructions 1: data processing instructions
•Data transfer instructions mov mvn
mov r1, r0 @Data transfer between two registers
mov r1, #0xff @Assign the immediate value to the register
mov and mvn are used in the same way, the difference is that mov is passed intact, while mvn is passed after bitwise inversion
•Arithmetic instructions add sub rsb adc sbc rsc
and logical AND
orr logical OR
eor logical exclusive or
•Logical instructions and orr eor bic
bic bit cleared
bic r0,r1,#0x1f @clear bits 0 to 4 of r1 and assign them to r0
•Comparison instructions cmp cmn tst teq (Comparison instructions focus on the process and not the result)
cmp r0, r1 @ equivalent to sub r2, r0,r1 (r2 = r0-r1)
cmn r0, r1 @ is equivalent to add r0,r1
tst r0,#0x08 @test whether bit_3 is 0
bne suspendup @Whether the previous instruction is true or not, if true, jump to the label suspendup
tst r0,#0x0f @test whether bits 0-3 of r0 are all 0
•Multiplication instructions mvl mla umull umlal smull smlal
• Leading zero count clz
Comparison instructions are used to compare the values in two registers. Note: comparison instructions do not need to be followed by an suffix of 's' to affect the flag bits in cpsr.
Common ARM instructions 2: cpsr access instructions: mrs & msr
•mrs is used to read psr (including cpsr, spsr), msr is used to write psrpsr (including cpsr, spsr)
The difference and connection between cpsr and spsr: there is only one cpsr program status register in the entire SOC; while there are 5 spsrs, which are used in 5 exception modes respectively. Their function is to enter the exception mode when the normal mode enters the exception mode.
Used to save the cpsr in the previous normal mode and restore the original spsr when returning to normal mode.
•CPSR registers are special and require special instructions to access them, namely mrs and msr.
Common ARM instructions 3: Jump (branch) instructions: b & bl & bx
•b Jump directly (if not opened, it will be considered a return)
•bl branch and link, put the return address into lr before jumping, so that it can be returned and used for function calls
•The bx jump switches to ARM mode at the same time, and is generally used for exception handling jumps.
Common ARM instructions 4: memory access instructions: ldr/str & ldm/stm & swp
• Single word/half word/byte access ldr/str
•Multi-word batch access ldm/stm
•swp r1, r2, [r0]
•swp r1, r1, [r0] (swap data between memory and register)
Immediate values in ARM assembly (legal and illegal immediate values)
•ARM instructions are all 32-bit, and in addition to the instruction tag and operation tag, they can only be accompanied by a small number of immediate values. Therefore, there are legal and illegal immediate values.
• Legal immediate number: After any number of shifts, the non-zero part can be represented by 8 bits, which is a legal immediate number.
For example: Legal immediate number: 0x000000ff, 0x00ff0000
Illegal immediate value: 0x000001ff
Common ARM instructions 5: software interrupt instruction: swi (software interrupt)
•Soft interrupt instructions are used to implement system calls in the operating system
Previous article:ARM assembly instruction set 1
Next article:ARM assembly instruction set 4
Recommended ReadingLatest update time:2024-11-16 12:03
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Embedded SBC plays AI reasoning
- Popular must-read! Can't these 20 amplifier Q&A selections help you solve your problems?
- Fudan Micro FM1935 self-polling door lock development information
- dsp28335 SCI Summary
- How to assign a separate segment to the bss of a C file in the link file?
- Voltage to Frequency Converter
- ON
- Why are PCBs mostly green?
- [GD32L233C-START Review] 5. UART+DMA receives variable length data
- 【TI Course】What is the resolution within 5 meters?