Skip to content

Instantly share code, notes, and snippets.

@rexim
Created September 13, 2019 02:36
Show Gist options
  • Save rexim/8c252ce17542693f850171034b9bc521 to your computer and use it in GitHub Desktop.
Save rexim/8c252ce17542693f850171034b9bc521 to your computer and use it in GitHub Desktop.
// gcc -nostdlib main.c
inline static
void write_syscall(int fd, const void *buf, unsigned int count)
{
asm("movq $1, %rax");
asm("syscall");
}
inline static
void exit_syscall(int code)
{
asm("movq $60, %rax");
asm("syscall");
}
void _start()
{
char message[] = "Hello, World\n";
write_syscall(1, message, sizeof(message));
exit_syscall(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment