I've recently been studying the book "ARM9 Principles and Application Design". When introducing the ARM instruction format, the book points out: "In ARM instructions, if the second operand (operand2) is a constant expression, the constant must correspond to an 8-bit bitmap (Pattern), that is, the constant is obtained by cyclically shifting an 8-bit constant by an even number of bits. For example, 0x3FC, 0, 200, etc. are legal constants, while 0x1FE, 511, etc. are illegal constants."
At first I didn't quite understand this sentence, and I didn't understand the examples given in the book. So I decided to start studying from the source - the ARM instruction format.
The basic format of a typical ARM instruction is In ARM data processing instructions, when the second operand involved in the operation is an immediate number, each immediate number is indirectly obtained by rotating an 8-bit constant right by an even number of bits, where the number of bits rotated right is represented by 2 times a 4-bit binary number. Then the effective immediate number can be expressed as: For example, By comparison, we can conclude as follows: To determine whether a number conforms to the principle of 8-bit bitmap, first check whether the number of 1s in the binary representation of the number does not exceed 8. If not, then check whether these n 1s (n<=8) can be put into 8 binary bits at the same time. If they can be put in, then check whether these eight binary bits can be cyclically right-shifted by even bits to get the number we want to use. If so, this number conforms to the principle of 8-bit bitmap and is a legal immediate number. Otherwise, it does not conform. The 32-bit number that cannot be represented can only be obtained through other means such as logical or arithmetic operations. For example, 0xffffff00 can be obtained by bitwise inversion of 0x000000ff. Therefore, in future programming, it is important to always check whether the second operand used conforms to the 8-bit bitmap. As for why the 12-bit operand2 is "split 80% to 40%", this question needs to be asked by an expert.
0x3FC (0000 0000 0000 0000 0000 0011 1111 1100) is obtained by rotating 0xff right by 2 bits;
200 (0000 0000 0000 0000 0000 0000 1100 1000) is obtained by rotating 0xc8 right by 2 bits, and they are both legal.
However, 0x1FE (0000 0000 0000 0000 0000 0000 0001 1111 1110) and
511 (0000 0000 0000 0000 0000 0001 1111 1111) cannot be regarded as an 8-bit constant rotated right by an even number of bits, and are therefore illegal.
Previous article:ARM assembly programming basics 1 - registers
Next article:Building an Arm-Linux-GCC cross-compilation environment under Ubuntu
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- Live presentation: Fujitsu FRAM and glasses-free 3D video technology
- [Submission Instructions] 2020-2021 ON Semiconductor and Avnet IoT Creative Design Competition
- 10/22 Uncover the secrets of the Tektronix factory and witness the birth of the millionth anniversary oscilloscope!
- Recruitment information of Beijing Chuangxin Micro Technology Co., Ltd.
- Just a few words
- Is there any video or material about the calculation process of converting 220V to 12V 9V 5V through a transformer in the peripheral circuit of a single-chip microcomputer?
- Can someone tell me what kind of controller should be used for this automatic servo crane?
- Structure of optical devices and chips
- Has anyone done OTA online upgrade for RL78?
- Millimeter wave radar IWR1443