PUSH Instruction - craterdog-archives/js-bali-virtual-machine GitHub Wiki
The PUSH Instruction
The PUSH
instruction causes a component (or an exception handler address) to be pushed onto the
component (or the exception handler) stack. The type of component or address depends on the
specified modifier:
The operand either contains an exception handler address in the range 0x001..0x7FF
, or an
index value in the range 1..2047
.
PUSH HANDLER label
The PUSH
instruction with a HANDLER
modifier pushes the exception handler at the address of
the label operand onto the exception handler stack. The bytecode for this instruction has
the form:
[00100aaa][aaaaaaaa] where aaaaaaaaaaa is the exception handler address of the label
The following pseudo-code defines this instruction:
context.handlers.push(context.operand)
context.address = context.address + 1
Example Context Before Execution
Example Context After Execution
PUSH LITERAL literal
The PUSH
instruction with a LITERAL
modifier pushes the literal operand onto the
component stack. The bytecode for this instruction has the form:
[00101xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the literal value
The following pseudo-code defines this instruction:
literal = context.literals.get(context.operand)
task.components.push(literal)
context.address = context.address + 1
Example Context Before Execution
Example Context After Execution
PUSH CONSTANT constant
The PUSH
instruction with a CONSTANT
modifier pushes the value of the constant
operand onto the component stack. The bytecode for this instruction has the form:
[00110xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the constant value
The following pseudo-code defines this instruction:
constant = context.constants.get(context.operand)
task.components.push(constant)
context.address = context.address + 1
Example Context Before Execution
Example Context After Execution
PUSH ARGUMENT argument
The PUSH
instruction with an ARGUMENT
modifier pushes the argument value of the argument
operand onto the component stack. The bytecode for this instruction has the form:
[00111xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the argument value
The following pseudo-code defines this instruction:
argument = context.arguments.get(context.operand)
task.components.push(argument)
context.address = context.address + 1