Programming : Low Level Languages

A computer can only process (execute) instructions that are written in machine code. A machine code instruction is a sequence of 1s and 0s. An example instruction which tests if a bit in memory is set to 1 is 0010100101110100110110. The machine code program below will convert an upper case letter stored in a particular memory location to lower case :

Machine Code ProgramExplanation
000011010100101010000000Load the contents of memory location E00 into the accumulator.
01101001Clear the carry flag.
0010101001000000Add 32 to the content of the accumulator.
000001010100101010000000Store the result back in memory location E00.

As you can see the program is quite difficult to understand! An assembly language is a set of simpler instructions (or mnemonics) which correspond to the machine code instructions that a computer understands. The assembly language equivalent of the program above is :

Assembly ProgramExplanation
LDA &E00Load the contents of memory location E00 into the accumulator.
CLCClear the carry flag.
ADC #32Add 32 to the content of the accumulator.
STA &E00Store the result back in memory location E00.

The program is still quite difficult to understand, but the instructions used in the program are much easier to remember than the binary codes in the machine code program.

A program called an assembler must be used to translate a program which has been written in an assembly language into machine code so it can be executed. Software such as operating systems and embedded control systems which must run in computers with only a small amount of memory are usually written in assembly language. For example a program to operate a washing machine would probably be written in assembly language.

Advantages and disadvantages of using assembly languages to produce programs are :

AdvantagesDisadvantages
It is much easier to learn assembly language instructions than machine code instructions. But it is still fairly hard to remember the instructions.

Programs written in assembly language can run faster and use up less memory than programs to do the same job written in a high level language.

Programs written in assembly language on one computer will not work on a different type of computer.

A programmer needs to know an awful lot about the computer hardware he is using to write a program in an assembly language.

GCSE ICT Companion 04 - (C) P Meakin 2004