summaryrefslogtreecommitdiff
path: root/src/virtualmachine/Syscalls.cpp
diff options
context:
space:
mode:
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