aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-08-02 20:54:08 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-08-02 20:54:08 +0300
commit9251fddfdfb11b9e1b2dff643aa20ec82e9f7036 (patch)
treefa6045ac60ab66cfd04b820d50b9f92f86f2bfc7 /src
parent6c12792402503705bf921d56ea3b309408bb417a (diff)
downloadcopyjit-9251fddfdfb11b9e1b2dff643aa20ec82e9f7036.tar.gz
copyjit-9251fddfdfb11b9e1b2dff643aa20ec82e9f7036.zip
add return values to main loop
Diffstat (limited to 'src')
-rw-r--r--src/copyjit.c5
-rw-r--r--src/copyjit.h2
-rw-r--r--src/main.c11
3 files changed, 10 insertions, 8 deletions
diff --git a/src/copyjit.c b/src/copyjit.c
index f09cb99..393c8e1 100644
--- a/src/copyjit.c
+++ b/src/copyjit.c
@@ -476,9 +476,10 @@ void compile_finish(ctx_t *ctx)
__builtin___clear_cache(ctx->buf, ctx->buf + ctx->size);
}
-void run(ctx_t *ctx)
+unsigned long run(ctx_t *ctx)
{
void *sp = malloc(4096);
- JUMP(ctx->buf, sp, 0, 0, 0, 0);
+ unsigned long a = CALL(ctx->buf, sp, 0, 0, 0, 0);
free(sp);
+ return a;
}
diff --git a/src/copyjit.h b/src/copyjit.h
index 6c0a247..d752144 100644
--- a/src/copyjit.h
+++ b/src/copyjit.h
@@ -32,6 +32,6 @@ void *compile_sly(ctx_t *ctx, unsigned long i);
void compile_start(ctx_t *ctx);
void compile_finish(ctx_t *ctx);
-void run(ctx_t *ctx);
+unsigned long run(ctx_t *ctx);
#endif /* HMMJIT_H */
diff --git a/src/main.c b/src/main.c
index 78f9f9e..de287f6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: copyleft-next-0.3.1 */
#include <stdint.h>
+#include <stdio.h>
#include <stddef.h>
#include "copyjit.h"
@@ -10,12 +11,12 @@ int main()
ctx_t ctx;
compile_start(&ctx);
- compile_fast_lia(&ctx, 0); // total in a
+ compile_fast_lix(&ctx, 0); // total in x
- compile_fast_liy(&ctx, 0);
+ compile_fast_liy(&ctx, 0); // iter in y
- void *top = compile_movxa(&ctx); // iter + total in a
- compile_add(&ctx);
+ void *top = compile_add(&ctx); // iter + total in a
+ compile_movxa(&ctx); // move total to x
compile_incy(&ctx); // increment iter
compile_fast_lio(&ctx, 1000000000); // limit in o
@@ -30,5 +31,5 @@ int main()
compile_finish(&ctx);
- run(&ctx);
+ printf("%lu\n", run(&ctx));
}