Skip to content
BetterDL

Assembly language

Also called: assembly, assembler, assembly code, mnemonic, mnemonics

A human-readable way to write machine instructions using names like LOAD E or ADD F. An assembler turns each line into its binary word.

Writing programs as hex words like 1E 3F 2D 00 is error-prone. Assembly language gives each opcode a short name, a mnemonic, and writes addresses as numbers or labels. One line of assembly is one machine instruction.

  • LOAD E is 1E.
  • ADD F is 3F.
  • HALT is 00.

An assembler is the program that translates assembly into machine code: it looks up each mnemonic's opcode, fills in the address field, and packs them by the instruction format. Going the other way, from words back to mnemonics, is disassembly.

Assembly is still one-to-one with the hardware. Unlike a high-level language, it has no variables, loops or if-statements built in. A loop is a jump instruction backwards; an if-statement is a conditional branch over some code.

To write a Tiny8 program, decide where each instruction and each data word goes in the 16-word memory, then write one line per word.

Worked example

Example

Assembling a short program

Assemble this Tiny8 program, starting at address 0: LOAD C, SUB D, STORE E, HALT.

  1. 1.

    LOAD C: opcode 1, address C → 1C.

  2. 2.

    SUB D: opcode 4, address D → 4D.

  3. 3.

    STORE E: opcode 2, address E → 2E.

  4. 4.

    HALT: opcode 0, address ignored → 00.

  5. 5.

    Memory 0–3: 1C 4D 2E 00. It computes M[E] = M[C] − M[D].

Common mistakes

  • Writing HALT as 0. Every Tiny8 word is two hex digits: 00.

  • Thinking assembly has variables. Names like E are just memory addresses.

Practice Assembly language

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Assembly language is taught in Basic CPU / Computer Architecture.