Assembly language represents the lowest level of human-readable programming, serving as a direct bridge between software logic and hardware execution. Because assembly instructions map directly to a CPU's machine code, the language is entirely dependent on the processor architecture. Code written for an Intel or AMD processor (x86-64) will not function on an Apple Silicon or Raspberry Pi chip (ARM64).

To provide a functional understanding of this language, it is necessary to examine implementation samples across different environments. This guide provides validated code for the two most prominent modern architectures, covering basic output, arithmetic logic, and control structures.

Understanding the Architecture Specificity

Before deploying any assembly code, identify the target environment. Assembly code requires an assembler (like NASM, YASM, or GNU Assembler) to convert text into object files, and a linker (like ld) to create the final executable. The way a program interacts with the operating system—known as a system call—also varies by OS. For instance, Linux and macOS use different numeric codes to request the same "write to screen" action from the kernel.

Basic x86-64 Assembly for Linux (Intel Syntax)

The x86-64 architecture is the standard for modern desktop and server computing. The following sample uses the NASM (Netwide Assembler) syntax, which is widely regarded for its readability.

Hello World Example

This program prints a string to the standard output and exits gracefully.