1.2.4

Cards (26)

  • There are 4 main types of languages: Low-Level, Procedural, Declarative, and Object-Orientated
  • A low-level language is one whose programming statements are related to the CPU. Low-level languages are almost machine code. Assembly language is an example of a low level programming language
  • Features of low level languages: They are CPU specific, making direct use of internal registers, Mnemonics are used as programming code such as ADD, HLT, Many different memory modes can be used and Labels are used as reference points to allow the code to jump from one part to another
  • Procedural Languages (High-level languages) - A high-level language is one that allows the programmer to set out, step-by-step what the computer needs to do. It does this in the form of instructions written in source code. Procedural language is imperative, meaning that it gives orders or instructions. A procedural language is sequential meaning that instructions carried out one after another. These steps form the program flow. Allows the use of subroutines for repeated code.
  • A block of code within a program that handles a smaller part of the program's task. It is often useful to break a task into smaller parts. Each of these smaller parts can be handled by separate blocks of code within the same program. These blocks are called procedures and are given a unique identifier.
  • A function takes one or more inputs which are called 'arguments' (sometimes called parameters). It performs an operation using those parameters. It then returns the result of that operation
  • The difference between a procedure and a function is that a function always returns a value
  • A variable is a location in memory which holds one or more values that the program will need. The values in the variable can change as the program runs
  • Declarative programming focuses on stating the desired result rather than the exact series of instructions that need to be performed to get the result. It is the role of programming language to determine how best to obtain the result and the details about HOW it is OBTAINED are ABSTRACTED from the User.
  • Assembly language is the next level up from machine code. This is converted to machine code using an assembler. Assembly language uses mnemonics rather than binary, which makes it easier to use than direct machine code.
  • A class is a construct that is used as a BLUEPRINT or TEMPLATE for an object
  • An object is an ENTITY that can be manipulated by the COMMANDS of the class
  • Example, the class called Box is defined. This class has 2 PRIVATE variables within called height and width. These Variables CANNOT be changed directly by any code outside the CLASS. The Functions/METHODS setHeight and setWidth have been defined that will set height and width of the object
  • There is a METHOD also called Box within the class. This is how an object is CREATED. This is called the 'CONSTRUCTOR' function. When called, a copy of this class is created in memory and given a NAME by the CALLING code. Another word for OBJECT is an 'Instance'
  • Example of Class, Attributes, Methods:
  • Inheritance means that the DATA and METHODS of a CLASS are automatically inherited by any other CLASS derived from the original one. Dervied class has all the properties (Attributes and Methods) from 'Superclass' (Parent Class). Dervied class is also called 'subclass'
  • Data encapsulation means that data within a class cannot normally be altered by any code outside the class
  • Polymorphism refers to a programming language's ability to process OBJECTS differently DEPENDING on their DATA TYPE or CLASS. It is the ability to redefine METHODS for subclasses
  • Assembly languages use various ADDRESSING modes: Immediate, Direct, Indirect and Indexed
  • Immediate Addressing - It means that the data to be used is hard coded into the instruction itself. It is the FASTEST method of ADDRESSING. E.g add 2 to content of accumulator --> Instruction: ADD2. Nothing has been FETCHED from memory. The instruction adds 2 to the ACCUMULATOR immediately. It is useful carrying out INSTRUCTIONS involving CONSTANTS rather than VARIABLES like Pi The operand is the actual value upon which the instruction is to be performed, represented in binary,
  • Immediate addressing is when a CONSTANT is used as part of the INSTRUCTION itself. No MEMORY or REGISTER access is required
  • With Direct Addressing an Instruction has a memory address included in it, enclosed within SQUARE brackets. At run time the data pointed to by the address must be fetched before it can be operated on. It means the codes referring directly to a LOCATION in memory. E.g. SUB(3001) --> the value held at the LOCATION 3001 in RAM is subtracted from the ACCUMULATOR. The operand gives the address which holds the value upon which the instruction is to be performed. Direct addressing is used in LMC.
  • Benefit of Direct Addressing - It is fast but not as fast as immediate. Drawback: The code depends on the correct DATA always being present at the SAME location.
  • Indirect addressing works like 2 direct memory fetches. The final data is pointed to by the address contained in the memory block pointed to by INDIRECT address STORED in the instruction. It means that the address of the data is held in an INTERMEDIATE location so that the address is first 'looked' up and then used to locate the data itself. Programs make use of software libraries that get loaded into memory at run time by the loader. The loader will place the library in a different memory location each time.
  • Example of Indirect Addressing
  • Indexed Addressing - An index register is used, which stores a certain value. The address of the operand is determined by adding the operand to the index register. This is necessary to add an offset in order to access data stored contiguously in memory such as in arrays.