Added C header and printing demo.
authornorly <ny-git@enpas.org>
Thu, 27 Oct 2011 19:03:29 +0000 (20:03 +0100)
committernorly <ny-git@enpas.org>
Thu, 27 Oct 2011 19:03:29 +0000 (20:03 +0100)
.gitignore
Makefile
demo-printing.c [new file with mode: 0644]
libmalice.h [new file with mode: 0644]

index 5761abcfdf0c26a75374c945dfe366eaeee04285..2c5af6353f1a9d6296fad7706e4c5c3097d750a0 100644 (file)
@@ -1 +1,2 @@
 *.o
+demo-printing
index cdd89df8203d6d86d144266e1935de001ec73b8f..8cdac422c0c3f56578eff0c226d7c44d8562b1d5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,26 @@
 NASMFLAGS = -f elf
+CINCLUDE=
+CWARNS=-Wall -Wpointer-arith -Wnested-externs
+CFLAGS=$(CINCLUDE) $(CWARNS) -O2
+LDFLAGS=
 
-all: libmalice.o
+SRCDIR=src
+BINDIR=build
+
+all: libmalice.o demo-printing
 
 libmalice.o: libmalice.asm
        nasm $(NASMFLAGS) -o $@ $<
 
+.c.o:
+       cc $(CFLAGS) -c -o $@ $<
+
+demo-printing: demo-printing.o libmalice.o
+       ld $(LDFLAGS) -nostdlib -e _lmStart -o demo-printing demo-printing.o libmalice.o
+
+demos: demo-printing
+
 .PHONY : clean
 clean:
        rm -f *.o
-
-.PHONY : distclean
-distclean: clean
-       rm -f *~
-
-.PHONY : test
-test: all
+       rm -f demo-printing
diff --git a/demo-printing.c b/demo-printing.c
new file mode 100644 (file)
index 0000000..1399e58
--- /dev/null
@@ -0,0 +1,12 @@
+#include "libmalice.h"
+
+int lmMain(void)
+{
+  lmPrintString("Goodbye cruel world, I had too much ");
+  lmPrintInt32s(-559038737);
+  lmPrintChar('.');
+  lmPrintChar('\n');
+  lmPrintString("Oh my, I'm still here... ok, I'll exit now.\n");
+
+  return 42;
+}
\ No newline at end of file
diff --git a/libmalice.h b/libmalice.h
new file mode 100644 (file)
index 0000000..b8715dc
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _LIBMALICE_H_
+#define _LIBMALICE_H_
+
+void _lmStart(void);
+int lmMain(void);
+
+void lmExit(int exitstatus);
+
+void lmPrintChar(int chr);
+void lmPrintString(char *string);
+void lmPrintInt32s(int num);
+
+int lmReadChar(void);
+int lmReadInt32s(void);
+
+#endif