Electronic Design
  • Resources
  • Directory
  • Webinars
  • CAD Models
  • Video
  • Blogs
  • More Publications
  • Advertise
    • Search
  • Top Stories
  • Tech Topics
  • Analog
  • Power
  • Embedded
  • Test
  • AI / ML
  • Automotive
  • Data Sheets
  • Topics
    - TechXchange Topics --- Markets --AutomotiveAutomation-- Technologies --AnalogPowerTest & MeasurementEmbedded
    Resources
    Electronic Design ResourcesTop Stories of the WeekNew ProductsKit Close-UpElectronic Design LibrarySearch Data SheetsCompany DirectoryBlogsContribute
    Members
    ContentBenefitsSubscribeDigital editions
    Advertise
    https://www.facebook.com/ElectronicDesign
    https://www.linkedin.com/groups/4210549/
    https://twitter.com/ElectronicDesgn
    https://www.youtube.com/channel/UCXKEiQ9dob20rIqTA7ONfJg
    1. News
    2. Products

    To Compile Or !(To Compile) Assembly Is The Question

    Feb. 3, 2003
    C is the language of choice for embedded development, but assembler still ranks high. This is especially true for 8-bit MCUs. But is assembler really the best choice for optimal code size and execution efficiency? For 32- and 64-bit...
    William G. Wong

    C is the language of choice for embedded development, but assembler still ranks high. This is especially true for 8-bit MCUs. But is assembler really the best choice for optimal code size and execution efficiency?

    For 32- and 64-bit environments, the answer is a resounding no. Assembler use is so rare that most developers don't even know how to run the assembler, let alone create a macro. Things get a little fuzzier when 16-bit processors are considered. Many 16-bit architectures lack the large register set preferred by C and C++ compiler writers. The 8-bit architectures are even harder for compilers to contend with. But even here, compilers can usually outdo the most experienced programmers.

    Of course, your mileage will vary depending on the compiler used. For example, Peter Dibble, distinguished engineer at TimeSys, notes that the typical C compiler, using minimal optimization, compiles a simple signed number function down to nine instructions for the Motorola 68000 family. Clever programmers can cut it to six, but they tend to leave in the conditional jumps that match the algorithm. The best is yet to come, though.

    Using a technique called superoptimization, a compiler was able to chop the size of the program down to four instructions with no jump instructions. This not only slashed the size, but also improved execution on pipeline machines. Superoptimization takes into account the entire instruction set and the side effects of each instruction. One of the first papers on the subject was by Henry Massalin, entitled "Superoptimizer—A Look at the Smallest Program," in the conference on Architectural Support for Programming Languages and Systems, 1987.

    Programmers are more productive when implementing a high-level language. They also make fewer errors and the code is easier to maintain. I know that I can accomplish more with C++ or Java than with assembler, even on small projects. A good compiler is important, so check out how well your compiler optimizes.

    Continue Reading

    Examining Today's RISC-V Ecosystem

    TrustInSoft Helps Root Out Bugs to Deliver Reliable Code

    Sponsored Recommendations

    Designing automotive-grade camera-based mirror systems

    Dec. 2, 2023

    Design security cameras and other low-power smart cameras with AI vision processors

    Dec. 2, 2023

    Automotive 1 TOPS vision SoC with RGB-IR ISP for 1-2 cameras, driver monitoring, dashcams

    Dec. 2, 2023

    AM62A starter kit for edge AI, vision, analytics and general purpose processors

    Dec. 2, 2023

    Comments

    To join the conversation, and become an exclusive member of Electronic Design, create an account today!

    I already have an account

    New

    Can Silicon Supply Enough Power for the Future of AI Silicon?

    Innovators in Electronic Design - Women in Science & Engineering: Maria Anhalt, CEO, Elektrobit

    DynaNIC Software Eases SmartNIC Development

    Most Read

    Measuring with Humor

    Quick Poll: A Memory Quiz

    Design Optimization for Engineering Problems — from Nanophotonics to Civil Infrastructure


    Sponsored

    How to build a smart retail scanner

    Develop an AI model with free "low-code" development tools

    TI Developer Zone - the fastest path to embedded development

    Electronic Design
    https://www.facebook.com/ElectronicDesign
    https://www.linkedin.com/groups/4210549/
    https://twitter.com/ElectronicDesgn
    https://www.youtube.com/channel/UCXKEiQ9dob20rIqTA7ONfJg
    • About Us
    • Contact Us
    • Advertise
    • Do Not Sell or Share
    • Privacy & Cookie Policy
    • Terms of Service
    © 2023 Endeavor Business Media, LLC. All rights reserved.
    Endeavor Business Media Logo