Category Archives

4 Articles

Modes of Addressing Memory

1.2.4 Types of Programming Language – Modes of Addressing Memory

Immediate Addressing

This is when the actual value is used in the operand. (SUB 15 would actually subtract 15 from the value in the accumulator)

Direct Addressing

This is when the memory location is used in the operand. (SUB 15 would get whatever is in memory location 15 from the value in the accumulator).

Indirect Addressing

This is when a memory location  is stored in the operand, but the memory address contains the memory address of the needed data. (SUB 15 means go to memory location 15,  then go to the address found in memory location 15, and take it away from the number in the accumulator).

This may be used to access larger addresses, which are otherwise unusable due to the number of bits avaialable.

Indexed Addressing

If you’re repeating the same instruction multiple times, you can set an index register and then add 1 each time to get the new data.

Set the index register to 0 for the first item, and then add 1 to it for each time the instruction is repeated.

For example: SUB 15, SUB 16, SUB 17, SUB 18.

SUB 15 would be index 0, SUB 16 index 1, etc, etc.

Linkers, Loaders and Libraries

1.2.2 (f) – Linkers, Loaders and Libraries

Libraries

Libraries are pieces of code which are already created and compiled and can be used in other programs.

They are useful because it means that code isn’t repeated, it saves the developers time and money, and they are usually very well tested.

Linkers and Loaders

Static linking – After code generation stage of compilation, a static linker is used to compile the object code with the libraries used to create machine code.

Dynamic linking – Dynamic linking is when the dependencies are loaded when the code is executed by loaders which are part of the operating system.

Stages of Compilation

1.2.2 (e) – Applications Generation – Stages of compilation

(1) Lexical Analysis

  1. All comments and white space is removed.
  2. Code is turned into tokens.
  3. Symbol table created.

(2) Syntactic Analysis

  1. Checks syntax.
  2. Syntax tree is created using the symbol tree.

(3) Code Generation

  1. Syntax tree is converted into object code.

(4) Code Optimisation

  1. Removes unneeded code to make sure it runs as fast as possible, such as unused functions or variables.

 

Structured Query Language (SQL)

1.3.2(d) – SQL

SELECT, FROM & WHERE

Used to get data from a database.

They follow the following format:

SELECT (something) FROM (table)

For example:

SELECT name FROM Students; 

WHERE can be used to add a condition to the query, for example:

SELECT name FROM students WHERE name = “Jeff”

SELECT statements can also be nested.

SELECT name FROM book WHERE Author = (SELECT id FROM Author WHERE surname = “Steinbeck”)


LIKE & Wildcards

LIKE is used alongside WHERE to speficy a specific format, and uses wildcards. The two you need to know are ‘*’ and ‘%’.

‘*’ means ALL

‘%’ means 0 or more unspecified characters.

It is used like: SELECT (something) FROM (table) WHERE (field name) LIKE (format)

For example:

SELECT * FROM book WHERE bookName LIKE ‘a%” finds any book which starts with “a”.


 AND & OR

AND and OR can be used alongside WHERE.

AND is used to only return the record if all of the conditions are true.

OR is used to only return the record if any of the conditions are true.

For example:

SELECT * FROM book WHERE bookName = “Great Expectations” AND ISBN = “9781548731854”

SELECT * FROM book WHERE bookName = “Great Expectations” OR ISBN = “9781548731854”


DELETE, INSERT & DROP

DELETE is used to delete records from a table.

For example: DELETE FROM book WHERE bookName = “Great Expectations”

INSERT is used to add new records to a table.

For example: INSERT INTO book (id, name, author) VALUES (1, “Great Expectations”, “Charles Dickens”)

DROP is used to delete tables or databases.

For example: DROP DATABASE bookInfo or DROP TABLE book


JOIN

JOIN returns multiple records joined by a field which is the same in both.

For example:

SELECT name FROM Student JOIN Course ON Student.CourseID = Course.ID