Assembly, assembler, and machine language
They Are Different Things
There are three different but related concepts that people often confuse. Let’s clarify each one.
Assembly
Assembly is a programming language made up of simple mnemonics. It directly corresponds to the instructions of the platform you’re using. When writing Assembly code, you know exactly what the processor is doing and gain access to resources that might not be available in higher-level languages. We can call Assembly a low-level language, meaning it’s closer to the hardware.
Assembler
The Assembler is the program that reads the file containing Assembly mnemonics and converts them into machine language. It works similarly to a compiler.
Machine Language
Machine language is the only language the processor can interpret. It consists solely of codes, making it unreadable to humans. With practice, you can recognize some hexadecimal codes and match them to their Assembly mnemonics. For example, on the 8086 platform, the NOP instruction is 0x90 and 0xCD is the code for calling an interrupt. On the Z80 platform, NOP is 0x00.
Examples
Hello World in DOS x86 16 bits
ORG 100h
section .text
MOV AH, 40h
MOV BX, 1
MOV CX, 11
MOV DX, msg
INT 21h
MOV AL, 1
MOV AH, 4Ch
INT 21h
section .data
msg db "hello world"
Program Compiled by the Assembler
B4 40 BB 01 00 B9 0B 00 BA 14 01 CD 21 B0 01 B4
4C CD 21 00 68 65 6C 6C 6F 20 77 6F 72 6C 64
Modern-Day Use
In the past, Assembly was the only option besides typing machine codes directly. Today, things have changed, but Assembly is still an important language and is part of the code in many modern languages.
It’s used to access hardware-based cryptographic instructions or to achieve maximum speed in critical tasks, like context switching in modern languages such as Go.
Learning Assembly means understanding how computers work internally. Every professional programmer who takes their work seriously should learn Assembly.
The Computer
To better understand how computer components work, I suggest writing an emulator. It doesn’t have to be complete; it can be a small interpreter that reads and executes binaries, simulating an interpreter and a bit of RAM.
I created a simple 8086 emulator aimed at being educational. If you have any questions about the concept or how it works, let me know.