Translators Flashcards
Converting source code to machine code.
Translation
Why is translation needed?
Source code is easy to understand for us, however computers need it converted into pure binary to understand and execute. (machine code)
Types of translators:
• Assemblers
• Interpreters
• Compilers
Translators that translate source code
Interpreters and compilers
translates assembly code
assemblers
Won’t run unless all errors in the code are corrected
Compiler
Runs program partially if an error is present in the code
Interpreters
Takes one line of source code, translates it and executes it
interpreter
takes entire source code and translates it
compiler
Assembler description
• Translates assembly language into machine code.
• Takes basic commands and operators from assembly code and converts them into binary code that can be recognised by a specific type of processor
• The translation process: one-to-one from assembly code to machine code
Advantages of an assembler
• Programs written in machine language can be replaced with mnemonics, which are easier to remember
• Memory-efficient
• Speed of execution is faster
• Hardware-oriented
• Requires fewer instructions to accomplish the same result
Disadvantages of an assembler
•Long programs written in such languages cannot be executed on small computers
• It takes lot of time to code or write the program, as it is more complex in nature
• Difficult to remember the syntax
• Lack of portability between computers of different makes
• Translates source code from high-level languages into object code and then machine code to be processed by the CPU
• The whole program is translated into machine code before it is run
Compiler description
Advantages of a compiler
• No need for translated at run-time
• Speed if execution is faster
• Code is usually optimised
• Original source code is kept secret
Disadvantages of a compiler
• Source code is easier to write in a high-level language, but the program will not run with syntax errors, which can make it more difficult to write the code
• Code needs to be recompiled when the code is changed
• Designed for a specific type of processor
• Translates source code from high-level languages into machine code, ready to be processed by the CPU
• The program is translated line by line as the program is running
Interpreter description
Advantages of an interpreter translator
• Easy to write source code, as the program will always run, stopping when it finds a syntax error
• Code does not need to be recompiled when code is changed
• It is easy to try out commands when the program has paused after finding an error - this makes interpreted languages very easy for beginner programmers to learn to write code
Disadvantages of an interpreter translator
• Translation software is required at run-time
• Speed of execution is slower
• Code is not optimised
• Source code is required