1.2.4 Types of Programming Techniques Flashcards
What is a programming paradigm?
- To describe an example of a pattern
- To describe an example of a way of doing things
Machine code (4)
- Least abstract
- Closest to what happens on a computer
- Programs directly in 1s and 0s
- These translate into matching electrical signals e.g. 1 for high voltage and 0 for lo
Assembly language (4)
- Low level language that uses short code (mnemonics)
- Each mnemonic matches a specific sequence of 1s and 0s
- One-to-one relationship
- Written in assembly language and translated by a specific assembler
High Level language
- Written in the language that is designed to be easily understood by humans
- Uses syntax that is similar to human language to form instructions
- Must be translated into machine code before it can be run (compilation)
Features of procedural languages
- Focus on telling a computer exactly what to do by way of step-by-step instructions
- Lay code as a series of statements (SSI)
- Code is developed in a modular way using functions and procedures
Features of procedural languages
- Pre defined functions
- Local variables
- Global variables
- Parameter passing
- Modularity
- Procedures
- Library
What are pre defined functions?
Functions pre-written within a programming language
What are local variables?
A variable that can only be accessed within the specific function or procedure it was declared in
What are global variables?
A variable that can be accessed throughout the whole program and used by all modules
What is parameter passing?
Allows variable values to be passed into procedures and functions for use in those blocks of code
What is modularity?
The concept of separating the functionality of a program into individual, interchangeable blocks, each designed to carry out a single task
- These all combine to make a complete program and make the program more readable
What is a library?
A collection of pre-built functions and procedures that can be linked and used y a programmer in their own code
LMC: ADD
Add
LMC: SUB
Subtract
LMC: STA
Store
LMC: LDA
Load
LMC: BRA
Branch always
LMC: BRZ
Branch if zero
LMC: BRP
Branch if positive
LMC: INP
Input
LMC: OUT
Output
LMC: HLT
End program
LMC: DAT
Data location
Different modes of addressing memory
- Immediate addressing
- Direct addressing
- Indirect addressing
- Indexed addressing
What is the opcode?
Part of the instruction that specifies which operation the processor should perform
What is the operand?
The pieces of data for the opcode to act on
What is immediate addressing?
- The operand specifies a values which will be used in the operation
What is direct addressing?
- The operand specifies the address of a memory location
- Contents of this memory location will be used in the operation
What is indirect addressing?
- The operand specifies the address of a memory location which holds the address if another memory location
- Contents of the second location will be used in the operation
What is indexed addressing?
- Operand specifies the address of a memory location
- Contents of the index register will be added to the address to determine a second address
- Contents of the second location will be used in the operation