Fixed error with the way the string pool worked
This commit is contained in:
6
test/abort.c0
Normal file
6
test/abort.c0
Normal file
@@ -0,0 +1,6 @@
|
||||
#use <conio>
|
||||
|
||||
int main () {
|
||||
error("assertion failure");
|
||||
return 0;
|
||||
}
|
||||
25
test/abort.c0.bc0
Normal file
25
test/abort.c0.bc0
Normal file
@@ -0,0 +1,25 @@
|
||||
C0 C0 FF EE # magic number
|
||||
00 09 # version 4, arch = 1 (64 bits)
|
||||
|
||||
00 00 # int pool count
|
||||
# int pool
|
||||
|
||||
00 12 # string pool total size
|
||||
# string pool
|
||||
61 73 73 65 72 74 69 6F 6E 20 66 61 69 6C 75 72 65 00 # "assertion failure"
|
||||
|
||||
00 01 # function count
|
||||
# function_pool
|
||||
|
||||
#<main>
|
||||
00 00 # number of arguments = 0
|
||||
00 00 # number of local variables = 0
|
||||
00 07 # code length = 7 bytes
|
||||
14 00 00 # aldc 0 # s[0] = "assertion failure"
|
||||
BF # athrow # error "assertion failure"
|
||||
10 00 # bipush 0 # 0
|
||||
B0 # return #
|
||||
|
||||
00 00 # native count
|
||||
# native pool
|
||||
|
||||
0
test/abort.c0.bc0out
Normal file
0
test/abort.c0.bc0out
Normal file
0
test/abort.c0.c0out
Normal file
0
test/abort.c0.c0out
Normal file
BIN
test/abort.c0.ex
Executable file
BIN
test/abort.c0.ex
Executable file
Binary file not shown.
129
test/arith.c0
Normal file
129
test/arith.c0
Normal file
@@ -0,0 +1,129 @@
|
||||
#use <conio>
|
||||
|
||||
int main()
|
||||
{
|
||||
int max; int min;
|
||||
int x; int y; int z;
|
||||
int constant;
|
||||
|
||||
//Testing overflow
|
||||
max = 2147483647;
|
||||
min = -2147483648;
|
||||
y = max + 1;
|
||||
printint(y);
|
||||
print(" ");
|
||||
y = min - 1;
|
||||
printint(y);
|
||||
print(" ");
|
||||
// printint(min / -1);
|
||||
|
||||
//Testing multiplication of negatives
|
||||
|
||||
x = -25;
|
||||
y = 15;
|
||||
printint(x * y);
|
||||
print(" ");
|
||||
printint(-15 * -2147483648);
|
||||
print(" ");
|
||||
|
||||
//Divide by 0
|
||||
// println("");
|
||||
// printint(x / 0);
|
||||
|
||||
//Modulus by 0
|
||||
// println("");
|
||||
// printint(x % 0);
|
||||
|
||||
//Testing addition
|
||||
x = -5;
|
||||
y = -4;
|
||||
printint(x + y);
|
||||
z = x - y;
|
||||
print(" ");
|
||||
printint(z);
|
||||
print(" ");
|
||||
|
||||
|
||||
//Division truncation
|
||||
x = 25;
|
||||
y = 2;
|
||||
z = x / y;
|
||||
printint(z);
|
||||
print(" ");
|
||||
|
||||
println("");
|
||||
x = -25;
|
||||
y = 2;
|
||||
z = x / y;
|
||||
printint(z);
|
||||
print(" ");
|
||||
x = -25;
|
||||
y = -2;
|
||||
z = x / y;
|
||||
printint(z);
|
||||
print(" ");
|
||||
|
||||
//Modulus testing
|
||||
print("Modulus testing ");
|
||||
printint(235%32);
|
||||
printint(-15%2);
|
||||
print(" ");
|
||||
printint(5%6);
|
||||
print(" ");
|
||||
printint(5%-2);
|
||||
print(" ");
|
||||
|
||||
//Testing constants
|
||||
print("Testing constants ");
|
||||
constant = -251;
|
||||
printint(constant);
|
||||
print(" ");
|
||||
|
||||
//Testing inequalities
|
||||
println("Testing inequalities ");
|
||||
if(5>4) print("y1 "); else print("n1 ");
|
||||
if(1>-1) print("y2 "); else print("n2 ");
|
||||
if(0>=0) print("y3 "); else print("n3 ");
|
||||
if(12945<-235) print("y4 "); else print("n4 ");
|
||||
if(5<5) print("y5 "); else print("n5 ");
|
||||
if(-5==5) print("y6 "); else print("n6 ");
|
||||
if(15!=-15) print("y7 "); else print("n7 ");
|
||||
|
||||
//Testing bitwise operators
|
||||
println("Testing bitwise operators ");
|
||||
printint(0xF232C & 0xFF2352);
|
||||
print(" ");
|
||||
printint(0xF232C | 0xFF232);
|
||||
print(" ");
|
||||
printint(0xCD25 ^ 0x1D27);
|
||||
print(" ");
|
||||
printint(~0x2F32);
|
||||
print(" ");
|
||||
|
||||
//Testing bit shifting
|
||||
println("Testing bit shifting");
|
||||
printint(1<<31);
|
||||
print(" ");
|
||||
printint(23<<5);
|
||||
print(" ");
|
||||
printint(1>>5<<7);
|
||||
print(" ");
|
||||
printint(2352352>>2);
|
||||
print(" ");
|
||||
|
||||
//Default value for integers
|
||||
// println("Testing default value for integers");
|
||||
// printint(default_int);
|
||||
// print(" ");
|
||||
|
||||
//Testing other arithmetic functions
|
||||
printint(-6-25);
|
||||
print(" ");
|
||||
printint(6-25);
|
||||
print(" ");
|
||||
|
||||
|
||||
|
||||
println("");
|
||||
return 0;
|
||||
}
|
||||
430
test/arith.c0.bc0
Normal file
430
test/arith.c0.bc0
Normal file
@@ -0,0 +1,430 @@
|
||||
C0 C0 FF EE # magic number
|
||||
00 09 # version 4, arch = 1 (64 bits)
|
||||
|
||||
00 0F # int pool count
|
||||
# int pool
|
||||
7F FF FF FF
|
||||
80 00 00 00
|
||||
80 00 00 00
|
||||
00 00 00 EB
|
||||
FF FF FF 05
|
||||
00 00 32 91
|
||||
FF FF FF 15
|
||||
00 0F 23 2C
|
||||
00 FF 23 52
|
||||
00 0F 23 2C
|
||||
00 0F F2 32
|
||||
00 00 CD 25
|
||||
00 00 1D 27
|
||||
00 00 2F 32
|
||||
00 23 E4 E0
|
||||
|
||||
01 16 # string pool total size
|
||||
# string pool
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
00 # ""
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
4D 6F 64 75 6C 75 73 20 74 65 73 74 69 6E 67 20 20 20 00 # "Modulus testing "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
54 65 73 74 69 6E 67 20 63 6F 6E 73 74 61 6E 74 73 20 20 20 00 # "Testing constants "
|
||||
20 20 20 00 # " "
|
||||
54 65 73 74 69 6E 67 20 69 6E 65 71 75 61 6C 69 74 69 65 73 20 20 20 00 # "Testing inequalities "
|
||||
79 31 20 20 00 # "y1 "
|
||||
6E 31 20 20 00 # "n1 "
|
||||
79 32 20 20 00 # "y2 "
|
||||
6E 32 20 20 00 # "n2 "
|
||||
79 33 20 20 00 # "y3 "
|
||||
6E 33 20 20 00 # "n3 "
|
||||
79 34 20 20 00 # "y4 "
|
||||
6E 34 20 20 00 # "n4 "
|
||||
79 35 20 20 00 # "y5 "
|
||||
6E 35 20 20 00 # "n5 "
|
||||
79 36 20 20 00 # "y6 "
|
||||
6E 36 20 20 00 # "n6 "
|
||||
79 37 20 20 00 # "y7 "
|
||||
6E 37 20 20 00 # "n7 "
|
||||
54 65 73 74 69 6E 67 20 62 69 74 77 69 73 65 20 6F 70 65 72 61 74 6F 72 73 20 20 20 00 # "Testing bitwise operators "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
54 65 73 74 69 6E 67 20 62 69 74 20 73 68 69 66 74 69 6E 67 00 # "Testing bit shifting"
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
20 20 20 00 # " "
|
||||
00 # ""
|
||||
|
||||
00 01 # function count
|
||||
# function_pool
|
||||
|
||||
#<main>
|
||||
00 00 # number of arguments = 0
|
||||
00 06 # number of local variables = 6
|
||||
02 C5 # code length = 709 bytes
|
||||
13 00 00 # ildc 0 # c[0] = 2147483647
|
||||
36 00 # vstore 0 # max = 2147483647;
|
||||
13 00 01 # ildc 1 # c[1] = -2147483648
|
||||
36 01 # vstore 1 # min = -(-2147483648);
|
||||
15 00 # vload 0 # max
|
||||
10 01 # bipush 1 # 1
|
||||
60 # iadd # (max + 1)
|
||||
36 03 # vstore 3 # y = (max + 1);
|
||||
15 03 # vload 3 # y
|
||||
B7 00 00 # invokenative 0 # printint(y)
|
||||
57 # pop # (ignore result)
|
||||
14 00 00 # aldc 0 # s[0] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
15 01 # vload 1 # min
|
||||
10 01 # bipush 1 # 1
|
||||
64 # isub # (min - 1)
|
||||
36 03 # vstore 3 # y = (min - 1);
|
||||
15 03 # vload 3 # y
|
||||
B7 00 00 # invokenative 0 # printint(y)
|
||||
57 # pop # (ignore result)
|
||||
14 00 04 # aldc 4 # s[4] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 E7 # bipush -25 # -25
|
||||
36 02 # vstore 2 # x = -(25);
|
||||
10 0F # bipush 15 # 15
|
||||
36 03 # vstore 3 # y = 15;
|
||||
15 02 # vload 2 # x
|
||||
15 03 # vload 3 # y
|
||||
68 # imul # (x * y)
|
||||
B7 00 00 # invokenative 0 # printint((x * y))
|
||||
57 # pop # (ignore result)
|
||||
14 00 08 # aldc 8 # s[8] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 F1 # bipush -15 # -15
|
||||
13 00 02 # ildc 2 # c[2] = -2147483648
|
||||
68 # imul # (-(15) * -(-2147483648))
|
||||
B7 00 00 # invokenative 0 # printint((-(15) * -(-2147483648)))
|
||||
57 # pop # (ignore result)
|
||||
14 00 0C # aldc 12 # s[12] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 FB # bipush -5 # -5
|
||||
36 02 # vstore 2 # x = -(5);
|
||||
10 FC # bipush -4 # -4
|
||||
36 03 # vstore 3 # y = -(4);
|
||||
15 02 # vload 2 # x
|
||||
15 03 # vload 3 # y
|
||||
60 # iadd # (x + y)
|
||||
B7 00 00 # invokenative 0 # printint((x + y))
|
||||
57 # pop # (ignore result)
|
||||
15 02 # vload 2 # x
|
||||
15 03 # vload 3 # y
|
||||
64 # isub # (x - y)
|
||||
36 04 # vstore 4 # z = (x - y);
|
||||
14 00 10 # aldc 16 # s[16] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
15 04 # vload 4 # z
|
||||
B7 00 00 # invokenative 0 # printint(z)
|
||||
57 # pop # (ignore result)
|
||||
14 00 14 # aldc 20 # s[20] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 19 # bipush 25 # 25
|
||||
36 02 # vstore 2 # x = 25;
|
||||
10 02 # bipush 2 # 2
|
||||
36 03 # vstore 3 # y = 2;
|
||||
15 02 # vload 2 # x
|
||||
15 03 # vload 3 # y
|
||||
6C # idiv # (x / y)
|
||||
36 04 # vstore 4 # z = (x / y);
|
||||
15 04 # vload 4 # z
|
||||
B7 00 00 # invokenative 0 # printint(z)
|
||||
57 # pop # (ignore result)
|
||||
14 00 18 # aldc 24 # s[24] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
14 00 1C # aldc 28 # s[28] = ""
|
||||
B7 00 02 # invokenative 2 # println("")
|
||||
57 # pop # (ignore result)
|
||||
10 E7 # bipush -25 # -25
|
||||
36 02 # vstore 2 # x = -(25);
|
||||
10 02 # bipush 2 # 2
|
||||
36 03 # vstore 3 # y = 2;
|
||||
15 02 # vload 2 # x
|
||||
15 03 # vload 3 # y
|
||||
6C # idiv # (x / y)
|
||||
36 04 # vstore 4 # z = (x / y);
|
||||
15 04 # vload 4 # z
|
||||
B7 00 00 # invokenative 0 # printint(z)
|
||||
57 # pop # (ignore result)
|
||||
14 00 1D # aldc 29 # s[29] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 E7 # bipush -25 # -25
|
||||
36 02 # vstore 2 # x = -(25);
|
||||
10 FE # bipush -2 # -2
|
||||
36 03 # vstore 3 # y = -(2);
|
||||
15 02 # vload 2 # x
|
||||
15 03 # vload 3 # y
|
||||
6C # idiv # (x / y)
|
||||
36 04 # vstore 4 # z = (x / y);
|
||||
15 04 # vload 4 # z
|
||||
B7 00 00 # invokenative 0 # printint(z)
|
||||
57 # pop # (ignore result)
|
||||
14 00 21 # aldc 33 # s[33] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
14 00 25 # aldc 37 # s[37] = "Modulus testing "
|
||||
B7 00 01 # invokenative 1 # print("Modulus testing ")
|
||||
57 # pop # (ignore result)
|
||||
13 00 03 # ildc 3 # c[3] = 235
|
||||
10 20 # bipush 32 # 32
|
||||
70 # irem # (235 % 32)
|
||||
B7 00 00 # invokenative 0 # printint((235 % 32))
|
||||
57 # pop # (ignore result)
|
||||
10 F1 # bipush -15 # -15
|
||||
10 02 # bipush 2 # 2
|
||||
70 # irem # (-(15) % 2)
|
||||
B7 00 00 # invokenative 0 # printint((-(15) % 2))
|
||||
57 # pop # (ignore result)
|
||||
14 00 38 # aldc 56 # s[56] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 05 # bipush 5 # 5
|
||||
10 06 # bipush 6 # 6
|
||||
70 # irem # (5 % 6)
|
||||
B7 00 00 # invokenative 0 # printint((5 % 6))
|
||||
57 # pop # (ignore result)
|
||||
14 00 3C # aldc 60 # s[60] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 05 # bipush 5 # 5
|
||||
10 FE # bipush -2 # -2
|
||||
70 # irem # (5 % -(2))
|
||||
B7 00 00 # invokenative 0 # printint((5 % -(2)))
|
||||
57 # pop # (ignore result)
|
||||
14 00 40 # aldc 64 # s[64] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
14 00 44 # aldc 68 # s[68] = "Testing constants "
|
||||
B7 00 01 # invokenative 1 # print("Testing constants ")
|
||||
57 # pop # (ignore result)
|
||||
13 00 04 # ildc 4 # c[4] = -251
|
||||
36 05 # vstore 5 # constant = -(251);
|
||||
15 05 # vload 5 # constant
|
||||
B7 00 00 # invokenative 0 # printint(constant)
|
||||
57 # pop # (ignore result)
|
||||
14 00 59 # aldc 89 # s[89] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
14 00 5D # aldc 93 # s[93] = "Testing inequalities "
|
||||
B7 00 02 # invokenative 2 # println("Testing inequalities ")
|
||||
57 # pop # (ignore result)
|
||||
10 05 # bipush 5 # 5
|
||||
10 04 # bipush 4 # 4
|
||||
A3 00 06 # if_icmpgt +6 # if (5 > 4) goto <00:then>
|
||||
A7 00 0D # goto +13 # goto <01:else>
|
||||
# <00:then>
|
||||
14 00 75 # aldc 117 # s[117] = "y1 "
|
||||
B7 00 01 # invokenative 1 # print("y1 ")
|
||||
57 # pop # (ignore result)
|
||||
A7 00 0A # goto +10 # goto <02:endif>
|
||||
# <01:else>
|
||||
14 00 7A # aldc 122 # s[122] = "n1 "
|
||||
B7 00 01 # invokenative 1 # print("n1 ")
|
||||
57 # pop # (ignore result)
|
||||
# <02:endif>
|
||||
10 01 # bipush 1 # 1
|
||||
10 FF # bipush -1 # -1
|
||||
A3 00 06 # if_icmpgt +6 # if (1 > -(1)) goto <03:then>
|
||||
A7 00 0D # goto +13 # goto <04:else>
|
||||
# <03:then>
|
||||
14 00 7F # aldc 127 # s[127] = "y2 "
|
||||
B7 00 01 # invokenative 1 # print("y2 ")
|
||||
57 # pop # (ignore result)
|
||||
A7 00 0A # goto +10 # goto <05:endif>
|
||||
# <04:else>
|
||||
14 00 84 # aldc 132 # s[132] = "n2 "
|
||||
B7 00 01 # invokenative 1 # print("n2 ")
|
||||
57 # pop # (ignore result)
|
||||
# <05:endif>
|
||||
10 00 # bipush 0 # 0
|
||||
10 00 # bipush 0 # 0
|
||||
A2 00 06 # if_icmpge +6 # if (0 >= 0) goto <06:then>
|
||||
A7 00 0D # goto +13 # goto <07:else>
|
||||
# <06:then>
|
||||
14 00 89 # aldc 137 # s[137] = "y3 "
|
||||
B7 00 01 # invokenative 1 # print("y3 ")
|
||||
57 # pop # (ignore result)
|
||||
A7 00 0A # goto +10 # goto <08:endif>
|
||||
# <07:else>
|
||||
14 00 8E # aldc 142 # s[142] = "n3 "
|
||||
B7 00 01 # invokenative 1 # print("n3 ")
|
||||
57 # pop # (ignore result)
|
||||
# <08:endif>
|
||||
13 00 05 # ildc 5 # c[5] = 12945
|
||||
13 00 06 # ildc 6 # c[6] = -235
|
||||
A1 00 06 # if_icmplt +6 # if (12945 < -(235)) goto <09:then>
|
||||
A7 00 0D # goto +13 # goto <10:else>
|
||||
# <09:then>
|
||||
14 00 93 # aldc 147 # s[147] = "y4 "
|
||||
B7 00 01 # invokenative 1 # print("y4 ")
|
||||
57 # pop # (ignore result)
|
||||
A7 00 0A # goto +10 # goto <11:endif>
|
||||
# <10:else>
|
||||
14 00 98 # aldc 152 # s[152] = "n4 "
|
||||
B7 00 01 # invokenative 1 # print("n4 ")
|
||||
57 # pop # (ignore result)
|
||||
# <11:endif>
|
||||
10 05 # bipush 5 # 5
|
||||
10 05 # bipush 5 # 5
|
||||
A1 00 06 # if_icmplt +6 # if (5 < 5) goto <12:then>
|
||||
A7 00 0D # goto +13 # goto <13:else>
|
||||
# <12:then>
|
||||
14 00 9D # aldc 157 # s[157] = "y5 "
|
||||
B7 00 01 # invokenative 1 # print("y5 ")
|
||||
57 # pop # (ignore result)
|
||||
A7 00 0A # goto +10 # goto <14:endif>
|
||||
# <13:else>
|
||||
14 00 A2 # aldc 162 # s[162] = "n5 "
|
||||
B7 00 01 # invokenative 1 # print("n5 ")
|
||||
57 # pop # (ignore result)
|
||||
# <14:endif>
|
||||
10 FB # bipush -5 # -5
|
||||
10 05 # bipush 5 # 5
|
||||
9F 00 06 # if_cmpeq +6 # if (-(5) == 5) goto <15:then>
|
||||
A7 00 0D # goto +13 # goto <16:else>
|
||||
# <15:then>
|
||||
14 00 A7 # aldc 167 # s[167] = "y6 "
|
||||
B7 00 01 # invokenative 1 # print("y6 ")
|
||||
57 # pop # (ignore result)
|
||||
A7 00 0A # goto +10 # goto <17:endif>
|
||||
# <16:else>
|
||||
14 00 AC # aldc 172 # s[172] = "n6 "
|
||||
B7 00 01 # invokenative 1 # print("n6 ")
|
||||
57 # pop # (ignore result)
|
||||
# <17:endif>
|
||||
10 0F # bipush 15 # 15
|
||||
10 F1 # bipush -15 # -15
|
||||
A0 00 06 # if_cmpne +6 # if (15 != -(15)) goto <18:then>
|
||||
A7 00 0D # goto +13 # goto <19:else>
|
||||
# <18:then>
|
||||
14 00 B1 # aldc 177 # s[177] = "y7 "
|
||||
B7 00 01 # invokenative 1 # print("y7 ")
|
||||
57 # pop # (ignore result)
|
||||
A7 00 0A # goto +10 # goto <20:endif>
|
||||
# <19:else>
|
||||
14 00 B6 # aldc 182 # s[182] = "n7 "
|
||||
B7 00 01 # invokenative 1 # print("n7 ")
|
||||
57 # pop # (ignore result)
|
||||
# <20:endif>
|
||||
14 00 BB # aldc 187 # s[187] = "Testing bitwise operators "
|
||||
B7 00 02 # invokenative 2 # println("Testing bitwise operators ")
|
||||
57 # pop # (ignore result)
|
||||
13 00 07 # ildc 7 # c[7] = 992044
|
||||
13 00 08 # ildc 8 # c[8] = 16720722
|
||||
7E # iand # (992044 & 16720722)
|
||||
B7 00 00 # invokenative 0 # printint((992044 & 16720722))
|
||||
57 # pop # (ignore result)
|
||||
14 00 D8 # aldc 216 # s[216] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
13 00 09 # ildc 9 # c[9] = 992044
|
||||
13 00 0A # ildc 10 # c[10] = 1045042
|
||||
80 # ior # (992044 | 1045042)
|
||||
B7 00 00 # invokenative 0 # printint((992044 | 1045042))
|
||||
57 # pop # (ignore result)
|
||||
14 00 DC # aldc 220 # s[220] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
13 00 0B # ildc 11 # c[11] = 52517
|
||||
13 00 0C # ildc 12 # c[12] = 7463
|
||||
82 # ixor # (52517 ^ 7463)
|
||||
B7 00 00 # invokenative 0 # printint((52517 ^ 7463))
|
||||
57 # pop # (ignore result)
|
||||
14 00 E0 # aldc 224 # s[224] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
13 00 0D # ildc 13 # c[13] = 12082
|
||||
10 FF # bipush -1 #
|
||||
82 # ixor # ~(12082)
|
||||
B7 00 00 # invokenative 0 # printint(~(12082))
|
||||
57 # pop # (ignore result)
|
||||
14 00 E4 # aldc 228 # s[228] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
14 00 E8 # aldc 232 # s[232] = "Testing bit shifting"
|
||||
B7 00 02 # invokenative 2 # println("Testing bit shifting")
|
||||
57 # pop # (ignore result)
|
||||
10 01 # bipush 1 # 1
|
||||
10 1F # bipush 31 # 31
|
||||
78 # ishl # (1 << 31)
|
||||
B7 00 00 # invokenative 0 # printint((1 << 31))
|
||||
57 # pop # (ignore result)
|
||||
14 00 FD # aldc 253 # s[253] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 17 # bipush 23 # 23
|
||||
10 05 # bipush 5 # 5
|
||||
78 # ishl # (23 << 5)
|
||||
B7 00 00 # invokenative 0 # printint((23 << 5))
|
||||
57 # pop # (ignore result)
|
||||
14 01 01 # aldc 257 # s[257] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 01 # bipush 1 # 1
|
||||
10 05 # bipush 5 # 5
|
||||
7A # ishr # (1 >> 5)
|
||||
10 07 # bipush 7 # 7
|
||||
78 # ishl # ((1 >> 5) << 7)
|
||||
B7 00 00 # invokenative 0 # printint(((1 >> 5) << 7))
|
||||
57 # pop # (ignore result)
|
||||
14 01 05 # aldc 261 # s[261] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
13 00 0E # ildc 14 # c[14] = 2352352
|
||||
10 02 # bipush 2 # 2
|
||||
7A # ishr # (2352352 >> 2)
|
||||
B7 00 00 # invokenative 0 # printint((2352352 >> 2))
|
||||
57 # pop # (ignore result)
|
||||
14 01 09 # aldc 265 # s[265] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 FA # bipush -6 # -6
|
||||
10 19 # bipush 25 # 25
|
||||
64 # isub # (-(6) - 25)
|
||||
B7 00 00 # invokenative 0 # printint((-(6) - 25))
|
||||
57 # pop # (ignore result)
|
||||
14 01 0D # aldc 269 # s[269] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
10 06 # bipush 6 # 6
|
||||
10 19 # bipush 25 # 25
|
||||
64 # isub # (6 - 25)
|
||||
B7 00 00 # invokenative 0 # printint((6 - 25))
|
||||
57 # pop # (ignore result)
|
||||
14 01 11 # aldc 273 # s[273] = " "
|
||||
B7 00 01 # invokenative 1 # print(" ")
|
||||
57 # pop # (ignore result)
|
||||
14 01 15 # aldc 277 # s[277] = ""
|
||||
B7 00 02 # invokenative 2 # println("")
|
||||
57 # pop # (ignore result)
|
||||
10 00 # bipush 0 # 0
|
||||
B0 # return #
|
||||
|
||||
00 03 # native count
|
||||
# native pool
|
||||
00 01 00 13 # printint
|
||||
00 01 00 10 # print
|
||||
00 01 00 14 # println
|
||||
|
||||
6
test/arith.c0.bc0out
Normal file
6
test/arith.c0.bc0out
Normal file
@@ -0,0 +1,6 @@
|
||||
-2147483648 2147483647 -375 -2147483648 -9 -1 12
|
||||
-12 12 Modulus testing 11-1 5 1 Testing constants -251 Testing inequalities
|
||||
y1 y2 y3 n4 n5 n6 y7 Testing bitwise operators
|
||||
992000 1045310 53250 -12083 Testing bit shifting
|
||||
-2147483648 736 0 588088 -31 -19
|
||||
0
|
||||
6
test/arith.c0.c0out
Normal file
6
test/arith.c0.c0out
Normal file
@@ -0,0 +1,6 @@
|
||||
-2147483648 2147483647 -375 -2147483648 -9 -1 12
|
||||
-12 12 Modulus testing 11-1 5 1 Testing constants -251 Testing inequalities
|
||||
y1 y2 y3 n4 n5 n6 y7 Testing bitwise operators
|
||||
992000 1045310 53250 -12083 Testing bit shifting
|
||||
-2147483648 736 0 588088 -31 -19
|
||||
0
|
||||
BIN
test/arith.c0.ex
Executable file
BIN
test/arith.c0.ex
Executable file
Binary file not shown.
7
test/chararrays.c0
Normal file
7
test/chararrays.c0
Normal file
@@ -0,0 +1,7 @@
|
||||
#use <conio>
|
||||
|
||||
int main() {
|
||||
char[] A = alloc_array(char, 5);
|
||||
printchar(A[3]);
|
||||
return 0;
|
||||
}
|
||||
3
test/easyMath.c0
Normal file
3
test/easyMath.c0
Normal file
@@ -0,0 +1,3 @@
|
||||
int main() {
|
||||
return (23 * 19)<<2;
|
||||
}
|
||||
26
test/easyMath.c0.bc0
Normal file
26
test/easyMath.c0.bc0
Normal file
@@ -0,0 +1,26 @@
|
||||
C0 C0 FF EE # magic number
|
||||
00 09 # version 4, arch = 1 (64 bits)
|
||||
|
||||
00 00 # int pool count
|
||||
# int pool
|
||||
|
||||
00 00 # string pool total size
|
||||
# string pool
|
||||
|
||||
00 01 # function count
|
||||
# function_pool
|
||||
|
||||
#<main>
|
||||
00 00 # number of arguments = 0
|
||||
00 00 # number of local variables = 0
|
||||
00 09 # code length = 9 bytes
|
||||
10 17 # bipush 23 # 23
|
||||
10 13 # bipush 19 # 19
|
||||
68 # imul # (23 * 19)
|
||||
10 02 # bipush 2 # 2
|
||||
78 # ishl # ((23 * 19) << 2)
|
||||
B0 # return #
|
||||
|
||||
00 00 # native count
|
||||
# native pool
|
||||
|
||||
1
test/easyMath.c0.bc0out
Normal file
1
test/easyMath.c0.bc0out
Normal file
@@ -0,0 +1 @@
|
||||
1748
|
||||
1
test/easyMath.c0.c0out
Normal file
1
test/easyMath.c0.c0out
Normal file
@@ -0,0 +1 @@
|
||||
1748
|
||||
BIN
test/easyMath.c0.ex
Executable file
BIN
test/easyMath.c0.ex
Executable file
Binary file not shown.
9
test/hellosir.c0
Normal file
9
test/hellosir.c0
Normal file
@@ -0,0 +1,9 @@
|
||||
#use <conio>
|
||||
#use <string>
|
||||
|
||||
int main () {
|
||||
print("What's your name? ");
|
||||
string name = readline();
|
||||
print(string_join("Hello, ", string_join(name, "!\n")));
|
||||
return 0;
|
||||
}
|
||||
40
test/hellosir.c0.bc0
Normal file
40
test/hellosir.c0.bc0
Normal file
@@ -0,0 +1,40 @@
|
||||
C0 C0 FF EE # magic number
|
||||
00 09 # version 4, arch = 1 (64 bits)
|
||||
|
||||
00 00 # int pool count
|
||||
# int pool
|
||||
|
||||
00 1E # string pool total size
|
||||
# string pool
|
||||
57 68 61 74 27 73 20 79 6F 75 72 20 6E 61 6D 65 3F 20 00 # "What\'s your name\? "
|
||||
48 65 6C 6C 6F 2C 20 00 # "Hello, "
|
||||
21 0A 00 # "!\n"
|
||||
|
||||
00 01 # function count
|
||||
# function_pool
|
||||
|
||||
#<main>
|
||||
00 00 # number of arguments = 0
|
||||
00 01 # number of local variables = 1
|
||||
00 21 # code length = 33 bytes
|
||||
14 00 00 # aldc 0 # s[0] = "What\'s your name\? "
|
||||
B7 00 00 # invokenative 0 # print("What\'s your name\? ")
|
||||
57 # pop # (ignore result)
|
||||
B7 00 01 # invokenative 1 # readline()
|
||||
36 00 # vstore 0 # name = readline();
|
||||
14 00 13 # aldc 19 # s[19] = "Hello, "
|
||||
15 00 # vload 0 # name
|
||||
14 00 1B # aldc 27 # s[27] = "!\n"
|
||||
B7 00 02 # invokenative 2 # string_join(name, "!\n")
|
||||
B7 00 02 # invokenative 2 # string_join("Hello, ", string_join(name, "!\n"))
|
||||
B7 00 00 # invokenative 0 # print(string_join("Hello, ", string_join(name, "!\n")))
|
||||
57 # pop # (ignore result)
|
||||
10 00 # bipush 0 # 0
|
||||
B0 # return #
|
||||
|
||||
00 03 # native count
|
||||
# native pool
|
||||
00 01 00 06 # print
|
||||
00 00 00 0B # readline
|
||||
00 02 00 4F # string_join
|
||||
|
||||
2
test/hellosir.c0.bc0out
Normal file
2
test/hellosir.c0.bc0out
Normal file
@@ -0,0 +1,2 @@
|
||||
What's your name? Hello, uo!
|
||||
0
|
||||
2
test/hellosir.c0.c0out
Normal file
2
test/hellosir.c0.c0out
Normal file
@@ -0,0 +1,2 @@
|
||||
What's your name? Hello, hi!
|
||||
0
|
||||
BIN
test/hellosir.c0.ex
Executable file
BIN
test/hellosir.c0.ex
Executable file
Binary file not shown.
1
test/iadd.c0.bc0out
Normal file
1
test/iadd.c0.bc0out
Normal file
@@ -0,0 +1 @@
|
||||
-2
|
||||
1
test/iadd.c0.c0out
Normal file
1
test/iadd.c0.c0out
Normal file
@@ -0,0 +1 @@
|
||||
-2
|
||||
BIN
test/iadd.c0.ex
Executable file
BIN
test/iadd.c0.ex
Executable file
Binary file not shown.
10
test/moreArrays.c0
Normal file
10
test/moreArrays.c0
Normal file
@@ -0,0 +1,10 @@
|
||||
#use <conio>
|
||||
|
||||
int main() {
|
||||
int[] A = alloc_array(int, 50);
|
||||
A[3] = 23;
|
||||
A[2] = 12;
|
||||
printint(A[3]);
|
||||
printint(A[2]);
|
||||
return 0;
|
||||
}
|
||||
48
test/moreArrays.c0.bc0
Normal file
48
test/moreArrays.c0.bc0
Normal file
@@ -0,0 +1,48 @@
|
||||
C0 C0 FF EE # magic number
|
||||
00 09 # version 4, arch = 1 (64 bits)
|
||||
|
||||
00 00 # int pool count
|
||||
# int pool
|
||||
|
||||
00 00 # string pool total size
|
||||
# string pool
|
||||
|
||||
00 01 # function count
|
||||
# function_pool
|
||||
|
||||
#<main>
|
||||
00 00 # number of arguments = 0
|
||||
00 01 # number of local variables = 1
|
||||
00 2D # code length = 45 bytes
|
||||
10 32 # bipush 50 # 50
|
||||
BC 04 # newarray 4 # alloc_array(int, 50)
|
||||
36 00 # vstore 0 # A = alloc_array(int, 50);
|
||||
15 00 # vload 0 # A
|
||||
10 03 # bipush 3 # 3
|
||||
63 # aadds # &A[3]
|
||||
10 17 # bipush 23 # 23
|
||||
4E # imstore # A[3] = 23;
|
||||
15 00 # vload 0 # A
|
||||
10 02 # bipush 2 # 2
|
||||
63 # aadds # &A[2]
|
||||
10 0C # bipush 12 # 12
|
||||
4E # imstore # A[2] = 12;
|
||||
15 00 # vload 0 # A
|
||||
10 03 # bipush 3 # 3
|
||||
63 # aadds # &A[3]
|
||||
2E # imload # A[3]
|
||||
B7 00 00 # invokenative 0 # printint(A[3])
|
||||
57 # pop # (ignore result)
|
||||
15 00 # vload 0 # A
|
||||
10 02 # bipush 2 # 2
|
||||
63 # aadds # &A[2]
|
||||
2E # imload # A[2]
|
||||
B7 00 00 # invokenative 0 # printint(A[2])
|
||||
57 # pop # (ignore result)
|
||||
10 00 # bipush 0 # 0
|
||||
B0 # return #
|
||||
|
||||
00 01 # native count
|
||||
# native pool
|
||||
00 01 00 13 # printint
|
||||
|
||||
1
test/moreArrays.c0.bc0out
Normal file
1
test/moreArrays.c0.bc0out
Normal file
@@ -0,0 +1 @@
|
||||
23120
|
||||
1
test/moreArrays.c0.c0out
Normal file
1
test/moreArrays.c0.c0out
Normal file
@@ -0,0 +1 @@
|
||||
23120
|
||||
BIN
test/moreArrays.c0.ex
Executable file
BIN
test/moreArrays.c0.ex
Executable file
Binary file not shown.
22
test/piazza1.c0
Normal file
22
test/piazza1.c0
Normal file
@@ -0,0 +1,22 @@
|
||||
struct s
|
||||
{
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int[] a;
|
||||
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
struct s* example=alloc(struct s);
|
||||
example->y=5;
|
||||
example->x=6;
|
||||
int x = example->x + 1;
|
||||
example->a=alloc_array(int,4);
|
||||
example->a[0] = 5;
|
||||
int y = example->a[0];
|
||||
example->a[0]=3;
|
||||
//@assert(\length(example->a)==4);
|
||||
return example->x + x +y;
|
||||
}
|
||||
70
test/piazza1.c0.bc0
Normal file
70
test/piazza1.c0.bc0
Normal file
@@ -0,0 +1,70 @@
|
||||
C0 C0 FF EE # magic number
|
||||
00 09 # version 4, arch = 1 (64 bits)
|
||||
|
||||
00 00 # int pool count
|
||||
# int pool
|
||||
|
||||
00 00 # string pool total size
|
||||
# string pool
|
||||
|
||||
00 01 # function count
|
||||
# function_pool
|
||||
|
||||
#<main>
|
||||
00 00 # number of arguments = 0
|
||||
00 03 # number of local variables = 3
|
||||
00 52 # code length = 82 bytes
|
||||
BB 10 # new 16 # alloc(struct s)
|
||||
36 00 # vstore 0 # example = alloc(struct s);
|
||||
15 00 # vload 0 # example
|
||||
62 04 # aaddf 4 # &example->y
|
||||
10 05 # bipush 5 # 5
|
||||
4E # imstore # example->y = 5;
|
||||
15 00 # vload 0 # example
|
||||
62 00 # aaddf 0 # &example->x
|
||||
10 06 # bipush 6 # 6
|
||||
4E # imstore # example->x = 6;
|
||||
15 00 # vload 0 # example
|
||||
62 00 # aaddf 0 # &example->x
|
||||
2E # imload # example->x
|
||||
10 01 # bipush 1 # 1
|
||||
60 # iadd # (example->x + 1)
|
||||
36 01 # vstore 1 # x = (example->x + 1);
|
||||
15 00 # vload 0 # example
|
||||
62 08 # aaddf 8 # &example->a
|
||||
10 04 # bipush 4 # 4
|
||||
BC 04 # newarray 4 # alloc_array(int, 4)
|
||||
4F # amstore # example->a = alloc_array(int, 4);
|
||||
15 00 # vload 0 # example
|
||||
62 08 # aaddf 8 # &example->a
|
||||
2F # amload # example->a
|
||||
10 00 # bipush 0 # 0
|
||||
63 # aadds # &example->a[0]
|
||||
10 05 # bipush 5 # 5
|
||||
4E # imstore # example->a[0] = 5;
|
||||
15 00 # vload 0 # example
|
||||
62 08 # aaddf 8 # &example->a
|
||||
2F # amload # example->a
|
||||
10 00 # bipush 0 # 0
|
||||
63 # aadds # &example->a[0]
|
||||
2E # imload # example->a[0]
|
||||
36 02 # vstore 2 # y = example->a[0];
|
||||
15 00 # vload 0 # example
|
||||
62 08 # aaddf 8 # &example->a
|
||||
2F # amload # example->a
|
||||
10 00 # bipush 0 # 0
|
||||
63 # aadds # &example->a[0]
|
||||
10 03 # bipush 3 # 3
|
||||
4E # imstore # example->a[0] = 3;
|
||||
15 00 # vload 0 # example
|
||||
62 00 # aaddf 0 # &example->x
|
||||
2E # imload # example->x
|
||||
15 01 # vload 1 # x
|
||||
60 # iadd # (example->x + x)
|
||||
15 02 # vload 2 # y
|
||||
60 # iadd # ((example->x + x) + y)
|
||||
B0 # return #
|
||||
|
||||
00 00 # native count
|
||||
# native pool
|
||||
|
||||
1
test/piazza1.c0.bc0out
Normal file
1
test/piazza1.c0.bc0out
Normal file
@@ -0,0 +1 @@
|
||||
18
|
||||
1
test/piazza1.c0.c0out
Normal file
1
test/piazza1.c0.c0out
Normal file
@@ -0,0 +1 @@
|
||||
18
|
||||
BIN
test/piazza1.c0.ex
Executable file
BIN
test/piazza1.c0.ex
Executable file
Binary file not shown.
29
test/strings.c0
Normal file
29
test/strings.c0
Normal file
@@ -0,0 +1,29 @@
|
||||
#use <conio>
|
||||
#use <string>
|
||||
|
||||
char char_tolower(char c) {
|
||||
int ccode = char_ord(c);
|
||||
if (char_ord('A') <= ccode && ccode <= char_ord('Z')) {
|
||||
int shift = char_ord('a') - char_ord('A');
|
||||
return char_chr(ccode + shift);
|
||||
} else {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
string string_lower(string s)
|
||||
//@ensures string_length(s) == string_length(\result);
|
||||
{
|
||||
int len = string_length(s);
|
||||
char[] A = string_to_chararray(s);
|
||||
char[] B = alloc_array(char, len+1);
|
||||
for (int i = 0; i < len; i++)
|
||||
B[i] = char_tolower(A[i]);
|
||||
B[len] = '\0'; /* redundant */
|
||||
return string_from_chararray(B);
|
||||
}
|
||||
|
||||
int main() {
|
||||
print (string_lower("HEllo There!?"));
|
||||
return 0;
|
||||
}
|
||||
118
test/strings.c0.bc0
Normal file
118
test/strings.c0.bc0
Normal file
@@ -0,0 +1,118 @@
|
||||
C0 C0 FF EE # magic number
|
||||
00 09 # version 4, arch = 1 (64 bits)
|
||||
|
||||
00 00 # int pool count
|
||||
# int pool
|
||||
|
||||
00 0E # string pool total size
|
||||
# string pool
|
||||
48 45 6C 6C 6F 20 54 68 65 72 65 21 3F 00 # "HEllo There!\?"
|
||||
|
||||
00 03 # function count
|
||||
# function_pool
|
||||
|
||||
#<main>
|
||||
00 00 # number of arguments = 0
|
||||
00 05 # number of local variables = 5
|
||||
00 0D # code length = 13 bytes
|
||||
14 00 00 # aldc 0 # s[0] = "HEllo There!\?"
|
||||
B8 00 02 # invokestatic 2 # string_lower("HEllo There!\?")
|
||||
B7 00 05 # invokenative 5 # print(string_lower("HEllo There!\?"))
|
||||
57 # pop # (ignore result)
|
||||
10 00 # bipush 0 # 0
|
||||
B0 # return #
|
||||
|
||||
|
||||
#<char_tolower>
|
||||
00 01 # number of arguments = 1
|
||||
00 03 # number of local variables = 3
|
||||
00 3D # code length = 61 bytes
|
||||
15 00 # vload 0 # c
|
||||
B7 00 00 # invokenative 0 # char_ord(c)
|
||||
36 01 # vstore 1 # ccode = char_ord(c);
|
||||
10 41 # bipush 65 # 'A'
|
||||
B7 00 00 # invokenative 0 # char_ord('A')
|
||||
15 01 # vload 1 # ccode
|
||||
A4 00 06 # if_icmple +6 # if (char_ord('A') <= ccode) goto <03:and>
|
||||
A7 00 29 # goto +41 # goto <01:else>
|
||||
# <03:and>
|
||||
15 01 # vload 1 # ccode
|
||||
10 5A # bipush 90 # 'Z'
|
||||
B7 00 00 # invokenative 0 # char_ord('Z')
|
||||
A4 00 06 # if_icmple +6 # if (ccode <= char_ord('Z')) goto <00:then>
|
||||
A7 00 1C # goto +28 # goto <01:else>
|
||||
# <00:then>
|
||||
10 61 # bipush 97 # 'a'
|
||||
B7 00 00 # invokenative 0 # char_ord('a')
|
||||
10 41 # bipush 65 # 'A'
|
||||
B7 00 00 # invokenative 0 # char_ord('A')
|
||||
64 # isub # (char_ord('a') - char_ord('A'))
|
||||
36 02 # vstore 2 # shift = (char_ord('a') - char_ord('A'));
|
||||
15 01 # vload 1 # ccode
|
||||
15 02 # vload 2 # shift
|
||||
60 # iadd # (ccode + shift)
|
||||
B7 00 01 # invokenative 1 # char_chr((ccode + shift))
|
||||
B0 # return #
|
||||
A7 00 06 # goto +6 # goto <02:endif>
|
||||
# <01:else>
|
||||
15 00 # vload 0 # c
|
||||
B0 # return #
|
||||
# <02:endif>
|
||||
|
||||
|
||||
#<string_lower>
|
||||
00 01 # number of arguments = 1
|
||||
00 05 # number of local variables = 5
|
||||
00 4C # code length = 76 bytes
|
||||
15 00 # vload 0 # s
|
||||
B7 00 02 # invokenative 2 # string_length(s)
|
||||
36 01 # vstore 1 # len = string_length(s);
|
||||
15 00 # vload 0 # s
|
||||
B7 00 03 # invokenative 3 # string_to_chararray(s)
|
||||
36 02 # vstore 2 # A = string_to_chararray(s);
|
||||
15 01 # vload 1 # len
|
||||
10 01 # bipush 1 # 1
|
||||
60 # iadd # (len + 1)
|
||||
BC 01 # newarray 1 # alloc_array(char, (len + 1))
|
||||
36 03 # vstore 3 # B = alloc_array(char, (len + 1));
|
||||
10 00 # bipush 0 # 0
|
||||
36 04 # vstore 4 # i = 0;
|
||||
# <04:loop>
|
||||
15 04 # vload 4 # i
|
||||
15 01 # vload 1 # len
|
||||
A1 00 06 # if_icmplt +6 # if (i < len) goto <05:body>
|
||||
A7 00 1C # goto +28 # goto <06:exit>
|
||||
# <05:body>
|
||||
15 03 # vload 3 # B
|
||||
15 04 # vload 4 # i
|
||||
63 # aadds # &B[i]
|
||||
15 02 # vload 2 # A
|
||||
15 04 # vload 4 # i
|
||||
63 # aadds # &A[i]
|
||||
34 # cmload # A[i]
|
||||
B8 00 01 # invokestatic 1 # char_tolower(A[i])
|
||||
55 # cmstore # B[i] = char_tolower(A[i]);
|
||||
15 04 # vload 4 # i
|
||||
10 01 # bipush 1 # 1
|
||||
60 # iadd #
|
||||
36 04 # vstore 4 # i += 1;
|
||||
A7 FF E0 # goto -32 # goto <04:loop>
|
||||
# <06:exit>
|
||||
15 03 # vload 3 # B
|
||||
15 01 # vload 1 # len
|
||||
63 # aadds # &B[len]
|
||||
10 00 # bipush 0 # '\000'
|
||||
55 # cmstore # B[len] = '\0';
|
||||
15 03 # vload 3 # B
|
||||
B7 00 04 # invokenative 4 # string_from_chararray(B)
|
||||
B0 # return #
|
||||
|
||||
00 06 # native count
|
||||
# native pool
|
||||
00 01 00 47 # char_ord
|
||||
00 01 00 46 # char_chr
|
||||
00 01 00 50 # string_length
|
||||
00 01 00 53 # string_to_chararray
|
||||
00 01 00 4B # string_from_chararray
|
||||
00 01 00 06 # print
|
||||
|
||||
1
test/strings.c0.bc0out
Normal file
1
test/strings.c0.bc0out
Normal file
@@ -0,0 +1 @@
|
||||
hello there!?0
|
||||
1
test/strings.c0.c0out
Normal file
1
test/strings.c0.c0out
Normal file
@@ -0,0 +1 @@
|
||||
hello there!?0
|
||||
BIN
test/strings.c0.ex
Executable file
BIN
test/strings.c0.ex
Executable file
Binary file not shown.
25
test/swapTest.c0.bc0
Normal file
25
test/swapTest.c0.bc0
Normal file
@@ -0,0 +1,25 @@
|
||||
C0 C0 FF EE # magic number
|
||||
00 09 # version 4, arch = 1 (64 bits)
|
||||
|
||||
00 00 # int pool count
|
||||
# int pool
|
||||
|
||||
00 00 # string pool total size
|
||||
# string pool
|
||||
|
||||
00 01 # function count
|
||||
# function_pool
|
||||
|
||||
#<main>
|
||||
00 00 # number of arguments = 0
|
||||
00 00 # number of local variables = 0
|
||||
00 07 # code length = 6 bytes
|
||||
10 FF # bipush -1 # -1
|
||||
10 23
|
||||
5F
|
||||
57
|
||||
B0 # return #
|
||||
|
||||
00 00 # native count
|
||||
# native pool
|
||||
|
||||
7
test/testError.c0
Normal file
7
test/testError.c0
Normal file
@@ -0,0 +1,7 @@
|
||||
#use <conio>
|
||||
|
||||
int main() {
|
||||
assert(2==2);
|
||||
print("yolomode");
|
||||
return 1;
|
||||
}
|
||||
40
test/testError.c0.bc0
Normal file
40
test/testError.c0.bc0
Normal file
@@ -0,0 +1,40 @@
|
||||
C0 C0 FF EE # magic number
|
||||
00 09 # version 4, arch = 1 (64 bits)
|
||||
|
||||
00 00 # int pool count
|
||||
# int pool
|
||||
|
||||
00 2E # string pool total size
|
||||
# string pool
|
||||
74 65 73 74 45 72 72 6F 72 2E 63 30 3A 34 2E 33 2D 34 2E 31 36 3A 20 61 73 73 65 72 74 20 66 61 69 6C 65 64 00 # "testError.c0:4.3-4.16: assert failed"
|
||||
79 6F 6C 6F 6D 6F 64 65 00 # "yolomode"
|
||||
|
||||
00 01 # function count
|
||||
# function_pool
|
||||
|
||||
#<main>
|
||||
00 00 # number of arguments = 0
|
||||
00 00 # number of local variables = 0
|
||||
00 1F # code length = 31 bytes
|
||||
10 02 # bipush 2 # 2
|
||||
10 02 # bipush 2 # 2
|
||||
9F 00 06 # if_cmpeq +6 # if (2 == 2) goto <00:cond_true>
|
||||
A7 00 08 # goto +8 # goto <01:cond_false>
|
||||
# <00:cond_true>
|
||||
10 01 # bipush 1 # true
|
||||
A7 00 05 # goto +5 # goto <02:cond_end>
|
||||
# <01:cond_false>
|
||||
10 00 # bipush 0 # false
|
||||
# <02:cond_end>
|
||||
14 00 00 # aldc 0 # s[0] = "testError.c0:4.3-4.16: assert failed"
|
||||
CF # assert # assert(2 == 2) [failure message on stack]
|
||||
14 00 25 # aldc 37 # s[37] = "yolomode"
|
||||
B7 00 00 # invokenative 0 # print("yolomode")
|
||||
57 # pop # (ignore result)
|
||||
10 01 # bipush 1 # 1
|
||||
B0 # return #
|
||||
|
||||
00 01 # native count
|
||||
# native pool
|
||||
00 01 00 06 # print
|
||||
|
||||
1
test/testError.c0.bc0out
Normal file
1
test/testError.c0.bc0out
Normal file
@@ -0,0 +1 @@
|
||||
yolomode1
|
||||
1
test/testError.c0.c0out
Normal file
1
test/testError.c0.c0out
Normal file
@@ -0,0 +1 @@
|
||||
yolomode1
|
||||
BIN
test/testError.c0.ex
Executable file
BIN
test/testError.c0.ex
Executable file
Binary file not shown.
Reference in New Issue
Block a user