Program Construction Flashcards
Machine Code
The CPU can only understand machine code, it is made up of coded instructions and data
Assembly Language
This language has a small set of commands which represent certain pieces of machine code. This helped programmers as they didn’t have to remember sets of binary code, instead they learnt commands.
High Level Languages
Its purpose is to be easier to write and still be easily translated into machine code so that it can be processed by the CPU.
Features of high level language
Each line of code translates into multiple lines of machine code, Does not give direct access to registers or other CPU features, Instructions are semantic and do not reflect the design of the processor.
Features of low level language
Each line of code translates into a single line of machine code, Allowing the developer to manipulate registers and the CPU directly, Instructions are directly linked with the instruction set of the processor and are based on the design of the processor.
Compiler
Converts the whole code into one file
Interpreter
Converts the source code into machine code 1 line at a time.
Assembler
It converts mnemonic assembly language instructions into machine code.
Lexical analysis
Comments and whitespace are removed from the source code. The high-level code is then converted into tokens.
Using the tokens, a symbol table would be produced containing all of the program key words and identifiers and their relative data types and memory locations for variables.
Syntax analysis
Check that the way the tokens are arranged makes sense in the grammar of the language.
Semantic analysis
Check whether the tokens themselves make sense.
Code generation
Producing machine code and storing it as an object file. Allocating memory locations to variables and constants. Working out relative addresses and adjusting the machine code appropriately.