Floating point operations on ARM

Source: Internet
Author: User

This article makes a summary of the floating point operation on arm recently encountered.
First, let's take a look at how the arm processor handles floating point operations.
During compilation, the cross-compiler will pre-set the hard floating Point operation FPA (Float Point Architecture) for floating-Point operations without the fpa cpu, such as SAMSUNG S3C2410/S3C2440, FPE is used (Float Point Emulation is soft floating Point), so that the speed will be greatly limited. That is to say, if there is a floating-point coprocessor, it will be handed over to it. If not, it will generate a trap (trap, the processor responds to exceptions ), we have prepared a trap handler for floating point commands in advance to simulate floating point operation commands through software.
Then, Let's explain the OABI and EABI concepts.
/*************************************** **************************************** */The following part is forwarded to linux.chinaunix.net/bbs/thread-1143604-1-1.html "> http://linux.chinaunix.net/bbs/thread-1143604-1-1.html. 1. what is ABI, application binary interface (ABI), and application binary interface.
Since it is an interface, it is the communication bridge between two things, there are these situations:. application <-> operating system; B. application <-> (used by the Application) Library C. application Components
Similar to the API, the API is used to make program code compatible. The ABI is used to make the program binary (level) compatible.
2. what is O in OABI and EABI, which indicates "Old", "Lagacy", Old and outdated, and OABI is the Old/Old ABI. E In EABI indicates "Embedded", which is a new ABI. EABI is sometimes called gnu eabi. both OABI and EABI are dedicated to arm CPUs.
3. benefits of EABI/why eabi. supports the use of software floating point and hardware for floating point functions. B. higher System Call efficiency C. later, the tools will be more compatible with D. in the case of software floating point, EABI's software floating point efficiency is much higher than OABI.
4. Differences between OABI and EABI: A. Call rules (including how parameters are passed and how to obtain returned values)
B. Number of system calls and how should the application perform system call C. binary format of the target file, library, and other D. padding/packing in the structure (padding/packing) and alignment.
E. OABI: * ABI flags passed to binutils:-mabi = apcs-gnu-mfpu = fpa * gcc-dumpmachine: arm-unknown-linux * objdump-x for compiled binary:
Private flags = 2: [APCS-32] [FPA float format] [has entry point] * "file" on compiled Debian binary: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), for GNU/Linux 2.2.0, stripped * "readelf-h | grep Flags" "Flags: 0x0 EABI: * ABI flags passed by gcc to binutils:-mabi = aapcs-linux-mfloat-abi = soft-meabi = 4 * gcc-dumpmachine: arm-unknown-l Inux-gnueabi * objdump-x for compiled binary: private flags = 4000002: [Version4 EABI] [has entry point] * "file" on compiled binary (under Debian ): ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.4.17, dynamically linked (uses shared libs), for GNU/Linux 2.4.17, stripped * "readelf-h | grep Flags" "Flags: 0x4000002, has entry point, version4 EABI /******************************* **************************************** * ********************/In a VM, run: arm_v5t_le-gcc-dumpmachine, output: armv5tl-montavista-linuxeabi; run arm_v5t_le-readelf-h EXEC | grep Flags, (note: EXEC represents the executable file name compiled with a cross-compilation tool), output: Flags: 0x4000002, has entry point, Version4 EABI. the above results indicate that the current montavista compiler complies with the EABI standard.
The use of EABI (Embedded Application Binary Interface) can improve the processing. arm EABI has many innovations, the most prominent of which is the Float Point Performance, it uses Vector Float Point (Vector floating Point), so it can greatly improve the program involving floating Point operations.
Here, we finally figured out a problem we encountered. Previously, Makefile contains a-mabi = apcs-gnu parameter, while apcs-gnu is an OABI parameter. Therefore, OABI parameters are passed to EABI-compliant compilation, there is no error in the compilation phase, but when running on the board, there are many inexplicable problems in the floating point involved in the program. For example, printf ("% s % f", s, f); the output floating point value is not a parameter passed to printf, but an inexplicable number. Solution: In Makefile, remove "-mabi = apcs-gnu" and re-compile and run the program!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.