summaryrefslogtreecommitdiffstats
path: root/src/emu/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/syscall.c')
-rw-r--r--src/emu/syscall.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/emu/syscall.c b/src/emu/syscall.c
new file mode 100644
index 0000000..fe0d83e
--- /dev/null
+++ b/src/emu/syscall.c
@@ -0,0 +1,23 @@
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "cpu.h"
+#include "mem.h"
+#include "syscall.h"
+
+void do_syscall(void)
+{
+ switch (GPR[1]) {
+ case SYS_exit:
+ exit(GPR[2]);
+ break;
+ case SYS_read:
+ GPR[2] = read(GPR[2], &MEM[GPR[3]], GPR[4]);
+ break;
+ case SYS_write:
+ GPR[2] = write(GPR[2], &MEM[GPR[3]], GPR[4]);
+ break;
+ default:
+ GPR[2] = -1;
+ }
+}