Programming Paradigms

Computer Science A2 · Further Programming. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science A2 topics

The idea

A programming paradigm is a style of programming, a way of thinking about how to build a solution. Low-level programming uses the instruction set of the processor, and each instruction finds its data through an addressing mode.

Imperative (procedural) programming gives the steps in order, using variables, selection, loops, procedures and functions. Object-oriented programming (OOP) builds a program from objects, which hold data (attributes) together with the methods that work on that data.

Declarative programming states facts and rules. The programmer asks a query (a goal) and the language finds the values that satisfy it, without being told the steps.

Rules to remember

Common mistake

Students stop one step early with indirect addressing and load the address instead of the data. With LDI, go to the operand address, read the address stored there, then go to that second address for the value.

Worked example

Address 40 holds 62, address 62 holds 17 and address 63 holds 90. The index register IX holds 1. What is in the accumulator after each of LDM #40, LDD 40, LDI 40 and LDX 62?

  1. LDM #40 is immediate: the number 40 itself is loaded.
  2. LDD 40 is direct: the contents of address 40 are loaded, which is 62.
  3. LDI 40 is indirect: address 40 holds 62, so the contents of address 62 are loaded, which is 17.
  4. LDX 62 is indexed: 62 + 1 = 63, so the contents of address 63 are loaded, which is 90.

Answer: 40, 62, 17 and 90.

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← RecursionFile Processing and Exception Handling →Take a Computer Science A2 test