The above article introduces ARM's data transfer instructions. This article will mainly introduce ARM's data processing instructions such as shift, sequence rotation and bit operation.
【Shift instruction】
Shifting includes logical shift and arithmetic shift. The so-called "logical" means that the content stored in the register is just regarded as a string of bits. When shifting, you only need to shift these bits directly to the left (LSL - Logical Shift Left) or right (LSR - Logical Shift Righ). Because the bit width of the register is fixed, some bits will be shifted out of the register.
If you use a circular logical shift instruction such as ROR (Rotate Right), the bits shifted out of the LSB will be moved to the MSB in sequence. Since LSR has a corresponding LSL, does ROR also have a corresponding ROL (Rotate Left)? No, taking a 32-bit system as an example, the effect of circularly shifting left by n bits and circularly shifting right by 32-n bits is actually the same.
Arithmetic, on the other hand, treats the contents of a register as a value, and when shifting, the positive and negative values need to be considered. In ARM, there is only an arithmetic shift right (ASR) instruction, but no arithmetic shift left instruction. In an arithmetic shift right, the vacant bit at the MSB end will be filled with the MSB representing the sign, and each right shift by one bit is equivalent to dividing by 2.
[Data sequence transfer instruction]
"Data reordering" refers to partially swapping bits or bytes in a register. There are many forms of reordering, including the RBIT instruction that reverses all bits, the REV instruction that reverses all bytes, and the REV16 instruction that reverses bytes in two 16-bit half words.
Among them, the REV instruction is probably the most used, because it can be used to convert between Little-Endian (LE) and Big-Endian (BE) in network transmission. In ARMv8, data access can be LE or BE according to the setting of the system control register SCTLR, but instruction fetch is always LE.
On 64-bit systems, a REV32 instruction is added to reverse the bytes in two 32-bit words:
【Bit's Scalpel】
Traditional bit operation instructions such as AND and ORR are frequently used and easy to understand, but if you want to implement some more complex bit operations, you need some more professional instructions, such as the BFI (Bit Field Insert) instruction to insert part of the bits of a register into the specified part of another register, or the BFX (Bit Field Extract) instruction to directly extract these bits, and the BFC (Bit Field Clear) instruction to clear the bits of a specified part.
For example, "BFI W0, W1, #9, #6" means inserting the 6 bits at the LSB end of the W1 register into the W0 register from bit 9 to bit 14.
As I write this, I think of gene editing, and I recommend everyone to read Professor Wang Liming’s "God's Scalpel".
The following will introduce the unconditional jump instructions and conditional jump instructions in ARM.
Previous article:ARM Assembly Language - Introduction [Part 3]
Next article:ARM Assembly Language - Introduction [I]
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Friends in Xi'an, please get out of this pit as soon as possible.
- Xianyu low-cost wireless digital microphone disassembly (Jerry solution)
- [Perf-V Review] + Solidification of Hummingbird Soft Core
- Read the good book "Electronic Engineer Self-study Handbook" + my impression
- Three-port network
- RSL10 drives ink screen
- GoKit Case Study: Gizwits IoT Development Platform’s Pet House Transformed into an Air Quality Detector
- Embedded licensing: why not and why not?
- I found a 1963 "Electron Tube Handbook"
- How to extract the effective value of fundamental wave and each harmonic in MATLAB?