aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-22 17:17:36 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-03-22 17:17:36 +0100
commit2c1c5fbb30c7d48db002e583cd8fe41490fddd0f (patch)
tree332950287b4943d5f3d74a79e07193442fbed2f9
parentf2c2b7f892bf7ec8b74e891bd3468e1429c6d749 (diff)
downloadvm.lv2-2c1c5fbb30c7d48db002e583cd8fe41490fddd0f.tar.xz
prototype opcodes break, goto.
-rw-r--r--VERSION2
-rw-r--r--vm.c13
-rw-r--r--vm.h23
-rw-r--r--vm.ttl4
4 files changed, 41 insertions, 1 deletions
diff --git a/VERSION b/VERSION
index 0ccf3e3..9123249 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.2867
+0.1.2869
diff --git a/vm.c b/vm.c
index db49545..5531f41 100644
--- a/vm.c
+++ b/vm.c
@@ -378,6 +378,19 @@ run(LV2_Handle instance, uint32_t nsamples)
const num_t c = handle->stack.regs[idx & REG_MASK];
_stack_push(&handle->stack, c);
} break;
+ case OP_BREAK:
+ {
+ const bool a = _stack_pop(&handle->stack);
+ if(a)
+ terminate = true;
+ } break;
+ /* dangerous
+ case OP_GOTO:
+ {
+ const int idx = _stack_pop(&handle->stack);
+ i = (idx - 1) & ITEMS_MASK;
+ } break;
+ */
case OP_RAND:
{
diff --git a/vm.h b/vm.h
index 9a585f0..e7d1364 100644
--- a/vm.h
+++ b/vm.h
@@ -48,6 +48,7 @@
#define CTRL_MASK (CTRL_MAX - 1)
#define ITEMS_MAX 128
+#define ITEMS_MASK (ITEMS_MAX - 1)
#define GRAPH_SIZE (ITEMS_MAX * sizeof(LV2_Atom_Long))
#define VM_MIN -1.f
@@ -81,6 +82,10 @@ enum _vm_opcode_enum_t {
OP_SWAP,
OP_STORE,
OP_LOAD,
+ OP_BREAK,
+ /* dangerous
+ OP_GOTO,
+ */
OP_RAND,
@@ -262,6 +267,24 @@ static const vm_api_def_t vm_api_def [OP_MAX] = {
.npops = 1,
.npushs = 1
},
+ [OP_BREAK] = {
+ .uri = VM_PREFIX"opBreak",
+ .label = "Break program execution if top of stack is true",
+ .mnemo = "break",
+ .key = '\0',
+ .npops = 1,
+ .npushs = 0
+ },
+ /* dangerous
+ [OP_GOTO] = {
+ .uri = VM_PREFIX"opGoto",
+ .label = "Goto given operation",
+ .mnemo = "goto",
+ .key = '\0',
+ .npops = 1,
+ .npushs = 0
+ },
+ */
[OP_RAND] = {
.uri = VM_PREFIX"opRand",
diff --git a/vm.ttl b/vm.ttl
index b6ff5c4..d9dfdc1 100644
--- a/vm.ttl
+++ b/vm.ttl
@@ -68,6 +68,10 @@ vm:opStore
a rdfs:Datatype .
vm:opLoad
a rdfs:Datatype .
+vm:opBreak
+ a rdfs:Datatype .
+#vm:opGoto
+# a rdfs:Datatype .
vm:opRand
a rdfs:Datatype .