Locale Icon
English
  • Forums

    Popular Forums

    • LTspice
    • Video
    • Power Management
    • RF & Microwave
    • Precision ADCs
    • FPGA Reference Designs

    Product Forums

    • Amplifiers
    • Clocks & Timers
    • Data Converters
    • Direct Digital Synthesis (DDS)
    • Energy
    • Interface and Isolation
    • MEMS Inertial Sensors
    • Power Management
    • Processors & DSP
    • Processors & Microcontrollers
    • Switches & Multiplexers
    • Sensors
    • Voltage References
    View All

    Application Forums

    • A2B Audio Bus
    • Audio
    • Automated Test Equipment (ATE)
    • Condition-Based Monitoring
    • Depth, Perception & Ranging Technologies
    • Embedded Vision Sensing Library
    • Motor Control Hardware Platforms
    • Precision Technology Signal Chains Library
    • Video
    • Wireless Sensor Networks Reference Library

    Design Center Forums

    • ACE Evaluation Software
    • ADEF System Platforms
    • Design Tools & Calculators
    • FPGA Reference Designs
    • Linux Software Drivers
    • Microcontroller no-OS Drivers
    • Power Studio Designer
    • Power Studio Planner
    • Reference Designs
    • Robot Operating System (ROS) SDK
    • Signal Chain Power (SCP)
    • Software Interface Tools
    • System Demonstration Platform (SDP) Support
  • Learn

    Highlighted Webinar

    Fast-Track Certification: Leveraging IC Safety App Notes for Functional Safety Designs

    Stop guessing, start certifying. Learn how to use IC safety application notes to streamline your FMEDA and meet IEC 61508 and ISO 13849 standards with...

    Places

    • ADI Academy
    • ADI Webinars
    • EZ Blogs
    • Video Annex
    • Virtual Classroom

    Libraries

    • 3D ToF Depth Sensing Library
    • Continuous-Wave CMOS Time of Flight (TOF) Library
    • Embedded Vision Sensing Library
    • Gigabit Multimedia Serial Link (GMSL) Library
    • Optical Sensing Library
    • Other Products Library
    • Precision Technology Signal Chains Library
    • Software Modules and SDKs Library
    • Supervisory Circuits Library
    • Wireless Sensor Networks Library
  • Community Hub

    Challenge Yourself!

      New KCC Quiz AQQ299 about Opamp open looop gain and LTspice (a kind proposal from Al Butvidas)

      1. Quote of the month: " A good friend calls you in jail. A great friend bails you out of jail. Your best friend sits next to you and says 'wasn't that...

    View All

    What's Brewing

      Read a Blog, Take this Quiz for Another Chance to Win a Gift Card!

      Important: Read the blog first . The quiz questions are all based on the content from the blog: Understanding Voltage Domain Isolation in Field-Bus...

    View All

    Places

    • Community Help
    • Analog Dialogue Quiz
    • Logic Lounge
    • Super User Program

    Resources

    • EZ Code of Conduct
    • EZ How To Help Articles
    • Getting Started Guide
    • ADI: Words Matter
    • Community Help Videos
    View All
  • ContentZone

    Visit ContentZone

    Search content by industry or technology.
    • Blogs
    • Technical Articles
    • Tutorials
    • Videos
    • Webinars
    Your ADI content all in one place.
    View ContentZone

    The Latest Read

    Master FPGA-Based DSP Design: The Complete Building Blocks Guide You Need to Read

    The Engineering Mind Blog on EngineerZone presents an exceptional five-part series titled " DSP Building Blocks " that walks engineers through the essential...

    New Release

    Signal Chain Designer: DC Error Simulation
    Signal Chain Designer: DC Error Simulation

    This video covers the DC error calculation capabilities of Signal Chain Designer. DC error is unique in that often requires calibration and has so many...

    Recent Technical Insights

    Latest Technical Article from Analog.com
    PSM Integration for Enhanced Module Solutions in 48 V Data Centers

    The integration of the LTC2971 into quarter brick solutions for 48 V data centers enhances monitoring, control, and reliability by providing high precision...

EngineerZone
EngineerZone
Software & Development Tools
  • Log In
  • User
  • Site
  • Search
OR
Ask a Question
Software & Development Tools
  • Processors & DSP
Software & Development Tools
Documents How to use assembly function in C++ code
  • Q&A
  • Documents
  • Members
  • Tags
  • Cancel
  • -Documents
    • -Software and Development Tools
      • BSP package and Help page for Linux
      • Does CCES supports argc and argv in ARM?
      • -How to use assembly function in C++ code
        • Calling assembly function from C code
      • I have a purchase/order details, but lost the license key. What should I do to get my purchased license key?
      • Inline ASM code using scratch register
      • L1 Block2 PM in Sharc+ core
      • Legacy SHARC to SHARC+ migration
      • Refresh memory window at runtime
  • +ADSP-SC58x: FAQ
  • +Blackfin BF707: FAQ
  • +CCE: FAQ
  • +CCES 2.6.0: FAQ
  • +CCES 2.8.0: FAQ
  • +External identifier in assembler: FAQ
  • +GCC Compiler Manual: FAQ
  • +VisualDSP++: FAQ

How to use assembly function in C++ code

Question:
How to use assembly function in C++ code?

Answer:
When using asm code from C++ code, you have to inform the build tools that these functions are in asm, so that it knows how to call them. When a asm source file is compiled, the function names are given an underscore prefix in the generated assembly. For example, "void foo(int a) {...}" becomes "_foo" in the generated assembly. This is the symbol used to call the function.

As C++ supports function overloading, simply adding an underscore would not differentiate between the variances of the same function. So, a suffix is added to the symbol name in assembly when a C++ source file is compiled. For example. "void foo(void)" becomes "_foo__Fv" ("__F" = function, "v" = void), while "void foo(unsigned char *a, int b)" would become "_func__FPUci" in the assembly file, where the "__FPUci" means the Function ("__F") takes a Pointer ("P") to an Unsigned char ("Uc"), and an integer ("i") as it's parameters: "__FPUci".

This is true not only when you build the source that contains the function definition, but also when you call the function from your code. Where this causes problems, is if you call "foo(void)" from your C++ source, but the function exists in a asm source file, the generated assembly will call "_foo_Fv", but the linker will not be able to resolve that reference, as compiling the C source file would only produce a symbol "_foo".

You can let the Compiler know how to resolve these references using the "extern" qualifier. For example, if you have a function named "asm_func()" in a asm source file, simply add the prototype to your C++ source code (or a header file included by the C++ source) as follows:

extern "asm" void asm_func(void);

This tells the C++ Compiler that "asm_func ()" is a asm function, and will generate references to this function in the generated assembly.

Also please note that, no need to add dot suffix in function definition of " asm_func()”, while using extern qualifier.

  • Share
  • History
  • More
  • Cancel
analog-devices logo

About Analog Devices

  • Who We Are
  • Careers
  • Newsroom
  • What We Do (Signals+)
  • Investor RelationsExternalLink
  • Quality & Reliability
  • Sales and Distribution
  • What's New on Analog.com
  • Contact Us

Find Help

  • Support
  • Resources
  • WikiExternalLink
  • Analog Dialogue
  • ADI Developer PortalExternalLink

myAnalog

Interested in the latest news and articles about ADI products, design tools, training, and events?

Go to myAnalog
  • Instagram page
  • Twitter page
  • Linkedin page
  • Youtube page
  • Facebook
  • Legal and Risk
  • Accessibility
  • Privacy Policy
  • Privacy Settings
  • Cookie Settings

©2026 Analog Devices, Inc. All Rights Reserved

analog-devices

About Analog Devices

Down Up
  • Who We Are
  • Careers
  • Newsroom
  • What We Do (Signals+)
  • Investor RelationsExternalLink
  • Quality & Reliability
  • Sales and Distribution
  • What's New on Analog.com
  • Contact Us

Find Help

Down Up
  • Support
  • Resources
  • WikiExternalLink
  • Analog Dialogue
  • ADI Developer PortalExternalLink

myAnalog

Interested in the latest news and articles about ADI products, design tools, training, and events?

Go to myAnalog
Instagram page Facebook Twitter page Linkedin page Youtube page
  • Legal and Risk
  • Accessibility
  • Privacy Policy
  • Privacy Settings
  • Cookie Settings

©2026 Analog Devices, Inc. All Rights Reserved