summaryrefslogtreecommitdiff
path: root/src/virtualmachine/Syscalls.cpp
blob: 5358833acfc4d7b10830fcd902b2b18350caf351 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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;
	}
}