Application Generaton Flashcards
1) What is machine code?
2) What are Opcodes and Operands?
1)
-Processors only understand machine code
-Machine code is binary sequences that represent instructions and data
-Originally no choice but to code in machine code
2)
-Opcodes are the sequences contain instructions
-Operands are the sequences containing data
What is an instruction set?
- Each processor has its own instruction set
- They are the instructions that are available for a certain processor to process
- Code has to be written for each processor
1) What is assembly language?
2) What is an assembler?
1)
-Written in mnemonics making code easier to read and write
-Not very portable (different chips will have different languages)
2)
-Assembler converts assembly into object code
Why were HLL’s introduced?
- in the 19950’s due to limitations on assembly code, more money was spent on developing software than purchasing hardware. Even with the relatively higher cost of hardware compared to today
- Fortran the first HLL made code more-readable
- HLL needs interpreters and compilers in order to convert it into something the CPU can utilise
What is an interpreter? +/-
*Reads code line by line
*Each line is converted into machine code
*Then Machine code is executed
+Useful when debugging as the execution will terminate at the line where the error occurs
-Runs slower
-May involve the translation of the same code multiple times
-User needs to have access to an interpreter to execute the code which takes up more memory
What is a compiler?
- Takes HLL source code and converts it to object code
- Compiled code can be run as often as required
- Faster than interpreted code after complication. The complication takes longer
- Hides the original code as compiled code is machine code
- small programs can compile in seconds, more complex can take a while
- Unlike interpreted code you do not have to release source code for other people to run it meaning other people cannot steel it
What is object code?
- Intermediary step taken before producing ‘pure’ machine code
- contains placeholders where library code should be placed
- Passing the object code through a linker generates machine code that can be executed by the processor
What are utilities? Examples?
- Relatively small program with one purpose usually concerned with system maintenance
- Anti Virus programs: detects and removes viruses
- Disk defragmentation: Groups all parts of paged/segmented data so they can be read in one go
- Compression: Reduce amount of space data takes up in storage. Makes use of regularly repeated patterns in data
- File managers: Allow files and directories to be moved, copied, deleted and renamed
- Backup utilities: Allow backups to be automatically made of specific data
What are applications? Examples?
- Software which allow user to perform a task or produce something
- Word processors, spreadsheet packages, presentation software, desktop publishing software, image editors, web browsers and computer aided design packages
How to compilers work? (In general terms)
-go through a defined sequence of steps
Each step brings the high level code closer to machine code
What is lexical analysis?
- All comments and whitespace stripped from code
- HHL converted into tokens
- tries to ID the reserved words (IF, THEN etc), operators, variables and constants
- all separate entities become their own tokens
What is a symbol table used for?
- Throughout compilation the complier must track the variables and subroutines within the code
- the names of these are added to the symbol table
- later on, info such as data type and scope (global/local) are added
What is syntax?
-set of rules that govern its structure
What is syntax analysis?
- compiler checks the code has been written in line with syntactic rules of the language
- if code doesn’t, a list of syntax errors will be generated
- generates an abstract syntax tree (AST) that will represent program
- if tokens generated in lexical analysis do not fit into this tree than we have a syntax error
What is the code generation step of compilation?
- the code is generated as an AST
- complainer now takes this and converts into object code
What is the optimisation step of compilation?
- we want code to run efficiently (as fast as possible or as low memory usage as possible)
- optimisation can remove redundant/unreachable code or replace instructions with more efficient alternatives
- occurs during and after code generation
What are libraries?
- Reusable, complex code written by other programmers to simplify programming tasks
- Accessed through API’s (application programming interface)
- not uncommon for a library to be written in one language and have API’s designed to allow other languages to work with it (different languages will be suited to different problems)
What are linkers/loaders?
- if we have used libraries we need to ensure they are included with final code
- a linkers is required to include the library code and our compiled code into a single exe
- linkers can be static or dynamic (loaders)
What is static linking?
- all library code is inserted directly into the program when it is complies
- final exe very large
- can have multiple exe’s with all the same library embedded
What is dynamic linking?
- attempt to bypass the size of static linking
- compiled versions of the library are stored
- OS links a program to the library when it is run
- loaders are core parts of the OS and are tasked with loading a program into memory
- reduces duplication of library packages