2.5 Translators and Facilities of Languages COMPLETE Flashcards
What are assemblers responsible for?
Converting low-level assembly language into machine code.
How do assemblers have a one to one relationship?
Each line of assembly code is converted or looked up by the assembler and translates directly into one line of binary.
Why are assemblers processor specific?
Each CPU has a unique set of instructions for itself, which won’t work on other CPU’s
Define translator
Any program which converts source code (code written in a programming language) into the machine code (binary).
What are compilers and interpreters responsible for?
Converting high-level languages into binary.
How do compilers and interpreters have a one to many relationship?
Each single line of high level source code written by a programmer translates into many lines of binary.
How do interpreters translate a high level language?
They take one line of high language program code and convert it directly into binary and then run it
Why are interpreters useful when debugging a program?
Because they will stop at the first line which contains an error.
What is a disadvantage of interpreters debugging a program?
The interpreter will require access to the whole source code each time it needs to translate it.
How are interpreters debugging a program inefficient?
It’s a security issue, the code can be stolen.
The code executes quite slowly, especially for large programs.
How do compilers translate a high level language?
They take the entire program and converts it into object code which can be quite slow.
Why can a compiler be better than an interpreter?
The compiled object code will run a lot faster than an interpreted version.
Why can an interpreter be better than a compiler?
If the program needs to be updated now, the original source code would have to be changed and a new version compiled and distributed.
What is an integrated development environment (IDE)?
A program which provides resources and tools with high level languages.
What are some included tools?
Multi-window text editing.
Run Time Environment.
Built-in translator.
Integrated debugger.
Why do most professional programmers use more complex IDE’s?
Because they provide a whole host of extra features and resources to help them complete their complex programs faster.
What is a text editor?
A text area used for programmers to enter code directly into the IDE.
It contains:
Syntax highlighting.
Autocomplete code.
Self-indentation support.
What are error diagnostics?
A feature which reports errors (mainly syntax) in the code and potential problems along with where they’re found and often suggestion on who to fix.
What are runtime environments?
Software to support the execution and running of programs.
They allow developer to run their code during development in order to check for logical error.
What is auto-documentation?
A feature which tracks variables declared by the programmer in order to produce self – documentation.
It helps with:
Program maintenance.
Debugging.
Support.
What is high-level language?
A programming language that uses key words such as PRINT or IF and it has a set of grammar rules (syntax) making it close to English.
E.g. python, java or C++
What is assembly language?
A low level language written in mnemonics that closely reflects CPU operations used for device drivers.
What is a driver?
It tells a specific hard drive what to do and is used when fast execution is required or there is limited memory / file size.
Why does the high level language need to translated into binary?
Because the only thing computers understand is binary as the 1’s and 0’s represent on and off for each instruction.
Why might someone compile their code?
If they made a new program worth millions and wanted to sell it to people, they could compile the code and then send them it in binary so the people can’t copy your source code.
What is a disadvantage of compiling?
If there are errors in the source code, you will have to fix it and compile the code again which takes time.
Define a program
Instructions which tell the computer what to do to find a solution to a problem.
Which languages are hardware specific and not portable (needs to be modified to run on another computer?
Machine and assembly.
Why might high-level languages need to be modified?
Because they can’t run on different OS.
Instructions for computers are written in programming languages that need to be translated into what before the computer can understand them?
Machine code
Is machine language a high level or low level language?
Low level
Is assembly language a high level or low level language?
Low level
Processors only understand instructions written in…
1s and 0s
At the processing level, what form are computer programs in?
Millions of 1s and 0s known as machine code or machine language
Computer programs being in the form of millions of 1s and 0s is known as…
machine code / machine language
Each instruction in assembly language is directly equivalent to…
one in machine code
How are mnemonics used to replace the command represented as strings of 1s and 0s with assembly language?
e.g. ADD is a mnemonic used to replace the binary command to add numbers together
Words called _________ are used to replace the command represented as strings of 1s and 0s in machine code with an assembly language
mneumonics
What are high-level languages?
Programming languages that resemble human languages
High-level languages use key words such as…
‘print’, ‘if’, ‘then’, etc
What do high-level languages do?
Address the programming logic rather than dealing with hardware issues such as memory addressing
Most programs are written in high/low level languages?
high
When is assembly language often used?
In programs used by embedded systems such as those in cameras, microwaves and televisions
Why is assembly language often used in programs used by embedded systems?
It can be used to directly control system hardware
Give an example of an embedded system
Any from cameras, microwaves, televisions, etc
High/low level languages are used to write device drivers and real-time systems where speed is essential
low
What type of programming language is specific to each type of CPU?
Assembly
With assembly language, programs written for one type of CPU can/cannot be used on others
cannot
Most software is developed using a high/low-level language
high
Why is most software developed using a high-level language?
It is less time-consuming to write and quicker to test
Programs written with low/high level languages are portable from one machine to another
high
Most low/high level languages can be used with different types of CPU
high
Programs written in assembly languages and high-level languages must be translated into what before the processor can execute them?
machine code
Give the 2 examples of translators
Compilers and interpreters
What does a compiler do?
Translates the source code into a standalone, machine code program that can then be executed by the processor
With a compiler/interpreter, the translation is done once and as a separate process
Compiler
With a compiler/interpreter, the program that is run is already translated into machine code so it can be executed more rapidly
Compiler
With a compiler/interpreter, it protects the software from competitors who would otherwise be able to see the source code
Compiler
When using a compiler, what happens if any errors are encountered?
It carries on trying to compile the program and reports the errors at the end. Programmers then have to use the error messages to identify and remove the bugs
What do programmers have to do when there are error messages when executing a programme?
Use error messages to identify and remove the bugs
With a compiler, you cannot change the program without…
going back to the original source code, editing that and recompiling
What does an interpreter do?
Translate high-level code line by line into machine code. It is needed each time the program is run
With a compiler/interpreter, when an error is found, the interpreter reports it and stops and pinpoints the error so that the programmer knows where it has occurred
interpreter
With a compiler/interpreter, the code is not platform specific and can be run on different operating systems and platforms as long as there is one of these
interpreter
With a compiler/interpreter, the program can be easily edited as it always exists as source code
interpreter
With a compiler/interpreter, every line has to be translated every time it is executed and therefore it is slower to run
interpreter
What do assemblers do?
Translate the mnemonics of assembly language into machine code instructions
Assembly language is very different from/similar to machine code
similar to
How many assembly language instructions are there for each machine language instruction?
1
Explain why program code developed using a high-level language must be translated
Instructions must be translated into machine code as that is the only language that the processor can execute
What does IDE stand for?
Integrated Development Environment
An IDE provides…
facilities for computer programmers to develop software more efficiently
What is a source code editor?
A text editor designed for writing and editing source code
What does syntax highlighting do?
Displays source code in different colours and fonts according to the type
What does bracket matching do?
Highlights matching sets of delimiters such as brackets and quotation marks to help the programmer navigate through the code and spot any that do not match
What does auto indentation do?
Automatically indents the next line if it is required
What does autocomplete/word completion do?
Predicts a word or command that the user is typing and completes it
With error diagnostics, facilities are provided to…
debug the code
What does single-stepping allow in terms of error diagnostics?
The code to be run and inspected one line at a time. It shows the result of a single command
What do breakpoints allow in terms of error diagnostics?
The code to be stopped at selected positions. If there is a problem, then the programmer can set sequential breakpoints to see in which section the error occurs
In terms of error diagnostics, what does variable tracing allow?
Allows the programmer to inspect the values of variables at any point in the program to check if they are as expected
What does run-time environment allow?
The code to run within the IDE as though it was actually running on the processor
What does run-time environment mean a programmer doesn’t have to do?
Waste time preparing the program to run on the real CPU
In order for code to run within an IDE, it has to go through what?
A translation
Give 3 examples of tools available in an IDE
Any 3 from source code editor (syntax highlighting, bracket matching, auto indentation and autocomplete), error diagnostics (single-stepping, breakpoints and variable tracing) and run-time environment