From 0ead095044c93825c7db8cec0a6b92769bac7a7d Mon Sep 17 00:00:00 2001 From: "Peter McGoron @ planck" Date: Tue, 4 Apr 2023 15:10:26 -0400 Subject: [PATCH] add adc and dac switch --- creole.c | 20 +++++++++++++++++--- creole.h | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/creole.c b/creole.c index d5f6648..474d205 100644 --- a/creole.c +++ b/creole.c @@ -42,7 +42,7 @@ enum creole_arg_type { [i] = v, * in C89 indicies are implicit from 0 to the maximum filled-in value. */ -#define defop(s, n, a1, a2, a3) {n, {a1, a2, a3}} +#define defop(s, n, a1, a2, a3) [CREOLE_##s] = {n, {a1, a2, a3}} static const struct { int arglen; enum creole_arg_type argtype[CREOLE_MAX_ARG]; @@ -66,7 +66,7 @@ static const struct { defop(CLOOP_READ, 2, TYPE_VAL, TYPE_REG, TYPE_NONE), defop(CLOOP_WRITE, 2, TYPE_VAL, TYPE_VAL, TYPE_NONE), defop(WF_LOAD, 2, TYPE_VAL, TYPE_IMM, TYPE_NONE), - defop(WF_EXEC, 3, TYPE_VAL, TYPE_VAL, TYPE_VAL), + defop(WF_ARM, 3, TYPE_VAL, TYPE_VAL, TYPE_VAL), defop(SENDVAL, 1, TYPE_VAL, TYPE_NONE, TYPE_NONE), defop(SENDDAT, 1, TYPE_IMM, TYPE_NONE, TYPE_NONE), defop(WF_DISARM, 1, TYPE_VAL, TYPE_NONE, TYPE_NONE), @@ -77,7 +77,9 @@ static const struct { defop(TAKE_WF, 2, TYPE_VAL, TYPE_VAL, TYPE_NONE), defop(RELEASE_WF, 1, TYPE_VAL, TYPE_NONE, TYPE_NONE), defop(TAKE_CLOOP, 1, TYPE_VAL, TYPE_NONE, TYPE_NONE), - defop(RELEASE_CLOOP, 0, TYPE_NONE, TYPE_NONE, TYPE_NONE) + defop(RELEASE_CLOOP, 0, TYPE_NONE, TYPE_NONE, TYPE_NONE), + defop(SWITCH_ADC, 2, TYPE_VAL, TYPE_VAL, TYPE_NONE), + defop(SWITCH_DAC, 2, TYPE_VAL, TYPE_VAL, TYPE_NONE) }; /************************************************************************* @@ -843,6 +845,18 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc) check(creole_push(env, cloop_release())); break; + case CREOLE_SWITCH_ADC: + check(read_val(env, &ins, 0, &a0)); + check(read_val(env, &ins, 1, &a1)); + check(creole_push(env, adc_switch(a0, a1, K_FOREVER))); + break; + + case CREOLE_SWITCH_DAC: + check(read_val(env, &ins, 0, &a0)); + check(read_val(env, &ins, 1, &a1)); + check(creole_push(env, dac_switch(a0, a1, K_FOREVER))); + break; + default: rcode = CREOLE_STEP_UNKNOWN_OPCODE; break; diff --git a/creole.h b/creole.h index 184ab0b..f35bd89 100644 --- a/creole.h +++ b/creole.h @@ -65,6 +65,8 @@ enum creole_opcode { CREOLE_RELEASE_WF = 28, CREOLE_TAKE_CLOOP = 29, CREOLE_RELEASE_CLOOP = 30, + CREOLE_SWITCH_ADC = 31, + CREOLE_SWITCH_DAC = 32, CREOLE_OPCODE_LEN };