• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Microcontroller Tips

Microcontroller engineering resources, new microcontroller products and electronics engineering news

  • Products
    • 8-bit
    • 16-bit
    • 32-bit
    • 64-bit
  • Applications
    • Automotive
    • Connectivity
    • Consumer Electronics
    • Industrial
    • Medical
    • Security
  • EE Forums
    • EDABoard.com
    • Electro-Tech-Online.com
  • Videos
    • TI Microcontroller Videos
  • EE Resources
    • DesignFast
    • eBooks / Tech Tips
    • FAQs
    • LEAP Awards
    • Podcasts
    • Webinars
    • White Papers
  • EE Learning Center

What are compilers, translators, interpreters, and assemblers?

February 17, 2017 By Scott Thornton 24 Comments

Translators, compilers, interpreters and assemblers are all software programming tools that convert code into another type of code, but each term has specific meaning. All of the above work in some way towards getting a high-level programming language translated into machine code that the central processing unit (CPU) can understand. Examples of CPUs include those made by Intel (e.g., x86), AMD (e.g., Athlon APU), NXP (e.g., PowerPC), and many others. It’s important to note that all translators, compilers, interpreters and assemblers are programs themselves.

Translators
The most general term for a software code converting tool is “translator.” A translator, in software programming terms, is a generic term that could refer to a compiler, assembler, or interpreter; anything that converts higher level code into another high-level code (e.g., Basic, C++, Fortran, Java) or lower-level (i.e., a language that the processor can understand), such as assembly language or machine code. If you don’t know what the tool actually does other than that it accomplishes some level of code conversion to a specific target language, then you can safely call it a translator.

Compilers
Compilers convert high-level language code to machine (object) code in one session. Compilers can take a while, because they have to translate high-level code to lower-level machine language all at once and then save the executable object code to memory. A compiler creates machine code that runs on a processor with a specific Instruction Set Architecture (ISA), which is processor-dependent. For example, you cannot compile code for an x86 and run it on a MIPS architecture without a special compiler. Compilers are also platform-dependent. That is, a compiler can convert C++, for example, to machine code that’s targeted at a platform that is running the Linux OS. A cross-compiler, however, can generate code for a platform other than the one it runs on itself.

A cross-compiler running on a Windows machine, for instance, could generate code that runs on a specific Windows operating system or a Linux (operating system) platform. Source-to-source compilers translate one program, or code, to another of a different language (e.g., from Java to C). Choosing a compiler then, means that first you need to know the ISA, operating system, and the programming language that you plan to use. Compilers often come as a package with other tools, and each processor manufacturer will have at least one compiler or a package of software development tools (that includes a compiler). Often the software tools (including compiler) are free; after all, a CPU is completely useless without software to run on it. Compilers will report errors after compiling has finished.

Interpreters
Another way to get code to run on your processor is to use an interpreter, which is not the same as a compiler. An interpreter translates code like a compiler but reads the code and immediately executes on that code, and therefore is initially faster than a compiler. Thus, interpreters are often used in software development tools as debugging tools, as they can execute a single in of code at a time. Compilers translate code all at once and the processor then executes upon the machine language that the compiler produced. If changes are made to the code after compilation, the changed code will need to be compiled and added to the compiled code (or perhaps the entire program will need to be re-compiled.) But an interpreter, although skipping the step of compilation of the entire program to start, is much slower to execute than the same program that’s been completely compiled.

Interpreters, however, have usefulness in areas where speed doesn’t matter (e.g., debugging and training) and it is possible to take the entire interpreter and use it on another ISA, which makes it more portable than a compiler when working between hardware architectures. There are several types of interpreters: the syntax-directed interpreter (i.e., the Abstract Syntax Tree (AST) interpreter), bytecode interpreter, and threaded interpreter (not to be confused with concurrent processing threads), Just-in-Time (a kind of hybrid interpreter/compiler), and a few others. Instructions on how to build an interpreter can be found on the web.[i] Some examples of programming languages that use interpreters are Python, Ruby, Perl, and PHP.

Assemblers
An assembler translates a program written in assembly language into machine language and is effectively a compiler for the assembly language, but can also be used interactively like an interpreter. Assembly language is a low-level programming language. Low-level programming languages are less like human language in that they are more difficult to understand at a glance; you have to study assembly code carefully in order to follow the intent of execution and in most cases, assembly code has many more lines of code to represent the same functions being executed as a higher-level language. An assembler converts assembly language code into machine code (also known as object code), an even lower-level language that the processor can directly understand.

Assembly language code is more often used with 8-bit processors and becomes increasingly unwieldy as the processor’s instruction set path becomes wider (e.g., 16-bit, 32-bit, and 64-bit). It is not impossible for people to read machine code, the strings of ones and zeros that digital devices (including processors) use to communicate, but it’s likely only read by people in cases of computer forensics or brute-force hacking. Assembly language is the next level up from machine code, and is quite useful in extreme cases of debugging code to determine exactly what’s going on in a problematic execution, for instance. Sometimes compilers will “optimize” code in unforeseen ways that affect outcomes to the bafflement of the developer or programmer such that it’s necessary to carefully follow the step-by-step action of the processor in assembly code, much like a hunter tracking prey or a detective following clues.

[i] “Let’s Build a Simple Interpreter”, https://ruslanspivak.com/lsbasi-part1

Filed Under: FAQ, Featured, microcontroller Tagged With: basics, FAQ

Reader Interactions

Comments

  1. LANSANA KABBA says

    March 20, 2019 at 5:42 pm

    Thanks Very Much, I have understand very well

    Reply
  2. mb katuwal says

    March 23, 2019 at 8:53 pm

    examples of assemblers?

    Reply
    • Aarna says

      September 24, 2020 at 12:48 am

      There is no example of assemblers. Assemblers are only assemblers.

      Reply
  3. Alex says

    April 9, 2019 at 3:13 pm

    Clear explanation, thank you.

    Reply
  4. Matrix says

    April 11, 2019 at 2:58 am

    I use this page for cheating in practical viva exam

    Reply
  5. makhanu shadrack says

    April 11, 2019 at 10:32 am

    good job guys you are doing. keep up

    Reply
  6. nsabo honore says

    May 24, 2019 at 6:32 am

    Thanks for your explanations

    Reply
  7. Milton says

    August 7, 2019 at 2:01 am

    I like your explanation

    Reply
  8. Pavan says

    December 7, 2019 at 1:06 am

    Thanks for good information and give examples

    Reply
  9. Sweta says

    December 16, 2019 at 12:02 pm

    Thanks for your explanation

    Reply
  10. Amir musa says

    January 6, 2020 at 11:20 am

    Very interesting,clear,precise and wonderful explanation thank you.

    Reply
  11. lauwali isa says

    March 21, 2020 at 7:58 am

    what are the difference between them

    Reply
  12. Agbesoyin Elizabeth says

    July 14, 2020 at 10:33 am

    Thanks for the explanation

    Reply
  13. Agbesoyin Elizabeth says

    July 14, 2020 at 10:35 am

    Thanks for the explanation keep it up

    Reply
    • Agbesoyin Elizabeth says

      July 14, 2020 at 10:37 am

      Pls I did not understand what you guys are talking about

      Reply
  14. Nadiia Kehrli says

    October 1, 2020 at 3:38 am

    Thank you for through explanation of various software programming tools

    Reply
  15. Rafi says

    October 20, 2020 at 12:40 am

    Beautifully Explained

    Reply
  16. Kolawole taofeeq babatunde says

    October 29, 2020 at 7:49 am

    That mean,compiler and interpreter carry out the same function in different way.

    Reply
  17. Maryam says

    January 30, 2021 at 7:23 am

    That is good

    Reply
  18. nasir says

    February 8, 2021 at 9:54 am

    thanks we
    are enjoying your contributions

    Reply
  19. Gift says

    February 14, 2021 at 1:17 pm

    Thanks for the explanation
    Very understanding.

    Reply

Trackbacks

  1. Top microcontroller stories of 2017 says:
    December 31, 2017 at 12:59 pm

    […] What are compilers, translators, interpreters, and assemblers? Translators, compilers, interpreters and assemblers are all software programming tools that convert code into another type of code, but each term has specific meaning. All of the above work in some way towards getting a high-level programming language translated into machine code that the central processing unit (CPU) can understand. […]

    Reply
  2. مفسر یا Interpreter در برنامه نویسی چیست؟ | برنامه چی says:
    March 11, 2019 at 2:21 pm

    […] What are compilers and interpreters […]

    Reply
  3. System Software (Assembler, Compiler, Translator, Debugger) – Vivid Mind says:
    May 6, 2020 at 4:55 am

    […] 3) What are compilers, translators, interpreters, and assemblers? […]

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

DesignFast

Component Selection Made Simple.

Try it Today
design fast globle

EE Training Center Classrooms

“ee

“ee

“ee

“ee

“ee

Subscribe to our Newsletter

Subscribe to weekly industry news, new product innovations and more.

Subscribe today

RSS Current EDABoard.com discussions

  • Bicycle antenna for long wave 200 khz
  • What's the format of Conformal LEC set_analyze_option -mapping_file file?
  • Relay with ACS712 overcurrent protection (schematic included)
  • Trying to fix PICkit3 boards
  • Problem in Process corner simulation using Cadence ADXL tool.

RSS Current Electro-Tech-Online.com Discussions

  • How to copy project in MPLAB X???
  • Drok meter Issue please help
  • Can anyone help?!
  • ST7066U 20x4 LCD problems
  • Power Transistor Voltage Source

Follow us on Twitter

Tweets by MicroContrlTips

Footer

Microcontroller Tips

EE World Online Network

  • DesignFast
  • EE World Online
  • EDA Board Forums
  • Electro Tech Online Forums
  • Connector Tips
  • Analog IC Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • Wire and Cable Tips
  • 5G Technology World

Microcontroller Tips

  • Subscribe to our newsletter
  • Advertise with us
  • Contact us
  • About us
Follow us on TwitterAdd us on FacebookFollow us on YouTube Follow us on Instagram

Copyright © 2021 · WTWH Media LLC and its licensors. All rights reserved.
The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media.

Privacy Policy