SLR 2.5 Translators and facilities of languages Flashcards
What is ‘source code’?
It is the high level language code written by programmers (for example code in Python, C#, C++ etc.)
What is ‘machine code’?
It is the binary code representation of instructions that the CPU can decode and execute (once fetched)
Why do programmers code in high level languages?
- high level languages are human readable
- high level languages can be translated to many different architectures / platforms
- high level languages take fewer lines of code to write
What is the role of an interpretter?
It translates a high level language such as Python, C++ etc. into machine code (binary) one line at a time at run time (when the code is executed)
What is the role of a compiler?
It translates a high level language such as Python, C++ etc. into machine code (binary) all at once. It produces compiled code which executes very quickly.
What is the role of an assembler?
It translates assembly code into machine code
What is the relationship between instructions in assembler and instructions in machine code
- there is a one-to-one (1:1) relationship between assembler instructions and machine code instructions.
- both have opcodes and operands
What type of code is represented below:
1001 0001
0001 0110
0011 0111
Machine code
What type of code is represented below:
INP
ADD 7
STA 99
Assembly code
What type of code is represented below:
result = input(“Enter the result”)
Source code
What is an IDE?
an Integrated Development Environment
What are the features of an IDE?
code completion code colouring auto-indentation debugging run-time environment syntax error highlighting
Describe two advantages of using a compiler instead of an interpreter
- The compiled code will run more quickly…
- …because the instructions only need to be translated once.
- …because the compiler optimises the code.
- Source code cannot easily be reverse engineered.
- …so is more easily protected from being copied.
- No translation software is required at runtime.