/
jit-int.cs
142 lines (99 loc) · 1.84 KB
/
jit-int.cs
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using System;
public class TestJit {
public static int test_short ()
{
int max = 32767;
int min = -32768;
int t1 = 0xffeedd;
short s1 = (short)t1;
int t2 = s1;
if ((uint)t2 != 0xffffeedd)
return 1;
Console.WriteLine (t2.ToString ("X"));
if (Int16.Parse((min).ToString()) != -32768)
return 1;
if (Int16.Parse((max).ToString()) != 32767)
return 1;
return 0;
}
public static int test_call (int a, int b) {
return a+b;
}
public static int test_shift ()
{
int a = 9, b = 1;
if ((a << 1) != 18)
return 1;
if ((a << b) != 18)
return 1;
if ((a >> 1) != 4)
return 1;
if ((a >> b) != 4)
return 1;
a = -9;
if ((a >> b) != -5)
return 1;
return 0;
}
public static int test_alu ()
{
int a = 9, b = 6;
if ((a + b) != 15)
return 1;
if ((a - b) != 3)
return 1;
if ((a & 8) != 8)
return 1;
if ((a | 2) != 11)
return 1;
if ((a * b) != 54)
return 1;
if ((a / 4) != 2)
return 1;
if ((a % 4) != 1)
return 1;
if (-a != -9)
return 1;
b = -1;
if (~b != 0)
return 1;
return 0;
}
public static int test_branch ()
{
int a = 5, b = 5, t;
if (a == b) t = 1; else t = 0;
if (t != 1) return 1;
if (a != b) t = 0; else t = 1;
if (t != 1) return 1;
if (a >= b) t = 1; else t = 0;
if (t != 1) return 1;
if (a > b) t = 0; else t = 1;
if (t != 1) return 1;
if (a <= b) t = 1; else t = 0;
if (t != 1) return 1;
if (a < b) t = 0; else t = 1;
if (t != 1) return 1;
return 0;
}
public static int Main() {
int num = 0;
num++;
if (test_short () != 0)
return num;
num++;
if (test_call (3, 5) != 8)
return num;
num++;
if (test_branch () != 0)
return num;
num++;
if (test_alu () != 0)
return num;
num++;
if (test_shift () != 0)
return num;
num++;
return 0;
}
}