4.6 Fundamentals of Computer Systems (Translators) Flashcards
What is the need for translators
-Program code can only be excecuted in machine code meaninng programs in assembly or HLL need to be translated into machine code
before they can be executed by a computer
How does an Interpreter work
- Translates and exceucutes each line of code line-by-line.
- For each line a syntax-check is performed and if there are no errors it calls predefined routines to translate lines.
What are the advantages of Interpreters
- They can run syntactically correct parts of code evemn when there are errors in other parts of code
- They can be used for debugging and development as they terminate at errors and can be used for testing in a sandbox
- More portable than compilers
Drawbacks of using an interpreter
- Program code will need translating every time. This means that the overall time needed
to execute a program can be very long. - The process of using it takes up a lot of system resources like RAM as memory space is need for both the source code and the interpreter
- The source code can only be translated and therefore executed on a computer that has the same interpreter installed.
- The source code must be distributed to users, whereas with a compiled
program, only the executable code is needed.
How does a compiler work
A compiler converts the whole source code into object code before the program can be executed.
Benefits of using a compiler:
- Once the source code has been compiled you no longer need the
compiler or the source code and you normally don’t need to recompile. - If you want to pass your object code on to someone else to use it is difficult to reverse engineer to obtain the source code
-Compiler optimises code in the form of object code , as it does not need to be translated but only executed meaning that it runs faster.
Drawbacks of using a compiler:
- Because the whole program has to be recompiled every time you make even the slightest alteration to your
code, it can take a long time to debug. - The compiled code will only execute on a computer with the same processor instruction set
- The compiler will not produce an executable file if a syntax error is encountered.
What does an assembler do
Assemblers translate assembly code programs into executable code.
What is Intermediate code (bytecode)
- A semi compiled form of code that is not directly executable
- Containing hardware specific parameters and instructions that will be run by a virtual machine, which is platform independent
How is intermediate code used subsequently
- An interpreter is used to convert the hardware specific instructions of the intermediate code into machine code
Why do some compilers produce intermediate code as a final output
- Can be executed on any computer using it regardless of the specific processor instruction set.
What is the difference between source and object code
Source code is the human-readable code written by a programmer, while object code is the machine-readable output produced after the source code is compiled.
Why is it an advantage to use as few gates as possible in a logic circuit
- Minimises the cost of production
- Reduces delay and speeds up processing
- Reduces Power consumption as less system resources will be used.
Explain the general purpose of a D Type Flip Flop
synchronous sequential circuit that is used to store state of a single binary data input, and also as a memory unit