CraftBook 3

CraftBook 3

139k Downloads

Add jump opcode to Perlstone

davr opened this issue ยท 3 comments

commented

Instead of requring matched [ and ] opcodes, also give us an arbitrary jump opcode. Maybe something like
j## where ## is the label number, and then a separate opcode l## which does nothing except create a location to jump to.

To make it really useful, also add conditional jumps:
jz## -- pop the value from the stack, if it's zero, jump to label ##, else do nothing
jnz## -- pop the value from the stack, if it's non-zero, jump to label ##, else do nothing

commented

For the record, using jumps is bad practice in programming.

commented

For the record, andrew12, things like assembly language are built on jumps. You don't have loops or if statements, everything must be constructed from jumps (usually conditional). I requested them in Perlstone, because it is a very simple language, like assembly. It would allow you to build more powerful scripts more easily. It's also often referred to as a 'branch' instruction.

commented

This is true. :<