test: Add "addition" codegen test
This commit is contained in:
parent
2d6c68b2ed
commit
314522210c
4 changed files with 38 additions and 0 deletions
3
test/simple_add.c0
Normal file
3
test/simple_add.c0
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
int main() {
|
||||
return 1 + 1;
|
||||
}
|
||||
15
test/simple_add.c0.expected
Normal file
15
test/simple_add.c0.expected
Normal 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
4
test/var_add.c0
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
int main() {
|
||||
int x = 1;
|
||||
return x + 2;
|
||||
}
|
||||
16
test/var_add.c0.expected
Normal file
16
test/var_add.c0.expected
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue