-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterpreter.cs
More file actions
87 lines (75 loc) · 2.51 KB
/
Copy pathinterpreter.cs
File metadata and controls
87 lines (75 loc) · 2.51 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using Raylib_cs;
// Code by NixxLTE -w-
namespace STR {
class RUN { //MOV EAX, 5
public static int DelayMs = 50;
// public static bool isCompiling;
public static void error(int code, bool fatal) {
Console.Write("ERROR! ");
switch (code)
{
case 1: { // getting invalid register
Console.Write("Cannot get invalid register\n");
break; }
case 2: { // setting invalid register
Console.Write("Cannot set invalid register\n");
break; }
case 998: { // using invalid int
Console.Write("Invalid int\n");
break; }
}
if (fatal) {
Console.Write("Fatal\n");
Thread.Sleep(1000 * 3);
Environment.Exit(0);
}
}
public static void Exit() {
Raylib.CloseWindow();
}
public static void HALT() {
CPU.mem[CPU.pc + 1] = 99;
}
// TODO: move this bullshit to a better place
// we arent even using this functions
public static void MOV(Int16 reg, Int16 val) {
CPU.SetRegister(reg, val);
}
public static void CLR(Int16 val) {
Int16 remain = 8;
while (remain != 11) {
CPU.SetRegister(remain, val);
remain += 1;
}
}
public static void LOAD(Int16 reg, Int16 val) {
CPU.SetRegister(reg, val);
}
public static void ADD(Int16 reg, Int16 imm) {
int result = CPU.GetRegister(reg) + imm;
CPU.SetRegister(reg, result);
}
public static void INT(Int16 interrupt) {
switch (interrupt) {
case 0: // print reg
Console.WriteLine(CPU.GetRegister(CPU.AX));
break;
case 10:
Console.Clear();
// Raylib.ClearBackground(Raylib_cs.Color.RayWhite);
break;
case 16:
// mov ah, 00h
// int 16h ; Program pauses here until a key is pressed
// al = a
// ah = 1e
CPU.SetRegister(CPU.AL, CPU.currentKey);
break;
default:
error(998, false);
break;
}
}
}
}