diff --git a/creole.c b/creole.c index 9df59bd..d5f6648 100644 --- a/creole.c +++ b/creole.c @@ -559,7 +559,7 @@ load_into_array(const struct creole_reader *start, creole_word *buf, size_t bufl { size_t i = 0; struct creole_word w; - struct creole_reader r = start; + struct creole_reader r = *start; while (creole_decode(&r, &w) && i < buflen) { buf[i++] = w.word; @@ -573,7 +573,7 @@ upsilon_load_waveform(struct creole_env *env, creole_word slot, creole_word db) { creole_word buf[MAX_WL_SIZE]; - size_t len = load_into_array(env->dats[db], buf, ARRAY_SIZE(buf)); + size_t len = load_into_array(env->dats + db, buf, ARRAY_SIZE(buf)); if (len < MAX_WL_SIZE) return 0; return waveform_load(buf, slot, K_FOREVER); @@ -591,12 +591,13 @@ upsilon_sendval(struct creole_env *env, creole_word num) static creole_word upsilon_senddat(struct creole_env *env, creole_word db) { - char buf[128]; +#define SENDDAT_BUFLEN 128 + char buf[SENDDAT_BUFLEN]; struct bufptr bp = {buf, 0}; struct creole_word w; - struct creole_reader r = start; + struct creole_reader r = env->dats[db]; - while (creole_decode(&r, &w) && bp.left < buflen) { + while (creole_decode(&r, &w) && bp.left < SENDDAT_BUFLEN) { if (w.word > 0xFF) return -EINVAL; buf[bp.left++] = w.word; @@ -641,8 +642,8 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc) switch (ins.opcode) { case CREOLE_DB: - env->dats[ins->w[0]].p = ins->datapt; - env->dats[ins->w[0]].left = ins->dataptlen; + env->dats[ins.w[0]].p = ins.datapt; + env->dats[ins.w[0]].left = ins.dataptlen; break; case CREOLE_PUSH: @@ -753,7 +754,7 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc) check(read_val(env, &ins, 0, &a1)); check(read_val(env, &ins, 0, &a2)); - if (valid_reglen(env, a1) && valid_reglen(env, a2)) { + if (valid_register(env, a1) && valid_register(env, a2)) { a0 = cloop_read(a0, env->reg + a1, env->reg + a2, K_FOREVER); check(creole_push(env, a0)); } else { @@ -792,7 +793,7 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc) case CREOLE_SENDVAL: check(read_val(env, &ins, 0, &a0)); - check(creole_push(env, upsilon_sendval(a0))); + check(creole_push(env, upsilon_sendval(env, a0))); break; case CREOLE_SENDDAT: