test: Add "addition" codegen test

This commit is contained in:
Laborratte 5 2025-05-15 17:50:53 +02:00
parent 2d6c68b2ed
commit 314522210c
Signed by: Laborratte5
GPG key ID: 3A30072E35202C02
4 changed files with 38 additions and 0 deletions

3
test/simple_add.c0 Normal file
View file

@ -0,0 +1,3 @@
int main() {
return 1 + 1;
}

View file

@ -0,0 +1,15 @@
.global main
.global _main
.text
main:
call _main
# move the return value into the first argument for the syscall
movq %rax, %rdi
# move the exit syscall number into rax
movq $0x3C, %rax
syscall
_main:
# your generated code here
mov $1,%0
add %0,%0
ret

4
test/var_add.c0 Normal file
View file

@ -0,0 +1,4 @@
int main() {
int x = 1;
return x + 2;
}

16
test/var_add.c0.expected Normal file
View file

@ -0,0 +1,16 @@
.global main
.global _main
.text
main:
call _main
# move the return value into the first argument for the syscall
movq %rax, %rdi
# move the exit syscall number into rax
movq $0x3C, %rax
syscall
_main:
# your generated code here
mov $1,%0
mov $2,%1
add %0,%1
ret