Low Level Language

From Higher Computing Science
Jump to: navigation, search

This article is unfinished. Please consider joining and adding to this article. Read about Page layout beforehand.

Key points

  • Computers are digital devices, which means they only store the values 1 and 0
  • Programs and data all end up in low level form (1s and 0s) – language used to directly control a computer is called low level language or machine code.
  • Low Level Language code is very hard to read and understand
  • Low level language can be arranged into assembly code (groups of 1s and 0s are replaced with keywords to make the code easier to read)
  • Each instruction in assembly code is equivalent to 1 line of LLL

Information

Low Level Language is code that works directly on a processor. LLL works with raw data in memory addresses, rather than data types, and every instruction is one machine code instruction that would be fetched and executed.

LLL programs are usually represented in assembly. Assembly is not a high-level languages but a way of displaying machine code instructions instead of using 1s and 0s or hexadecimal.

LLL and Assembly

Here is an example of the machine code to load three items of data into memory, written in 6502 machine code. It is represented in hexadecimal code.

a9 01 8d 00 02 a9 05 8d 01 02 a9 08 8d 02 02

This would be very hard to debug. Assembly can be used to represent a program in a more meaningful way. Here is the same program as a list of assembly steps.

LDA #$01
STA $0200
LDA #$05
STA $0201
LDA #$08
STA $0202

In assembly code, registers are named and used. Data is moved between processor and memory. Each line of assembly is a symbolic representation of a line of machine code (we could work out each line of code in binary by separating out the 1s and 0s above into groups of 8).

Examples of Low Level Language code

Load and store

This is an example of loading and storing. The values are loading into the accumulator register (A), then stored into the memory of the computer. Try changing the addresses or the values.

Snake

This example is a functional version of the game, Snake. It uses the keys W,S,A and D to control.

Videos

More:

Further information

6502 tutorials

Test yourself

Teaching resources