Chapter 10 - Programming language translators
No description yet. This curated deck is ready for daily study.
Card preview (24)
What type of code is needed for the CPU to understand it and execute the instructions?
» Machine code
What is the relationship between assembly code and a binary code instruction?
» One - to -one
What does the machine code instructions that a particular computer can execute depend on?
» The instruction set
What is the processor instruction set?
» Manufacturer defines a set of these instructions that processor will be able to carry out that will only work with that particular processor » Each type of processor will have a different instruction set and different assembly code
What are 2 features of low level language?
» Specific to the instruction set of the processor » Non-portable (Meaning it can only be run on a processor of the same type that it was written for)
What is an advantage of using low level languages?
» Can make use of specific registers » Therfore programmers have greater control over the movement of data in and out of the processor
Why are low-level languages not portable?
» As the machine code and assembly code are designed for that specific processor » Therefore cannot be processed on other processors
What are 2 disadvantages of using low level languages?
» Difficult to write programs in low level languages as programmers need to have a very good understanding of the hardware being used » Do not have libraries
What are the categories of low level language?
» Assembly code » Machine code
What is the source code?
» Programming statements that are created by a programmer
What are 2 features of assembly code?
» Type of low-level-language, which is made up of commands/mnemonics » Each code translates into 1 machine code instruction
What are the advantages of high-level languages?
» Much easier to write/read words » Portable » Come with libraries
How are assembly code instructions translated into machine code? 4 marks
» Done by an assembler » Replaces mnemonic opcodes with machine code - LDA » Replaces numeric operands with machine code - NUM2 » Chekcs syntax and runs error diagnostics if erros is found
What does the compiler do?
» Translates whole program written in a high level language into executable machine code » Creates object code before being executed into machine code
How does a compiler work?
» Translates high-level code into machine all at once » Carrying out a number of checks first » Compiled code is non-portable » Code can be run without a translater being present
What does an interpreter do?
» Translate code from high level language into machine code line by line
What are the advantages of a compiler?
» Code can be optimised by the compilier » Can be distributed as machine code,meaning that the source code is hiddent
What are the disavantages of a compiler?
» You have to wait until the entire program is compiled before receiving any errors - may take a large time for a large program » Executable code is non-portable
What are the benefits of an interpreter?
» Errors will be reported as soon as they are ecountered - dont have to wait for the entire program to be compiled » Debugging is quick and easily
What are the drawbacks of an interpreter?
» Program requires an interpreter to be run » The interpreter takes up space in memory
What is object code?
» Halway code between high level and machine code » Set of instruction codes that is understood by a computer at the lowest hardware level, but not ready to be executed by the CPU
What is the difference between a compiler and an interpreter in terms of the steps to turn code in machine code?
» Compiler - Source code - Object code - Machine code » Interpreter - Source code - Machince code
What are 2 differences between a compiler and an interpreter?
» Compiler does produce object code - interpreter does not » Compiler translates the whole source code at once, intepreter analyses the code line by kine
What is a library, and give an example?
» Sections of code already pre-programmed by other developers containg useful routines » Such as RANDOM