Hello world in Linux samples...in assembly language. For multiple CPU architectures
Go to file
Emil Lerch dca4fb897f
2022-12-23 15:59:04 -08:00
LICENSE add license 2022-12-15 11:27:50 -08:00
README.md add README 2022-12-23 15:59:04 -08:00
hello-aarch64.s add arm/riscv samples 2022-12-15 23:08:11 -08:00
hello-amd64.s add x86 ISA assembly 2022-12-15 11:28:54 -08:00
hello-arm7l.s add arm/riscv samples 2022-12-15 23:08:11 -08:00
hello-riscv64.s add arm/riscv samples 2022-12-15 23:08:11 -08:00
hello-x86-32.s add x86 ISA assembly 2022-12-15 11:28:54 -08:00


Hello world, in Linux, for multiple architectures


  • x86-32
  • amd64 (aka x86-64)
  • arm7l (32 bit arm)
  • aarch64 (64 bit arm)
  • riscv64 (RISC-V 64 bit)


I wanted to create a "real" sample of assembly in different architectures. By "real", the program should do some actual work, and interface with the operating system. Real programs typically have "functions", so our program should do that as well.

This repository serves to provide examples of assembly language implementations of a hello world program. The program prints a hard coded string, then exits. The exit code is calculated based on the square of the arguments (think argc in C). The argument count is inserted into the stack by Linux, and is described well at LWN. Doing this will use a function to square our argc and interface with Linux to print our string and set the correct exit code.

Linkers typically set the entry point of the program based on a symbol named "_start". In C, the _start entry point will perform some logistical work required by the compiler, then transfer control to main. Here in assembly, we can start work directly.

I have tried to fully annotate each architecture's assembly with suitable references. I have also left some optimizations out. Transferring function arguments to memory only to turn around and load them into registers makes little sense; however, this is a useful pattern, so I have not optimized these patterns.