Skip to content

Instantly share code, notes, and snippets.

@michidk

michidk/hello.rs Secret

Last active October 10, 2026 13:22
Show Gist options
  • Select an option

  • Save michidk/0addb0fdcb7de291033027e742f44522 to your computer and use it in GitHub Desktop.

Select an option

Save michidk/0addb0fdcb7de291033027e742f44522 to your computer and use it in GitHub Desktop.
Rust 1.98.1 naked assembly Hello World: 209 bytes with default GNU ld script, 153 with minimal.ld; 1616 unoptimized with required static entry-point flags; exits 0 after returned write errors
#![no_std]
#![no_main]
use core::{arch::naked_asm, panic::PanicInfo};
static MSG: [u8; 14] = *b"Hello, World!\n";
#[unsafe(naked)]
#[unsafe(no_mangle)]
extern "C" fn _start() -> ! {
naked_asm!(
"mov al, 1",
"mov edi, eax",
"mov esi, offset {msg}",
"mov dl, 14",
"syscall",
"xchg eax, ebx",
"xchg eax, edi",
"mov al, 60",
"syscall",
msg = sym MSG,
);
}
#[panic_handler]
fn panic(_: &PanicInfo<'_>) -> ! { loop {} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment