summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--main.c8
2 files changed, 17 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 8590ef7..ff24a4f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,14 @@
CFLAGS = -O0 -g3
-mach_print: main.o mach_print.o
- gcc -o mach_print main.o mach_print.o
+DEPS = main.o
+
+# Uncomment to include the portable assembly file. If commented out, the
+# inline x86 code is included in main.o instead.
+#DEPS += mach_print.o
+#CFLAGS += -DEXTERNAL_MACH_PRINT
+
+mach_print: $(DEPS)
+ gcc -o $@ $^
clean:
rm -f mach_print *.o
diff --git a/main.c b/main.c
index 44140be..2755f8b 100644
--- a/main.c
+++ b/main.c
@@ -7,6 +7,14 @@
void mach_print(const char *);
+#ifndef EXTERNAL_MACH_PRINT
+asm (".global mach_print;"
+ " mach_print:;"
+ " mov $0xffffffe2, %eax;"
+ " lcall $0x7, $0x0;"
+ " ret;");
+#endif /* EXTERNAL_MACH_PRINT */
+
static void
mach_printf(const char *format, ...)
{