Assembly and high-level programming lanaguges

Assembly code

Assembly language

Rather than machine code, programs can be written in human readable form. For example, we can use short English language strings instead of hexidecimal or binary.


Assembly code can be converted to machine code using an assembler.

The assembler takes the assembly code as input and returns machine code.

Stack buffer overflow

High-level programming languages


Directly to machine code


Evaluate each line as it is run


Compile to code in intermediate language which has its own compiler for further compiling




Assigning variables

Direct storage and pointers

Variables can either refer to a part of memory, reserving that space for just that variable, alternatively, rather than store value, we can store pointer.

Assigning variables from other variables

Static and dynamic typing

Mutable and immutable variables

Garbage collection


So in first case we have \(x=2\) and \(y=2\), and then we want to change both to \(3\).

In first example, initiate both and store \(2\) in memory twice. update both.

In second example we can have x and y have the same value of a pointer, pointing to a third memory location. we can the update this memory location to change both to \(3\).

Two variable can be the same by value, but additionally by pointer.

eg \(x=2\) and \(y=2\). \(x==y\), but if they have the same pointer, they are the same thing. changing one changes the other.

We can update \(x\) and \(y\) will automatically update

When we say \(x=2\), \(y=x\) we are either making \(y\) mutable or immutable. mutable means same pointer. language specific rules apply.

Integer caching

If we set \(x=2\) we can either create \(2\) in memory, or simply point \(x\) to \(2\), which is already in memory

That means if we do \(x=2\) \(y=2\) they have the same pointer.

Can also cache some other common data values, eg empty lists.

Makes sense if pointer is smaller in memory than value.



Not separate, code is replaced before it is run



Global and local variables

Call by value and call by name

Two ways of giving args to parameters, value evals when func called, name evals whenever needed.

Memory allocation and stack buffer overflow

Can cause change of state outside of function.

Recurrance and the master method

Stack overflows

Write too many instructions to stack. can be caused by infinite recursion. eg fun x() return x()).

Segmentation faults and memory access restrictions


Propositional logic

Zero-order logic

Equality, inequality

Structured programming

Go to



For each loops

Loop x times

Defining and calling functions




Integer caching

if we set x =2 we can either create 2 in memory, or simply point x to 2, which is already in memory

that means if we do x=2 y=2 they have the same pointer

can also cache some other common data values, eg empty lists

makes sense if pointer is smaller in memory than value