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.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/emu/syscall.c b/src/emu/syscall.c
index fe0d83e..625bbf4 100644
--- a/src/emu/syscall.c
+++ b/src/emu/syscall.c
@@ -5,19 +5,21 @@
#include "mem.h"
#include "syscall.h"
+#define arg(n) load(GPR[SP] + 4*n)
+
void do_syscall(void)
{
- switch (GPR[1]) {
+ switch (arg(0)) {
case SYS_exit:
- exit(GPR[2]);
+ exit(arg(1));
break;
case SYS_read:
- GPR[2] = read(GPR[2], &MEM[GPR[3]], GPR[4]);
+ push(read(arg(1), &MEM[arg(2)], arg(3)));
break;
case SYS_write:
- GPR[2] = write(GPR[2], &MEM[GPR[3]], GPR[4]);
+ push(write(arg(1), &MEM[arg(2)], arg(3)));
break;
default:
- GPR[2] = -1;
+ push(-1);
}
}