tests update

This commit is contained in:
Scarlett
2025-05-06 22:35:26 -04:00
parent 6e34758ac9
commit 5a01cb8419
49 changed files with 442 additions and 291 deletions

View File

@ -1,4 +1,4 @@
001:
001:
002: type string: 1 -> character
003: type BooleanXBoolean: [Boolean: x; Boolean: y]
004: type characterXcharacter: [character: x; character: y]
@ -34,7 +34,7 @@
034: external function inC: integer2character
035:
036: function entry: string2integer
037:
037:
038: entry (arg) := {
039: [integer:x; integer:y; integer: result]
040:

View File

@ -1,16 +1,12 @@
1: func_dec : entry
2: func : entry
3: $t0 = 1
4: Label : 1
5: y = $t0
6: $t1 = 3
7: Label : 2
8: x = $t1
9: $t2 = x + y
10: Label : 3
11: y = $t2
12: param y
13: call : printInteger 1
14: Label : 4
15: result = $t3
16: return : y
4: y = $t0
5: $t1 = 3
6: x = $t1
7: $t2 = x + y
8: y = $t2
9: param y
10: call : printInteger 1
11: result = $t3
12: return : y

View File

@ -2,27 +2,23 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $400, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $1, -12(%rbp) #constant assign
.L1:
movl -12(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl $3, -20(%rbp) #constant assign
.L2:
movl -20(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -24(%rbp), %eax #addition start
addl -16(%rbp), %eax
movl %eax, -28(%rbp) #addition end
.L3:
movl -28(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl -16(%rbp), %edi #adding param start
call printInteger
movl %eax, -32(%rbp) #store return from call
.L4:
movl -32(%rbp), %eax #assign start
movl %eax, -36(%rbp) #assign end
movl -16(%rbp), %eax #return y

View File

@ -35,26 +35,26 @@
035:
036: function entry: string2integer
037:
038:
039: type rec: [integer: x; integer: y; integer: z; integer: a; integer: b; integer: c; integer: d]
040: type T2: rec -> integer
041: type T: integer -> integer
042: function bar: T2
043: function ahh: T
044:
045: ahh (a) := {
046: a := printInteger(a);
047: return -1;
048: }
049:
050: bar (a, b, c,d,e,f,g) := {
051: a := printInteger(g);
052: return b;
053: }
054:
055: entry (arg) := {
056: [integer:x; integer:y; integer: result]
057:
038: type rec: [integer: x; integer: y; integer: z; integer: a; integer: b; integer: c; integer: d]
039: type T2: rec -> integer
040: type T: integer -> integer
041: function bar: T2
042: function ahh: T
043:
044: ahh (a) := {
045: a := printInteger(a);
046: return -1;
047: }
048:
049: bar (a, b, c,d,e,f,g) := {
050: a := printInteger(g);
051: return b;
052: }
053:
054: entry (arg) := {
055: [integer:x; integer:y; integer: result; character: a]
056: a := 'a';
057: x := printCharacter(a);
058: result := bar(1,2,3,4,5,6,7);
059: return 1;
060: }

View File

@ -4,34 +4,36 @@
4: func : ahh
5: param a
6: call : printInteger 1
7: Label : 1
8: a = $t0
9: $t1 = 1
10: $t2 = -$t1
11: return : $t2
12: func : bar
13: param g
14: call : printInteger 1
15: Label : 2
16: a = $t3
17: return : b
18: func : entry
19: $t4 = 1
20: $t5 = 2
21: $t6 = 3
22: $t7 = 4
23: $t8 = 5
24: $t9 = 6
25: $t10 = 7
26: param $t10
27: param $t9
28: param $t8
29: param $t7
30: param $t6
31: param $t5
32: param $t4
33: call : bar 7
34: Label : 3
35: result = $t11
36: $t12 = 1
37: return : $t12
7: a = $t0
8: $t1 = 1
9: $t2 = -$t1
10: return : $t2
11: func : bar
12: param g
13: call : printInteger 1
14: a = $t3
15: return : b
16: func : entry
17: $t4 = a
18: a = $t4
19: param a
20: call : printCharacter 1
21: x = $t5
22: $t6 = 1
23: $t7 = 2
24: $t8 = 3
25: $t9 = 4
26: $t10 = 5
27: $t11 = 6
28: $t12 = 7
29: param $t12
30: param $t11
31: param $t10
32: param $t9
33: param $t8
34: param $t7
35: param $t6
36: call : bar 7
37: result = $t13
38: $t14 = 1
39: return : $t14

View File

@ -2,12 +2,11 @@
ahh:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $576, %rsp
movl %edi, -4(%rbp) #FunctionStart1param end
movl -4(%rbp), %edi #adding param start
call printInteger
movl %eax, -8(%rbp) #store return from call
.L1:
movl -8(%rbp), %eax #assign start
movl %eax, -4(%rbp) #assign end
movl $1, -12(%rbp) #constant assign
@ -20,7 +19,7 @@ ahh:
bar:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $576, %rsp
movl 20(%rbp), %eax #FunctionStart1Param start
movl %eax, -4(%rbp) #FunctionStart1param end
movl %r9d, -12(%rbp) #FunctionStart1param end
@ -32,7 +31,6 @@ bar:
movl -32(%rbp), %edi #adding param start
call printInteger
movl %eax, -36(%rbp) #store return from call
.L2:
movl -36(%rbp), %eax #assign start
movl %eax, -4(%rbp) #assign end
movl -12(%rbp), %eax #return b
@ -41,29 +39,36 @@ bar:
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $1, -12(%rbp) #constant assign
movl $2, -16(%rbp) #constant assign
movl $3, -20(%rbp) #constant assign
movl $4, -24(%rbp) #constant assign
movl $5, -28(%rbp) #constant assign
movl $6, -32(%rbp) #constant assign
movl $7, -36(%rbp) #constant assign
movl -36(%rbp), %edi #adding param start
movl -32(%rbp), %esi #adding param start
movl -28(%rbp), %edx #adding param start
movl -24(%rbp), %ecx #adding param start
movl -20(%rbp), %r8d #adding param start
movl -16(%rbp), %r9d #adding param start
movl -12(%rbp), %eax #adding param start
movl %eax, 88(%rbp) #adding param end
subq $576, %rsp
movl %edi, -12(%rbp) #FunctionStart1param end
movl $97, -13(%rbp) #constant assign
movl -13(%rbp), %eax #assign start
movl %eax, -14(%rbp) #assign end
movl -14(%rbp), %edi #adding param start
call printCharacter
movl %eax, -20(%rbp) #store return from call
movl -20(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl $1, -28(%rbp) #constant assign
movl $2, -32(%rbp) #constant assign
movl $3, -36(%rbp) #constant assign
movl $4, -40(%rbp) #constant assign
movl $5, -44(%rbp) #constant assign
movl $6, -48(%rbp) #constant assign
movl $7, -52(%rbp) #constant assign
movl -52(%rbp), %edi #adding param start
movl -48(%rbp), %esi #adding param start
movl -44(%rbp), %edx #adding param start
movl -40(%rbp), %ecx #adding param start
movl -36(%rbp), %r8d #adding param start
movl -32(%rbp), %r9d #adding param start
movl -28(%rbp), %eax #adding param start
movl %eax, 152(%rbp) #adding param end
call bar
movl %eax, -44(%rbp) #store return from call
.L3:
movl -44(%rbp), %eax #assign start
movl %eax, -48(%rbp) #assign end
movl $1, -52(%rbp) #constant assign
movl -52(%rbp), %eax #return $t12
movl %eax, -60(%rbp) #store return from call
movl -60(%rbp), %eax #assign start
movl %eax, -64(%rbp) #assign end
movl $1, -68(%rbp) #constant assign
movl -68(%rbp), %eax #return $t14
leave
ret

View File

@ -1,16 +1,12 @@
1: func_dec : entry
2: func : entry
3: $t0 = 24
4: Label : 1
5: x = $t0
6: $t1 = 3
7: Label : 2
8: y = $t1
9: $t2 = x / y
10: Label : 3
11: y = $t2
12: param y
13: call : printInteger 1
14: Label : 4
15: result = $t3
16: return : y
4: x = $t0
5: $t1 = 3
6: y = $t1
7: $t2 = x / y
8: y = $t2
9: param y
10: call : printInteger 1
11: result = $t3
12: return : y

View File

@ -2,27 +2,23 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $400, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $24, -12(%rbp) #constant assign
.L1:
movl -12(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl $3, -20(%rbp) #constant assign
.L2:
movl -20(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -16(%rbp), %eax #division start
cltd
idivl -24(%rbp)
movl %eax, -28(%rbp) #division end
.L3:
movl -28(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -24(%rbp), %edi #adding param start
call printInteger
movl %eax, -32(%rbp) #store return from call
.L4:
movl -32(%rbp), %eax #assign start
movl %eax, -36(%rbp) #assign end
movl -24(%rbp), %eax #return y

View File

@ -1,17 +1,16 @@
1: func_dec : entry
2: func : entry
3: $t0 = 1
4: Label : 1
5: x = $t0
6: $t1 = 2
7: Label : 2
8: y = $t1
9: $t2 = x == y
10: Label : 3
4: x = $t0
5: $t1 = 2
6: y = $t1
7: $t2 = x == y
8: if $t2 True GOTO 1
9: GOTO : 1
10: Label : 1
11: b = $t2
12: param b
13: call : printBoolean 1
14: Label : 4
15: result = $t3
16: $t4 = 1
17: return : $t4
14: result = $t3
15: $t4 = 1
16: return : $t4

View File

@ -2,30 +2,31 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $416, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $1, -12(%rbp) #constant assign
.L1:
movl -12(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl $2, -20(%rbp) #constant assign
.L2:
movl -20(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -16(%rbp), %eax #equal to start
cmpl -24(%rbp), %eax
sete %al
movb $0, -25(%rbp)
movb %al, -25(%rbp) #equal to end
.L3:
cmpb $0, -25(%rbp) #if true start
jne .L1 #if true end
jmp .L1
.L1:
movl -25(%rbp), %eax #assign start
movl %eax, -26(%rbp) #assign end
movl -26(%rbp), %edi #adding param start
call printBoolean
movl %eax, -30(%rbp) #store return from call
.L4:
movl -30(%rbp), %eax #assign start
movl %eax, -34(%rbp) #assign end
movl $1, -38(%rbp) #constant assign
movl -38(%rbp), %eax #return $t4
movl %eax, -32(%rbp) #store return from call
movl -32(%rbp), %eax #assign start
movl %eax, -36(%rbp) #assign end
movl $1, -40(%rbp) #constant assign
movl -40(%rbp), %eax #return $t4
leave
ret

View File

@ -1,17 +1,16 @@
1: func_dec : entry
2: func : entry
3: $t0 = 1
4: Label : 1
5: x = $t0
6: $t1 = 2
7: Label : 2
8: y = $t1
9: $t2 = x < y
10: Label : 3
4: x = $t0
5: $t1 = 2
6: y = $t1
7: $t2 = x < y
8: if $t2 True GOTO 1
9: GOTO : 1
10: Label : 1
11: b = $t2
12: param b
13: call : printBoolean 1
14: Label : 4
15: result = $t3
16: $t4 = 1
17: return : $t4
14: result = $t3
15: $t4 = 1
16: return : $t4

View File

@ -2,30 +2,30 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $416, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $1, -12(%rbp) #constant assign
.L1:
movl -12(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl $2, -20(%rbp) #constant assign
.L2:
movl -20(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -16(%rbp), %eax #less than start
cmpl -24(%rbp), %eax
setl %al
movb %al, -25(%rbp) #less than end
.L3:
cmpb $0, -25(%rbp) #if true start
jne .L1 #if true end
jmp .L1
.L1:
movl -25(%rbp), %eax #assign start
movl %eax, -26(%rbp) #assign end
movl -26(%rbp), %edi #adding param start
call printBoolean
movl %eax, -30(%rbp) #store return from call
.L4:
movl -30(%rbp), %eax #assign start
movl %eax, -34(%rbp) #assign end
movl $1, -38(%rbp) #constant assign
movl -38(%rbp), %eax #return $t4
movl %eax, -32(%rbp) #store return from call
movl -32(%rbp), %eax #assign start
movl %eax, -36(%rbp) #assign end
movl $1, -40(%rbp) #constant assign
movl -40(%rbp), %eax #return $t4
leave
ret

View File

@ -1,16 +1,12 @@
1: func_dec : entry
2: func : entry
3: $t0 = 4
4: Label : 1
5: x = $t0
6: $t1 = 20
7: Label : 2
8: y = $t1
9: $t2 = y % x
10: Label : 3
11: y = $t2
12: param y
13: call : printInteger 1
14: Label : 4
15: result = $t3
16: return : y
4: x = $t0
5: $t1 = 20
6: y = $t1
7: $t2 = y % x
8: y = $t2
9: param y
10: call : printInteger 1
11: result = $t3
12: return : y

View File

@ -2,27 +2,23 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $400, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $4, -12(%rbp) #constant assign
.L1:
movl -12(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl $20, -20(%rbp) #constant assign
.L2:
movl -20(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -24(%rbp), %eax #mod start
cltd
idivl -16(%rbp)
movl %edx, -28(%rbp) #mod end
.L3:
movl -28(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -24(%rbp), %edi #adding param start
call printInteger
movl %eax, -32(%rbp) #store return from call
.L4:
movl -32(%rbp), %eax #assign start
movl %eax, -36(%rbp) #assign end
movl -24(%rbp), %eax #return y

View File

@ -1,16 +1,12 @@
1: func_dec : entry
2: func : entry
3: $t0 = 3
4: Label : 1
5: x = $t0
6: $t1 = 20
7: Label : 2
8: y = $t1
9: $t2 = x * y
10: Label : 3
11: y = $t2
12: param y
13: call : printInteger 1
14: Label : 4
15: result = $t3
16: return : y
4: x = $t0
5: $t1 = 20
6: y = $t1
7: $t2 = x * y
8: y = $t2
9: param y
10: call : printInteger 1
11: result = $t3
12: return : y

View File

@ -2,26 +2,22 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $400, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $3, -12(%rbp) #constant assign
.L1:
movl -12(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl $20, -20(%rbp) #constant assign
.L2:
movl -20(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -16(%rbp), %eax #multiplication start
imull -24(%rbp), %eax
movl %eax, -28(%rbp) #multiplication end
.L3:
movl -28(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -24(%rbp), %edi #adding param start
call printInteger
movl %eax, -32(%rbp) #store return from call
.L4:
movl -32(%rbp), %eax #assign start
movl %eax, -36(%rbp) #assign end
movl -24(%rbp), %eax #return y

View File

@ -1,13 +1,10 @@
1: func_dec : entry
2: func : entry
3: $t0 = 3
4: Label : 1
5: x = $t0
6: $t1 = -x
7: Label : 2
8: y = $t1
9: param y
10: call : printInteger 1
11: Label : 3
12: result = $t2
13: return : y
4: x = $t0
5: $t1 = -x
6: y = $t1
7: param y
8: call : printInteger 1
9: result = $t2
10: return : y

View File

@ -2,22 +2,19 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $400, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $3, -12(%rbp) #constant assign
.L1:
movl -12(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl -16(%rbp), %eax #negation start
negl %eax
movl %eax, -20(%rbp) #negation end
.L2:
movl -20(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -24(%rbp), %edi #adding param start
call printInteger
movl %eax, -28(%rbp) #store return from call
.L3:
movl -28(%rbp), %eax #assign start
movl %eax, -32(%rbp) #assign end
movl -24(%rbp), %eax #return y

View File

@ -7,7 +7,6 @@
7: d = $t1
8: param d
9: call : printBoolean 1
10: Label : 3
11: result = $t2
12: $t3 = 1
13: return : $t3
10: result = $t2
11: $t3 = 1
12: return : $t3

View File

@ -2,20 +2,19 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $400, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $-1, -9(%rbp) #constant assign
movl $1, -9(%rbp) #constant assign
.L1:
movl -9(%rbp), %eax #assign start
movl %eax, -10(%rbp) #assign end
.L2:
movl -11(%rbp), %edi #adding param start
call printBoolean
movl %eax, -15(%rbp) #store return from call
.L3:
movl -15(%rbp), %eax #assign start
movl %eax, -19(%rbp) #assign end
movl $1, -23(%rbp) #constant assign
movl -23(%rbp), %eax #return $t3
movl %eax, -18(%rbp) #store return from call
movl -18(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl $1, -28(%rbp) #constant assign
movl -28(%rbp), %eax #return $t3
leave
ret

View File

@ -7,18 +7,16 @@
7: Label : 2
8: d = $t1
9: $t2 = true
10: Label : 3
11: if c True GOTO 5
12: GOTO : 4
13: Label : 4
14: if d True GOTO 5
15: $t2 = false
16: GOTO : 5
17: Label : 5
18: d = $t2
19: param d
20: call : printBoolean 1
21: Label : 6
22: result = $t3
23: $t4 = 1
24: return : $t4
10: if c True GOTO 4
11: GOTO : 3
12: Label : 3
13: if d True GOTO 4
14: $t2 = false
15: GOTO : 4
16: Label : 4
17: d = $t2
18: param d
19: call : printBoolean 1
20: result = $t3
21: $t4 = 1
22: return : $t4

View File

@ -2,30 +2,34 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $416, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $-1, -9(%rbp) #constant assign
movl $1, -9(%rbp) #constant assign
.L1:
movl -9(%rbp), %eax #assign start
movl %eax, -10(%rbp) #assign end
movl $-1, -11(%rbp) #constant assign
movl $0, -11(%rbp) #constant assign
.L2:
movl -11(%rbp), %eax #assign start
movl %eax, -12(%rbp) #assign end
movl $-1, -13(%rbp) #constant assign
movl $1, -13(%rbp) #constant assign
cmpb $0, -10(%rbp) #if true start
jne .L4 #if true end
jmp .L3
.L3:
cmpb $0, -12(%rbp) #if true start
jne .L4 #if true end
movl $0, -13(%rbp) #constant assign
jmp .L4
.L4:
movl $-1, -13(%rbp) #constant assign
.L5:
movl -13(%rbp), %eax #assign start
movl %eax, -12(%rbp) #assign end
movl -12(%rbp), %edi #adding param start
call printBoolean
movl %eax, -17(%rbp) #store return from call
.L6:
movl -17(%rbp), %eax #assign start
movl %eax, -21(%rbp) #assign end
movl $1, -25(%rbp) #constant assign
movl -25(%rbp), %eax #return $t4
movl %eax, -18(%rbp) #store return from call
movl -18(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl $1, -28(%rbp) #constant assign
movl -28(%rbp), %eax #return $t4
leave
ret

View File

@ -1,16 +1,12 @@
1: func_dec : entry
2: func : entry
3: $t0 = 1
4: Label : 1
5: y = $t0
6: $t1 = 3
7: Label : 2
8: x = $t1
9: $t2 = x - y
10: Label : 3
11: y = $t2
12: param y
13: call : printInteger 1
14: Label : 4
15: result = $t3
16: return : y
4: y = $t0
5: $t1 = 3
6: x = $t1
7: $t2 = x - y
8: y = $t2
9: param y
10: call : printInteger 1
11: result = $t3
12: return : y

View File

@ -2,26 +2,22 @@
entry:
pushq %rbp
movq %rsp, %rbp
subq $128, %rsp
subq $400, %rsp
movl %edi, -8(%rbp) #FunctionStart1param end
movl $1, -12(%rbp) #constant assign
.L1:
movl -12(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl $3, -20(%rbp) #constant assign
.L2:
movl -20(%rbp), %eax #assign start
movl %eax, -24(%rbp) #assign end
movl -24(%rbp), %eax #subtraction start
subl -16(%rbp), %eax
movl %eax, -28(%rbp) #subtraction end
.L3:
movl -28(%rbp), %eax #assign start
movl %eax, -16(%rbp) #assign end
movl -16(%rbp), %edi #adding param start
call printInteger
movl %eax, -32(%rbp) #store return from call
.L4:
movl -32(%rbp), %eax #assign start
movl %eax, -36(%rbp) #assign end
movl -16(%rbp), %eax #return y