machine.h (869B)
1 /* VM's instructions */ 2 enum { 3 I_HALT = 0, 4 /* * * * * */ 5 I_LIT, 6 I_FETCH, 7 I_OP, 8 I_ADSR, 9 I_WAVE, 10 I_2DT, 11 /* * * * * */ 12 I_DUP, 13 I_DROP, 14 I_SWAP, 15 /* * * * * */ 16 I_ADD, 17 I_COMB, 18 }; 19 20 void i_halt(int16_t*, uint8_t); 21 void i_lit(int16_t*, uint8_t); 22 void i_fetch(int16_t*, uint8_t); 23 void i_op(int16_t*, uint8_t); 24 void i_adsr(int16_t*, uint8_t); 25 void i_wave(int16_t*, uint8_t); 26 void i_2dt(int16_t*, uint8_t); 27 void i_dup(int16_t*, uint8_t); 28 void i_drop(int16_t*, uint8_t); 29 void i_swap(int16_t*, uint8_t); 30 void i_add(int16_t*, uint8_t); 31 void i_comb(int16_t*, uint8_t); 32 33 struct Iset{ 34 void (*instr)(int16_t*, uint8_t); 35 char *name; 36 }; 37 38 extern struct Iset vm_iset[]; 39 40 /* VM's memory state */ 41 enum { 42 VM_PC, 43 VM_ACTIVE, 44 VM_HALTED, 45 VM_KEY, 46 VM_KEY_ON, 47 VM_OPERATORS = 128, 48 VM_SP, 49 VM_STACK = 256, 50 VM_PROG_START = 1024, 51 VM_MEM_END = 4096, 52 }; 53 54 int16_t vm_run(int16_t*);