Menu

#7 indirect value in offset of jmp instructions

Unsupported
open
NBC (2)
5
2013-01-02
2007-08-30
No

Is there any chance to introduce a new kind of JMP in enhanced firmware that would jmp to an address provided indirectly in some memory location? This would allow faster implementation of longer switch commands, which is in particular an issue in cases where such switch is executed often - and that is not unusual in robot programs. Robot program simply is in some state and has to proceed to another state based on its sensor inputs/reasoning... The speed of this transition determines how fast the robot reacts to events.

switch (state) {

case state1:
switch (event) {
case event1: jmp service_event1
case event2: jmp service_event2
case event3: jmp service_event3
...
}
break;
case state2:
switch (event) {
case event1: jmp anotherservice_event1
case event2: jmp anotherservice_event2
case event3: jmp anotherservice_event3
...
}
break;
....
}

Instead, I would like to do, for example, this:

mul x, state, 10
add x, x, event
index label, service_labels, x
jmp label

And then you could introduce some kind of label dereferencing, something like:

replace service_labels, service_labels, 0, @service_event1

so that one could initialize the table of labels.

Discussion