SPRU514Y August   2001  – June 2022

 

  1.   Read This First
    1.     About This Manual
    2.     Notational Conventions
    3.     Related Documentation
    4.     Related Documentation From Texas Instruments
    5.     Trademarks
  2. Introduction to the Software Development Tools
    1. 1.1 Software Development Tools Overview
    2. 1.2 Compiler Interface
    3. 1.3 ANSI/ISO Standard
    4. 1.4 Output Files
    5. 1.5 Utilities
  3. Using the C/C++ Compiler
    1. 2.1  About the Compiler
    2. 2.2  Invoking the C/C++ Compiler
    3. 2.3  Changing the Compiler's Behavior with Options
      1. 2.3.1  Linker Options
      2. 2.3.2  Frequently Used Options
      3. 2.3.3  Miscellaneous Useful Options
      4. 2.3.4  Run-Time Model Options
      5. 2.3.5  Symbolic Debugging and Profiling Options
      6. 2.3.6  Specifying Filenames
      7. 2.3.7  Changing How the Compiler Interprets Filenames
      8. 2.3.8  Changing How the Compiler Processes C Files
      9. 2.3.9  Changing How the Compiler Interprets and Names Extensions
      10. 2.3.10 Specifying Directories
      11. 2.3.11 Assembler Options
      12. 2.3.12 Deprecated Options
    4. 2.4  Controlling the Compiler Through Environment Variables
      1. 2.4.1 Setting Default Compiler Options (C2000_C_OPTION)
      2. 2.4.2 Naming One or More Alternate Directories (C2000_C_DIR)
    5. 2.5  Controlling the Preprocessor
      1. 2.5.1  Predefined Macro Names
      2. 2.5.2  The Search Path for #include Files
        1. 2.5.2.1 Adding a Directory to the #include File Search Path (--include_path Option)
      3. 2.5.3  Support for the #warning and #warn Directives
      4. 2.5.4  Generating a Preprocessed Listing File (--preproc_only Option)
      5. 2.5.5  Continuing Compilation After Preprocessing (--preproc_with_compile Option)
      6. 2.5.6  Generating a Preprocessed Listing File with Comments (--preproc_with_comment Option)
      7. 2.5.7  Generating Preprocessed Listing with Line-Control Details (--preproc_with_line Option)
      8. 2.5.8  Generating Preprocessed Output for a Make Utility (--preproc_dependency Option)
      9. 2.5.9  Generating a List of Files Included with #include (--preproc_includes Option)
      10. 2.5.10 Generating a List of Macros in a File (--preproc_macros Option)
    6. 2.6  Passing Arguments to main()
    7. 2.7  Understanding Diagnostic Messages
      1. 2.7.1 Controlling Diagnostic Messages
      2. 2.7.2 How You Can Use Diagnostic Suppression Options
    8. 2.8  Other Messages
    9. 2.9  Generating Cross-Reference Listing Information (--gen_cross_reference_listing Option)
    10. 2.10 Generating a Raw Listing File (--gen_preprocessor_listing Option)
    11. 2.11 Using Inline Function Expansion
      1. 2.11.1 Inlining Intrinsic Operators
      2. 2.11.2 Inlining Restrictions
      3. 2.11.3 Unguarded Definition-Controlled Inlining
        1. 2.11.3.1 Using the Inline Keyword
      4. 2.11.4 Guarded Inlining and the _INLINE Preprocessor Symbol
        1. 2.11.4.1 Header File string.h
        2. 2.11.4.2 Library Definition File
    12. 2.12 Using Interlist
    13. 2.13 About the Application Binary Interface
    14. 2.14 Enabling Entry Hook and Exit Hook Functions
    15. 2.15 Live Firmware Update (LFU)
  4. Optimizing Your Code
    1. 3.1  Invoking Optimization
    2. 3.2  Controlling Code Size Versus Speed
    3. 3.3  Performing File-Level Optimization (--opt_level=3 option)
      1. 3.3.1 Creating an Optimization Information File (--gen_opt_info Option)
    4. 3.4  Program-Level Optimization (--program_level_compile and --opt_level=3 options)
      1. 3.4.1 Controlling Program-Level Optimization (--call_assumptions Option)
      2. 3.4.2 Optimization Considerations When Mixing C/C++ and Assembly
    5. 3.5  Automatic Inline Expansion (--auto_inline Option)
    6. 3.6  Link-Time Optimization (--opt_level=4 Option)
      1. 3.6.1 Option Handling
      2. 3.6.2 Incompatible Types
    7. 3.7  Using Feedback Directed Optimization
      1. 3.7.1 Feedback Directed Optimization
        1. 3.7.1.1 Phase 1 -- Collect Program Profile Information
        2. 3.7.1.2 Phase 2 -- Use Application Profile Information for Optimization
        3. 3.7.1.3 Generating and Using Profile Information
        4. 3.7.1.4 Example Use of Feedback Directed Optimization
        5. 3.7.1.5 The .ppdata Section
        6. 3.7.1.6 Feedback Directed Optimization and Code Size Tune
        7. 3.7.1.7 Instrumented Program Execution Overhead
        8. 3.7.1.8 Invalid Profile Data
      2. 3.7.2 Profile Data Decoder
      3. 3.7.3 Feedback Directed Optimization API
      4. 3.7.4 Feedback Directed Optimization Summary
    8. 3.8  Using Profile Information to Analyze Code Coverage
      1. 3.8.1 Code Coverage
        1. 3.8.1.1 Phase1 -- Collect Program Profile Information
        2. 3.8.1.2 Phase 2 -- Generate Code Coverage Reports
      2. 3.8.2 Related Features and Capabilities
        1. 3.8.2.1 Path Profiler
        2. 3.8.2.2 Analysis Options
        3. 3.8.2.3 Environment Variables
    9. 3.9  Special Considerations When Using Optimization
      1. 3.9.1 Use Caution With asm Statements in Optimized Code
      2. 3.9.2 Use the Volatile Keyword for Necessary Memory Accesses
        1. 3.9.2.1 Use Caution When Accessing Aliased Variables
        2. 3.9.2.2 Use the --aliased_variables Option to Indicate That the Following Technique Is Used
        3. 3.9.2.3 On FPU Targets Only: Use restrict Keyword to Indicate That Pointers Are Not Aliased
          1. 3.9.2.3.1 Use of the restrict Type Qualifier With Pointers
          2. 3.9.2.3.2 Use of the restrict Type Qualifier With Pointers
    10. 3.10 Using the Interlist Feature With Optimization
    11. 3.11 Data Page (DP) Pointer Load Optimization
    12. 3.12 Debugging and Profiling Optimized Code
      1. 3.12.1 Profiling Optimized Code
    13. 3.13 Increasing Code-Size Optimizations (--opt_for_space Option)
      1. 3.13.1 C Code to Show Code-Size Optimizations
      2. 3.13.2 Section 1 Compiled With the --opt_for_space Option
    14. 3.14 Compiler Support for Re-Entrant VCU Code
    15. 3.15 Compiler Support for Generating DMAC Instructions
      1. 3.15.1 Automatic Generation of DMAC Instructions
      2. 3.15.2 Assertions to Specify Data Address Alignment
      3. 3.15.3 __dmac Intrinsic
    16. 3.16 What Kind of Optimization Is Being Performed?
      1. 3.16.1  Cost-Based Register Allocation
      2. 3.16.2  Alias Disambiguation
      3. 3.16.3  Branch Optimizations and Control-Flow Simplification
      4. 3.16.4  Data Flow Optimizations
      5. 3.16.5  Expression Simplification
      6. 3.16.6  Inline Expansion of Functions
      7. 3.16.7  Function Symbol Aliasing
      8. 3.16.8  Induction Variables and Strength Reduction
      9. 3.16.9  Loop-Invariant Code Motion
      10. 3.16.10 Loop Rotation
      11. 3.16.11 Instruction Scheduling
      12. 3.16.12 Register Variables
      13. 3.16.13 Register Tracking/Targeting
      14. 3.16.14 Tail Merging
      15. 3.16.15 Autoincrement Addressing
      16. 3.16.16 Removing Comparisons to Zero
      17. 3.16.17 RPTB Generation (for FPU Targets Only)
  5. Linking C/C++ Code
    1. 4.1 Invoking the Linker Through the Compiler (-z Option)
      1. 4.1.1 Invoking the Linker Separately
      2. 4.1.2 Invoking the Linker as Part of the Compile Step
      3. 4.1.3 Disabling the Linker (--compile_only Compiler Option)
    2. 4.2 Linker Code Optimizations
      1. 4.2.1 Generating Function Subsections (--gen_func_subsections Compiler Option)
      2. 4.2.2 Generating Aggregate Data Subsections (--gen_data_subsections Compiler Option)
    3. 4.3 Controlling the Linking Process
      1. 4.3.1 Including the Run-Time-Support Library
        1. 4.3.1.1 Automatic Run-Time-Support Library Selection
          1. 4.3.1.1.1 Using the --issue_remarks Option
        2. 4.3.1.2 Manual Run-Time-Support Library Selection
        3. 4.3.1.3 Library Order for Searching for Symbols
      2. 4.3.2 Run-Time Initialization
      3. 4.3.3 Initialization by the Interrupt Vector
      4. 4.3.4 Global Object Constructors
      5. 4.3.5 Specifying the Type of Global Variable Initialization
      6. 4.3.6 Specifying Where to Allocate Sections in Memory
      7. 4.3.7 A Sample Linker Command File
    4. 4.4 Linking C28x and C2XLP Code
  6. Post-Link Optimizer
    1. 5.1 The Post-Link Optimizer’s Role in the Software Development Flow
    2. 5.2 Removing Redundant DP Loads
    3. 5.3 Tracking DP Values Across Branches
    4. 5.4 Tracking DP Values Across Function Calls
    5. 5.5 Other Post-Link Optimizations
    6. 5.6 Controlling Post-Link Optimizations
      1. 5.6.1 Excluding Files (-ex Option)
      2. 5.6.2 Controlling Post-Link Optimization Within an Assembly File
      3. 5.6.3 Retaining Post-Link Optimizer Output (--keep_asm Option)
      4. 5.6.4 Disable Optimization Across Function Calls (-nf Option )
      5. 5.6.5 Annotating Assembly with Advice (--plink_advice_only option)
    7. 5.7 Restrictions on Using the Post-Link Optimizer
    8. 5.8 Naming the Outfile (--output_file Option)
  7. C/C++ Language Implementation
    1. 6.1  Characteristics of TMS320C28x C
      1. 6.1.1 Implementation-Defined Behavior
    2. 6.2  Characteristics of TMS320C28x C++
    3. 6.3  Data Types
      1. 6.3.1 Size of Enum Types
      2. 6.3.2 Support for 64-Bit Integers
      3. 6.3.3 C28x double and long double Floating-Point Types
    4. 6.4  File Encodings and Character Sets
    5. 6.5  Keywords
      1. 6.5.1 The const Keyword
      2. 6.5.2 The __cregister Keyword
      3. 6.5.3 The __interrupt Keyword
      4. 6.5.4 The restrict Keyword
      5. 6.5.5 The volatile Keyword
    6. 6.6  C++ Exception Handling
    7. 6.7  Register Variables and Parameters
    8. 6.8  The __asm Statement
    9. 6.9  Pragma Directives
      1. 6.9.1  The CALLS Pragma
      2. 6.9.2  The CLINK Pragma
      3. 6.9.3  The CODE_ALIGN Pragma
      4. 6.9.4  The CODE_SECTION Pragma
      5. 6.9.5  The DATA_ALIGN Pragma
      6. 6.9.6  The DATA_SECTION Pragma
        1. 6.9.6.1 Using the DATA_SECTION Pragma C Source File
        2. 6.9.6.2 Using the DATA_SECTION Pragma C++ Source File
        3. 6.9.6.3 Using the DATA_SECTION Pragma Assembly Source File
      7. 6.9.7  The Diagnostic Message Pragmas
      8. 6.9.8  The FAST_FUNC_CALL Pragma
      9. 6.9.9  The FORCEINLINE Pragma
      10. 6.9.10 The FORCEINLINE_RECURSIVE Pragma
      11. 6.9.11 The FUNC_ALWAYS_INLINE Pragma
      12. 6.9.12 The FUNC_CANNOT_INLINE Pragma
      13. 6.9.13 The FUNC_EXT_CALLED Pragma
      14. 6.9.14 The FUNCTION_OPTIONS Pragma
      15. 6.9.15 The INTERRUPT Pragma
      16. 6.9.16 The LOCATION Pragma
      17. 6.9.17 The MUST_ITERATE Pragma
        1. 6.9.17.1 The MUST_ITERATE Pragma Syntax
        2. 6.9.17.2 Using MUST_ITERATE to Expand Compiler Knowledge of Loops
      18. 6.9.18 The NOINIT and PERSISTENT Pragmas
      19. 6.9.19 The NOINLINE Pragma
      20. 6.9.20 The NO_HOOKS Pragma
      21. 6.9.21 The once Pragma
      22. 6.9.22 The RETAIN Pragma
      23. 6.9.23 The SET_CODE_SECTION and SET_DATA_SECTION Pragmas
      24. 6.9.24 The UNROLL Pragma
      25. 6.9.25 The WEAK Pragma
    10. 6.10 The _Pragma Operator
    11. 6.11 Application Binary Interface
    12. 6.12 Object File Symbol Naming Conventions (Linknames)
    13. 6.13 Initializing Static and Global Variables in COFF ABI Mode
      1. 6.13.1 Initializing Static and Global Variables With the Linker
      2. 6.13.2 Initializing Static and Global Variables With the const Type Qualifier
    14. 6.14 Changing the ANSI/ISO C/C++ Language Mode
      1. 6.14.1 C99 Support (--c99)
      2. 6.14.2 C11 Support (--c11)
      3. 6.14.3 Strict ANSI Mode and Relaxed ANSI Mode (--strict_ansi and --relaxed_ansi)
    15. 6.15 GNU and Clang Language Extensions
      1. 6.15.1 Extensions
      2. 6.15.2 Function Attributes
      3. 6.15.3 For Loop Attributes
      4. 6.15.4 Variable Attributes
      5. 6.15.5 Type Attributes
      6. 6.15.6 Built-In Functions
      7. 6.15.7 Using the Byte Peripheral Type Attribute
    16. 6.16 Compiler Limits
  8. Run-Time Environment
    1. 7.1  Memory Model
      1. 7.1.1 Sections
      2. 7.1.2 C/C++ System Stack
      3. 7.1.3 Allocating .econst to Program Memory
      4. 7.1.4 Dynamic Memory Allocation
      5. 7.1.5 Initialization of Variables
      6. 7.1.6 Allocating Memory for Static and Global Variables
      7. 7.1.7 Field/Structure Alignment
      8. 7.1.8 Character String Constants
    2. 7.2  Register Conventions
      1. 7.2.1 TMS320C28x Register Use and Preservation
      2. 7.2.2 Status Registers
    3. 7.3  Function Structure and Calling Conventions
      1. 7.3.1 How a Function Makes a Call
      2. 7.3.2 How a Called Function Responds
      3. 7.3.3 Special Case for a Called Function (Large Frames)
      4. 7.3.4 Accessing Arguments and Local Variables
      5. 7.3.5 Allocating the Frame and Accessing 32-Bit Values in Memory
    4. 7.4  Accessing Linker Symbols in C and C++
    5. 7.5  Interfacing C and C++ With Assembly Language
      1. 7.5.1 Using Assembly Language Modules With C/C++ Code
      2. 7.5.2 Accessing Assembly Language Functions From C/C++
        1. 7.5.2.1 Calling an Assembly Language Function From a C/C++ Program
        2. 7.5.2.2 Assembly Language Program Called by Section 1
        3.       262
      3. 7.5.3 Accessing Assembly Language Variables From C/C++
        1. 7.5.3.1 Accessing Assembly Language Global Variables
          1. 7.5.3.1.1 Assembly Language Variable Program
          2. 7.5.3.1.2 C Program to Access Assembly Language From Section 1
        2.       267
        3. 7.5.3.2 Accessing Assembly Language Constants
          1. 7.5.3.2.1 Accessing an Assembly Language Constant From C
          2. 7.5.3.2.2 Assembly Language Program for Section 1
          3.        271
      4. 7.5.4 Sharing C/C++ Header Files With Assembly Source
      5. 7.5.5 Using Inline Assembly Language
    6. 7.6  Using Intrinsics to Access Assembly Language Statements
      1. 7.6.1 Floating Point Conversion Intrinsics
      2. 7.6.2 Floating Point Unit (FPU) Intrinsics
      3. 7.6.3 Trigonometric Math Unit (TMU) Intrinsics
      4. 7.6.4 Fast Integer Division Intrinsics
    7. 7.7  Interrupt Handling
      1. 7.7.1 General Points About Interrupts
      2. 7.7.2 Using C/C++ Interrupt Routines
        1.       282
    8. 7.8  Integer Expression Analysis
      1. 7.8.1 Operations Evaluated With Run-Time-Support Calls
      2. 7.8.2 Division Operations with Fast Integer Division Support
      3. 7.8.3 C/C++ Code Access to the Upper 16 Bits of 16-Bit Multiply
    9. 7.9  Floating-Point Expression Analysis
    10. 7.10 System Initialization
      1. 7.10.1 Boot Hook Functions for System Pre-Initialization
      2. 7.10.2 Run-Time Stack
      3. 7.10.3 Automatic Initialization of Variables for COFF
        1. 7.10.3.1 Initialization Tables
        2.       293
        3. 7.10.3.2 Autoinitialization of Variables at Run Time for COFF
        4. 7.10.3.3 Initialization of Variables at Load Time for COFF
        5. 7.10.3.4 Global Constructors
      4. 7.10.4 Automatic Initialization of Variables for EABI
        1. 7.10.4.1 Zero Initializing Variables
        2. 7.10.4.2 Direct Initialization for EABI
        3. 7.10.4.3 Autoinitialization of Variables at Run Time for EABI
        4. 7.10.4.4 Autoinitialization Tables for EABI
          1. 7.10.4.4.1 Length Followed by Data Format
          2. 7.10.4.4.2 Zero Initialization Format
          3. 7.10.4.4.3 Run Length Encoded (RLE) Format
          4. 7.10.4.4.4 Lempel-Ziv-Storer-Szymanski Compression (LZSS) Format
        5. 7.10.4.5 Initialization of Variables at Load Time
        6. 7.10.4.6 Global Constructors
  9. Using Run-Time-Support Functions and Building Libraries
    1. 8.1 C and C++ Run-Time Support Libraries
      1. 8.1.1 Linking Code With the Object Library
      2. 8.1.2 Header Files
      3. 8.1.3 Modifying a Library Function
      4. 8.1.4 Support for String Handling
      5. 8.1.5 Minimal Support for Internationalization
      6. 8.1.6 Support for Time and Clock Functions
      7. 8.1.7 Allowable Number of Open Files
      8. 8.1.8 Library Naming Conventions
    2. 8.2 The C I/O Functions
      1. 8.2.1 High-Level I/O Functions
        1. 8.2.1.1 Formatting and the Format Conversion Buffer
      2. 8.2.2 Overview of Low-Level I/O Implementation
        1.       open
        2.       close
        3.       read
        4.       write
        5.       lseek
        6.       unlink
        7.       rename
      3. 8.2.3 Device-Driver Level I/O Functions
        1.       DEV_open
        2.       DEV_close
        3.       DEV_read
        4.       DEV_write
        5.       DEV_lseek
        6.       DEV_unlink
        7.       DEV_rename
      4. 8.2.4 Adding a User-Defined Device Driver for C I/O
        1. 8.2.4.1 Mapping Default Streams to Device
      5. 8.2.5 The device Prefix
        1.       add_device
        2.       341
        3. 8.2.5.1 Program for C I/O Device
    3. 8.3 Handling Reentrancy (_register_lock() and _register_unlock() Functions)
    4. 8.4 Reinitializing Variables During a Warm Start
    5. 8.5 Library-Build Process
      1. 8.5.1 Required Non-Texas Instruments Software
      2. 8.5.2 Using the Library-Build Process
        1. 8.5.2.1 Automatic Standard Library Rebuilding by the Linker
        2. 8.5.2.2 Invoking mklib Manually
          1. 8.5.2.2.1 Building Standard Libraries
          2. 8.5.2.2.2 Shared or Read-Only Library Directory
          3. 8.5.2.2.3 Building Libraries With Custom Options
          4. 8.5.2.2.4 The mklib Program Option Summary
      3. 8.5.3 Extending mklib
        1. 8.5.3.1 Underlying Mechanism
        2. 8.5.3.2 Libraries From Other Vendors
  10. C++ Name Demangler
    1. 9.1 Invoking the C++ Name Demangler
    2. 9.2 Sample Usage of the C++ Name Demangler
  11. 10CLA Compiler
    1. 10.1 How to Invoke the CLA Compiler
      1. 10.1.1 CLA-Specific Options
    2. 10.2 CLA C Language Implementation
      1. 10.2.1 Variables and Data Types
      2. 10.2.2 Pragmas, Keywords, and Intrinsics
      3. 10.2.3 Optimizations with the CLA Compiler
      4. 10.2.4 C Language Restrictions
      5. 10.2.5 Memory Model - Sections
      6. 10.2.6 Function Structure and Calling Conventions
  12.   A Glossary
    1.     A.1 Terminology
  13.   B Revision History
  14.   373
  15.   374
  16.   375
  17.   376
  18.   B Earlier Revisions

Fast Integer Division Intrinsics

The intrinsics listed in Table 8-9 perform faster division using hardware fast integer division support. These intrinsics are enabled if the --idiv_support=idiv0 compiler option is used.

In order to use these intrinsics, your code must include the stdlib.h header file and the --float_support option must be set to fpu32 or fpu64. Fast integer division support is available for EABI only.

These intrinsics follow the format of the ldiv and lldiv standard library functions. They take as input the dividend and divisor, and return a structure containing both the quotient and remainder in the fields quot and rem, respectively. The __uldiv_t and __ulldiv_t types are unsigned equivalents to ldiv and lldiv provided by stdlib.h . In addition, the following additional structure types are provided to return long long quotients with a long remainder:

typedef struct { long long quot; long rem; }                   __llldiv_t;
typedef struct { unsigned long long quot; unsigned long rem; } __ullldiv_t;

These intrinsics support three types of integer division:

  • Traditional division. Also called truncated division or C99 division. This type of division rounds toward zero. As a consequence, the remainder sign is the same as the sign of the dividend.
  • Modulo division. Also called floored division. This type of division rounds toward negative infinity. As a consequence, the remainder sign is the same as the sign of the divisor.
  • Euclidean division. This type of division rounds toward infinite magnitude. As a consequence, the remainder is always non-negative.

For all three types of division, the dividend is exactly equal to quotient * divisor + remainder. All three types of division compute the same quotient and remainder if the remainder is zero or if the dividend and divisor are positive.

Since the results of division between two unsigned values do not vary for the traditional, Euclidean, and modulo versions, only the traditional versions are provided for unsigned inputs.

In general, if the dividend and divisor are of different types, the divisor is converted to the type of the dividend before division. However, in cases where the dividend type is signed, the divisor type is unsigned, and the dividend type is not larger than the divisor type—that is, for the *_div_i32byu32 and *_div_i64byu64 intrinsics—division is carried out using a signed type larger than both the dividend and divisor, and then converted to the type of the dividend.

Division by 0 is always undefined.

In addition to these intrinsics, when the --idiv_support=idiv0 compiler option is used, the built-in integer division and modulo operators ("/" and "%") use the appropriate faster instructions as described in Section 8.9.2. The faster versions of these built-in operators are used whether or not the stdlib.h header file is included.

Table 7-9 C/C++ Compiler Intrinsics for Fast Integer Division (--idiv_support=idiv0)
Intrinsic Assembly Instruction(s) Description
16-bit by 16-bit
ldiv_t __traditional_div_i16byi16( int dividend, int divisor );
I16TOF32    R3H,@Den
F32TOI32    R3H,R3H
I16TOF32    R1H,@Num
MPYF32      R1H,R1H,#65536.0
NOP
F32TOI32    R1H,R1H
ABSI32DIV32 R2H, R1H, R3H
.loop       #4 {SUBC4UI32 R2H, R1H, R3H}
NEGI32DIV32 R1H, R2H
Return the result of traditional 16-bit by 16-bit division.
ldiv_t __euclidean_div_i16byi16( int dividend, int divisor );
I16TOF32    R3H,@Den
F32TOI32    R3H,R3H
I16TOF32    R1H,@Num
MPYF32      R1H,R1H,#65536.0
NOP
F32TOI32    R1H,R1H
ABSI32DIV32 R2H, R1H, R3H
.loop       #4 {SUBC4UI32 R2H, R1H, R3H}
ENEGI32DIV32 R1H, R2H, R3H
Return the result of Eucildean 16-bit by 16-bit division.
ldiv_t __modulo_div_i16byi16( int dividend, int divisor );
I16TOF32    R3H,@Den
F32TOI32    R3H,R3H
I16TOF32    R1H,@Num
MPYF32      R1H,R1H,#65536.0
NOP
F32TOI32    R1H,R1H
ABSI32DIV32 R2H, R1H, R3H
.loop       #4 {SUBC4UI32 R2H, R1H, R3H}
MNEGI32DIV32 R1H, R2H, R3H
Return the result of modulo 16-bit by 16-bit division.
__uldiv_t __traditional_div_u16byu16( unsigned int dividend, unsigned int divisor);
UI16TOF32  R3H,@Den
F32TOUI32  R3H,R3H
UI16TOF32  R1H,@Num
MPYF32     R1H,R1H,#65536.0
NOP
F32TOUI32  R1H,R1H
.loop      #4{SUBC4UI32 R2H, R1H, R3H}
Return the unsigned result of traditional 16-bit by 16-bit division, when the dividend and divisor are unsigned.
32-bit by 32-bit
ldiv_t __traditional_div_i32byi32( long dividend, long divisor);
MOV32 R3H @DEN
MOV32 R1H @NUM
ABSI32DIV32 R2H, R1H, R3H
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
NEGI32DIV32 R1H, R2H
Return the result of traditional 32-bit by 32-bit division.
ldiv_t __euclidean_div_i32byi32( long dividend, long divisor );
MOV32 R3H @DEN
MOV32 R1H @NUM
ABSI32DIV32 R2H, R1H, R3H
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
ENEGI32DIV32 R1H, R2H, R3H
Return the result of Eucildean 32-bit by 32-bit division.
ldiv_t __modulo_div_i32byi32( long dividend, long divisor );
MOV32 R3H @DEN
MOV32 R1H @NUM
ABSI32DIV32 R2H, R1H, R3H
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
MNEGI32DIV32 R1H, R2H, R3H
Return the result of modulo 32-bit by 32-bit division.
ldiv_t __traditional_div_i32byu32( long dividend, unsigned long divisor);
MOV32 R3H @DEN
MOV32 R1H @NUM
ABSI32DIV32U R2H, R1H
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
NEGI32DIV32 R1H, R2H
Return the result of traditional 32-bit by 32-bit division, when the divisor is unsigned.
ldiv_t __euclidean_div_i32byu32( long dividend, unsigned long divisor );
MOV32 R3H @DEN
MOV32 R1H @NUM
ABSI32DIV32U R2H, R1H
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
ENEGI32DIV32 R1H, R2H, R3H
Return the result of Eucildean 32-bit by 32-bit division, when the divisor is unsigned.
ldiv_t __modulo_div_i32byu32( long dividend, unsigned long divisor );
MOV32 R3H @DEN
MOV32 R1H @NUM
ABSI32DIV32U R2H, R1H
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
MNEGI32DIV32 R1H, R2H, R3H
Return the result of modulo 32-bit by 32-bit division, when the divisor is unsigned.
__uldiv_t __traditional_div_u32byu32( unsigned long dividend, unsigned long divisor);
MOV32 R3H @DEN
MOV32 R1H @NUM
ZERO R2
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
Return the unsigned result of traditional 32-bit by 32-bit division, when the dividend and divisor are unsigned.
32-bit by 16-bit
ldiv_t __traditional_div_i32byi16( long dividend, int divisor);
I16TOF32    R3H,@Den
F32TOI32    R3H,R3H
MOV R1H, @NUM
.loop #3  {NOP}
ABSI32DIV32 R2H, R1H, R3H
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
NEGI32DIV32 R1H, R2H
Return the result of traditional 32-bit by 16-bit division.
ldiv_t __euclidean_div_i32byi16( long dividend, int divisor );
I16TOF32    R3H,@Den
F32TOI32    R3H,R3H
MOV R1H, @NUM
.loop #3  {NOP}
ABSI32DIV32 R2H, R1H, R3H
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
ENEGI32DIV32 R1H, R2H, R3H
Return the result of Eucildean 32-bit by 16-bit division.
ldiv_t __modulo_div_i32byi16( long dividend, int divisor );
I16TOF32    R3H,@Den
F32TOI32    R3H,R3H
MOV R1H, @NUM
.loop #3  {NOP}
ABSI32DIV32 R2H, R1H, R3H
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
MNEGI32DIV32 R1H, R2H, R3H
Return the result of modulo 32-bit by 16-bit division.
__uldiv_t __traditional_div_u32byu16( unsigned long dividend, unsigned int divisor);
I16TOF32    R3H,@Den
F32TOI32    R3H,R3H                 
MOV R1H, @NUM
ZERO R2
.loop #2  {NOP}
.loop #8 {SUBC4UI32 R2H, R1H, R3H}
Return the unsigned result of traditional 32-bit by 16-bit division, when the dividend and divisor are unsigned.
64-bit by 64-bit
lldiv_t __traditional_div_i64byi64( long long dividend, long long divisor);
MOV32 R5H @DEN_L
MOV32 R3H @DEN_H
MOV32 R0H @NUM_L
MOV32 R1H @NUM_H
ABSI64DIV64 R2H:R4H, R1H:R0H, R3H:R5H
.loop #32 {SUBC2UI64 R2H:R4H, R1H:R0H, R3H:R5H}
NEGI64DIV64 R1H:R0H, R2H:R4H
Return the result of traditional 64-bit by 64-bit division.
lldiv_t __euclidean_div_i64byi64( long long dividend, long long divisor);
MOV32 R5H @DEN_L
MOV32 R3H @DEN_H
MOV32 R0H @NUM_L
MOV32 R1H @NUM_H
ABSI64DIV64 R2H:R4H, R1H:R0H, R3H:R5H
.loop #32 {SUBC2UI64 R2H:R4H, R1H:R0H, R3H:R5H}
ENEGI64DIV64 R1H:R0H, R2H:R4H, R3H:R5H
Return the result of Eucildean 64-bit by 64-bit division.
lldiv_t __modulo_div_i64byi64( long long dividend, long long divisor);
MOV32 R5H @DEN_L
MOV32 R3H @DEN_H
MOV32 R0H @NUM_L
MOV32 R1H @NUM_H
ABSI64DIV64 R2H:R4H, R1H:R0H, R3H:R5H
.loop #32 {SUBC2UI64 R2H:R4H, R1H:R0H, R3H:R5H}
MNEGI64DIV64 R1H:R0H, R2H:R4H, R3H:R5H
Return the result of modulo 64-bit by 64-bit division.
lldiv_t __traditional_div_i64byu64( long long dividend, unsigned long long divisor);
MOV32 R5H @DEN_L
MOV32 R3H @DEN_H
MOV32 R0H @NUM_L
MOV32 R1H @NUM_H
ABSI64DIV64U R2H:R4H, R1H:R0H
.loop #32 {SUBC2UI64 R2H:R4H, R1H:R0H, R3H:R5H}
NEGI64DIV64 R1H:R0H, R2H:R4H
Return the result of traditional 64-bit by 64-bit division, when the divisor is unsigned.
lldiv_t __euclidean_div_i64byu64( long long dividend, unsigned long long divisor);
MOV32 R5H @DEN_L
MOV32 R3H @DEN_H
MOV32 R0H @NUM_L
MOV32 R1H @NUM_H
ABSI64DIV64U R2H:R4H, R1H:R0H
.loop #32 {SUBC2UI64 R2H:R4H, R1H:R0H, R3H:R5H}
ENEGI64DIV64 R1H:R0H, R2H:R4H, R3H:R5H
Return the result of Eucildean 64-bit by 64-bit division, when the divisor is unsigned.
lldiv_t __modulo_div_i64byu64( long long dividend, unsigned long long divisor);
MOV32 R5H @DEN_L
MOV32 R3H @DEN_H
MOV32 R0H @NUM_L
MOV32 R1H @NUM_H
ABSI64DIV64U R2H:R4H, R1H:R0H
.loop #32 {SUBC2UI64 R2H:R4H, R1H:R0H, R3H:R5H}
MNEGI64DIV64 R1H:R0H, R2H:R4H, R3H:R5H
Return the result of modulo 64-bit by 64-bit division, when the divisor is unsigned.
__ulldiv_t __traditional_div_u64byu64( unsigned long long dividend, unsigned long long divisor);
ZERO R2
ZERO R4
MOV32 R5H @DEN_L
MOV32 R3H @DEN_H
MOV32 R0H @NUM_L
MOV32 R1H @NUM_H
.loop #32 {SUBC2UI64 R2H:R4H, R1H:R0H, R3H:R5H}
Return the unsigned result of traditional 64-bit by 64-bit division, when the dividend and divisor are unsigned.
64-bit by 32-bit
__llldiv_t __traditional_div_i64byi32( signed long long dividend, long divisor);
ABSI64DIV32 R2H, R1H:R0H, R3H
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
NEGI64DIV32 R1H:R0H, R2H
LRETR
Return the result of traditional 64-bit by 32-bit division.
__llldiv_t __euclidean_div_i64byi32( signed long long dividend, long divisor);
ABSI64DIV32 R2H, R1H:R0H, R3H
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
ENEGI64DIV32 R1H:R0H, R2H, R3H
LRETR
Return the result of Eucildean 64-bit by 32-bit division.
__llldiv_t __modulo_div_i64byi32( signed long long dividend, long divisor);
ABSI64DIV32 R2H, R1H:R0H, R3H
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
MNEGI64DIV32 R1H:R0H, R2H, R3H
LRETR
Return the result of modulo 64-bit by 32-bit division.
__llldiv_t __traditional_div_i64byu32( signed long long dividend, unsigned long divisor);
ABSI64DIV32U R2H, R1H:R0H
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
ZERO R4
SWAPF R4, R2
NEGI64DIV64 R1H:R0H, R2H:R4H
LRETR
Return the result of traditional 64-bit by 32-bit division, when the divisor is unsigned.
__llldiv_t __euclidean_div_i64byu32( signed long long dividend, unsigned long divisor);
ABSI64DIV32U R2H, R1H:R0H
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
ENEGI64DIV32 R1H:R0H, R2H, R3H
LRETR
Return the result of Eucildean 64-bit by 32-bit division, when the divisor is unsigned.
__llldiv_t __modulo_div_i64byu32( unsigned long long dividend, unsigned long divisor);
ABSI64DIV32U R2H, R1H:R0H
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
MNEGI64DIV32 R1H:R0H, R2H, R3H
LRETR
Return the result of modulo 64-bit by 32-bit division, when the divisor is unsigned.
__ullldiv_t __traditional_div_u64byu32( unsigned long long dividend, unsigned long divisor);
ZERO R2
ZERO R4
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
.loop 8
SUBC4UI32 R2H, R1H, R3H
.endloop
SWAPF R1, R0
LRETR
Return the unsigned result of traditional 64-bit by 32-bit division, when the dividend and divisor are unsigned.