add adc and dac switch

This commit is contained in:
Peter McGoron @ planck 2023-04-04 15:10:26 -04:00
parent c7fc965fcf
commit 0ead095044
2 changed files with 19 additions and 3 deletions

View File

@ -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;

View File

@ -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
};