Last active
August 29, 2015 14:25
-
-
Save maxdeliso/a6f9734b1339df39370c to your computer and use it in GitHub Desktop.
uch - messaging program written in assembly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC=gcc | |
LD=ld | |
CFLAGS=-Wall -Wextra -pedantic -std=c11 -g | |
LDFLAGS=-entry run | |
uch: uch.o | |
$(LD) $(LDFLAGS) $< -o $@ | |
uch.o: uch.c | |
$(CC) $(CFLAGS) -c $< -o $@ | |
clean: | |
rm -f uch uch.o |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <x86_64-linux-gnu/asm/unistd.h> | |
#include <stdint.h> | |
static _Noreturn void __exit(const uint64_t exitCode); | |
void run() { | |
__exit(0); | |
} | |
static _Noreturn void __exit(const uint64_t exitCode) { | |
__asm__ ("mov %[n], %%rax;" | |
"mov %[c], %%rdi;" | |
"syscall;" | |
: /* no output */ | |
: [n] "i" (__NR_exit), [c] "r" (exitCode) | |
: "rcx", "r11" ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment