diff --git a/test/simple_add.c0 b/test/simple_add.c0 new file mode 100644 index 0000000..932f743 --- /dev/null +++ b/test/simple_add.c0 @@ -0,0 +1,3 @@ +int main() { + return 1 + 1; +} \ No newline at end of file diff --git a/test/simple_add.c0.expected b/test/simple_add.c0.expected new file mode 100644 index 0000000..19c78a0 --- /dev/null +++ b/test/simple_add.c0.expected @@ -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 diff --git a/test/var_add.c0 b/test/var_add.c0 new file mode 100644 index 0000000..959d0ec --- /dev/null +++ b/test/var_add.c0 @@ -0,0 +1,4 @@ +int main() { + int x = 1; + return x + 2; +} \ No newline at end of file diff --git a/test/var_add.c0.expected b/test/var_add.c0.expected new file mode 100644 index 0000000..4d57163 --- /dev/null +++ b/test/var_add.c0.expected @@ -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