diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/copyjit.c | 5 | ||||
| -rw-r--r-- | src/copyjit.h | 2 | ||||
| -rw-r--r-- | src/main.c | 11 |
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 */ @@ -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)); } |
