summaryrefslogtreecommitdiff
path: root/src/virtualmachine/Syscalls.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-09-09 16:55:03 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-09 16:55:03 (GMT)
commit2d2f8713bc86fe02aa6eae3fcb56365d39a65b21 (patch)
tree81232229f92b7684bfcdf0af82e4d17dbef4ab43 /src/virtualmachine/Syscalls.cpp
parent7b05862cfe69ece782493b9f3f78338262e569bd (diff)
downloadpowder-2d2f8713bc86fe02aa6eae3fcb56365d39a65b21.zip
powder-2d2f8713bc86fe02aa6eae3fcb56365d39a65b21.tar.gz
Move opcodes and syscalls out of main virtualmachine coee
Diffstat (limited to 'src/virtualmachine/Syscalls.cpp')
-rw-r--r--src/virtualmachine/Syscalls.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/virtualmachine/Syscalls.cpp b/src/virtualmachine/Syscalls.cpp
new file mode 100644
index 0000000..5358833
--- /dev/null
+++ b/src/virtualmachine/Syscalls.cpp
@@ -0,0 +1,33 @@
+#include "VirtualMachine.h"
+#include <cstdio>
+#include <cstdlib>
+
+namespace vm
+{
+ #define ARG(n) (Get<int4_t>(RP + ((2 + n) * sizeof(word))))
+
+ #define TRAPDEF(f) int VirtualMachine::trap##f()
+
+ TRAPDEF(Print)
+ {
+
+ char *text;
+
+ //crumb("SYSCALL Print [%d]\n", ARG(0));
+ text = (char*)(ram) + ARG(0);
+ //crumb("PRINTING [%s]\n", text);
+ printf("%s", text);
+ return 0;
+ }
+
+
+ TRAPDEF(Error)
+ {
+ char *msg;
+
+ msg = (char*)(ram) + ARG(0);
+ printf("%s", msg);
+ PC = romSize + 1;
+ return 0;
+ }
+} \ No newline at end of file