aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrun.sh2
-rw-r--r--src/generator.c10
2 files changed, 11 insertions, 1 deletions
diff --git a/run.sh b/run.sh
index 19360df..402c058 100755
--- a/run.sh
+++ b/run.sh
@@ -21,5 +21,5 @@ make build/output.out
set +e
-build/output.out
+build/output.out 1 2 3 4 "Hello World" "huh looky here :^)"
echo "Exit status: $?" \ No newline at end of file
diff --git a/src/generator.c b/src/generator.c
index 829bf73..6fcccbf 100644
--- a/src/generator.c
+++ b/src/generator.c
@@ -454,6 +454,13 @@ void generate_asm(Node *root, FILE *out)
fprintf(out, "global _start\n");
fprintf(out, "_start:\n");
#endif
+ // Push argv
+ fprintf(out, " mov rax, rsi\n");
+ fprintf(out, " push rax\n");
+ // Push argc
+ fprintf(out, " mov rax, rdi\n");
+ fprintf(out, " push rax\n");
+
fprintf(out, " call func_main\n");
fprintf(out, " mov rdi, rax\n");
@@ -468,6 +475,9 @@ void generate_asm(Node *root, FILE *out)
// Global strings
fprintf(out, "section .data\n");
+ // TODO: Don't to this here because a string containing a backtick will
+ // cause invalid output and break everything. Maybe just output the
+ // byte values.
for (i64 i = 0; i < num_string_literals; i++) {
fprintf(out, " global_string_%lld: db `%s`, 0\n", i, all_string_literals[i]);
}