成人快手

Principles of programming - EduqasLow-level languages

Programming languages can be categorised as high-level and low-level. They each have very different characteristics and are used for different purposes. Machine code and assembly languages are very different to the languages most programmers use.

Part of Computer ScienceUnderstanding Computer Science

Low-level languages

are languages that sit close to the computer's set and do not resemble natural languages such as English or Welsh. An is the set of instructions that the understands. Every processor has its own instruction set.

Two types of low-level language are:

Machine code

contain that programmers use to instruct the computer what to do. They are restricted by the limited number of commands that they can implement. In fact, high-level commands are nothing more than a series of machine code instructions in a more readable format.

Machine code is made up of bit patterns that are executed directly by the CPU.

Advantages of using machine code

Writing in machine code allows programmers to do things that might not be possible in a high-level language. High-level language commands are like predefined sentences, where machine code instructions are like predefined words. Using words as opposed to sentences gives more flexibility - to build complex sentences or to keep programs very short and simple.

For example, many high-level languages do not allow the programmer to specify items such as the screen's refresh rate. However, it is usually possible to specify this using machine code.

Disadvantages of using machine code

Machine code is notoriously difficult to write in, understand and because it consists of code. Usually, when programmers need direct control they use another type of low-level language called assembly language.

Assembly language

Assembly language sits between and high-level languages. While high-level languages use to form instructions, assembly language uses (short abbreviations). Each mnemonic directly corresponds to a single machine code instruction. As a result, assembly language is known as a one-to-one language. Some examples of mnemonics are shown in the table.

MnemonicAction
LDATransfers a number from RAM (random access memory) to the accumulator.
STATransfers a number from the accumulator to RAM.
ADDAdds the value held in a memory address to the value held in the accumulator.
SUBSubtracts the contents of the accumulator from the contents held in a memory address.
BRAGoes to another memory address.
MnemonicLDA
ActionTransfers a number from RAM (random access memory) to the accumulator.
MnemonicSTA
ActionTransfers a number from the accumulator to RAM.
MnemonicADD
ActionAdds the value held in a memory address to the value held in the accumulator.
MnemonicSUB
ActionSubtracts the contents of the accumulator from the contents held in a memory address.
MnemonicBRA
ActionGoes to another memory address.

In assembly language, programmers write programs as a series of mnemonics. Mnemonics are much easier to understand and debug than machine code, giving programmers a simpler way of directly controlling a computer.

In assembly language, a machine code program would look like this:

INP
                    STA 06
                    LDA A1

Writing in mnemonics is easier for programmers because they are usually brief representations of the commands. They are quicker to write than binary and it is easier to spot mistakes.

Little Man Computer is a simulation of a very basic processor using . It uses an example of simple assembly language that contains a limited set of mnemonic instructions that can be used to program simple assembly programs. Little Man Computer is freely available on the internet for students to use.