Introduction: This chapter will help readers write efficient C code on ARM processors. Some of the techniques involved in this chapter are not only applicable to ARM processors, but also to other RISC processors. (EEFOCUS)
14.4 Boolean Expressions 14.4.1 Range Checks
Boolean expressions are often used to check whether a value is within a specific range. For example, in a graphics window handler, Boolean expressions are often used to determine whether a point on the screen is within the range of the currently active window.
The following program uses a structure to define point coordinates and calculate the current position of the coordinates.
boolPointInRect1(Pointp,Rectangle*r)
{return(px>=r->xmin&&p.x py>=r->ymin&&p.y } The above function is compiled into the following instruction sequence. PointInRect1 LDRa4,[a3,#0] CMPa1,a4 BLT|L000034.J5.PointInRect1| LDRa4,[a3,#4] CMPa4,a1 BLE|L000034.J5.PointInRect1| LDRa1,[a3,#8] CMPa2,a1 BLT|L000034.J5.PointInRect1| LDRa1,[a3,#&c]! CMPa2,a1 MOVLTa1,#1 MOVLTpc,lr |L000034.J5.PointInRect1| MOVa1,#0 MOVpc,lr But the above code is not the most concise. The compiler's processing of Boolean expressions of the form (x>=min&&x boolPointInRect2(Pointp,Rectangle*r) {return((unsigned)(px-r->xmin) (unsigned)(py-r->ymin) } The compiled assembly instruction sequence is as follows. PointInRect2 LDRa4,[a3,#0] SUBa1,a1,a4 LDRa4,[a3,#4] CMPa1,a4 LDRCCa1,[a3,#8] SUBCCa1,a2,a1 LDRCCa2,[a3,#&c]! CMPCCa1,a2 MOVCSa1,#0 MOVCCa1,#1 MOVpc,lr
Previous article:Application of ARM9 hardware coprocessor on WinCE embedded motherboard
Next article:Arm assembly language calls C functions with parameters and related examples
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- It’s too difficult for beginners.
- Help converting brd file to AD pcbdoc file
- Circuit Principle
- A novice asks about the selection of optocouplers for PWM isolation control of MOS tubes
- Signal Generator and DA Conversion FPGA Case Tutorial
- IAR Mini Classroom | How to place a group of functions or variables in a specific segment
- Are there any FPGA weekend training courses in Xi'an?
- The simplest sensor circuit diagram
- Simulation software selection
- Pure MicroPython drawing package microplot