diff --git a/asm/creole.py b/asm/creole.py index d8f5d32..bdf8ea7 100644 --- a/asm/creole.py +++ b/asm/creole.py @@ -210,6 +210,16 @@ class Instruction(Enum): J = "JE", "_render_j", ArgType.LAB JNE = 10, "_render_default", ArgType.LAB, ArgType.VAL, ArgType.VAL DB = 11, "_render_default", ArgType.DAT, ArgType.STR + READ_ADC = 12, "_render_default", ArgType.VAL, ArgType.REG + READ_DAC = 13, "_render_default", ArgType.VAL, ArgType.REG + WRITE_DAC = 14, "_render_default", ArgType.VAL, ArgType.VAL + SLEEP = 15, "_render_default", ArgType.VAL + CLOOP_READ = 16, "_render_default", ArgType.VAL, ArgType.REG + CLOOP_WRITE = 17, "_render_default", ArgType.VAL, ArgType.VAL + WF_LOAD = 18, "_render_default", ArgType.VAL, ArgType.DAT + WF_EXEC = 19, "_render_default", ArgType.VAL, ArgType.VAL + SENDVAL = 20, "_render_default", ArgType.VAL + SENDDAT = 21, "_render_default", ArgType.DAT def __int__(self): """ Returns the opcode associated with the Instruction. diff --git a/creole.c b/creole.c index 5ddfb0c..37c444b 100644 --- a/creole.c +++ b/creole.c @@ -13,6 +13,7 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "creole.h" +#include "upsilon_creole.h" /************************************************************************* * Static information @@ -53,7 +54,17 @@ static const struct { defop(JLE, 3, TYPE_IMM, TYPE_VAL, TYPE_VAL), defop(JE, 3, TYPE_IMM, TYPE_VAL, TYPE_VAL), defop(JNE, 3, TYPE_IMM, TYPE_VAL, TYPE_VAL), - defop(DB, 1, TYPE_IMM, TYPE_NONE, TYPE_NONE) + defop(DB, 1, TYPE_IMM, TYPE_NONE, TYPE_NONE), + defop(READ_ADC, 2, TYPE_VAL, TYPE_REG, TYPE_NONE), + defop(READ_DAC, 2, TYPE_VAL, TYPE_REG, TYPE_NONE), + defop(WRITE_DAC, 2, TYPE_VAL, TYPE_VAL, TYPE_NONE), + defop(SLEEP, 1, TYPE_VAL, TYPE_NONE, TYPE_NONE), + 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_NONE), + defop(SENDVAL, 1, TYPE_VAL, TYPE_NONE, TYPE_NONE), + defop(SENDDAT, 1, TYPE_IMM, TYPE_NONE, TYPE_NONE) }; /************************************************************************* @@ -560,6 +571,7 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc) switch (ins.opcode) { case CREOLE_DB: env->dats[ins.w[0]] = ins.datapt; + break; case CREOLE_PUSH: check(read_val(env, &ins, 0, &a1)); check(creole_push(env, a1)); @@ -621,6 +633,53 @@ enum creole_run_ret creole_step(struct creole_env *env, creole_word *sc) if (a1 != a2 && !creole_jump(env, a0)) return CREOLE_JUMP_OVERFLOW; break; + case CREOLE_READ_ADC: + check(read_val(env, &ins, 0, &a0)); + a1 = upsilon_get_adc(a0); + check(creole_reg_write(env, ins.w[1], a1)); + break; + case CREOLE_READ_DAC: + check(read_val(env, &ins, 0, &a0)); + a1 = upsilon_get_dac(a0); + check(creole_reg_write(env, ins.w[1], a1)); + break; + case CREOLE_WRITE_DAC: + check(read_val(env, &ins, 0, &a0)); + check(read_val(env, &ins, 1, &a1)); + upsilon_write_dac(a0, a1); + break; + case CREOLE_SLEEP: + check(read_val(env, &ins, 0, &a0)); + upsilon_sleep(a0); + break; + case CREOLE_CLOOP_READ: + check(read_val(env, &ins, 0, &a0)); + a1 = upsilon_control_loop_read(a0); + check(creole_reg_write(env, ins.w[1], a1)); + break; + case CREOLE_CLOOP_WRITE: + check(read_val(env, &ins, 0, &a0)); + check(read_val(env, &ins, 1, &a1)); + upsilon_control_loop_write(a0, a1); + break; + case CREOLE_WF_LOAD: + check(read_val(env, &ins, 0, &a0)); + check(read_val(env, &ins, 1, &a1)); + upsilon_load_waveform(env, a0, a1); + break; + case CREOLE_WF_EXEC: + check(read_val(env, &ins, 0, &a0)); + check(read_val(env, &ins, 1, &a1)); + upsilon_exec_waveform(a0, a1); + break; + case CREOLE_SENDVAL: + check(read_val(env, &ins, 0, &a0)); + upsilon_sendval(a0); + break; + case CREOLE_SENDDAT: + check(read_val(env, &ins, 0, &a0)); + upsilon_senddat(env, a0); + break; default: rcode = CREOLE_STEP_UNKNOWN_OPCODE; } diff --git a/creole.h b/creole.h index fe888ef..8ebb2c2 100644 --- a/creole.h +++ b/creole.h @@ -34,18 +34,28 @@ typedef CREOLE_WORD creole_word; typedef CREOLE_SIGNED_WORD creole_signed; enum creole_opcode { - CREOLE_NOOP, - CREOLE_PUSH, - CREOLE_POP, - CREOLE_ADD, - CREOLE_MUL, - CREOLE_DIV, - CREOLE_SYS, - CREOLE_JL, - CREOLE_JLE, - CREOLE_JE, - CREOLE_JNE, - CREOLE_DB, + CREOLE_NOOP = 0, + CREOLE_PUSH = 1, + CREOLE_POP = 2, + CREOLE_ADD = 3, + CREOLE_MUL = 4, + CREOLE_DIV = 5, + CREOLE_SYS = 6, + CREOLE_JL = 7, + CREOLE_JLE = 8, + CREOLE_JE = 9, + CREOLE_JNE = 10, + CREOLE_DB = 11, + CREOLE_READ_ADC = 12, + CREOLE_READ_DAC = 13, + CREOLE_WRITE_DAC = 14, + CREOLE_SLEEP = 15, + CREOLE_CLOOP_READ = 16, + CREOLE_CLOOP_WRITE = 17, + CREOLE_WF_LOAD = 18, + CREOLE_WF_EXEC = 19, + CREOLE_SENDVAL = 20, + CREOLE_SENDDAT = 21, CREOLE_OPCODE_LEN };