Skip to content

Instantly share code, notes, and snippets.

@jld
Last active December 14, 2015 18:09
Show Gist options
  • Select an option

  • Save jld/5127759 to your computer and use it in GitHub Desktop.

Select an option

Save jld/5127759 to your computer and use it in GitHub Desktop.
Hello, Assembly World
#ifdef __ELF__
#define SYMBOL_THING ""
#else
#define SYMBOL_THING "_"
#endif
int main() {
int r;
asm volatile(
".pushsection .rodata\n"
"1:\t.asciz \"Hello, World!\"\n"
"\t.popsection\n"
"\tlea 1b(%%rip), %%rdi\n"
"\tcall "SYMBOL_THING"puts"
: "=a"(r)
::"rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", "r11");
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment