Classification of programming languages and translators - AQALow-level languages

High-level languages allow programmers to write instructions in a language that is easier to understand than low-level languages. Translators translate programs written in high-level languages into the machine code that a computer understands.

Part ofComputer ScienceTheoretical knowledge

Low-level languages

are languages that sit close to the computer's . An instruction set is the set of instructions that the processor understands.

Two types of low-level language are:

Machine code

Machine code is the set of instructions that a understands directly and can act upon. A written in machine code would consist of only 0s and 1s - . This is very difficult to write and . Even a very simple program could have thousands of 0s and 1s in it.

Assembly language

Assembly language sits between machine code and in terms of ease of use. While high-level languages use to form instructions, assembly language uses - short abbreviations. Each mnemonic directly corresponds with a machine code instruction. Here are some examples of mnemonics:

MnemonicAction
LDALoads a value from a memory address
STAStores a value in a memory address
ADDAdds the value held in a memory address to the value held in the accumulator
SUBSubtracts from the accumulator the value held in a memory address
MOVMoves the contents of one memory address to another
MnemonicLDA
ActionLoads a value from a memory address
MnemonicSTA
ActionStores a value in a memory address
MnemonicADD
ActionAdds the value held in a memory address to the value held in the accumulator
MnemonicSUB
ActionSubtracts from the accumulator the value held in a memory address
MnemonicMOV
ActionMoves the contents of one memory address to another

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.

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

Little Man Computer (LMC) 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 which can be used to program simple assembly programs. LMC is freely available on the internet for students to use.

Opcodes and operands

Many machine code and assembly instructions contain two parts:

  • the - this is the actual instruction
  • the - this is a value that the instruction uses or manipulates

Consider this set of program instructions:

Assembly languageOpcodeOperandInstruction
INP100100000000Input a number
STR 6001100000110Store it in address 06
LDR A1010110100001Load data from address A1
ADD #10001000001010Add the number 10 to the loaded address
Assembly languageINP
Opcode1001
Operand00000000
InstructionInput a number
Assembly languageSTR 6
Opcode0011
Operand00000110
InstructionStore it in address 06
Assembly languageLDR A1
Opcode0101
Operand10100001
InstructionLoad data from address A1
Assembly languageADD #10
Opcode0010
Operand00001010
InstructionAdd the number 10 to the loaded address

Both opcode and operand values are ultimately represented in binary. However, values may also be represented in when programming as this number system can represent larger values in fewer characters, for example, 250 is 11111010 in binary, but only FA in hexadecimal. Hexadecimal is therefore easier to read and understand by humans.

Compare high-level and low-level languages

Programming languages can be classified into high and low-level languages. High-level languages allow programmers to write in a language that is easier for them to understand than low-level languages. Low-level languages are closer to the computer’s instruction set.

Advantages of high-level languages

  • It is easier for programmers to read, write and understand high-level languages.
  • One instruction can represent many instructions of machine code.
  • The high-level code is portable, so it will work on different machines and .
  • The programmer doesn’t need to know how the computer will store the data.

Disadvantages of high-level languages

  • The code must be translated before it can be understood by the computer.
  • The programmer can’t control how the will interpret the code, so programs might be less efficient.

Advantages of low-level languages

  • The code does not need to be translated for the computer to understand it.
  • The program will be faster and more efficient.
  • The programmer can control what the CPU will do and how its memory will be used.

Disadvantages of low-level languages

  • It is very difficult to learn how to program in a low-level language.
  • The code will only work on one type of machine or processor.
  • The programmer needs to know how the CPU works.