diff options
author | kdx <kikoodx@paranoici.org> | 2023-06-10 04:20:47 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-06-10 04:20:47 +0200 |
commit | e1ff68811c2283154d08c21b88441891c7c29896 (patch) | |
tree | bc5b1373d2990ed436cfb7c4e9e1a58f83b6a8b1 | |
parent | 0e97b7a73a142c91268a605e3b0cf024a9a48981 (diff) | |
download | golem-e1ff68811c2283154d08c21b88441891c7c29896.tar.gz |
save function args
-rw-r--r-- | src/main.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -643,6 +643,15 @@ gen_function(Node *node) printf("\tLIT %04x ADD\n", locals_size); printf("\tLIT ,__stack_ptr STA\n"); + /* TODO: optimize this using DUP */ + cur = locals; + for (int i = 0; i < argcount; i++) { + printf("\tLIT ,__stack_ptr LDA ( %.*s )\n", cur->len, cur->loc); + printf("\tLIT %04x SUB\n", locals_size - i - 1); + printf("\tSWP STA\n"); + cur = cur->next; + } + while (node != NULL) { switch (node->type) { case NOD_EXPR_STMT: |